Changeset - d14723711d17
[Not reviewed]
beta
1 6 1
Marcin Kuzminski - 15 years ago 2011-02-04 17:36:41
marcin@python-works.com
fixes for journal, added paging now it's possible to view whole journal
fixed tooltip events for shortlog and journal paging. Moved journal to it's own templates
7 files changed with 63 insertions and 54 deletions:
0 comments (0 inline, 0 general)
docs/changelog.rst
Show inline comments
 
.. _changelog:
 

	
 
Changelog
 
=========
 

	
 
1.2.0 (**2011-XX-XX**)
 
======================
 

	
 
:status: in-progress
 
:branch: beta
 

	
 
news
 
----
 

	
 
- implemented #89 Can setup google analytics code from settings menu
 
- implemented #91 added nicer looking archive urls with more download options
 
  like tags, branches
 
- implemented #44 into file browsing, and added follow branch option
 
- implemented #102 allowing '.' in username
 
- implemented #84 downloads can be enabled/disabled for each repository 
 
- anonymous repository can be cloned without having to pass default:default
 
  into clone url
 
- fixed #90 whoosh indexer can index chooses repositories passed in command 
 
  line
 
- added dynamic download links in summary. With quick branch/tag selection
 
- extended journal with day aggregates and paging
 
- implemented #107 customizable code highlights on code sources
 

	
 
- implemented #108 extended and more powerfull LDAP configuration
 
fixes
 
-----
 

	
 
- fixed file browser bug, when switching into given form revision the url was 
 
  not changing
 
- fixed propagation to error controller on simplehg and simplegit middlewares
 
- fixed error when trying to make a download on empty repository
 
- fixed ehlo command on mailserver. Was not working on some hosting setups
 
- fixed problem with '[' chars in commit messages in journal
 
- fixed #99 Unicode errors, on file node paths with non utf-8 characters
 
- fixed #106 relation issues on databases different than sqlite
 

	
 
1.1.2 (**2011-01-12**)
 
======================
 

	
 
news
 
----
 

	
 

	
 
fixes
 
-----
 

	
 
- fixes #98 protection against float division of percentage stats
 
- fixed graph bug
rhodecode/controllers/journal.py
Show inline comments
 
@@ -9,90 +9,95 @@
 
    :author: marcink
 
    :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>    
 
    :license: GPLv3, see COPYING for more details.
 
