Show More
@@ -15,6 +15,7 b' except ImportError:' | |||||
15 | from mercurial.util import matchdate, Abort, makedate |
|
15 | from mercurial.util import matchdate, Abort, makedate | |
16 | from mercurial.hgweb.common import get_contact |
|
16 | from mercurial.hgweb.common import get_contact | |
17 | from mercurial.templatefilters import age |
|
17 | from mercurial.templatefilters import age | |
|
18 | from operator import itemgetter | |||
18 | log = logging.getLogger(__name__) |
|
19 | log = logging.getLogger(__name__) | |
19 |
|
20 | |||
20 | class HgController(BaseController): |
|
21 | class HgController(BaseController): | |
@@ -25,6 +26,7 b' class HgController(BaseController):' | |||||
25 |
|
26 | |||
26 | def index(self): |
|
27 | def index(self): | |
27 | c.repos_list = [] |
|
28 | c.repos_list = [] | |
|
29 | c.current_sort = request.GET.get('sort', 'name') | |||
28 |
|
30 | |||
29 | def get_mtime(spath): |
|
31 | def get_mtime(spath): | |
30 | cl_path = os.path.join(spath, "00changelog.i") |
|
32 | cl_path = os.path.join(spath, "00changelog.i") | |
@@ -40,20 +42,37 b' class HgController(BaseController):' | |||||
40 | untrusted=True): |
|
42 | untrusted=True): | |
41 | yield {"type" : i[0], "extension": i[1], |
|
43 | yield {"type" : i[0], "extension": i[1], | |
42 | "node": nodeid, "url": url} |
|
44 | "node": nodeid, "url": url} | |
43 |
|
45 | |||
44 | for name, r in get_repositories(g.paths[0][0], g.paths[0][1]).items(): |
|
46 | for name, r in get_repositories(g.paths[0][0], g.paths[0][1]).items(): | |
45 | last_change = (get_mtime(r.spath), makedate()[1]) |
|
47 | last_change = (get_mtime(r.spath), makedate()[1]) | |
46 | tip = r.changectx('tip') |
|
48 | tip = r.changectx('tip') | |
47 | tmp_d = {} |
|
49 | tmp_d = {} | |
48 | tmp_d['name'] = name |
|
50 | tmp_d['name'] = name | |
49 | tmp_d['desc'] = r.ui.config('web', 'description', 'Unknown', untrusted=True) |
|
51 | tmp_d['name_sort'] = tmp_d['name'] | |
|
52 | tmp_d['description'] = r.ui.config('web', 'description', 'Unknown', untrusted=True) | |||
|
53 | tmp_d['description_sort'] = tmp_d['description'] | |||
50 | tmp_d['last_change'] = age(last_change) |
|
54 | tmp_d['last_change'] = age(last_change) | |
|
55 | tmp_d['last_change_sort'] = last_change[1] - last_change[0] | |||
51 | tmp_d['tip'] = str(tip) |
|
56 | tmp_d['tip'] = str(tip) | |
|
57 | tmp_d['tip_sort'] = tip.rev() | |||
52 | tmp_d['rev'] = tip.rev() |
|
58 | tmp_d['rev'] = tip.rev() | |
53 | tmp_d['contact'] = get_contact(r.ui.config) |
|
59 | tmp_d['contact'] = get_contact(r.ui.config) | |
|
60 | tmp_d['contact_sort'] = get_contact(r.ui.config) | |||
54 | tmp_d['repo_archives'] = archivelist(r.ui, "tip", 'sa') |
|
61 | tmp_d['repo_archives'] = archivelist(r.ui, "tip", 'sa') | |
55 |
|
62 | |||
56 | c.repos_list.append(tmp_d) |
|
63 | c.repos_list.append(tmp_d) | |
|
64 | ||||
|
65 | cs = c.current_sort | |||
|
66 | c.cs_slug = cs.replace('-', '') | |||
|
67 | sortables = ['name', 'description', 'last_change', 'tip', 'contact'] | |||
|
68 | ||||
|
69 | if cs and c.cs_slug in sortables: | |||
|
70 | sort_key = c.cs_slug + '_sort' | |||
|
71 | if cs.startswith('-'): | |||
|
72 | c.repos_list.sort(key=itemgetter(sort_key), reverse=True) | |||
|
73 | else: | |||
|
74 | c.repos_list.sort(key=itemgetter(sort_key), reverse=False) | |||
|
75 | ||||
57 | return render('/index.html') |
|
76 | return render('/index.html') | |
58 |
|
77 | |||
59 | def view(self, *args, **kwargs): |
|
78 | def view(self, *args, **kwargs): |
@@ -5,7 +5,7 b'' | |||||
5 | ${c.repos_prefix} Mercurial Repositories |
|
5 | ${c.repos_prefix} Mercurial Repositories | |
6 | </%def> |
|
6 | </%def> | |
7 | <%def name="breadcrumbs()"> |
|
7 | <%def name="breadcrumbs()"> | |
8 |
|
|
8 | ${c.repos_prefix} Mercurial Repositories | |
9 | </%def> |
|
9 | </%def> | |
10 | <%def name="page_nav()"> |
|
10 | <%def name="page_nav()"> | |
11 | <li class="current">${_('Home')}</li> |
|
11 | <li class="current">${_('Home')}</li> | |
@@ -13,11 +13,16 b'' | |||||
13 | </%def> |
|
13 | </%def> | |
14 | <%def name="main()"> |
|
14 | <%def name="main()"> | |
15 | <%def name="get_sort(name)"> |
|
15 | <%def name="get_sort(name)"> | |
16 |
<%name_slug = name.lower().replace(' ',' |
|
16 | <%name_slug = name.lower().replace(' ','_') %> | |
17 | %if not name_slug.startswith('-') and c.current_sort: |
|
17 | %if name_slug == c.cs_slug: | |
18 | <%name_slug = '-'+name_slug%> |
|
18 | <span style="font-weight: bold;color:#006699">${name}</span> | |
|
19 | %else: | |||
|
20 | <span style="font-weight: bold">${name}</span> | |||
19 | %endif |
|
21 | %endif | |
20 | <a href="?sort=${name_slug}">${name}</a> |
|
22 | ||
|
23 | <a href="?sort=${name_slug}">↓</a> | |||
|
24 | <a href="?sort=-${name_slug}">↑</a> | |||
|
25 | ||||
21 | </%def> |
|
26 | </%def> | |
22 | <table> |
|
27 | <table> | |
23 | <tr> |
|
28 | <tr> | |
@@ -26,11 +31,13 b'' | |||||
26 | <td>${get_sort(_('Last change'))}</td> |
|
31 | <td>${get_sort(_('Last change'))}</td> | |
27 | <td>${get_sort(_('Tip'))}</td> |
|
32 | <td>${get_sort(_('Tip'))}</td> | |
28 | <td>${get_sort(_('Contact'))}</td> |
|
33 | <td>${get_sort(_('Contact'))}</td> | |
|
34 | <td></td> | |||
|
35 | <td></td> | |||
29 | </tr> |
|
36 | </tr> | |
30 | %for cnt,repo in enumerate(c.repos_list): |
|
37 | %for cnt,repo in enumerate(c.repos_list): | |
31 | <tr class="parity${cnt%2}"> |
|
38 | <tr class="parity${cnt%2}"> | |
32 | <td><a href="/${repo['name']}">${repo['name']}</a></td> |
|
39 | <td><a href="/${repo['name']}">${repo['name']}</a></td> | |
33 | <td>${repo['desc']}</td> |
|
40 | <td>${repo['description']}</td> | |
34 | <td>${repo['last_change']}</td> |
|
41 | <td>${repo['last_change']}</td> | |
35 | <td>r${repo['rev']}:<a href="/${repo['name']}/rev/${repo['tip']}/">${repo['tip']}</a></td> |
|
42 | <td>r${repo['rev']}:<a href="/${repo['name']}/rev/${repo['tip']}/">${repo['tip']}</a></td> | |
36 | <td>${repo['contact']}</td> |
|
43 | <td>${repo['contact']}</td> |
General Comments 0
You need to be logged in to leave comments.
Login now