changeset 80:928416088790

reimplemented summary page, added few filters, removed age from models and made it as filter.
author Marcin Kuzminski <marcin@python-blog.com>
date Sat, 17 Apr 2010 22:17:17 +0200
parents 9fe23fdab9e9
children c2f27b9b81bc
files pylons_app/config/routing.py pylons_app/controllers/hg.py pylons_app/lib/app_globals.py pylons_app/lib/filters.py pylons_app/model/hg_model.py pylons_app/templates/index.html pylons_app/templates/summary.html
diffstat 7 files changed, 33 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- 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='/')
 
--- 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')
+
--- 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)
 
--- 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")
--- 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
--- 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 @@
 	  </tr>	
 	%for cnt,repo in enumerate(c.repos_list):
  		<tr class="parity${cnt%2}">
-		    <td><a href="/${repo['name']}">${repo['name']}</a></td>
+		    <td>${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td>
 		    <td>${repo['description']}</td>
-	        <td>${repo['last_change']}</td>
+	        <td>${repo['last_change']|n,self.f.age}</td>
 	        <td>r${repo['rev']}:<a href="/${repo['name']}/rev/${repo['tip']}/">${repo['tip']}</a></td>
 	        <td>${repo['contact']}</td>
 	        <td class="indexlinks">
--- 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 @@
         <dt>contact</dt>
         <dd>${c.repo_info.contact}</dd>
         <dt>last change</dt>
-        <dd>${c.repo_info.last_change|n,self.f.rfc822date}</dd>
+        <dd>${c.repo_info.last_change|n,self.f.time_ago}</dd>
     </dl>
 
     <h2><a href="{url}shortlog{sessionvars%urlparameter}">Changes</a></h2>
     <table>
 	%for cnt,cs in enumerate(c.repo_changesets):
 		<tr class="parity${cnt%2}">
-			<td>${cs.date}</td>
+			<td>${cs._ctx.date()|n,self.f.time_ago}</td>
 			<td>${cs.author}</td>
-			<td>${cs.message}</td>
+			<td>${h.link_to(cs.message,h.url('rev/'+str(cs._ctx)))}</td>
 			<td class="nowrap">
-			${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)))}
 			</td>
 		</tr>
 	%endfor
@@ -62,9 +62,11 @@
         </tr>
     </table>
 
-    <h2><a href="{url}tags{sessionvars%urlparameter}">Tags</a></h2>
+    <h2><a href="{url}tags{sessionvars%urlparameter}">${_('Tags')}</a></h2>
     <table>
-{tags}
+		%for tag in c.repo_tags:
+			${tag}
+		%endfor
         <tr class="light">
             <td colspan="3"><a class="list" href="{url}tags{sessionvars%urlparameter}">...</a></td>
         </tr>
@@ -72,7 +74,9 @@
 
     <h2 class="no-link">Branches</h2>
     <table>
-    {branches%branchentry}
+		%for branch in c.repo_branches:
+			${branch}
+		%endfor
         <tr class="light">
           <td colspan="4"><a class="list"  href="#">...</a></td>
         </tr>