Changeset - db39d0ca5308
[Not reviewed]
default
0 8 4
Marcin Kuzminski - 16 years ago 2010-04-18 11:23:10
marcin@python-blog.com
implemented Shortlog as seperate controller,
filters rewrite. Little html fixes
12 files changed with 148 insertions and 22 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -19,6 +19,7 @@ debug = true
 
#error_message = 'mercurial crash !'
 

	
 
[server:main]
 
threadpool_workers = 5
 
use = egg:Paste#http
 
host = 127.0.0.1
 
port = 5000
production.ini
Show inline comments
 
@@ -19,6 +19,7 @@ debug = true
 
#error_message = 'mercurial crash !'
 

	
 
[server:main]
 
threadpool_workers = 10
 
use = egg:Paste#http
 
host = 127.0.0.1
 
port = 8001
pylons_app/config/routing.py
Show inline comments
 
@@ -31,6 +31,7 @@ def make_map(config):
 
    
 
    
 
    map.connect('summary_home', '/{repo_name}/_summary', controller='summary')
 
    map.connect('shortlog_home', '/{repo_name}/_shortlog', controller='shortlog')
 
    
 
    map.connect('hg', '/{path_info:.*}', controller='hg',
 
                action="view", path_info='/')
pylons_app/controllers/shortlog.py
Show inline comments
 
new file 100644
 
import logging
 

	
 
from pylons import tmpl_context as c, app_globals as g, session, request, config, url
 
from pylons.controllers.util import abort, redirect
 

	
 
from pylons_app.lib.base import BaseController, render
 
from pylons_app.lib.utils import get_repo_slug
 
from pylons_app.model.hg_model import HgModel
 
from webhelpers.paginate import Page
 
log = logging.getLogger(__name__)
 

	
 
class ShortlogController(BaseController):
 
    def __before__(self):
 
        c.repos_prefix = config['repos_name']
 
        c.staticurl = g.statics
 
        c.repo_name = get_repo_slug(request)
 
        
 
        
 
    def index(self):
 
        hg_model = HgModel()
 
        lim = 20
 
        p = int(request.params.get('page', 1))
 
        repo = hg_model.get_repo(c.repo_name)
 
        cnt = repo.revisions[-1]
 
        gen = repo.get_changesets(None)
 
        repo_changesets = list(gen)
 
        repo_changesets2 = list(gen)
 
        repo_changesets3 = list(gen)
 
        repo_changesets4 = list(gen)
 
         
 
        c.repo_changesets = Page(repo_changesets, page=p, item_count=cnt, items_per_page=lim)
 
        c.shortlog_data = render('shortlog_data.html')
 
        if request.params.get('partial'):
 
            return c.shortlog_data
 
        return render('/shortlog.html')
pylons_app/lib/filters.py
Show inline comments
 
from mercurial import util
 
from mercurial.templatefilters import age as _age
 
from mercurial.templatefilters import age as _age, person as _person
 

	
 
age = lambda context, x:_age(x)
 
age = lambda  x:_age(x)
 
capitalize = lambda x: x.capitalize()
 
date = lambda x: util.datestr(x)
 
email = util.email
 
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 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")
 
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/admin_log.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
%if c.users_log:
 
<table>
 
	<tr>
 
