Changeset - 928416088790
[Not reviewed]
default
0 7 0
Marcin Kuzminski - 16 years ago 2010-04-17 22:17:17
marcin@python-blog.com
reimplemented summary page,
added few filters, removed age from models and made it as filter.
7 files changed with 33 insertions and 23 deletions:
0 comments (0 inline, 0 general)
pylons_app/config/routing.py
Show inline comments
 
@@ -30,7 +30,8 @@ def make_map(config):
 
        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='/')
 

	
pylons_app/controllers/hg.py
Show inline comments
 
@@ -38,9 +38,12 @@ class HgController(BaseController):
 
    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 @@ class HgController(BaseController):
 
            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')
 

	
pylons_app/lib/app_globals.py
Show inline comments
 
@@ -22,9 +22,6 @@ class Globals(object):
 
        '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)
 

	
pylons_app/lib/filters.py
Show inline comments
 
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")
pylons_app/model/hg_model.py
Show inline comments
 
@@ -15,7 +15,6 @@ try:
 
    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 @@ class HgModel(object):
 
            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 @@ class HgModel(object):
 
            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
pylons_app/templates/index.html
Show inline comments
 
@@ -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">
pylons_app/templates/summary.html
Show inline comments
 
@@ -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>
0 comments (0 inline, 0 general)