Changeset - cdf4fda66dd9
[Not reviewed]
default
0 4 2
Marcin Kuzminski - 16 years ago 2010-04-12 10:29:18
marcin@python-blog.com
Started summary page. Added filters to templates. used by n,self.f.filtername prefixed by n to disable other filters. Few other fixes found
6 files changed with 123 insertions and 2 deletions:
0 comments (0 inline, 0 general)
pylons_app/config/routing.py
Show inline comments
 
@@ -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='/')
 

	
pylons_app/controllers/hg.py
Show inline comments
 
@@ -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')
pylons_app/lib/filters.py
Show inline comments
 
new file 100644
 
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")
pylons_app/model/hg_model.py
Show inline comments
 
@@ -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
pylons_app/templates/base/base.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
##filters definition
 
<%namespace name="f" module="pylons_app.lib.filters" inheritable="True"/>
 

	
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
pylons_app/templates/summary.html
Show inline comments
 
new file 100644
 
<%inherit file="base/base.html"/>
 

	
 
<%def name="title()">
 
    ${_('Repository managment')}
 
</%def>
 
<%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>
 
<%def name="page_nav()">
 
        <form action="{url}log">
 
            {sessionvars%hiddenformentry}
 
            <dl class="search">
 
                <dt><label>Search: </label></dt>
 
                <dd><input type="text" name="rev" /></dd>
 
            </dl>
 
        </form>
 

	
 
        <ul class="page-nav">
 
            <li class="current">summary</li>
 
            <li><a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a></li>
 
            <li><a href="{url}log{sessionvars%urlparameter}">changelog</a></li>
 
            <li><a href="{url}graph/{node|short}{sessionvars%urlparameter}">graph</a></li>
 
            <li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li>
 
            <li><a href="{url}branches{sessionvars%urlparameter}">branches</a></li>
 
            <li><a href="{url}file/{node|short}{sessionvars%urlparameter}">files</a></li>
 
        </ul>
 
</%def>
 
<%def name="main()">
 

	
 
    <h2 class="no-link no-border">${_('Mercurial Repository Overview')}</h2>
 
    <dl class="overview">
 
        <dt>name</dt>
 
        <dd>${c.repo_info.name}</dd>
 
        <dt>description</dt>
 
        <dd>${c.repo_info.description}</dd>
 
        <dt>contact</dt>
 
        <dd>${c.repo_info.contact}</dd>
 
        <dt>last change</dt>
 
        <dd>${c.repo_info.last_change|n,self.f.rfc822date}</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.author}</td>
 
			<td>${cs.message}</td>
 
			<td class="nowrap">
 
			${h.link_to(u'changset')}
 
			|
 
			${h.link_to(u'files')}
 
			</td>
 
		</tr>
 
	%endfor
 
        <tr class="light">
 
            <td colspan="4"><a class="list" href="{url}shortlog{sessionvars%urlparameter}">...</a></td>
 
        </tr>
 
    </table>
 

	
 
    <h2><a href="{url}tags{sessionvars%urlparameter}">Tags</a></h2>
 
    <table>
 
{tags}
 
        <tr class="light">
 
            <td colspan="3"><a class="list" href="{url}tags{sessionvars%urlparameter}">...</a></td>
 
        </tr>
 
    </table>
 

	
 
    <h2 class="no-link">Branches</h2>
 
    <table>
 
    {branches%branchentry}
 
        <tr class="light">
 
          <td colspan="4"><a class="list"  href="#">...</a></td>
 
        </tr>
 
    </table>
 

	
 
</%def>    
 
\ No newline at end of file
0 comments (0 inline, 0 general)