Changeset - 237470e64bb8
[Not reviewed]
default
1 13 2
Marcin Kuzminski - 15 years ago 2010-06-13 23:56:16
marcin@python-works.com
switched filters into webhelpers for easy of usage.
Rewrite of html to use predefined templates from branches shortlog tags, for DRY usage.
Added info messages about empty branches/tags etc.
16 files changed with 119 insertions and 225 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/changelog.py
Show inline comments
 
@@ -49,12 +49,13 @@ class ChangelogController(BaseController
 
            session['changelog_size'] = c.size
 
            session.save()
 
        else:
 
            c.size = session.get('changelog_size', default)
 
            c.size = int(session.get('changelog_size', default))
 

	
 
        changesets = HgModel().get_repo(c.repo_name)
 
            
 
        p = int(request.params.get('page', 1))
 
        c.pagination = Page(changesets, page=p, item_count=len(changesets),
 
        c.total_cs = len(changesets)
 
        c.pagination = Page(changesets, page=p, item_count=c.total_cs,
 
                            items_per_page=c.size)
 
            
 
        #self._graph(c.repo, c.size,p)
pylons_app/controllers/graph.py
Show inline comments
 
@@ -25,9 +25,9 @@ graph controller for pylons
 
from mercurial.graphmod import revisions as graph_rev, colored, CHANGESET
 
from mercurial.node import short
 
from pylons import request, tmpl_context as c
 
import pylons_app.lib.helpers as h
 
from pylons_app.lib.auth import LoginRequired
 
from pylons_app.lib.base import BaseController, render
 
from pylons_app.lib.filters import age as _age, person
 
from pylons_app.model.hg_model import HgModel
 
from simplejson import dumps
 
from webhelpers.paginate import Page
 
@@ -74,9 +74,9 @@ class GraphController(BaseController):
 
            if type != CHANGESET:
 
                continue
 
            node = short(ctx.node())
 
            age = _age(ctx.date())
 
            age = h.age(ctx.date())
 
            desc = ctx.description()
 
            user = person(ctx.user())
 
            user = h.person(ctx.user())
 
            branch = ctx.branch()
 
            branch = branch, repo.repo.branchtags().get(branch) == ctx.node()
 
            data.append((node, vtx, edges, desc, user, age, branch, ctx.tags()))
pylons_app/controllers/summary.py
Show inline comments
 
@@ -25,7 +25,8 @@ summary controller for pylons
 
from pylons import tmpl_context as c, request
 
from pylons_app.lib.auth import LoginRequired
 
from pylons_app.lib.base import BaseController, render
 
from pylons_app.model.hg_model import HgModel, _full_changelog_cached
 
from pylons_app.model.hg_model import HgModel
 
from webhelpers.paginate import Page
 
import logging
 

	
 
log = logging.getLogger(__name__)
 
@@ -39,7 +40,7 @@ class SummaryController(BaseController):
 
    def index(self):
 
        hg_model = HgModel()
 
        c.repo_info = hg_model.get_repo(c.repo_name)
 
        c.repo_changesets = _full_changelog_cached(c.repo_name)[:10]
 
        c.repo_changesets = Page(list(c.repo_info[:10]), page=1, items_per_page=20)
 
        e = request.environ
 
        uri = u'%(protocol)s://%(user)s@%(host)s/%(repo_name)s' % {
 
                                        'protocol': e.get('wsgi.url_scheme'),
pylons_app/lib/filters.py
Show inline comments
 
deleted file
pylons_app/lib/helpers.py
Show inline comments
 
@@ -203,3 +203,29 @@ def repo_name_slug(value):
 
    return slug
 

	
 
flash = _Flash()
 

	
 

	
 
#===============================================================================
 
# MERCURIAL FILTERS available via h.
 
#===============================================================================
 

	
 

	
 
from mercurial import util
 
from mercurial.templatefilters import age as _age, person as _person
 

	
 
age = lambda  x:_age(x)
 
capitalize = lambda x: x.capitalize()
 
date = lambda x: util.datestr(x)
 
email = util.email
 
person = lambda x: _person(x)
 
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  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")
 
time_ago = lambda x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2")
 

	
 

	
 

	
 

	
pylons_app/templates/branches/branches.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 
<%! from pylons_app.lib import filters %>
 
<%def name="title()">
 
    ${_('Branches')}
 
</%def>
 
@@ -14,33 +13,6 @@
 
	${self.menu('branches')}    
 
</%def>
 
<%def name="main()">
 

	
 
    <h2 class="no-link no-border">${_('Branches')}</h2>
 

	
 
    <table class="table_disp">
 
    	<tr class="header">
 
			<td>${_('date')}</td>
 
			<td>${_('revision')}</td>
 
			<td>${_('name')}</td>
 
			<td>${_('links')}</td>
 
    	</tr>
 
		%for cnt,branch in enumerate(c.repo_branches.items()):
 
		<tr class="parity${cnt%2}">
 
			<td>${branch[1]._ctx.date()|n,filters.age}</td>
 
			<td>r${branch[1].revision}:${branch[1].raw_id}</td>
 
			<td>
 
				<span class="logtags">
 
					<span class="branchtag">${h.link_to(branch[0],
 
					h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}</span>
 
				</span>			
 
			</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			</td>
 
		</tr>	
 
		%endfor
 
    </table>
 

	
 
	<%include file='branches_data.html'/>
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/branches/branches_data.html
Show inline comments
 
new file 100644
 
% if c.repo_branches:
 
    <table class="table_disp">
 
    	<tr class="header">
 
			<td>${_('date')}</td>
 
			<td>${_('revision')}</td>
 
			<td>${_('name')}</td>
 
			<td>${_('links')}</td>
 
    	</tr>
 
		%for cnt,branch in enumerate(c.repo_branches.items()):
 
		<tr class="parity${cnt%2}">
 
			<td>${h.age(branch[1]._ctx.date())}</td>
 
			<td>r${branch[1].revision}:${branch[1].raw_id}</td>
 
			<td>
 
				<span class="logtags">
 
					<span class="branchtag">${h.link_to(branch[0],
 
					h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}</span>
 
				</span>			
 
			</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			</td>
 
		</tr>	
 
		%endfor
 
    </table>
 
%else:
 
	${_('There are no branches yet')}
 
%endif
 

	
pylons_app/templates/changelog/changelog.html
Show inline comments
 
<%!
 
from pylons_app.lib import filters
 
%>
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
@@ -19,8 +16,12 @@ from pylons_app.lib import filters
 

	
 
<%def name="main()">
 

	
 
    <h2 class="no-link no-border">${_('Changelog')} - ${_('showing last ')} ${c.size} ${_('revisions')}</h2>
 
    <h2 class="no-link no-border">${_('Changelog')} - ${_('showing ')} 
 
    	${c.size if c.size <= c.total_cs else c.total_cs}
 
    	${_('out of')} ${c.total_cs} ${_('revisions')}
 
    </h2>
 
	<noscript>${_('The revision graph only works with JavaScript-enabled browsers.')}</noscript>
 
% if c.pagination:
 

	
 
<div id="graph">
 
	##<div id="graph_nodes" style="height:1000px">
 
@@ -89,4 +90,7 @@ from pylons_app.lib import filters
 
<div>
 
	<h2>${c.pagination.pager('$link_previous ~2~ $link_next')}</h2>
 
</div>	
 
%else:
 
	${_('There are no changes yet')}
 
%endif
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/changeset/changeset.html
Show inline comments
 
<%!
 
from pylons_app.lib import filters
 
%>
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
pylons_app/templates/errors/error_404.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%!
 
from pylons_app.lib import filters
 
%>
 
<%inherit file="./../base/base.html"/>
 
            
 
<%def name="title()">
pylons_app/templates/index.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%!
 
from pylons_app.lib import filters
 
%>
 
<%inherit file="base/base.html"/>
 
<%def name="title()">
 
    ${c.repos_prefix} Mercurial Repositories
 
@@ -38,12 +35,12 @@ from pylons_app.lib import filters
 
		    <td>${h.link_to(repo['name'],
 
		    	h.url('summary_home',repo_name=repo['name']))}</td>
 
		    <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
 
	        <td>${repo['last_change']|n,filters.age}</td>
 
	        <td>${h.age(repo['last_change'])}</td>
 
	        <td>${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),
 
		        h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
 
	        	class_="tooltip",
 
		    	tooltip_title=h.tooltip(repo['last_msg']))}</td>
 
	        <td title="${repo['contact']}">${repo['contact']|n,filters.person}</td>
 
	        <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
 
			<td>
 
				<a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_logo"  href="${h.url('rss_feed_home',repo_name=repo['name'])}"></a>
 
			</td>        
pylons_app/templates/login.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%!
 
from pylons_app.lib import filters
 
%>
 
<%inherit file="base/base.html"/>
 
<%def name="title()">
 
    ${c.repos_prefix} Mercurial Repositories
pylons_app/templates/shortlog/shortlog_data.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%!
 
from pylons_app.lib import filters
 
%>
 
% if c.repo_changesets:
 

	
 
<table class="table_disp">
 
	<tr class="header">
 
		<td>${_('date')}</td>
 
@@ -15,8 +14,8 @@ from pylons_app.lib import filters
 
	</tr>
 
%for cnt,cs in enumerate(c.repo_changesets):
 
	<tr class="parity${cnt%2}">
 
		<td>${cs._ctx.date()|n,filters.age}</td>
 
		<td title="${cs.author}">${cs.author|n,filters.person}</td>
 
		<td>${h.age(cs._ctx.date())}</td>
 
		<td title="${cs.author}">${h.person(cs.author)}</td>
 
		<td>r${cs.revision}:${cs.raw_id}</td>
 
		<td>
 
			${h.link_to(h.truncate(cs.message,60),
 
@@ -59,4 +58,7 @@ from pylons_app.lib import filters
 
				YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');});		
 
		YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")}
 
		</h2>
 
	</div>	
 
\ No newline at end of file
 
	</div>	
 
%else:
 
	${_('There are no commits yet')}
 
%endif
 
\ No newline at end of file
pylons_app/templates/summary/summary.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 
<%!
 
from pylons_app.lib import filters
 
%>
 
<%def name="title()">
 
    ${_('Repository managment')}
 
</%def>
 
@@ -41,7 +38,7 @@ E.onDOMReady(function(e){
 
        <dt>${_('contact')}</dt>
 
        <dd>${c.repo_info.contact}</dd>
 
        <dt>${_('last change')}</dt>
 
        <dd>${c.repo_info.last_change|n,filters.age} - ${c.repo_info.last_change|n,filters.rfc822date}</dd>
 
        <dd>${h.age(c.repo_info.last_change)} - ${h.rfc822date(c.repo_info.last_change)}</dd>
 
        <dt>${_('clone url')}</dt>
 
        <dd><input type="text" id="clone_url"  readonly="readonly" value="hg clone ${c.clone_repo_url}" size="70"/></dd>
 
        <dt>${_('download')}</dt>
 
@@ -63,100 +60,12 @@ E.onDOMReady(function(e){
 
    </dl>
 

	
 
    <h2>${h.link_to(_('Last ten changes'),h.url('changelog_home',repo_name=c.repo_name))}</h2>
 
<table class="table_disp">
 
	<tr class="header">
 
		<td>${_('date')}</td>
 
		<td>${_('author')}</td>
 
		<td>${_('revision')}</td>
 
		<td>${_('commit message')}</td>
 
		<td>${_('branch')}</td>
 
		<td>${_('tags')}</td>
 
		<td>${_('links')}</td>
 
		
 
	</tr>
 
	%for cnt,cs in enumerate(c.repo_changesets):
 
		<tr class="parity${cnt%2}">
 
			<td>${cs._ctx.date()|n,filters.age}</td>
 
			<td>${cs.author|n,filters.person}</td>
 
			<td>r${cs.revision}:${cs.raw_id}</td>
 
			<td>
 
				${h.link_to(h.truncate(cs.message,60),
 
				h.url('changeset_home',repo_name=c.repo_name,revision=cs._short),
 
				title=cs.message)}
 
			</td>
 
			<td>
 
				<span class="logtags">
 
					<span class="branchtag">${cs.branch}</span>
 
				</span>
 
			</td>
 
			<td>
 
				<span class="logtags">
 
					%for tag in cs.tags:
 
						<span class="tagtag">${tag}</span>
 
					%endfor
 
				</span>
 
			</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=cs._short))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=cs._short))}
 
			</td>
 
		</tr>
 
	%endfor
 
    </table>
 
	<%include file='../shortlog/shortlog_data.html'/>
 

	
 
    <h2>${h.link_to(_('Last ten tags'),h.url('tags_home',repo_name=c.repo_name))}</h2>
 
    <table class="table_disp">
 
    	<tr class="header">
 
			<td>${_('date')}</td>
 
			<td>${_('revision')}</td>
 
			<td>${_('name')}</td>
 
			<td>${_('links')}</td>
 
    	</tr>
 
		%for cnt,tag in enumerate(c.repo_tags.items()):
 
		<tr class="parity${cnt%2}">
 
			<td>${tag[1]._ctx.date()|n,filters.age}</td>
 
			<td>r${tag[1].revision}:${tag[1].raw_id}</td>
 
			<td>
 
				<span class="logtags">
 
					<span class="tagtag">${h.link_to(tag[0],
 
					h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id))}</span>
 
				</span>
 
			</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
 
			</td>
 
		</tr>	
 
		%endfor
 
    </table>
 

	
 
	<%include file='../tags/tags_data.html'/>
 
    
 
    <h2>${h.link_to(_('Last ten branches'),h.url('branches_home',repo_name=c.repo_name))}</h2>
 
    <table class="table_disp">
 
    	<tr class="header">
 
			<td>${_('date')}</td>
 
			<td>${_('revision')}</td>
 
			<td>${_('name')}</td>
 
			<td>${_('links')}</td>
 
    	</tr>
 
		%for cnt,branch in enumerate(c.repo_branches.items()):
 
		<tr class="parity${cnt%2}">
 
			<td>${branch[1]._ctx.date()|n,filters.age}</td>
 
			<td>r${branch[1].revision}:${branch[1].raw_id}</td>
 
			<td>
 
				<span class="logtags">
 
					<span class="branchtag">${h.link_to(branch[0],
 
					h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}</span>
 
				</span>			
 
			</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			</td>
 
		</tr>	
 
		%endfor
 
    </table>
 
	<%include file='../branches/branches_data.html'/>
 

	
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/tags/tags.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 
<%!
 
from pylons_app.lib import filters
 
%>
 
<%def name="title()">
 
    ${_('Tags')}
 
</%def>
 
@@ -18,30 +15,6 @@ from pylons_app.lib import filters
 
<%def name="main()">
 

	
 
    <h2 class="no-link no-border">${_('Tags')}</h2>
 
    <table class="table_disp">
 
    	<tr class="header">
 
			<td>${_('date')}</td>
 
			<td>${_('revision')}</td>
 
			<td>${_('name')}</td>
 
			<td>${_('links')}</td>
 
    	</tr>
 
		%for cnt,tag in enumerate(c.repo_tags.items()):
 
		<tr class="parity${cnt%2}">
 
			<td>${tag[1]._ctx.date()|n,filters.age}</td>
 
			<td>r${tag[1].revision}:${tag[1].raw_id}</td>
 
			<td>
 
				<span class="logtags">
 
					<span class="tagtag">${h.link_to(tag[0],
 
					h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id))}</span>
 
				</span>
 
			</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
 
			</td>
 
		</tr>	
 
		%endfor
 
    </table>
 
	<%include file='tags_data.html'/>
 

	
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/tags/tags_data.html
Show inline comments
 
new file 100644
 
%if c.repo_tags:    
 
    <table class="table_disp">
 
    	<tr class="header">
 
			<td>${_('date')}</td>
 
			<td>${_('revision')}</td>
 
			<td>${_('name')}</td>
 
			<td>${_('links')}</td>
 
    	</tr>
 
		%for cnt,tag in enumerate(c.repo_tags.items()):
 
		<tr class="parity${cnt%2}">
 
			<td>${h.age(tag[1]._ctx.date())}</td>
 
			<td>r${tag[1].revision}:${tag[1].raw_id}</td>
 
			<td>
 
				<span class="logtags">
 
					<span class="tagtag">${h.link_to(tag[0],
 
					h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id))}</span>
 
				</span>
 
			</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
 
			</td>
 
		</tr>	
 
		%endfor
 
    </table>
 
%else:
 
	${_('There are no tags yet')}
 
%endif    
 
\ No newline at end of file
0 comments (0 inline, 0 general)