Mercurial > public > src > rhodecode
changeset 83:db39d0ca5308
implemented Shortlog as seperate controller,
filters rewrite. Little html fixes
author | Marcin Kuzminski <marcin@python-blog.com> |
---|---|
date | Sun, 18 Apr 2010 11:23:10 +0200 |
parents | 670713507d03 |
children | 00b17b3a0978 |
files | development.ini production.ini pylons_app/config/routing.py pylons_app/controllers/shortlog.py pylons_app/lib/filters.py pylons_app/templates/admin_log.html pylons_app/templates/base/base.html pylons_app/templates/index.html pylons_app/templates/shortlog.html pylons_app/templates/shortlog_data.html pylons_app/templates/summary.html pylons_app/tests/functional/test_shortlog.py |
diffstat | 12 files changed, 148 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/development.ini Sun Apr 18 00:31:58 2010 +0200 +++ b/development.ini Sun Apr 18 11:23:10 2010 +0200 @@ -19,6 +19,7 @@ #error_message = 'mercurial crash !' [server:main] +threadpool_workers = 5 use = egg:Paste#http host = 127.0.0.1 port = 5000
--- a/production.ini Sun Apr 18 00:31:58 2010 +0200 +++ b/production.ini Sun Apr 18 11:23:10 2010 +0200 @@ -19,6 +19,7 @@ #error_message = 'mercurial crash !' [server:main] +threadpool_workers = 10 use = egg:Paste#http host = 127.0.0.1 port = 8001
--- a/pylons_app/config/routing.py Sun Apr 18 00:31:58 2010 +0200 +++ b/pylons_app/config/routing.py Sun Apr 18 11:23:10 2010 +0200 @@ -31,6 +31,7 @@ map.connect('summary_home', '/{repo_name}/_summary', controller='summary') + map.connect('shortlog_home', '/{repo_name}/_shortlog', controller='shortlog') map.connect('hg', '/{path_info:.*}', controller='hg', action="view", path_info='/')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/controllers/shortlog.py Sun Apr 18 11:23:10 2010 +0200 @@ -0,0 +1,35 @@ +import logging + +from pylons import tmpl_context as c, app_globals as g, session, request, config, url +from pylons.controllers.util import abort, redirect + +from pylons_app.lib.base import BaseController, render +from pylons_app.lib.utils import get_repo_slug +from pylons_app.model.hg_model import HgModel +from webhelpers.paginate import Page +log = logging.getLogger(__name__) + +class ShortlogController(BaseController): + def __before__(self): + c.repos_prefix = config['repos_name'] + c.staticurl = g.statics + c.repo_name = get_repo_slug(request) + + + def index(self): + hg_model = HgModel() + lim = 20 + p = int(request.params.get('page', 1)) + repo = hg_model.get_repo(c.repo_name) + cnt = repo.revisions[-1] + gen = repo.get_changesets(None) + repo_changesets = list(gen) + repo_changesets2 = list(gen) + repo_changesets3 = list(gen) + repo_changesets4 = list(gen) + + c.repo_changesets = Page(repo_changesets, page=p, item_count=cnt, items_per_page=lim) + c.shortlog_data = render('shortlog_data.html') + if request.params.get('partial'): + return c.shortlog_data + return render('/shortlog.html')
--- a/pylons_app/lib/filters.py Sun Apr 18 00:31:58 2010 +0200 +++ b/pylons_app/lib/filters.py Sun Apr 18 11:23:10 2010 +0200 @@ -1,14 +1,15 @@ from mercurial import util -from mercurial.templatefilters import age as _age +from mercurial.templatefilters import age as _age, person as _person -age = lambda context, x:_age(x) +age = lambda x:_age(x) capitalize = lambda x: x.capitalize() date = lambda x: util.datestr(x) email = util.email -hgdate = lambda context, x: "%d %d" % x -isodate = lambda context, x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') -isodatesec = lambda context, x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') -localdate = lambda context, x: (x[0], util.makedate()[1]) -rfc822date = lambda context, x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") -rfc3339date = lambda context, x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") -time_ago = lambda context, x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2") +person = lambda x: _person(x) +hgdate = lambda x: "%d %d" % x +isodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') +isodatesec = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') +localdate = lambda x: (x[0], util.makedate()[1]) +rfc822date = lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") +rfc3339date = lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") +time_ago = lambda x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2")
--- a/pylons_app/templates/admin_log.html Sun Apr 18 00:31:58 2010 +0200 +++ b/pylons_app/templates/admin_log.html Sun Apr 18 11:23:10 2010 +0200 @@ -1,3 +1,4 @@ +## -*- coding: utf-8 -*- %if c.users_log: <table> <tr> @@ -17,11 +18,19 @@ %endfor <tr> + <script type="text/javascript"> + var data_div = 'user_log'; + YAHOO.util.Event.onDOMReady(function(){ + YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){ + YAHOO.util.Dom.setStyle('shortlog_data','opacity','0.3');});}); + </script> <td>${c.users_log.pager('$link_previous ~2~ $link_next', onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{ - success:function(o){YAHOO.util.Dom.get('user_log').innerHTML=o.responseText;} - },null); return false;""")}</td> - </tr> + success:function(o){YAHOO.util.Dom.get(data_div).innerHTML=o.responseText; + YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){ + YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');}); + YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")}</td> + </tr> </table> %else:
--- a/pylons_app/templates/base/base.html Sun Apr 18 00:31:58 2010 +0200 +++ b/pylons_app/templates/base/base.html Sun Apr 18 11:23:10 2010 +0200 @@ -1,7 +1,4 @@ ## -*- coding: utf-8 -*- -##filters definition -<%namespace name="f" module="pylons_app.lib.filters" inheritable="True"/> - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
--- a/pylons_app/templates/index.html Sun Apr 18 00:31:58 2010 +0200 +++ b/pylons_app/templates/index.html Sun Apr 18 11:23:10 2010 +0200 @@ -1,5 +1,7 @@ ## -*- coding: utf-8 -*- - +<%! +from pylons_app.lib import filters +%> <%inherit file="base/base.html"/> <%def name="title()"> ${c.repos_prefix} Mercurial Repositories @@ -38,7 +40,7 @@ <tr class="parity${cnt%2}"> <td>${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td> <td>${repo['description']}</td> - <td>${repo['last_change']|n,self.f.age}</td> + <td>${repo['last_change']|n,filters.age}</td> <td>r${repo['rev']}:<a href="/${repo['name']}/rev/${repo['tip']}/">${repo['tip']}</a></td> <td>${repo['contact']}</td> <td class="indexlinks">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/templates/shortlog.html Sun Apr 18 11:23:10 2010 +0200 @@ -0,0 +1,38 @@ +<%inherit file="base/base.html"/> + +<%def name="title()"> + ${_('Repository managment')} +</%def> +<%def name="breadcrumbs()"> + ${h.link_to(u'Home',h.url('/'))} + / + ${h.link_to(c.repo_name,h.url('shortlog_home',repo_name=c.repo_name))} + / + ${_('shortlog')} +</%def> +<%def name="page_nav()"> + <form action="log"> + <dl class="search"> + <dt><label>Search: </label></dt> + <dd><input type="text" name="rev" /></dd> + </dl> + </form> + + <ul class="page-nav"> + <li>${h.link(_('summary'),h.url('summary_home',repo_name=c.repo_name))}</li> + <li class="current">${_('shortlog')}</li> + <li><a href="log">changelog</a></li> + <li><a href="graph/{node|short}">graph</a></li> + <li><a href="tags">tags</a></li> + <li><a href="branches">branches</a></li> + <li><a href="file/{node|short}">files</a></li> + </ul> +</%def> +<%def name="main()"> + + <h2 class="no-link no-border">${_('Shortlog')}</h2> + + <div id="shortlog_data"> + ${c.shortlog_data} + </div> +</%def> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/templates/shortlog_data.html Sun Apr 18 11:23:10 2010 +0200 @@ -0,0 +1,32 @@ +## -*- coding: utf-8 -*- +<%! +from pylons_app.lib import filters +%> +<table> +%for cnt,cs in enumerate(c.repo_changesets): + <tr class="parity${cnt%2}"> + <td>${cs._ctx.date()|n,filters.age}</td> + <td title="${cs.author}">${cs.author|n,filters.person}</td> + <td>${h.link_to(cs.message,h.url('rev/'+str(cs._ctx)))}</td> + <td class="nowrap"> + ${h.link_to(_('changeset'),h.url('file/'+str(cs._ctx)))} + | + ${h.link_to(_('files'),h.url('file/'+str(cs._ctx)))} + </td> + </tr> +%endfor + <tr> + <script type="text/javascript"> + var data_div = 'shortlog_data'; + YAHOO.util.Event.onDOMReady(function(){ + YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){ + YAHOO.util.Dom.setStyle('shortlog_data','opacity','0.3');});}); + </script> + <td>${c.repo_changesets.pager('$link_previous ~2~ $link_next', + onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{ + success:function(o){YAHOO.util.Dom.get(data_div).innerHTML=o.responseText; + YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){ + YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');}); + YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")}</td> + </tr> +</table> \ No newline at end of file
--- a/pylons_app/templates/summary.html Sun Apr 18 00:31:58 2010 +0200 +++ b/pylons_app/templates/summary.html Sun Apr 18 11:23:10 2010 +0200 @@ -1,5 +1,7 @@ <%inherit file="base/base.html"/> - +<%! +from pylons_app.lib import filters +%> <%def name="title()"> ${_('Repository managment')} </%def> @@ -19,8 +21,8 @@ </form> <ul class="page-nav"> - <li class="current">summary</li> - <li><a href="shortlog">shortlog</a></li> + <li class="current">${_('summary')}</li> + <li>${h.link(_('shortlog'),h.url('shortlog_home',repo_name=c.repo_name))}</li> <li><a href="log">changelog</a></li> <li><a href="graph/{node|short}">graph</a></li> <li><a href="tags">tags</a></li> @@ -39,7 +41,7 @@ <dt>${_('contact')}</dt> <dd>${c.repo_info.contact}</dd> <dt>${_('last change')}</dt> - <dd>${c.repo_info.last_change|n,self.f.rfc822date} - ${c.repo_info.last_change|n,self.f.age}</dd> + <dd>${c.repo_info.last_change|n,filters.rfc822date} - ${c.repo_info.last_change|n,filters.age}</dd> <dt>${_('url')}</dt> <dd><pre>$ hg clone <a href="${c.clone_repo_url}">${c.clone_repo_url}</a></pre></dd> <dt>${_('Download')}</dt> @@ -57,7 +59,7 @@ <table> %for cnt,cs in enumerate(c.repo_changesets): <tr class="parity${cnt%2}"> - <td>${cs._ctx.date()|n,self.f.age}</td> + <td>${cs._ctx.date()|n,filters.age}</td> <td>${cs.author}</td> <td>${h.link_to(cs.message,h.url('rev/'+str(cs._ctx)))}</td> <td class="nowrap">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/tests/functional/test_shortlog.py Sun Apr 18 11:23:10 2010 +0200 @@ -0,0 +1,7 @@ +from pylons_app.tests import * + +class TestShortlogController(TestController): + + def test_index(self): + response = self.app.get(url(controller='shortlog', action='index')) + # Test response...