Show More
@@ -1,47 +1,39 b'' | |||
|
1 | 1 | #!/usr/bin/python |
|
2 | 2 | # -*- coding: utf-8 -*- |
|
3 | from mako.template import Template | |
|
4 | from mercurial.hg import repository | |
|
5 | from mercurial.hgweb import hgweb | |
|
6 | from mercurial.hgweb.request import wsgiapplication | |
|
7 | from mercurial.localrepo import localrepository | |
|
3 | import logging | |
|
8 | 4 | from operator import itemgetter |
|
9 |
from pylons import tmpl_context as c, |
|
|
10 | from pylons.controllers.util import abort | |
|
11 | from pylons_app.lib import helpers as h | |
|
5 | from pylons import tmpl_context as c, request, config | |
|
12 | 6 | from pylons_app.lib.base import BaseController, render |
|
13 | 7 | from pylons_app.lib.utils import get_repo_slug |
|
14 | 8 | from pylons_app.model.hg_model import HgModel |
|
15 | import logging | |
|
16 | import os | |
|
17 | 9 | from beaker.cache import cache_region |
|
18 | 10 | log = logging.getLogger(__name__) |
|
19 | 11 | |
|
20 | 12 | class HgController(BaseController): |
|
21 | 13 | |
|
22 | 14 | def __before__(self): |
|
23 | 15 | c.repos_prefix = config['repos_name'] |
|
24 | 16 | c.repo_name = get_repo_slug(request) |
|
25 | 17 | |
|
26 | 18 | def index(self): |
|
27 | 19 | |
|
28 | 20 | hg_model = HgModel() |
|
29 | 21 | @cache_region('short_term', 'repo_list') |
|
30 | 22 | def _list(): |
|
31 | 23 | return list(hg_model.get_repos()) |
|
32 | 24 | |
|
33 | 25 | c.repos_list = _list() |
|
34 | 26 | c.current_sort = request.GET.get('sort', 'name') |
|
35 | 27 | |
|
36 | 28 | cs = c.current_sort |
|
37 | 29 | c.cs_slug = cs.replace('-', '') |
|
38 | 30 | sortables = ['name', 'description', 'last_change', 'tip', 'contact'] |
|
39 | 31 | |
|
40 | 32 | if cs and c.cs_slug in sortables: |
|
41 | 33 | sort_key = c.cs_slug + '_sort' |
|
42 | 34 | if cs.startswith('-'): |
|
43 | 35 | c.repos_list.sort(key=itemgetter(sort_key), reverse=True) |
|
44 | 36 | else: |
|
45 | 37 | c.repos_list.sort(key=itemgetter(sort_key), reverse=False) |
|
46 | 38 | |
|
47 | 39 | return render('/index.html') |
General Comments 0
You need to be logged in to leave comments.
Login now