Show More
@@ -0,0 +1,35 b'' | |||
|
1 | import logging | |
|
2 | ||
|
3 | from pylons import tmpl_context as c, app_globals as g, session, request, config, url | |
|
4 | from pylons.controllers.util import abort, redirect | |
|
5 | ||
|
6 | from pylons_app.lib.base import BaseController, render | |
|
7 | from pylons_app.lib.utils import get_repo_slug | |
|
8 | from pylons_app.model.hg_model import HgModel | |
|
9 | from webhelpers.paginate import Page | |
|
10 | log = logging.getLogger(__name__) | |
|
11 | ||
|
12 | class ShortlogController(BaseController): | |
|
13 | def __before__(self): | |
|
14 | c.repos_prefix = config['repos_name'] | |
|
15 | c.staticurl = g.statics | |
|
16 | c.repo_name = get_repo_slug(request) | |
|
17 | ||
|
18 | ||
|
19 | def index(self): | |
|
20 | hg_model = HgModel() | |
|
21 | lim = 20 | |
|
22 | p = int(request.params.get('page', 1)) | |
|
23 | repo = hg_model.get_repo(c.repo_name) | |
|
24 | cnt = repo.revisions[-1] | |
|
25 | gen = repo.get_changesets(None) | |
|
26 | repo_changesets = list(gen) | |
|
27 | repo_changesets2 = list(gen) | |
|
28 | repo_changesets3 = list(gen) | |
|
29 | repo_changesets4 = list(gen) | |
|
30 | ||
|
31 | c.repo_changesets = Page(repo_changesets, page=p, item_count=cnt, items_per_page=lim) | |
|
32 | c.shortlog_data = render('shortlog_data.html') | |
|
33 | if request.params.get('partial'): | |
|
34 | return c.shortlog_data | |
|
35 | return render('/shortlog.html') |
@@ -0,0 +1,38 b'' | |||
|
1 | <%inherit file="base/base.html"/> | |
|
2 | ||
|
3 | <%def name="title()"> | |
|
4 | ${_('Repository managment')} | |
|
5 | </%def> | |
|
6 | <%def name="breadcrumbs()"> | |
|
7 | ${h.link_to(u'Home',h.url('/'))} | |
|
8 | / | |
|
9 | ${h.link_to(c.repo_name,h.url('shortlog_home',repo_name=c.repo_name))} | |
|
10 | / | |
|
11 | ${_('shortlog')} | |
|
12 | </%def> | |
|
13 | <%def name="page_nav()"> | |
|
14 | <form action="log"> | |
|
15 | <dl class="search"> | |
|
16 | <dt><label>Search: </label></dt> | |
|
17 | <dd><input type="text" name="rev" /></dd> | |
|
18 | </dl> | |
|
19 | </form> | |
|
20 | ||
|
21 | <ul class="page-nav"> | |
|
22 | <li>${h.link(_('summary'),h.url('summary_home',repo_name=c.repo_name))}</li> | |
|
23 | <li class="current">${_('shortlog')}</li> | |
|
24 | <li><a href="log">changelog</a></li> | |
|
25 | <li><a href="graph/{node|short}">graph</a></li> | |
|
26 | <li><a href="tags">tags</a></li> | |
|
27 | <li><a href="branches">branches</a></li> | |
|
28 | <li><a href="file/{node|short}">files</a></li> | |
|
29 | </ul> | |
|
30 | </%def> | |
|
31 | <%def name="main()"> | |
|
32 | ||
|
33 | <h2 class="no-link no-border">${_('Shortlog')}</h2> | |
|
34 | ||
|
35 | <div id="shortlog_data"> | |
|
36 | ${c.shortlog_data} | |
|
37 | </div> | |
|
38 | </%def> No newline at end of file |
@@ -0,0 +1,32 b'' | |||
|
1 | ## -*- coding: utf-8 -*- | |
|
2 | <%! | |
|
3 | from pylons_app.lib import filters | |
|
4 | %> | |
|
5 | <table> | |
|
6 | %for cnt,cs in enumerate(c.repo_changesets): | |
|
7 | <tr class="parity${cnt%2}"> | |
|
8 | <td>${cs._ctx.date()|n,filters.age}</td> | |
|
9 | <td title="${cs.author}">${cs.author|n,filters.person}</td> | |
|
10 | <td>${h.link_to(cs.message,h.url('rev/'+str(cs._ctx)))}</td> | |
|
11 | <td class="nowrap"> | |
|
12 | ${h.link_to(_('changeset'),h.url('file/'+str(cs._ctx)))} | |
|
13 | | | |
|
14 | ${h.link_to(_('files'),h.url('file/'+str(cs._ctx)))} | |
|
15 | </td> | |
|
16 | </tr> | |
|
17 | %endfor | |
|
18 | <tr> | |
|
19 | <script type="text/javascript"> | |
|
20 | var data_div = 'shortlog_data'; | |
|
21 | YAHOO.util.Event.onDOMReady(function(){ | |
|
22 | YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){ | |
|
23 | YAHOO.util.Dom.setStyle('shortlog_data','opacity','0.3');});}); | |
|
24 | </script> | |
|
25 | <td>${c.repo_changesets.pager('$link_previous ~2~ $link_next', | |
|
26 | onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{ | |
|
27 | success:function(o){YAHOO.util.Dom.get(data_div).innerHTML=o.responseText; | |
|
28 | YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){ | |
|
29 | YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');}); | |
|
30 | YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")}</td> | |
|
31 | </tr> | |
|
32 | </table> No newline at end of file |
@@ -0,0 +1,7 b'' | |||
|
1 | from pylons_app.tests import * | |
|
2 | ||
|
3 | class TestShortlogController(TestController): | |
|
4 | ||
|
5 | def test_index(self): | |
|
6 | response = self.app.get(url(controller='shortlog', action='index')) | |
|
7 | # Test response... |
@@ -19,6 +19,7 b' debug = true' | |||
|
19 | 19 | #error_message = 'mercurial crash !' |
|
20 | 20 | |
|
21 | 21 | [server:main] |
|
22 | threadpool_workers = 5 | |
|
22 | 23 | use = egg:Paste#http |
|
23 | 24 | host = 127.0.0.1 |
|
24 | 25 | port = 5000 |
@@ -19,6 +19,7 b' debug = true' | |||
|
19 | 19 | #error_message = 'mercurial crash !' |
|
20 | 20 | |
|
21 | 21 | [server:main] |
|
22 | threadpool_workers = 10 | |
|
22 | 23 | use = egg:Paste#http |
|
23 | 24 | host = 127.0.0.1 |
|
24 | 25 | port = 8001 |
@@ -31,6 +31,7 b' def make_map(config):' | |||
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | map.connect('summary_home', '/{repo_name}/_summary', controller='summary') |
|
34 | map.connect('shortlog_home', '/{repo_name}/_shortlog', controller='shortlog') | |
|
34 | 35 | |
|
35 | 36 | map.connect('hg', '/{path_info:.*}', controller='hg', |
|
36 | 37 | action="view", path_info='/') |
@@ -1,14 +1,15 b'' | |||
|
1 | 1 | from mercurial import util |
|
2 | from mercurial.templatefilters import age as _age | |
|
2 | from mercurial.templatefilters import age as _age, person as _person | |
|
3 | 3 | |
|
4 |
age = lambda |
|
|
4 | age = lambda x:_age(x) | |
|
5 | 5 | capitalize = lambda x: x.capitalize() |
|
6 | 6 | date = lambda x: util.datestr(x) |
|
7 | 7 | email = util.email |
|
8 | hgdate = lambda context, x: "%d %d" % x | |
|
9 | isodate = lambda context, x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') | |
|
10 |
isodate |
|
|
11 | localdate = lambda context, x: (x[0], util.makedate()[1]) | |
|
12 | rfc822date = lambda context, x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") | |
|
13 |
rfc |
|
|
14 |
t |
|
|
8 | person = lambda x: _person(x) | |
|
9 | hgdate = lambda x: "%d %d" % x | |
|
10 | isodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') | |
|
11 | isodatesec = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') | |
|
12 | localdate = lambda x: (x[0], util.makedate()[1]) | |
|
13 | rfc822date = lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") | |
|
14 | rfc3339date = lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") | |
|
15 | time_ago = lambda x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2") |
@@ -1,3 +1,4 b'' | |||
|
1 | ## -*- coding: utf-8 -*- | |
|
1 | 2 | %if c.users_log: |
|
2 | 3 | <table> |
|
3 | 4 | <tr> |
@@ -17,11 +18,19 b'' | |||
|
17 | 18 | %endfor |
|
18 | 19 | |
|
19 | 20 | <tr> |
|
21 | <script type="text/javascript"> | |
|
22 | var data_div = 'user_log'; | |
|
23 | YAHOO.util.Event.onDOMReady(function(){ | |
|
24 | YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){ | |
|
25 | YAHOO.util.Dom.setStyle('shortlog_data','opacity','0.3');});}); | |
|
26 | </script> | |
|
20 | 27 | <td>${c.users_log.pager('$link_previous ~2~ $link_next', |
|
21 | 28 | onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{ |
|
22 |
success:function(o){YAHOO.util.Dom.get( |
|
|
23 | },null); return false;""")}</td> | |
|
24 | </tr> | |
|
29 | success:function(o){YAHOO.util.Dom.get(data_div).innerHTML=o.responseText; | |
|
30 | YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){ | |
|
31 | YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');}); | |
|
32 | YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")}</td> | |
|
33 | </tr> | |
|
25 | 34 | </table> |
|
26 | 35 | |
|
27 | 36 | %else: |
@@ -1,7 +1,4 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | ##filters definition | |
|
3 | <%namespace name="f" module="pylons_app.lib.filters" inheritable="True"/> | |
|
4 | ||
|
5 | 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
6 | 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
7 | 4 | <head> |
@@ -1,5 +1,7 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | ||
|
2 | <%! | |
|
3 | from pylons_app.lib import filters | |
|
4 | %> | |
|
3 | 5 | <%inherit file="base/base.html"/> |
|
4 | 6 | <%def name="title()"> |
|
5 | 7 | ${c.repos_prefix} Mercurial Repositories |
@@ -38,7 +40,7 b'' | |||
|
38 | 40 | <tr class="parity${cnt%2}"> |
|
39 | 41 | <td>${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td> |
|
40 | 42 | <td>${repo['description']}</td> |
|
41 |
<td>${repo['last_change']|n,s |
|
|
43 | <td>${repo['last_change']|n,filters.age}</td> | |
|
42 | 44 | <td>r${repo['rev']}:<a href="/${repo['name']}/rev/${repo['tip']}/">${repo['tip']}</a></td> |
|
43 | 45 | <td>${repo['contact']}</td> |
|
44 | 46 | <td class="indexlinks"> |
@@ -1,5 +1,7 b'' | |||
|
1 | 1 | <%inherit file="base/base.html"/> |
|
2 | ||
|
2 | <%! | |
|
3 | from pylons_app.lib import filters | |
|
4 | %> | |
|
3 | 5 | <%def name="title()"> |
|
4 | 6 | ${_('Repository managment')} |
|
5 | 7 | </%def> |
@@ -19,8 +21,8 b'' | |||
|
19 | 21 | </form> |
|
20 | 22 | |
|
21 | 23 | <ul class="page-nav"> |
|
22 | <li class="current">summary</li> | |
|
23 | <li><a href="shortlog">shortlog</a></li> | |
|
24 | <li class="current">${_('summary')}</li> | |
|
25 | <li>${h.link(_('shortlog'),h.url('shortlog_home',repo_name=c.repo_name))}</li> | |
|
24 | 26 | <li><a href="log">changelog</a></li> |
|
25 | 27 | <li><a href="graph/{node|short}">graph</a></li> |
|
26 | 28 | <li><a href="tags">tags</a></li> |
@@ -39,7 +41,7 b'' | |||
|
39 | 41 | <dt>${_('contact')}</dt> |
|
40 | 42 | <dd>${c.repo_info.contact}</dd> |
|
41 | 43 | <dt>${_('last change')}</dt> |
|
42 |
<dd>${c.repo_info.last_change|n,s |
|
|
44 | <dd>${c.repo_info.last_change|n,filters.rfc822date} - ${c.repo_info.last_change|n,filters.age}</dd> | |
|
43 | 45 | <dt>${_('url')}</dt> |
|
44 | 46 | <dd><pre>$ hg clone <a href="${c.clone_repo_url}">${c.clone_repo_url}</a></pre></dd> |
|
45 | 47 | <dt>${_('Download')}</dt> |
@@ -57,7 +59,7 b'' | |||
|
57 | 59 | <table> |
|
58 | 60 | %for cnt,cs in enumerate(c.repo_changesets): |
|
59 | 61 | <tr class="parity${cnt%2}"> |
|
60 |
<td>${cs._ctx.date()|n,s |
|
|
62 | <td>${cs._ctx.date()|n,filters.age}</td> | |
|
61 | 63 | <td>${cs.author}</td> |
|
62 | 64 | <td>${h.link_to(cs.message,h.url('rev/'+str(cs._ctx)))}</td> |
|
63 | 65 | <td class="nowrap"> |
General Comments 0
You need to be logged in to leave comments.
Login now