##// END OF EJS Templates
Implemented paging to admin user acion log
Implemented paging to admin user acion log

File last commit:

r76:71401840 default
r78:6f524697 default
Show More
hg.py
82 lines | 3.0 KiB | text/x-python | PythonLexer
Marcin Kuzminski
initial commit.
r0 #!/usr/bin/python
# -*- coding: utf-8 -*-
import logging
Marcin Kuzminski
Added app basic auth....
r41 from pylons import tmpl_context as c, app_globals as g, session, request, config
Marcin Kuzminski
Removed default contact name...
r22 from pylons_app.lib import helpers as h
Marcin Kuzminski
refactoring update
r76 from pylons_app.lib.base import BaseController, render
Marcin Kuzminski
initial commit.
r0 from mako.template import Template
Bugfix when client is using old mercurial version and not setting http accept
r37 from pylons.controllers.util import abort
Marcin Kuzminski
refactoring update
r76
Marcin Kuzminski
Implemented main page sorting
r57 from operator import itemgetter
Marcin Kuzminski
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
r58 from pylons_app.model.hg_model import HgModel
Marcin Kuzminski
major app speedup moved the wsgi creation to app globals, in order to make it run only once....
r10 log = logging.getLogger(__name__)
Marcin Kuzminski
initial commit.
r0
class HgController(BaseController):
Marcin Kuzminski
Wrapped into mako templates,...
r21
def __before__(self):
Marcin Kuzminski
Added app basic auth....
r41 c.repos_prefix = config['repos_name']
Marcin Kuzminski
Implemented index page using vcs
r55 c.staticurl = g.statics
def index(self):
Marcin Kuzminski
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
r58 hg_model = HgModel()
c.repos_list = list(hg_model.get_repos())
Marcin Kuzminski
Implemented main page sorting
r57 c.current_sort = request.GET.get('sort', 'name')
Marcin Kuzminski
Implemented index page using vcs
r55
Marcin Kuzminski
Implemented main page sorting
r57 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)
Marcin Kuzminski
Implemented index page using vcs
r55 return render('/index.html')
Marcin Kuzminski
Wrapped into mako templates,...
r21
Marcin Kuzminski
Changed to webapp, removed get from routes,
r8 def view(self, *args, **kwargs):
Marcin Kuzminski
Implemented index page using vcs
r55 #TODO: reimplement this not tu use hgwebdir
Marcin Kuzminski
Started summary page. Added filters to templates. used by n,self.f.filtername prefixed by n to disable other filters. Few other fixes found
r74
vcs_impl = self._get_vcs_impl(request.environ)
if vcs_impl:
return vcs_impl
Marcin Kuzminski
Wrapped into mako templates,...
r21 response = g.hgapp(request.environ, self.start_response)
Bugfix when client is using old mercurial version and not setting http accept
r37
http_accept = request.environ.get('HTTP_ACCEPT', False)
if not http_accept:
return abort(status_code=400, detail='no http accept in header')
Marcin Kuzminski
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
r31 #for mercurial protocols and raw files we can't wrap into mako
Bugfix when client is using old mercurial version and not setting http accept
r37 if http_accept.find("mercurial") != -1 or \
Marcin Kuzminski
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
r31 request.environ['PATH_INFO'].find('raw-file') != -1:
Marcin Kuzminski
Wrapped into mako templates,...
r21 return response
Marcin Kuzminski
dirty fix for multiple file encodings,
r32 try:
tmpl = u''.join(response)
template = Template(tmpl, lookup=request.environ['pylons.pylons']\
Marcin Kuzminski
Added app basic auth....
r41 .config['pylons.app_globals'].mako_lookup)
Marcin Kuzminski
dirty fix for multiple file encodings,
r32
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']\
Marcin Kuzminski
Added app basic auth....
r41 .config['pylons.app_globals'].mako_lookup, disable_unicode=True)
Marcin Kuzminski
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
r31
Marcin Kuzminski
Wrapped into mako templates,...
r21
Marcin Kuzminski
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
r31 return template.render(g=g, c=c, session=session, h=h)
Marcin Kuzminski
Started summary page. Added filters to templates. used by n,self.f.filtername prefixed by n to disable other filters. Few other fixes found
r74
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)
return render('/summary.html')