"""
 
# This program is free software; you can redistribute it and/or
 
# modify it under the terms of the GNU General Public License
 
# as published by the Free Software Foundation; version 2
 
# of the License or (at your opinion) any later version of the license.
 
# 
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
# 
 
# You should have received a copy of the GNU General Public License
 
# along with this program; if not, write to the Free Software
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
# MA  02110-1301, USA.
 

	
 
import logging
 
from sqlalchemy import or_
 

	
 
from pylons import request, response, session, tmpl_context as c, url
 

	
 
from webhelpers.paginate import Page
 

	
 
from rhodecode.lib.auth import LoginRequired, NotAnonymous
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.helpers import get_token
 
from rhodecode.lib.utils import OrderedDict
 
from rhodecode.model.db import UserLog, UserFollowing
 
from rhodecode.model.scm import ScmModel
 

	
 
from paste.httpexceptions import HTTPInternalServerError
 

	
 
log = logging.getLogger(__name__)
 

	
 
class JournalController(BaseController):
 

	
 

	
 
    @LoginRequired()
 
    @NotAnonymous()
 
    def __before__(self):
 
        super(JournalController, self).__before__()
 

	
 
    def index(self):
 
        # Return a rendered template
 

	
 
        c.following = self.sa.query(UserFollowing)\
 
            .filter(UserFollowing.user_id == c.rhodecode_user.user_id).all()
 

	
 
        repo_ids = [x.follows_repository.repo_id for x in c.following
 
                    if x.follows_repository is not None]
 
        user_ids = [x.follows_user.user_id for x in c.following
 
                    if x.follows_user is not None]
 

	
 
        journal = self.sa.query(UserLog)\
 
            .filter(or_(
 
                        UserLog.repository_id.in_(repo_ids),
 
                        UserLog.user_id.in_(user_ids),
 
                        ))\
 
            .order_by(UserLog.action_date.desc())\
 
            .limit(30)\
 
            .all()
 
            .order_by(UserLog.action_date.desc())
 

	
 

	
 
        c.journal_day_aggreagate = self._get_daily_aggregate(journal)
 
        p = int(request.params.get('page', 1))
 
        c.journal_pager = Page(journal, page=p, items_per_page=10)
 
        c.journal_day_aggreagate = self._get_daily_aggregate(c.journal_pager)
 
        c.journal_data = render('journal/journal_data.html')
 
        if request.params.get('partial'):
 
            return c.journal_data
 

	
 
        return render('/journal.html')
 
        return render('journal/journal.html')
 

	
 

	
 
    def _get_daily_aggregate(self, journal):
 
        from itertools import groupby
 
        groups = []
 
        for k, g in groupby(journal, lambda x:x.action_as_day):
 
            groups.append((k, list(g),))      # Store group iterator as a list
 

	
 
        return groups
 

	
 

	
 
    def toggle_following(self):
 
        cur_token = request.POST.get('auth_token')
 
        token = get_token()
 
        if cur_token == token:
 
            scm_model = ScmModel()
 

	
 
            user_id = request.POST.get('follows_user_id')
 
            if user_id:
 
                try:
 
                    scm_model.toggle_following_user(user_id,
 
                                                    c.rhodecode_user.user_id)
 
                    return 'ok'
 
                except:
rhodecode/lib/helpers.py
Show inline comments
 
@@ -458,49 +458,49 @@ def action_parser(user_log):
 

	
 
    x = action.split(':')
 

	
 
    if len(x) > 1:
 
        action, action_params = x
 

	
 
    def get_cs_links():
 
        revs_limit = 5 #display this amount always
 
        revs_top_limit = 50 #show upto this amount of changesets hidden
 
        revs = action_params.split(',')
 
        repo_name = user_log.repository.repo_name
 
        from rhodecode.model.scm import ScmModel
 

	
 
        message = lambda rev: get_changeset_safe(ScmModel().get(repo_name),
 
                                                 rev).message
 

	
 
        cs_links = " " + ', '.join ([link_to(rev,
 
                url('changeset_home',
 
                repo_name=repo_name,
 
                revision=rev), title=tooltip(message(rev)),
 
                class_='tooltip') for rev in revs[:revs_limit] ])
 
        if len(revs) > revs_limit:
 
            uniq_id = revs[0]
 
            html_tmpl = ('<span> %s '
 
            '<a class="show_more" id="_%s" href="#">%s</a> '
 
            '<a class="show_more" id="_%s" href="#more">%s</a> '
 
            '%s</span>')
 
            cs_links += html_tmpl % (_('and'), uniq_id, _('%s more') \
 
                                        % (len(revs) - revs_limit),
 
                                        _('revisions'))
 

	
 
            html_tmpl = '<span id="%s" style="display:none"> %s </span>'
 
            cs_links += html_tmpl % (uniq_id, ', '.join([link_to(rev,
 
                url('changeset_home',
 
                repo_name=repo_name, revision=rev),
 
                title=message(rev), class_='tooltip')
 
                for rev in revs[revs_limit:revs_top_limit]]))
 

	
 
        return cs_links
 

	
 
    def get_fork_name():
 
        from rhodecode.model.scm import ScmModel
 
        repo_name = action_params
 
        repo = ScmModel().get(repo_name)
 
        if repo is None:
 
            return repo_name
 
        return link_to(action_params, url('summary_home',
 
                                          repo_name=repo.name,),
 
                                          title=repo.dbrepo.description)
 

	
rhodecode/public/css/style.css
Show inline comments
 
@@ -1384,48 +1384,77 @@ padding:7px 7px 6px;
 
}
 
 
#register div.form div.fields div.buttons {
 
clear:both;
 
overflow:hidden;
 
border-top:1px solid #DDD;
 
text-align:left;
 
margin:0;
 
padding:10px 0 0 150px;
 
}
 
 
#register div.form div.fields div.buttons div.highlight input.ui-button {
 
background:url("../images/button_highlight.png") repeat-x scroll 0 0 #4E85BB;
 
color:#FFF;
 
border-color:#5C91A4 #2B7089 #1A6480 #2A6F89;
 
border-style:solid;
 
border-width:1px;
 
}
 
 
#register div.form div.activation_msg {
 
padding-top:4px;
 
padding-bottom:4px;
 
}
 
 
#journal .journal_day{
 
font-size:20px;
 
padding:10px 0px;
 
border-bottom:2px solid #DDD;
 
margin-left:10px;
 
margin-right:10px;
 
}
 
 
#journal .journal_action{
 
padding-top:4px;
 
min-height:15px;
 
}
 
 
#journal .journal_icon{
 
float: left;
 
padding-top: 4px;
 
padding-left:12px;
 
}
 
 
#journal .journal_repo{
 
margin-left: 38px;
 
padding-top: 5px;
 
}
 
 
#journal .journal_repo .journal_repo_name{
 
font-weight: bold;
 
font-size: 1.1em;
 
}
 
 
.trending_language_tbl,.trending_language_tbl td {
 
border:0 !important;
 
margin:0 !important;
 
padding:0 !important;
 
}
 
 
.trending_language {
 
background-color:#003367;
 
color:#FFF;
 
display:block;
 
min-width:20px;
 
text-decoration:none;
 
height:12px;
 
margin-bottom:4px;
 
margin-left:5px;
 
white-space:pre;
 
padding:3px;
 
}
 
 
h3.files_location {
 
font-size:1.8em;
 
font-weight:700;
 
border-bottom:none !important;
 
margin:10px 0 !important;
rhodecode/templates/base/base.html
Show inline comments
 
@@ -84,49 +84,54 @@
 
            <% messages = h.flash.pop_messages() %>
 
            % if messages:
 
            <ul id="flash-messages">
 
                % for message in messages:
 
                <li class="${message.category}_msg">${message}</li>
 
                % endfor
 
            </ul>
 
            % endif
 
        </div>	    
 
	    <div id="main"> 
 
	        ${next.main()}
 
	    </div>
 
	</div> 
 
    <!-- END CONTENT -->
 

	
 
	<!-- footer -->
 
	<div id="footer">
 
	   <div id="footer-inner" class="title bottom-left-rounded-corner bottom-right-rounded-corner">
 
	       <div>
 
	           <p class="footer-link">${h.link_to(_('Submit a bug'),h.url('bugtracker'))}</p>
 
		       <p class="footer-link">${h.link_to(_('GPL license'),h.url('gpl_license'))}</p>
 
		       <p>RhodeCode ${c.rhodecode_version} &copy; 2010 by Marcin Kuzminski</p>
 
	       </div>
 
	   </div>
 
        <script type="text/javascript">${h.tooltip.activate()}</script>
 
        <script type="text/javascript">
 
        function tooltip_activate(){
 
        ${h.tooltip.activate()}
 
        }
 
        tooltip_activate();
 
        </script>
 
	</div>
 
	<!-- end footer -->
 
</body>
 

	
 
</html>
 

	
 
### MAKO DEFS ### 
 
<%def name="page_nav()">
 
	${self.menu()}
 
</%def>
 

	
 
<%def name="menu(current=None)">
 
		<% 
 
		def is_current(selected):
 
			if selected == current:
 
				return h.literal('class="current"')
 
		%>
 
		%if current not in ['home','admin']:           		
 
		   ##REGULAR MENU            
 
	        <ul id="quick">
 
				<!-- repo switcher -->
 
				<li>
 
					<a id="repo_switcher" title="${_('Switch repository')}" href="#">
 
                    <span class="icon">
rhodecode/templates/journal/journal.html
Show inline comments
 
file renamed from rhodecode/templates/journal.html to rhodecode/templates/journal/journal.html
 
## -*- coding: utf-8 -*-
 
<%inherit file="base/base.html"/>
 
<%inherit file="/base/base.html"/>
 
<%def name="title()">
 
    ${_('Journal')} - ${c.rhodecode_name}
 
</%def>
 
<%def name="breadcrumbs()">
 
	${c.rhodecode_name}
 
</%def>
 
<%def name="page_nav()">
 
	${self.menu('home')}
 
</%def>
 
<%def name="main()">
 
	
 
    <div class="box box-left">
 
	    <!-- box / title -->
 
	    <div class="title">
 
	        <h5>${_('Journal')}</h5>
 
	    </div>
 
	    <div>
 
	    %if c.journal_day_aggreagate:
 
            %for day,items in c.journal_day_aggreagate:
 
            <div style="font-size:20px;padding:10px 5px">${day}</div>
 
	            % for entry in items:
 
	            <div style="padding:10px">
 
	                <div class="gravatar">
 
	                    <img alt="gravatar" src="${h.gravatar_url(entry.user.email)}"/>
 
	                </div>
 
	                <div>${entry.user.name} ${entry.user.lastname}</div>
 
	                <div style="padding-left: 45px;padding-top:5px;min-height:20px">${h.action_parser(entry)}</div>
 
	                <div style="float: left; padding-top: 8px;padding-left:18px">
 
	                ${h.action_parser_icon(entry)}
 
	                </div>
 
	                <div style="margin-left: 45px;padding-top: 10px">
 
	                <span style="font-weight: bold;font-size: 1.1em">
 
			        %if entry.repository:
 
			          ${h.link_to(entry.repository.repo_name,
 
			                      h.url('summary_home',repo_name=entry.repository.repo_name))}
 
			        %else:
 
			          ${entry.repository_name}
 
			        %endif             
 
	                </span> - <span title="${entry.action_date}">${h.age(entry.action_date)}</span>
 
	                </div>
 
	            </div>
 
	            <div style="clear:both;border-bottom:1px dashed #DDD;padding:3px 3px;margin:0px 10px 0px 10px"></div>
 
	            %endfor
 
            %endfor
 
        %else:
 
            ${_('No entries yet')}
 
        %endif   
 
	    </div>
 
		<script type="text/javascript">
 
		function show_more_event(){
 
		YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){
 
		    var el = e.target;
 
		    YUD.setStyle(YUD.get(el.id.substring(1)),'display','');
 
		    YUD.setStyle(el.parentNode,'display','none');
 
		});
 
		}
 
		</script> 	    
 
	    <div id="journal">${c.journal_data}</div>
 
    </div>
 
    
 
    <div class="box box-right">
 
        <!-- box / title -->
 
        <div class="title">
 
            <h5>${_('Following')}</h5>
 
        </div>
 
        <div>
 
        %if c.following:
 
            %for entry in c.following:
 
                <div class="currently_following">
 
                    %if entry.follows_user_id:
 
                      <img title="${_('following user')}" alt="${_('user')}" src="/images/icons/user.png"/>
 
                      ${entry.follows_user.full_contact}
 
                    %endif
 
                    
 
                    %if entry.follows_repo_id:
 
                    
 
                      %if entry.follows_repository.private:
 
                        <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="/images/icons/lock.png"/>
 
                      %else:
 
                        <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="/images/icons/lock_open.png"/>
 
                      %endif
 
                      
 
                      ${h.link_to(entry.follows_repository.repo_name,h.url('summary_home',
 
                        repo_name=entry.follows_repository.repo_name))}
 
                      
 
                    %endif
 
                </div>
 
            %endfor
 
        %else:
 
            ${_('You are not following any users or repositories')}
 
        %endif               
 
        </div>
 
    </div>
 
    
 
    <script type="text/javascript">
 
    YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){
 
        var el = e.target;
 
        YUD.setStyle(YUD.get(el.id.substring(1)),'display','');
 
        YUD.setStyle(el.parentNode,'display','none');
 
    });    
 
    </script>
 
    
 
</%def>    
rhodecode/templates/shortlog/shortlog_data.html
Show inline comments
 
@@ -28,38 +28,39 @@
 
				<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.raw_id))}
 
		|
 
		${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}
 
		</td>
 
	</tr>
 
%endfor
 

	
 
</table>
 

	
 
<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');});});
 
            YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');});});
 
</script>
 

	
 
<div class="pagination-wh pagination-left">
 
${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(){
 
tooltip_activate();
 
YUE.on(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;""")}
 
</div>
 
%else:
 
    ${_('There are no changes yet')}
 
%endif
0 comments (0 inline, 0 general)