Mercurial > public > src > rhodecode
comparison pylons_app/controllers/hg.py @ 82:670713507d03
Moved summary to seperate controller,
little cleanups in templates.
added archives to summary
author | Marcin Kuzminski <marcin@python-blog.com> |
---|---|
date | Sun, 18 Apr 2010 00:31:58 +0200 |
parents | 928416088790 |
children | aec4c0071cb3 |
comparison
equal
deleted
inserted
replaced
81:c2f27b9b81bc | 82:670713507d03 |
---|---|
4 from pylons import tmpl_context as c, app_globals as g, session, request, config | 4 from pylons import tmpl_context as c, app_globals as g, session, request, config |
5 from pylons_app.lib import helpers as h | 5 from pylons_app.lib import helpers as h |
6 from pylons_app.lib.base import BaseController, render | 6 from pylons_app.lib.base import BaseController, render |
7 from mako.template import Template | 7 from mako.template import Template |
8 from pylons.controllers.util import abort | 8 from pylons.controllers.util import abort |
9 | 9 from pylons_app.lib.utils import get_repo_slug |
10 from operator import itemgetter | 10 from operator import itemgetter |
11 from pylons_app.model.hg_model import HgModel | 11 from pylons_app.model.hg_model import HgModel |
12 log = logging.getLogger(__name__) | 12 log = logging.getLogger(__name__) |
13 | 13 |
14 class HgController(BaseController): | 14 class HgController(BaseController): |
15 | 15 |
16 def __before__(self): | 16 def __before__(self): |
17 c.repos_prefix = config['repos_name'] | 17 c.repos_prefix = config['repos_name'] |
18 c.staticurl = g.statics | 18 c.staticurl = g.statics |
19 | 19 c.repo_name = get_repo_slug(request) |
20 | |
20 def index(self): | 21 def index(self): |
21 hg_model = HgModel() | 22 hg_model = HgModel() |
22 c.repos_list = list(hg_model.get_repos()) | 23 c.repos_list = list(hg_model.get_repos()) |
23 c.current_sort = request.GET.get('sort', 'name') | 24 c.current_sort = request.GET.get('sort', 'name') |
24 | 25 |
35 | 36 |
36 return render('/index.html') | 37 return render('/index.html') |
37 | 38 |
38 def view(self, *args, **kwargs): | 39 def view(self, *args, **kwargs): |
39 #TODO: reimplement this not tu use hgwebdir | 40 #TODO: reimplement this not tu use hgwebdir |
40 | 41 |
41 #patch for replacing mercurial servings with hg_app servings | |
42 vcs_impl = self._get_vcs_impl(request.environ) | |
43 if vcs_impl: | |
44 return vcs_impl | |
45 | |
46 | |
47 response = g.hgapp(request.environ, self.start_response) | 42 response = g.hgapp(request.environ, self.start_response) |
48 | 43 |
49 http_accept = request.environ.get('HTTP_ACCEPT', False) | 44 http_accept = request.environ.get('HTTP_ACCEPT', False) |
50 if not http_accept: | 45 if not http_accept: |
51 return abort(status_code=400, detail='no http accept in header') | 46 return abort(status_code=400, detail='no http accept in header') |
66 template = Template(tmpl, lookup=request.environ['pylons.pylons']\ | 61 template = Template(tmpl, lookup=request.environ['pylons.pylons']\ |
67 .config['pylons.app_globals'].mako_lookup, disable_unicode=True) | 62 .config['pylons.app_globals'].mako_lookup, disable_unicode=True) |
68 | 63 |
69 | 64 |
70 return template.render(g=g, c=c, session=session, h=h) | 65 return template.render(g=g, c=c, session=session, h=h) |
71 | |
72 | |
73 | |
74 | |
75 def _get_vcs_impl(self, environ): | |
76 path_info = environ['PATH_INFO'] | |
77 c.repo_name = path_info.split('/')[-2] | |
78 action = path_info.split('/')[-1] | |
79 if not action.startswith('_'): | |
80 return False | |
81 else: | |
82 hg_model = HgModel() | |
83 c.repo_info = hg_model.get_repo(c.repo_name) | |
84 c.repo_changesets = c.repo_info.get_changesets(10) | |
85 # c.repo_tags = c.repo_info.get_tags(limit=10) | |
86 # c.repo_branches = c.repo_info.get_branches(limit=10) | |
87 return render('/summary.html') | |
88 |