diff --git a/pylons_app/config/routing.py b/pylons_app/config/routing.py --- a/pylons_app/config/routing.py +++ b/pylons_app/config/routing.py @@ -28,7 +28,9 @@ def make_map(config): with map.submapper(path_prefix='/_admin', controller='admin') as m: m.connect('admin_home', '/', action='index')#main page m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', action='add_repo') - + + + map.connect('summary_home', '/{repo_name}/_summary', controller='hg', action='view') map.connect('hg', '/{path_info:.*}', controller='hg', action="view", path_info='/') diff --git a/pylons_app/controllers/hg.py b/pylons_app/controllers/hg.py --- a/pylons_app/controllers/hg.py +++ b/pylons_app/controllers/hg.py @@ -39,6 +39,10 @@ class HgController(BaseController): def view(self, *args, **kwargs): #TODO: reimplement this not tu use hgwebdir + + 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) @@ -63,3 +67,18 @@ class HgController(BaseController): 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) + return render('/summary.html') diff --git a/pylons_app/lib/filters.py b/pylons_app/lib/filters.py new file mode 100644 --- /dev/null +++ b/pylons_app/lib/filters.py @@ -0,0 +1,11 @@ +from mercurial import util + +capitalize = lambda x: x.capitalize() +date = lambda x: util.datestr(x) +email = util.email +hgdate = lambda x: "%d %d" % x +isodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') +isodatesec = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') +localdate = lambda x: (x[0], util.makedate()[1]) +rfc822date = lambda context, x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") +rfc3339date = lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") diff --git a/pylons_app/model/hg_model.py b/pylons_app/model/hg_model.py --- a/pylons_app/model/hg_model.py +++ b/pylons_app/model/hg_model.py @@ -12,7 +12,7 @@ import os from pylons import tmpl_context as c, app_globals as g, session, request, config from pylons.controllers.util import abort try: - from vcs.backends.hg import get_repositories + from vcs.backends.hg import get_repositories, MercurialRepository except ImportError: print 'You have to import vcs module' from mercurial.templatefilters import age @@ -53,3 +53,8 @@ class HgModel(object): tmp_d['repo_archives'] = mercurial_repo._get_archive_list() yield tmp_d + + def get_repo(self, repo_name): + path = g.paths[0][1] + repo = MercurialRepository(os.path.join(path, repo_name), g.baseui) + return repo diff --git a/pylons_app/templates/base/base.html b/pylons_app/templates/base/base.html --- a/pylons_app/templates/base/base.html +++ b/pylons_app/templates/base/base.html @@ -1,4 +1,7 @@ ## -*- coding: utf-8 -*- +##filters definition +<%namespace name="f" module="pylons_app.lib.filters" inheritable="True"/> + diff --git a/pylons_app/templates/summary.html b/pylons_app/templates/summary.html new file mode 100644 --- /dev/null +++ b/pylons_app/templates/summary.html @@ -0,0 +1,81 @@ +<%inherit file="base/base.html"/> + +<%def name="title()"> + ${_('Repository managment')} + +<%def name="breadcrumbs()"> + ${h.link_to(u'Home',h.url('/'))} + / + ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} + / + ${_('summary')} + +<%def name="page_nav()"> +
+ {sessionvars%hiddenformentry} + +
+ + + +<%def name="main()"> + + +
+
name
+
${c.repo_info.name}
+
description
+
${c.repo_info.description}
+
contact
+
${c.repo_info.contact}
+
last change
+
${c.repo_info.last_change|n,self.f.rfc822date}
+
+ +

Changes

+ + %for cnt,cs in enumerate(c.repo_changesets): + + + + + + + %endfor + + + +
${cs.date}${cs.author}${cs.message} + ${h.link_to(u'changset')} + | + ${h.link_to(u'files')} +
...
+ +

Tags

+ +{tags} + + + +
...
+ + + + {branches%branchentry} + + + +
...
+ + \ No newline at end of file