# HG changeset patch # User Marcin Kuzminski # Date 1271535437 -7200 # Node ID 9284160887908f727a47e5abbbb25f90477cce4f # Parent 9fe23fdab9e958b1d963dc75fb4c304e5cfd66bf reimplemented summary page, added few filters, removed age from models and made it as filter. diff -r 9fe23fdab9e9 -r 928416088790 pylons_app/config/routing.py --- a/pylons_app/config/routing.py Sat Apr 17 19:59:06 2010 +0200 +++ b/pylons_app/config/routing.py Sat Apr 17 22:17:17 2010 +0200 @@ -30,7 +30,8 @@ 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('summary_home', '/{repo_name}/_summary', controller='hg', action='view') + map.connect('hg', '/{path_info:.*}', controller='hg', action="view", path_info='/') diff -r 9fe23fdab9e9 -r 928416088790 pylons_app/controllers/hg.py --- a/pylons_app/controllers/hg.py Sat Apr 17 19:59:06 2010 +0200 +++ b/pylons_app/controllers/hg.py Sat Apr 17 22:17:17 2010 +0200 @@ -38,9 +38,12 @@ 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) @@ -79,4 +82,7 @@ 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') + diff -r 9fe23fdab9e9 -r 928416088790 pylons_app/lib/app_globals.py --- a/pylons_app/lib/app_globals.py Sat Apr 17 19:59:06 2010 +0200 +++ b/pylons_app/lib/app_globals.py Sat Apr 17 22:17:17 2010 +0200 @@ -22,9 +22,6 @@ 'app_globals' variable """ - #two ways of building the merc app i don't know - #the fastest one but belive the wsgiapp is better - #self.hgapp = self.make_web_app() self.cache = CacheManager(**parse_cache_config_options(config)) self.hgapp = wsgiapplication(self.make_web_app) diff -r 9fe23fdab9e9 -r 928416088790 pylons_app/lib/filters.py --- a/pylons_app/lib/filters.py Sat Apr 17 19:59:06 2010 +0200 +++ b/pylons_app/lib/filters.py Sat Apr 17 22:17:17 2010 +0200 @@ -1,11 +1,14 @@ from mercurial import util +from mercurial.templatefilters import age as _age +age = lambda context, x:_age(x) 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]) +hgdate = lambda context, x: "%d %d" % x +isodate = lambda context, x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') +isodatesec = lambda context, x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') +localdate = lambda context, 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") +rfc3339date = lambda context, x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") +time_ago = lambda context, x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2") diff -r 9fe23fdab9e9 -r 928416088790 pylons_app/model/hg_model.py --- a/pylons_app/model/hg_model.py Sat Apr 17 19:59:06 2010 +0200 +++ b/pylons_app/model/hg_model.py Sat Apr 17 22:17:17 2010 +0200 @@ -15,7 +15,6 @@ from vcs.backends.hg import get_repositories, MercurialRepository except ImportError: print 'You have to import vcs module' -from mercurial.templatefilters import age class HgModel(object): """ @@ -43,7 +42,7 @@ tmp_d['name_sort'] = tmp_d['name'] tmp_d['description'] = mercurial_repo.description tmp_d['description_sort'] = tmp_d['description'] - tmp_d['last_change'] = age(last_change) + tmp_d['last_change'] = last_change tmp_d['last_change_sort'] = last_change[1] - last_change[0] tmp_d['tip'] = str(tip) tmp_d['tip_sort'] = tip.rev() @@ -55,6 +54,6 @@ yield tmp_d def get_repo(self, repo_name): - path = g.paths[0][1] - repo = MercurialRepository(os.path.join(path, repo_name), g.baseui) + path = g.paths[0][1].replace('*', '') + repo = MercurialRepository(os.path.join(path, repo_name), baseui=g.baseui) return repo diff -r 9fe23fdab9e9 -r 928416088790 pylons_app/templates/index.html --- a/pylons_app/templates/index.html Sat Apr 17 19:59:06 2010 +0200 +++ b/pylons_app/templates/index.html Sat Apr 17 22:17:17 2010 +0200 @@ -36,9 +36,9 @@ %for cnt,repo in enumerate(c.repos_list): - ${repo['name']} + ${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))} ${repo['description']} - ${repo['last_change']} + ${repo['last_change']|n,self.f.age} r${repo['rev']}:${repo['tip']} ${repo['contact']} diff -r 9fe23fdab9e9 -r 928416088790 pylons_app/templates/summary.html --- a/pylons_app/templates/summary.html Sat Apr 17 19:59:06 2010 +0200 +++ b/pylons_app/templates/summary.html Sat Apr 17 22:17:17 2010 +0200 @@ -40,20 +40,20 @@
contact
${c.repo_info.contact}
last change
-
${c.repo_info.last_change|n,self.f.rfc822date}
+
${c.repo_info.last_change|n,self.f.time_ago}

Changes

%for cnt,cs in enumerate(c.repo_changesets): - + - + %endfor @@ -62,9 +62,11 @@
${cs.date}${cs._ctx.date()|n,self.f.time_ago} ${cs.author}${cs.message}${h.link_to(cs.message,h.url('rev/'+str(cs._ctx)))} - ${h.link_to(u'changset')} + ${h.link_to(_('changeset'),h.url('file/'+str(cs._ctx)))} | - ${h.link_to(u'files')} + ${h.link_to(_('files'),h.url('file/'+str(cs._ctx)))}
-

Tags

+

${_('Tags')}

-{tags} + %for tag in c.repo_tags: + ${tag} + %endfor @@ -72,7 +74,9 @@
...
- {branches%branchentry} + %for branch in c.repo_branches: + ${branch} + %endfor
...