Files
@ c2f27b9b81bc
Branch filter:
Location: kallithea/pylons_app/controllers/hg.py - annotation
c2f27b9b81bc
3.2 KiB
text/x-python
added date detail to summary
564e40829f80 564e40829f80 564e40829f80 71ffa932799d 3142616771cd 71401840ed86 564e40829f80 707dfdb1c7a8 71401840ed86 e96bc5a01490 8fb1abd4178a 525ed90e4577 564e40829f80 564e40829f80 fac1f62a1d71 fac1f62a1d71 71ffa932799d e00dccb6f211 e00dccb6f211 e00dccb6f211 8fb1abd4178a 8fb1abd4178a e96bc5a01490 e00dccb6f211 e96bc5a01490 e96bc5a01490 e96bc5a01490 e96bc5a01490 e96bc5a01490 e96bc5a01490 e96bc5a01490 e96bc5a01490 e96bc5a01490 e96bc5a01490 e96bc5a01490 e00dccb6f211 fac1f62a1d71 3092016c6d0c e00dccb6f211 cdf4fda66dd9 928416088790 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 928416088790 928416088790 fac1f62a1d71 707dfdb1c7a8 707dfdb1c7a8 707dfdb1c7a8 707dfdb1c7a8 707dfdb1c7a8 2963f2894a7a 707dfdb1c7a8 2963f2894a7a fac1f62a1d71 f93b523c0be3 f93b523c0be3 f93b523c0be3 71ffa932799d f93b523c0be3 f93b523c0be3 f93b523c0be3 f93b523c0be3 f93b523c0be3 f93b523c0be3 71ffa932799d 2963f2894a7a fac1f62a1d71 2963f2894a7a cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 cdf4fda66dd9 928416088790 928416088790 cdf4fda66dd9 928416088790 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import logging
from pylons import tmpl_context as c, app_globals as g, session, request, config
from pylons_app.lib import helpers as h
from pylons_app.lib.base import BaseController, render
from mako.template import Template
from pylons.controllers.util import abort
from operator import itemgetter
from pylons_app.model.hg_model import HgModel
log = logging.getLogger(__name__)
class HgController(BaseController):
def __before__(self):
c.repos_prefix = config['repos_name']
c.staticurl = g.statics
def index(self):
hg_model = HgModel()
c.repos_list = list(hg_model.get_repos())
c.current_sort = request.GET.get('sort', 'name')
cs = c.current_sort
c.cs_slug = cs.replace('-', '')
sortables = ['name', 'description', 'last_change', 'tip', 'contact']
if cs and c.cs_slug in sortables:
sort_key = c.cs_slug + '_sort'
if cs.startswith('-'):
c.repos_list.sort(key=itemgetter(sort_key), reverse=True)
else:
c.repos_list.sort(key=itemgetter(sort_key), reverse=False)
return render('/index.html')
def view(self, *args, **kwargs):
#TODO: reimplement this not tu use hgwebdir
#patch for replacing mercurial servings with hg_app servings
vcs_impl = self._get_vcs_impl(request.environ)
if vcs_impl:
return vcs_impl
response = g.hgapp(request.environ, self.start_response)
http_accept = request.environ.get('HTTP_ACCEPT', False)
if not http_accept:
return abort(status_code=400, detail='no http accept in header')
#for mercurial protocols and raw files we can't wrap into mako
if http_accept.find("mercurial") != -1 or \
request.environ['PATH_INFO'].find('raw-file') != -1:
return response
try:
tmpl = u''.join(response)
template = Template(tmpl, lookup=request.environ['pylons.pylons']\
.config['pylons.app_globals'].mako_lookup)
except (RuntimeError, UnicodeDecodeError):
log.info('disabling unicode due to encoding error')
response = g.hgapp(request.environ, self.start_response)
tmpl = ''.join(response)
template = Template(tmpl, lookup=request.environ['pylons.pylons']\
.config['pylons.app_globals'].mako_lookup, disable_unicode=True)
return template.render(g=g, c=c, session=session, h=h)
def _get_vcs_impl(self, environ):
path_info = environ['PATH_INFO']
c.repo_name = path_info.split('/')[-2]
action = path_info.split('/')[-1]
if not action.startswith('_'):
return False
else:
hg_model = HgModel()
c.repo_info = hg_model.get_repo(c.repo_name)
c.repo_changesets = c.repo_info.get_changesets(10)
# c.repo_tags = c.repo_info.get_tags(limit=10)
# c.repo_branches = c.repo_info.get_branches(limit=10)
return render('/summary.html')
|