@@ -17,11 +18,19 @@
 
	%endfor
 

	
 
	<tr>
 
	<script type="text/javascript">
 
	var data_div = 'user_log';
 
	YAHOO.util.Event.onDOMReady(function(){
 
		YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){
 
				YAHOO.util.Dom.setStyle('shortlog_data','opacity','0.3');});});
 
	</script>
 
		<td>${c.users_log.pager('$link_previous ~2~ $link_next',
 
		onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{
 
		success:function(o){YAHOO.util.Dom.get('user_log').innerHTML=o.responseText;}
 
		},null); return false;""")}</td>
 
	</tr>
 
		success:function(o){YAHOO.util.Dom.get(data_div).innerHTML=o.responseText;
 
		YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){
 
				YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');});		
 
		YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")}</td>
 
	</tr>	
 
</table>
 

	
 
%else: 
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/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,7 +40,7 @@
 
 		<tr class="parity${cnt%2}">
 
		    <td>${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td>
 
		    <td>${repo['description']}</td>
 
	        <td>${repo['last_change']|n,self.f.age}</td>
 
	        <td>${repo['last_change']|n,filters.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/shortlog.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('shortlog_home',repo_name=c.repo_name))}
 
    /
 
    ${_('shortlog')}
 
</%def>
 
<%def name="page_nav()">
 
        <form action="log">
 
            <dl class="search">
 
                <dt><label>Search: </label></dt>
 
                <dd><input type="text" name="rev" /></dd>
 
            </dl>
 
        </form>
 

	
 
        <ul class="page-nav">
 
            <li>${h.link(_('summary'),h.url('summary_home',repo_name=c.repo_name))}</li>
 
            <li class="current">${_('shortlog')}</li>
 
            <li><a href="log">changelog</a></li>
 
            <li><a href="graph/{node|short}">graph</a></li>
 
            <li><a href="tags">tags</a></li>
 
            <li><a href="branches">branches</a></li>
 
            <li><a href="file/{node|short}">files</a></li>
 
        </ul>      
 
</%def>
 
<%def name="main()">
 

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

	
 
	<div id="shortlog_data">
 
		${c.shortlog_data}
 
	</div>
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/shortlog_data.html
Show inline comments
 
new file 100644
 
## -*- coding: utf-8 -*-
 
<%!
 
from pylons_app.lib import filters
 
%>
 
<table>
 
%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.link_to(cs.message,h.url('rev/'+str(cs._ctx)))}</td>
 
		<td class="nowrap">
 
		${h.link_to(_('changeset'),h.url('file/'+str(cs._ctx)))}
 
		|
 
		${h.link_to(_('files'),h.url('file/'+str(cs._ctx)))}
 
		</td>
 
	</tr>
 
%endfor
 
	<tr>
 
	<script type="text/javascript">
 
	var data_div = 'shortlog_data';
 
	YAHOO.util.Event.onDOMReady(function(){
 
		YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){
 
				YAHOO.util.Dom.setStyle('shortlog_data','opacity','0.3');});});
 
	</script>
 
		<td>${c.repo_changesets.pager('$link_previous ~2~ $link_next',
 
		onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{
 
		success:function(o){YAHOO.util.Dom.get(data_div).innerHTML=o.responseText;
 
		YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){
 
				YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');});		
 
		YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")}</td>
 
	</tr>
 
</table>	
 
\ No newline at end of file
pylons_app/templates/summary.html
Show inline comments
 
<%inherit file="base/base.html"/>
 

	
 
<%!
 
from pylons_app.lib import filters
 
%>
 
<%def name="title()">
 
    ${_('Repository managment')}
 
</%def>
 
@@ -19,8 +21,8 @@
 
        </form>
 

	
 
        <ul class="page-nav">
 
            <li class="current">summary</li>
 
            <li><a href="shortlog">shortlog</a></li>
 
            <li class="current">${_('summary')}</li>
 
            <li>${h.link(_('shortlog'),h.url('shortlog_home',repo_name=c.repo_name))}</li>
 
            <li><a href="log">changelog</a></li>
 
            <li><a href="graph/{node|short}">graph</a></li>
 
            <li><a href="tags">tags</a></li>
 
@@ -39,7 +41,7 @@
 
        <dt>${_('contact')}</dt>
 
        <dd>${c.repo_info.contact}</dd>
 
        <dt>${_('last change')}</dt>
 
        <dd>${c.repo_info.last_change|n,self.f.rfc822date} - ${c.repo_info.last_change|n,self.f.age}</dd>
 
        <dd>${c.repo_info.last_change|n,filters.rfc822date} - ${c.repo_info.last_change|n,filters.age}</dd>
 
        <dt>${_('url')}</dt>
 
        <dd><pre>$ hg clone <a href="${c.clone_repo_url}">${c.clone_repo_url}</a></pre></dd>
 
        <dt>${_('Download')}</dt>
 
@@ -57,7 +59,7 @@
 
    <table>
 
	%for cnt,cs in enumerate(c.repo_changesets):
 
		<tr class="parity${cnt%2}">
 
			<td>${cs._ctx.date()|n,self.f.age}</td>
 
			<td>${cs._ctx.date()|n,filters.age}</td>
 
			<td>${cs.author}</td>
 
			<td>${h.link_to(cs.message,h.url('rev/'+str(cs._ctx)))}</td>
 
			<td class="nowrap">
pylons_app/tests/functional/test_shortlog.py
Show inline comments
 
new file 100644
 
from pylons_app.tests import *
 

	
 
class TestShortlogController(TestController):
 

	
 
    def test_index(self):
 
        response = self.app.get(url(controller='shortlog', action='index'))
 
        # Test response...
0 comments (0 inline, 0 general)