Changeset - 9a7ae16ff53e
[Not reviewed]
default
0 8 0
Marcin Kuzminski - 15 years ago 2010-08-18 16:24:27
marcin@python-works.com
fixes translations, style updates.
Added some extra info to activity graph
8 files changed with 78 insertions and 30 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/search.py
Show inline comments
 
@@ -23,16 +23,17 @@ search controller for pylons
 
@author: marcink
 
"""
 
from pylons import request, response, session, tmpl_context as c, url
 
from pylons.controllers.util import abort, redirect
 
from pylons_app.lib.auth import LoginRequired
 
from pylons_app.lib.base import BaseController, render
 
from pylons_app.lib.indexers import ANALYZER, IDX_LOCATION, SCHEMA
 
from pylons_app.lib.indexers import ANALYZER, IDX_LOCATION, SCHEMA, IDX_NAME
 
from webhelpers.html.builder import escape
 
from whoosh.highlight import highlight, SimpleFragmenter, HtmlFormatter, \
 
    ContextFragmenter
 
from pylons.i18n.translation import _
 
from whoosh.index import open_dir, EmptyIndexError
 
from whoosh.qparser import QueryParser, QueryParserError
 
from whoosh.query import Phrase
 
import logging
 
import traceback
 

	
 
@@ -53,13 +54,13 @@ class SearchController(BaseController):
 
        if c.cur_query:
 
            cur_query = c.cur_query.lower()
 
        
 
        
 
        if c.cur_query:
 
            try:
 
                idx = open_dir(IDX_LOCATION, indexname='HG_INDEX')
 
                idx = open_dir(IDX_LOCATION, indexname=IDX_NAME)
 
                searcher = idx.searcher()
 
            
 
                qp = QueryParser("content", schema=SCHEMA)
 
                try:
 
                    query = qp.parse(unicode(cur_query))
 
                    
 
@@ -96,17 +97,17 @@ class SearchController(BaseController):
 
                        d.update({'content_short':hl,
 
                                  'f_path':f_path})
 
                        #del d['content']
 
                        c.formated_results.append(d)
 
                                                    
 
                except QueryParserError:
 
                    c.runtime = 'Invalid search query. Try quoting it.'
 
                    c.runtime = _('Invalid search query. Try quoting it.')
 

	
 
            except (EmptyIndexError, IOError):
 
                log.error(traceback.format_exc())
 
                log.error('Empty Index data')
 
                c.runtime = 'There is no index to search in. Please run whoosh indexer'
 
                c.runtime = _('There is no index to search in. Please run whoosh indexer')
 
            
 

	
 
                
 
        # Return a rendered template
 
        return render('/search/search.html')
pylons_app/controllers/summary.py
Show inline comments
 
@@ -74,13 +74,14 @@ class SummaryController(BaseController):
 
        
 
        #graph range
 
        td = datetime.today() + timedelta(days=1) 
 
        y = td.year
 
        m = td.month
 
        d = td.day
 
        c.ts_min = mktime((y, (td - timedelta(days=calendar.mdays[m] - 1)).month, d, 0, 0, 0, 0, 0, 0,))
 
        c.ts_min = mktime((y, (td - timedelta(days=calendar.mdays[m] - 1)).month,
 
                            d, 0, 0, 0, 0, 0, 0,))
 
        c.ts_max = mktime((y, m, d, 0, 0, 0, 0, 0, 0,))
 

	
 
        
 
        def author_key_cleaner(k):
 
            k = person(k)
 
            return k
 
@@ -90,31 +91,50 @@ class SummaryController(BaseController):
 
                              cs.date.timetuple()[2])
 
            timetupple = [int(x) for x in k.split('-')]
 
            timetupple.extend([0 for _ in xrange(6)])
 
            k = mktime(timetupple)
 
            if aggregate.has_key(author_key_cleaner(cs.author)):
 
                if aggregate[author_key_cleaner(cs.author)].has_key(k):
 
                    aggregate[author_key_cleaner(cs.author)][k] += 1
 
                    aggregate[author_key_cleaner(cs.author)][k]["commits"] += 1
 
                    aggregate[author_key_cleaner(cs.author)][k]["added"] += len(cs.added)
 
                    aggregate[author_key_cleaner(cs.author)][k]["changed"] += len(cs.changed)
 
                    aggregate[author_key_cleaner(cs.author)][k]["removed"] += len(cs.removed)
 
                    
 
                else:
 
                    #aggregate[author_key_cleaner(cs.author)].update(dates_range)
 
                    if k >= c.ts_min and k <= c.ts_max:
 
                        aggregate[author_key_cleaner(cs.author)][k] = 1
 
                        aggregate[author_key_cleaner(cs.author)][k] = {}
 
                        aggregate[author_key_cleaner(cs.author)][k]["commits"] = 1
 
                        aggregate[author_key_cleaner(cs.author)][k]["added"] = len(cs.added)
 
                        aggregate[author_key_cleaner(cs.author)][k]["changed"] = len(cs.changed)
 
                        aggregate[author_key_cleaner(cs.author)][k]["removed"] = len(cs.removed) 
 
                                            
 
            else:
 
                if k >= c.ts_min and k <= c.ts_max:
 
                    aggregate[author_key_cleaner(cs.author)] = OrderedDict()
 
                    #aggregate[author_key_cleaner(cs.author)].update(dates_range)
 
                    aggregate[author_key_cleaner(cs.author)][k] = 1
 
                    aggregate[author_key_cleaner(cs.author)][k] = {}
 
                    aggregate[author_key_cleaner(cs.author)][k]["commits"] = 1
 
                    aggregate[author_key_cleaner(cs.author)][k]["added"] = len(cs.added)
 
                    aggregate[author_key_cleaner(cs.author)][k]["changed"] = len(cs.changed)
 
                    aggregate[author_key_cleaner(cs.author)][k]["removed"] = len(cs.removed)                 
 
        
 
        d = ''
 
        tmpl0 = u""""%s":%s"""
 
        tmpl1 = u"""{label:"%s",data:%s},"""
 
        tmpl1 = u"""{label:"%s",data:%s,schema:["commits"]},"""
 
        for author in aggregate:
 
            
 
            d += tmpl0 % (author.decode('utf8'),
 
                          tmpl1 \
 
                          % (author.decode('utf8'),
 
                        [[x, aggregate[author][x]] for x in aggregate[author]]))
 
                        [{"time":x,
 
                          "commits":aggregate[author][x]['commits'],
 
                          "added":aggregate[author][x]['added'],
 
                          "changed":aggregate[author][x]['changed'],
 
                          "removed":aggregate[author][x]['removed'],
 
                          } for x in aggregate[author]]))
 
        if d == '':
 
            d = '"%s":{label:"%s",data:[[0,1],]}' \
 
                % (author_key_cleaner(repo.contact),
 
                   author_key_cleaner(repo.contact))
 
        return d
 

	
pylons_app/public/css/diff.css
Show inline comments
 
@@ -64,13 +64,13 @@ table.code-difftable td {
 
.code-difftable .lineno{
 
	background:none repeat scroll 0 0 #EEEEEE !important;
 
	border-right:1px solid #DDDDDD;
 
	padding-left:2px;
 
	padding-right:2px;
 
	text-align:right;
 
	width:20px;
 
	width:30px;
 
	-moz-user-select:none;
 
	-webkit-user-select: none;
 
}
 
.code-difftable .lineno pre{
 
	color:#747474 !important;
 
	font:11px "Bitstream Vera Sans Mono",Monaco,"Courier New",Courier,monospace !important;
pylons_app/public/css/style.css
Show inline comments
 
@@ -182,13 +182,13 @@ div.options a:hover
 
	header
 
----------------------------------------------------------- */ 
 
 
#header
 
{
 
	margin: 0;
 
	padding: 0 60px 0 60px;
 
	padding: 0 30px 0 30px;
 
	background: #b0b0b0 url("../images/header_background.png") repeat;
 
}
 
 
 
/* -----------------------------------------------------------
 
	header -> user
pylons_app/public/css/style_full.css
Show inline comments
 
/* -----------------------------------------------------------
 
	GLOBAL WIDTH
 
----------------------------------------------------------- */
 
#header,#content,#footer{
 
	min-width: 1024px;
 
	min-width: 1224px;
 
}
 
 
/* -----------------------------------------------------------
 
	content
 
----------------------------------------------------------- */ 
 
 
#content 
 
{
 
	margin: 10px 60px 0 60px;
 
	margin: 10px 30px 0 30px;
 
	padding: 0;
 
    min-height: 100%;
 
	clear: both;
 
	overflow: hidden;
 
	background: transparent;
 
}
pylons_app/templates/files/files_annotate.html
Show inline comments
 
@@ -23,13 +23,14 @@
 
    </div>
 
    <div class="table">
 
		<div id="files_data">
 
			<h2>${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cur_rev,c.file.path)}</h2>
 
			<dl class="overview">
 
				<dt>${_('Last revision')}</dt>
 
				<dd>r${c.file.last_changeset.revision}:${c.file.last_changeset._short}</dd>
 
				<dd>${h.link_to("r%s:%s" % (c.file.last_changeset.revision,c.file.last_changeset._short),
 
						h.url('files_annotate_home',repo_name=c.repo_name,revision=c.file.last_changeset._short,f_path=c.f_path))} </dd>
 
				<dt>${_('Size')}</dt>
 
				<dd>${h.format_byte_size(c.file.size,binary=True)}</dd>
 
				<dt>${_('Options')}</dt>
 
				<dd>${h.link_to(_('show source'),
 
						h.url('files_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.f_path))}  
 
					/ ${h.link_to(_('download as raw'),
pylons_app/templates/files/files_source.html
Show inline comments
 
<dl>
 
	<dt>${_('Last revision')}</dt>
 
	<dd>r${c.files_list.last_changeset.revision}:${c.files_list.last_changeset._short}</dd>
 
	<dd>
 
		${h.link_to("r%s:%s" % (c.files_list.last_changeset.revision,c.files_list.last_changeset._short),
 
						h.url('files_home',repo_name=c.repo_name,revision=c.files_list.last_changeset._short,f_path=c.f_path))} 
 
	</dd>
 
	<dt>${_('Size')}</dt>
 
	<dd>${h.format_byte_size(c.files_list.size,binary=True)}</dd>
 
	<dt>${_('Options')}</dt>
 
	<dd>${h.link_to(_('show annotation'),
 
			h.url('files_annotate_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.f_path))}  
 
		 / ${h.link_to(_('download as raw'),
 
			h.url('files_raw_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.f_path))}
 
	</dd>
 
	<dt>${_('History')}</dt>
 
	<dd>
 
		${h.form(h.url('files_diff_home',repo_name=c.repo_name,f_path=c.f_path),method='GET')}
 
		<div>
 
		${h.form(h.url('files_diff_home',repo_name=c.repo_name,f_path=c.f_path),method='get')}
 
		${h.hidden('diff2',c.files_list.last_changeset._short)}
 
		${h.select('diff1','',c.file_history)}
 
		${h.submit('diff','diff',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
		${h.end_form()}
 
		</div>
 
	</dd>
 
</dl>	
 

	
 
	
 
<div id="body" class="codeblock">
 
	<div class="code-header">
pylons_app/templates/summary/summary.html
Show inline comments
 
@@ -115,20 +115,20 @@ E.onDOMReady(function(e){
 
			  </div>
 
			 </div>				 			 			 
 
	  </div>		 
 
	</div>				
 
</div>
 
        
 
<div class="box box-right">
 
<div class="box box-right"  style="min-height:455px">
 
    <!-- box / title -->
 
    <div class="title">
 
        <h5>${_('Last month commit activity')}</h5>
 
    </div>
 
    
 
    <div class="table">
 
        <div id="commit_history" style="width:460px;height:370px;float:left"></div>
 
        <div id="commit_history" style="width:560px;height:300px;float:left"></div>
 
    	<div id="legend_data">
 
	    	<div id="legend_container"></div>
 
	    	<div id="legend_choices">
 
				<table id="legend_choices_tables" style="font-size:smaller;color:#545454"></table>
 
	    	</div>
 
    	</div>
 
@@ -139,17 +139,16 @@ E.onDOMReady(function(e){
 
			var i = 0;
 
		    var choiceContainer = YAHOO.util.Dom.get("legend_choices");
 
		    var choiceContainerTable = YAHOO.util.Dom.get("legend_choices_tables");
 
		    for(var key in datasets) {
 
		        datasets[key].color = i;
 
		        i++;
 
		        choiceContainerTable.innerHTML += '<tr>'+
 
		        									'<td>'+
 
		        									'<input type="checkbox" name="' + key +'" checked="checked" />'+datasets[key].label+
 
		        									'</td>'+
 
		        								  '</tr>';
 
		        choiceContainerTable.innerHTML += '<tr><td>'+
 
		        '<input type="checkbox" name="' + key +'" checked="checked" />'
 
		        +datasets[key].label+
 
		        '</td></tr>';
 
		    };
 
		    
 

	
 
		    function plotAccordingToChoices() {
 
		        var data = [];
 

	
 
@@ -161,12 +160,13 @@ E.onDOMReady(function(e){
 
		            var key = inputs[i].name;
 
		            if (key && datasets[key])
 
		                data.push(datasets[key]);
 
		        };
 

	
 
		        if (data.length > 0){
 

	
 
				    var plot = YAHOO.widget.Flot("commit_history", data,
 
					        { bars: { show: true, align:'center',lineWidth:4 },
 
			    			  points: { show: true, radius:0,fill:true },
 
			    			  legend:{show:true, container:"legend_container"},
 
			    	          selection: { mode: "xy" },
 
			    	          yaxis: {tickDecimals:0},
 
@@ -208,24 +208,42 @@ E.onDOMReady(function(e){
 
		                        var tooltip = YAHOO.util.Dom.get("tooltip");
 
		                        if(tooltip) {
 
		                        	  tooltip.parentNode.removeChild(tooltip);
 
		                        }
 
		                        var x = item.datapoint.x.toFixed(2);
 
		                        var y = item.datapoint.y.toFixed(2);
 

	
 
								
 
		                        if (!item.series.label){
 
		                            item.series.label = 'commits';
 
			                    }
 
		                        var d = new Date(x*1000);
 
		                        var fd = d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate();
 
		                        var nr_commits = parseInt(y);
 
		                        var suffix = '';
 
		                        if(nr_commits > 1){
 
									var suffix = 's';		
 
				                }
 
		                        showTooltip(item.pageX, item.pageY, item.series.label + " on " + fd + ": " + nr_commits+" commit" + suffix);
 
		                        
 
		                        var cur_data = datasets[item.series.label].data[item.dataIndex];
 
				                var added = cur_data.added;
 
				                var changed = cur_data.changed;
 
				                var removed = cur_data.removed;
 
				                
 
		                        var nr_commits_suffix = " ${_('commits')} ";
 
		                        var added_suffix = " ${_('files added')} ";
 
			                    var changed_suffix = " ${_('files changed')} ";
 
				                var removed_suffix = " ${_('files removed')} ";
 

	
 
				                
 
		                        if(nr_commits == 1){nr_commits_suffix = " ${_('commit')} ";}
 
								if(added==1){added_suffix=" ${_('file added')} ";}
 
								if(changed==1){changed_suffix=" ${_('file changed')} ";}
 
								if(removed==1){removed_suffix=" ${_('file removed')} ";}
 
												                
 
		                        showTooltip(item.pageX, item.pageY, item.series.label + " on " + fd
 
										 +'<br/>'+
 
				                         nr_commits + nr_commits_suffix+'<br/>'+
 
				                         added + added_suffix +'<br/>'+
 
				                         changed + changed_suffix + '<br/>'+
 
				                         removed + removed_suffix + '<br/>');
 
		                    }
 
		                }
 
		                else {
 
		                	  var tooltip = YAHOO.util.Dom.get("tooltip");
 
		                	  
 
					          if(tooltip) {
 
@@ -250,26 +268,29 @@ E.onDOMReady(function(e){
 
<div class="box">    
 
    <div class="title">
 
        <div class="breadcrumbs">${h.link_to(_('Last ten changes'),h.url('changelog_home',repo_name=c.repo_name))}</div>
 
    </div>    
 
    <div class="table">
 
        <%include file='../shortlog/shortlog_data.html'/>
 
        ${h.link_to(_('show more'),h.url('changelog_home',repo_name=c.repo_name))}
 
    </div>
 
</div>
 
<div class="box">    
 
    <div class="title">
 
        <div class="breadcrumbs">${h.link_to(_('Last ten tags'),h.url('tags_home',repo_name=c.repo_name))}</div>
 
    </div>    
 
    <div class="table">
 
        <%include file='../tags/tags_data.html'/>
 
        ${h.link_to(_('show more'),h.url('tags_home',repo_name=c.repo_name))}
 
    </div>
 
</div>
 
<div class="box">
 
    <div class="title">
 
        <div class="breadcrumbs">${h.link_to(_('Last ten branches'),h.url('branches_home',repo_name=c.repo_name))}</div>
 
    </div>    
 
    <div class="table">
 
        <%include file='../branches/branches_data.html'/>
 
        ${h.link_to(_('show more'),h.url('branches_home',repo_name=c.repo_name))}
 
    </div>      
 
</div> 
 

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