Changeset - ffd07396d315
rhodecode/config/routing.py
Show inline comments
 
"""
 
Routes configuration
 

	
 
The more specific and detailed routes should be defined first so they
 
may take precedent over the more generic routes. For more information
 
refer to the routes manual at http://routes.groovie.org/docs/
 
"""
 
from __future__ import with_statement
 
from routes import Mapper
 
from rhodecode.lib.utils import check_repo_fast as cr
 

	
 
def make_map(config):
 
    """Create, configure and return the routes Mapper"""
 
    map = Mapper(directory=config['pylons.paths']['controllers'],
 
                 always_scan=config['debug'])
 
    map.minimization = False
 
    map.explicit = False
 

	
 
    def check_repo(environ, match_dict):
 
        """
 
        check for valid repository for proper 404 handling
 
        :param environ:
 
        :param match_dict:
 
        """
 
        repo_name = match_dict.get('repo_name')
 
        return not cr(repo_name, config['base_path'])
 

	
 
    # The ErrorController route (handles 404/500 error pages); it should
 
    # likely stay at the top, ensuring it can always be resolved
 
    map.connect('/error/{action}', controller='error')
 
    map.connect('/error/{action}/{id}', controller='error')
 

	
 
    #==========================================================================
 
    # CUSTOM ROUTES HERE
 
    #==========================================================================
 

	
 
    #MAIN PAGE
 
    map.connect('hg_home', '/', controller='hg', action='index')
 
    map.connect('home', '/', controller='home', action='index')
 
    map.connect('bugtracker', "http://bitbucket.org/marcinkuzminski/rhodecode/issues", _static=True)
 
    map.connect('gpl_license', "http://www.gnu.org/licenses/gpl.html", _static=True)
 
    #ADMIN REPOSITORY REST ROUTES
 
    with map.submapper(path_prefix='/_admin', controller='admin/repos') as m:
 
        m.connect("repos", "/repos",
 
             action="create", conditions=dict(method=["POST"]))
 
        m.connect("repos", "/repos",
 
             action="index", conditions=dict(method=["GET"]))
 
        m.connect("formatted_repos", "/repos.{format}",
 
             action="index",
 
            conditions=dict(method=["GET"]))
 
        m.connect("new_repo", "/repos/new",
 
             action="new", conditions=dict(method=["GET"]))
 
        m.connect("formatted_new_repo", "/repos/new.{format}",
 
             action="new", conditions=dict(method=["GET"]))
 
        m.connect("/repos/{repo_name:.*}",
 
             action="update", conditions=dict(method=["PUT"],
 
                                              function=check_repo))
 
        m.connect("/repos/{repo_name:.*}",
 
             action="delete", conditions=dict(method=["DELETE"],
 
                                              function=check_repo))
 
        m.connect("edit_repo", "/repos/{repo_name:.*}/edit",
 
             action="edit", conditions=dict(method=["GET"],
 
                                            function=check_repo))
 
        m.connect("formatted_edit_repo", "/repos/{repo_name:.*}.{format}/edit",
 
             action="edit", conditions=dict(method=["GET"],
 
                                            function=check_repo))
 
        m.connect("repo", "/repos/{repo_name:.*}",
 
             action="show", conditions=dict(method=["GET"],
 
                                            function=check_repo))
 
        m.connect("formatted_repo", "/repos/{repo_name:.*}.{format}",
 
             action="show", conditions=dict(method=["GET"],
 
                                            function=check_repo))
 
        #ajax delete repo perm user
 
        m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*}",
 
             action="delete_perm_user", conditions=dict(method=["DELETE"],
 
                                                        function=check_repo))
 

	
 
    #ADMIN USER REST ROUTES
 
    map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
 

	
 
    #ADMIN PERMISSIONS REST ROUTES
 
    map.resource('permission', 'permissions', controller='admin/permissions', path_prefix='/_admin')
 

	
 
    #ADMIN SETTINGS REST ROUTES
 
    with map.submapper(path_prefix='/_admin', controller='admin/settings') as m:
 
        m.connect("admin_settings", "/settings",
 
             action="create", conditions=dict(method=["POST"]))
 
        m.connect("admin_settings", "/settings",
 
             action="index", conditions=dict(method=["GET"]))
 
        m.connect("formatted_admin_settings", "/settings.{format}",
 
             action="index", conditions=dict(method=["GET"]))
 
        m.connect("admin_new_setting", "/settings/new",
 
             action="new", conditions=dict(method=["GET"]))
 
        m.connect("formatted_admin_new_setting", "/settings/new.{format}",
 
             action="new", conditions=dict(method=["GET"]))
 
        m.connect("/settings/{setting_id}",
 
             action="update", conditions=dict(method=["PUT"]))
 
        m.connect("/settings/{setting_id}",
 
             action="delete", conditions=dict(method=["DELETE"]))
 
        m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
 
             action="edit", conditions=dict(method=["GET"]))
 
        m.connect("formatted_admin_edit_setting", "/settings/{setting_id}.{format}/edit",
 
             action="edit", conditions=dict(method=["GET"]))
 
        m.connect("admin_setting", "/settings/{setting_id}",
 
             action="show", conditions=dict(method=["GET"]))
 
        m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
 
             action="show", conditions=dict(method=["GET"]))
 
        m.connect("admin_settings_my_account", "/my_account",
 
             action="my_account", conditions=dict(method=["GET"]))
 
        m.connect("admin_settings_my_account_update", "/my_account_update",
 
             action="my_account_update", conditions=dict(method=["PUT"]))
 
        m.connect("admin_settings_create_repository", "/create_repository",
 
             action="create_repository", conditions=dict(method=["GET"]))
 

	
 
    #ADMIN MAIN PAGES
 
    with map.submapper(path_prefix='/_admin', controller='admin/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')
 
    #SEARCH
 
    map.connect('search', '/_admin/search', controller='search',)
 
    map.connect('search_repo', '/_admin/search/{search_repo:.*}', controller='search')
 

	
 
    #LOGIN/LOGOUT/REGISTER/SIGN IN
 
    map.connect('login_home', '/_admin/login', controller='login')
 
    map.connect('logout_home', '/_admin/logout', controller='login', action='logout')
 
    map.connect('register', '/_admin/register', controller='login', action='register')
 
    map.connect('reset_password', '/_admin/password_reset', controller='login', action='password_reset')
 

	
 
    #FEEDS
 
    map.connect('rss_feed_home', '/{repo_name:.*}/feed/rss',
 
                controller='feed', action='rss',
 
                conditions=dict(function=check_repo))
 
    map.connect('atom_feed_home', '/{repo_name:.*}/feed/atom',
 
                controller='feed', action='atom',
rhodecode/controllers/admin/repos.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# repos controller for pylons
 
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 
#
 
# 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.
 
"""
 
Created on April 7, 2010
 
admin controller for pylons
 
@author: marcink
 
"""
 
from formencode import htmlfill
 
from operator import itemgetter
 
from paste.httpexceptions import HTTPInternalServerError
 
from pylons import request, response, session, tmpl_context as c, url
 
from pylons.controllers.util import abort, redirect
 
from pylons.i18n.translation import _
 
from rhodecode.lib import helpers as h
 
from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
 
    HasPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.utils import invalidate_cache, action_logger
 
from rhodecode.model.db import User
 
from rhodecode.model.forms import RepoForm
 
from rhodecode.model.hg import HgModel
 
from rhodecode.model.repo import RepoModel
 
import formencode
 
import logging
 
import traceback
 

	
 
log = logging.getLogger(__name__)
 

	
 
class ReposController(BaseController):
 
    """REST Controller styled on the Atom Publishing Protocol"""
 
    # To properly map this controller, ensure your config/routing.py
 
    # file has a resource setup:
 
    #     map.resource('repo', 'repos')
 
    
 

	
 
    @LoginRequired()
 
    @HasPermissionAnyDecorator('hg.admin', 'hg.create.repository')
 
    def __before__(self):
 
        c.admin_user = session.get('admin_user')
 
        c.admin_username = session.get('admin_username')
 
        super(ReposController, self).__before__()
 
    
 
    @HasPermissionAllDecorator('hg.admin')            
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def index(self, format='html'):
 
        """GET /repos: All items in the collection"""
 
        # url('repos')
 
        cached_repo_list = HgModel().get_repos()
 
        c.repos_list = sorted(cached_repo_list, key=itemgetter('name_sort'))
 
        return render('admin/repos/repos.html')
 
    
 

	
 
    @HasPermissionAnyDecorator('hg.admin', 'hg.create.repository')
 
    def create(self):
 
        """POST /repos: Create a new item"""
 
        # url('repos')
 
        repo_model = RepoModel()
 
        _form = RepoForm()()
 
        form_result = {}
 
        try:
 
            form_result = _form.to_python(dict(request.POST))
 
            repo_model.create(form_result, c.rhodecode_user)
 
            invalidate_cache('cached_repo_list')
 
            h.flash(_('created repository %s') % form_result['repo_name'],
 
                    category='success')
 

	
 
            if request.POST.get('user_created'):
 
                action_logger(self.rhodecode_user, 'user_created_repo',
 
                              form_result['repo_name'], '', self.sa)
 
            else:
 
                action_logger(self.rhodecode_user, 'admin_created_repo',
 
                              form_result['repo_name'], '', self.sa)                
 
                                                                             
 
                              form_result['repo_name'], '', self.sa)
 

	
 
        except formencode.Invalid, errors:
 
            c.new_repo = errors.value['repo_name']
 
            
 

	
 
            if request.POST.get('user_created'):
 
                r = render('admin/repos/repo_add_create_repository.html')
 
            else:              
 
            else:
 
                r = render('admin/repos/repo_add.html')
 
            
 

	
 
            return htmlfill.render(
 
                r,
 
                defaults=errors.value,
 
                errors=errors.error_dict or {},
 
                prefix_error=False,
 
                encoding="UTF-8")      
 
                encoding="UTF-8")
 

	
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            msg = _('error occured during creation of repository %s') \
 
                    % form_result.get('repo_name')
 
            h.flash(msg, category='error')
 
        if request.POST.get('user_created'):
 
            return redirect(url('hg_home'))    
 
            return redirect(url('home'))
 
        return redirect(url('repos'))
 
    
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def new(self, format='html'):
 
        """GET /repos/new: Form to create a new item"""
 
        new_repo = request.GET.get('repo', '')
 
        c.new_repo = h.repo_name_slug(new_repo)
 

	
 
        return render('admin/repos/repo_add.html')
 
    
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def update(self, repo_name):
 
        """PUT /repos/repo_name: Update an existing item"""
 
        # Forms posted to this method should contain a hidden field:
 
        #    <input type="hidden" name="_method" value="PUT" />
 
        # Or using helpers:
 
        #    h.form(url('repo', repo_name=ID),
 
        #           method='put')
 
        # url('repo', repo_name=ID)
 
        repo_model = RepoModel()
 
        changed_name = repo_name
 
        _form = RepoForm(edit=True, old_data={'repo_name':repo_name})()
 
        
 

	
 
        try:
 
            form_result = _form.to_python(dict(request.POST))
 
            repo_model.update(repo_name, form_result)
 
            invalidate_cache('cached_repo_list')
 
            h.flash(_('Repository %s updated succesfully' % repo_name),
 
                    category='success')
 
            changed_name = form_result['repo_name']
 
        except formencode.Invalid, errors:
 
            c.repo_info = repo_model.get(repo_name)
 
            c.users_array = repo_model.get_users_js()
 
            errors.value.update({'user':c.repo_info.user.username})
 
            return htmlfill.render(
 
                render('admin/repos/repo_edit.html'),
 
                defaults=errors.value,
 
                errors=errors.error_dict or {},
 
                prefix_error=False,
 
                encoding="UTF-8")
 
 
 

	
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            h.flash(_('error occured during update of repository %s') \
 
                    % repo_name, category='error')
 
            
 

	
 
        return redirect(url('edit_repo', repo_name=changed_name))
 
    
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def delete(self, repo_name):
 
        """DELETE /repos/repo_name: Delete an existing item"""
 
        # Forms posted to this method should contain a hidden field:
 
        #    <input type="hidden" name="_method" value="DELETE" />
 
        # Or using helpers:
 
        #    h.form(url('repo', repo_name=ID),
 
        #           method='delete')
 
        # url('repo', repo_name=ID)
 
        
 

	
 
        repo_model = RepoModel()
 
        repo = repo_model.get(repo_name)
 
        if not repo:
 
            h.flash(_('%s repository is not mapped to db perhaps' 
 
            h.flash(_('%s repository is not mapped to db perhaps'
 
                      ' it was moved or renamed  from the filesystem'
 
                      ' please run the application again'
 
                      ' in order to rescan repositories') % repo_name,
 
                      category='error')
 
        
 

	
 
            return redirect(url('repos'))
 
        try:
 
            action_logger(self.rhodecode_user, 'admin_deleted_repo',
 
                              repo_name, '', self.sa)
 
            repo_model.delete(repo)            
 
            repo_model.delete(repo)
 
            invalidate_cache('cached_repo_list')
 
            h.flash(_('deleted repository %s') % repo_name, category='success')
 
           
 

	
 
        except Exception, e:
 
            log.error(traceback.format_exc())
 
            h.flash(_('An error occured during deletion of %s') % repo_name,
 
                    category='error')
 
        
 

	
 
        return redirect(url('repos'))
 
    
 
    @HasPermissionAllDecorator('hg.admin')        
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def delete_perm_user(self, repo_name):
 
        """
 
        DELETE an existing repository permission user
 
        :param repo_name:
 
        """
 
        
 

	
 
        try:
 
            repo_model = RepoModel()
 
            repo_model.delete_perm_user(request.POST, repo_name)            
 
            repo_model.delete_perm_user(request.POST, repo_name)
 
        except Exception, e:
 
            h.flash(_('An error occured during deletion of repository user'),
 
                    category='error')
 
            raise HTTPInternalServerError()
 
    
 
    @HasPermissionAllDecorator('hg.admin')    
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def show(self, repo_name, format='html'):
 
        """GET /repos/repo_name: Show a specific item"""
 
        # url('repo', repo_name=ID)
 
    
 
    @HasPermissionAllDecorator('hg.admin')    
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def edit(self, repo_name, format='html'):
 
        """GET /repos/repo_name/edit: Form to edit an existing item"""
 
        # url('edit_repo', repo_name=ID)
 
        repo_model = RepoModel()
 
        c.repo_info = repo = repo_model.get(repo_name)
 
        if not repo:
 
            h.flash(_('%s repository is not mapped to db perhaps' 
 
            h.flash(_('%s repository is not mapped to db perhaps'
 
                      ' it was created or renamed from the filesystem'
 
                      ' please run the application again'
 
                      ' in order to rescan repositories') % repo_name,
 
                      category='error')
 
        
 
            return redirect(url('repos'))        
 

	
 
            return redirect(url('repos'))
 
        defaults = c.repo_info.__dict__
 
        if c.repo_info.user:
 
            defaults.update({'user':c.repo_info.user.username})
 
        else:
 
            replacement_user = self.sa.query(User)\
 
            .filter(User.admin == True).first().username
 
            defaults.update({'user':replacement_user})
 
            
 

	
 
        c.users_array = repo_model.get_users_js()
 
        
 

	
 
        for p in c.repo_info.repo_to_perm:
 
            defaults.update({'perm_%s' % p.user.username: 
 
            defaults.update({'perm_%s' % p.user.username:
 
                             p.permission.permission_name})
 
            
 

	
 
        return htmlfill.render(
 
            render('admin/repos/repo_edit.html'),
 
            defaults=defaults,
 
            encoding="UTF-8",
 
            force_defaults=False
 
        )          
 
        )
rhodecode/controllers/changelog.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# changelog controller for pylons
 
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 
# 
 
# 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.
 
"""
 
Created on April 21, 2010
 
changelog controller for pylons
 
@author: marcink
 
"""
 

	
 
try:
 
    import json
 
except ImportError:
 
    #python 2.5 compatibility
 
    import simplejson as json
 
from mercurial.graphmod import colored, CHANGESET, revisions as graph_rev
 
from pylons import request, session, tmpl_context as c
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.model.hg import HgModel
 
from webhelpers.paginate import Page
 
import logging
 
log = logging.getLogger(__name__)
 

	
 
class ChangelogController(BaseController):
 
    
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')    
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(ChangelogController, self).__before__()
 
                
 

	
 
    def index(self):
 
        limit = 100
 
        default = 20
 
        if request.params.get('size'):
 
            try:
 
                int_size = int(request.params.get('size'))
 
            except ValueError:
 
                int_size = default
 
            int_size = int_size if int_size <= limit else limit 
 
            int_size = int_size if int_size <= limit else limit
 
            c.size = int_size
 
            session['changelog_size'] = c.size
 
            session.save()
 
        else:
 
            c.size = int(session.get('changelog_size', default))
 

	
 
        changesets = HgModel().get_repo(c.repo_name)
 
            
 

	
 
        p = int(request.params.get('page', 1))
 
        c.total_cs = len(changesets)
 
        c.pagination = Page(changesets, page=p, item_count=c.total_cs,
 
                            items_per_page=c.size)
 
            
 

	
 
        self._graph(changesets, c.size, p)
 
        
 

	
 
        return render('changelog/changelog.html')
 

	
 

	
 
    def _graph(self, repo, size, p):
 
        revcount = size
 
        if not repo.revisions:return json.dumps([]), 0
 
        
 

	
 
        max_rev = repo.revisions[-1]
 

	
 
        offset = 1 if p == 1 else  ((p - 1) * revcount + 1)
 

	
 
        rev_start = repo.revisions[(-1 * offset)]
 
        
 

	
 
        revcount = min(max_rev, revcount)
 
        rev_end = max(0, rev_start - revcount)
 
        dag = graph_rev(repo.repo, rev_start, rev_end)
 
        
 

	
 
        c.dag = tree = list(colored(dag))
 
        data = []
 
        for (id, type, ctx, vtx, edges) in tree:
 
            if type != CHANGESET:
 
                continue
 
            data.append(('', vtx, edges))
 
    
 
        c.jsdata = json.dumps(data) 
 

	
 
        c.jsdata = json.dumps(data)
 

	
rhodecode/controllers/changeset.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# changeset controller for pylons
 
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 
# 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.
 
from rhodecode.lib.utils import EmptyChangeset
 
"""
 
Created on April 25, 2010
 
changeset controller for pylons
 
@author: marcink
 
"""
 
from pylons import tmpl_context as c, url, request, response
 
from pylons.i18n.translation import _
 
from pylons.controllers.util import redirect
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.model.hg import HgModel
 
from vcs.exceptions import RepositoryError, ChangesetError
 
from vcs.nodes import FileNode
 
from vcs.utils import diffs as differ
 
import logging
 
import traceback
 

	
 
log = logging.getLogger(__name__)
 

	
 
class ChangesetController(BaseController):
 
    
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')       
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(ChangesetController, self).__before__()
 
        
 

	
 
    def index(self, revision):
 
        hg_model = HgModel()
 
        cut_off_limit = 1024 * 250
 
        
 

	
 
        def wrap_to_table(str):
 
            
 

	
 
            return '''<table class="code-difftable">
 
                        <tr class="line">
 
                        <td class="lineno new"></td>
 
                        <td class="code"><pre>%s</pre></td>
 
                        </tr>
 
                      </table>''' % str
 
            
 

	
 
        try:
 
            c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision)
 
        except RepositoryError:
 
            log.error(traceback.format_exc())
 
            return redirect(url('hg_home'))
 
            return redirect(url('home'))
 
        else:
 
            try:
 
                c.changeset_old = c.changeset.parents[0]
 
            except IndexError:
 
                c.changeset_old = None
 
            c.changes = []
 
            
 

	
 
            #===================================================================
 
            # ADDED FILES
 
            #===================================================================
 
            c.sum_added = 0
 
            for node in c.changeset.added:
 
                
 

	
 
                filenode_old = FileNode(node.path, '', EmptyChangeset())
 
                if filenode_old.is_binary or node.is_binary:
 
                    diff = wrap_to_table(_('binary file'))
 
                else:
 
                    c.sum_added += node.size
 
                    if c.sum_added < cut_off_limit:
 
                        f_udiff = differ.get_udiff(filenode_old, node)
 
                        diff = differ.DiffProcessor(f_udiff).as_html()
 
                                                    
 

	
 
                    else:
 
                        diff = wrap_to_table(_('Changeset is to big and was cut'
 
                                            ' off, see raw changeset instead'))
 
                        
 

	
 
                cs1 = None
 
                cs2 = node.last_changeset.short_id                                        
 
                cs2 = node.last_changeset.raw_id
 
                c.changes.append(('added', node, diff, cs1, cs2))
 
            
 

	
 
            #===================================================================
 
            # CHANGED FILES
 
            #===================================================================
 
            c.sum_removed = 0    
 
            c.sum_removed = 0
 
            for node in c.changeset.changed:
 
                try:
 
                    filenode_old = c.changeset_old.get_node(node.path)
 
                except ChangesetError:
 
                    filenode_old = FileNode(node.path, '', EmptyChangeset())
 
                    
 

	
 
                if filenode_old.is_binary or node.is_binary:
 
                    diff = wrap_to_table(_('binary file'))
 
                else:
 
                    
 

	
 
                    if c.sum_removed < cut_off_limit:
 
                        f_udiff = differ.get_udiff(filenode_old, node)
 
                        diff = differ.DiffProcessor(f_udiff).as_html()
 
                        if diff:
 
                            c.sum_removed += len(diff)
 
                    else:
 
                        diff = wrap_to_table(_('Changeset is to big and was cut'
 
                                            ' off, see raw changeset instead'))
 
                
 
                
 
                cs1 = filenode_old.last_changeset.short_id
 
                cs2 = node.last_changeset.short_id                    
 

	
 

	
 
                cs1 = filenode_old.last_changeset.raw_id
 
                cs2 = node.last_changeset.raw_id
 
                c.changes.append(('changed', node, diff, cs1, cs2))
 
                
 

	
 
            #===================================================================
 
            # REMOVED FILES    
 
            #===================================================================
 
            for node in c.changeset.removed:
 
                c.changes.append(('removed', node, None, None, None))            
 
            
 
                c.changes.append(('removed', node, None, None, None))
 

	
 
        return render('changeset/changeset.html')
 

	
 
    def raw_changeset(self, revision):
 
        
 

	
 
        hg_model = HgModel()
 
        method = request.GET.get('diff', 'show')
 
        try:
 
            c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision)
 
        except RepositoryError:
 
            log.error(traceback.format_exc())
 
            return redirect(url('hg_home'))
 
            return redirect(url('home'))
 
        else:
 
            try:
 
                c.changeset_old = c.changeset.parents[0]
 
            except IndexError:
 
                c.changeset_old = None
 
            c.changes = []
 
            
 

	
 
            for node in c.changeset.added:
 
                filenode_old = FileNode(node.path, '')
 
                if filenode_old.is_binary or node.is_binary:
 
                    diff = _('binary file')
 
                else:    
 
                else:
 
                    f_udiff = differ.get_udiff(filenode_old, node)
 
                    diff = differ.DiffProcessor(f_udiff).raw_diff()
 

	
 
                cs1 = None
 
                cs2 = node.last_changeset.short_id                                        
 
                cs2 = node.last_changeset.raw_id
 
                c.changes.append(('added', node, diff, cs1, cs2))
 
                
 

	
 
            for node in c.changeset.changed:
 
                filenode_old = c.changeset_old.get_node(node.path)
 
                if filenode_old.is_binary or node.is_binary:
 
                    diff = _('binary file')
 
                else:    
 
                else:
 
                    f_udiff = differ.get_udiff(filenode_old, node)
 
                    diff = differ.DiffProcessor(f_udiff).raw_diff()
 

	
 
                cs1 = filenode_old.last_changeset.short_id
 
                cs2 = node.last_changeset.short_id                    
 
                c.changes.append(('changed', node, diff, cs1, cs2))      
 
        
 
                cs1 = filenode_old.last_changeset.raw_id
 
                cs2 = node.last_changeset.raw_id
 
                c.changes.append(('changed', node, diff, cs1, cs2))
 

	
 
        response.content_type = 'text/plain'
 
        if method == 'download':
 
            response.content_disposition = 'attachment; filename=%s.patch' % revision 
 
            response.content_disposition = 'attachment; filename=%s.patch' % revision
 
        parent = True if len(c.changeset.parents) > 0 else False
 
        c.parent_tmpl = 'Parent  %s' % c.changeset.parents[0].raw_id if parent else ''
 
    
 

	
 
        c.diffs = ''
 
        for x in c.changes:
 
            c.diffs += x[2]
 
            
 

	
 
        return render('changeset/raw_changeset.html')
rhodecode/controllers/feed.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# feed controller for pylons
 
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 
 
 
# 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.
 
"""
 
Created on April 23, 2010
 
feed controller for pylons
 
@author: marcink
 
"""
 
from pylons import tmpl_context as c, url, response
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.model.hg import HgModel
 
from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
 
import logging
 
log = logging.getLogger(__name__)
 

	
 
class FeedController(BaseController):
 
    
 
    #secure it or not ?
 
    def __before__(self):
 
        super(FeedController, self).__before__()
 
        #common values for feeds
 
        self.description = 'Changes on %s repository'
 
        self.title = "%s feed"
 
        self.language = 'en-us'
 
        self.ttl = "5"
 
        self.feed_nr = 10
 

	
 
    def atom(self, repo_name):
 
        """Produce an atom-1.0 feed via feedgenerator module"""
 
        feed = Atom1Feed(title=self.title % repo_name,
 
                         link=url('summary_home', repo_name=repo_name, qualified=True),
 
                         description=self.description % repo_name,
 
                         language=self.language,
 
                         ttl=self.ttl)
 
        
 
        changesets = HgModel().get_repo(repo_name)
 

	
 
        for cs in changesets[:self.feed_nr]:
 
            feed.add_item(title=cs.message,
 
                          link=url('changeset_home', repo_name=repo_name,
 
                                   revision=cs.short_id, qualified=True),
 
                                   revision=cs.raw_id, qualified=True),
 
                                   description=str(cs.date))
 
        
 
        response.content_type = feed.mime_type
 
        return feed.writeString('utf-8')
 

	
 
    
 
    def rss(self, repo_name):
 
        """Produce an rss2 feed via feedgenerator module"""
 
        feed = Rss201rev2Feed(title=self.title % repo_name,
 
                         link=url('summary_home', repo_name=repo_name, qualified=True),
 
                         description=self.description % repo_name,
 
                         language=self.language,
 
                         ttl=self.ttl)
 
        
 
        changesets = HgModel().get_repo(repo_name)
 
        for cs in changesets[:self.feed_nr]:
 
            feed.add_item(title=cs.message,
 
                          link=url('changeset_home', repo_name=repo_name,
 
                                   revision=cs.short_id, qualified=True),
 
                                   revision=cs.raw_id, qualified=True),
 
                          description=str(cs.date))
 
            
 
        response.content_type = feed.mime_type
 
        return feed.writeString('utf-8')
rhodecode/controllers/files.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# files controller for pylons
 
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 

	
 
# 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.
 
"""
 
Created on April 21, 2010
 
files controller for pylons
 
@author: marcink
 
"""
 
from mercurial import archival
 
from pylons import request, response, session, tmpl_context as c, url
 
from pylons.i18n.translation import _
 
from pylons.controllers.util import redirect
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.utils import EmptyChangeset
 
from rhodecode.model.hg import HgModel
 
from vcs.exceptions import RepositoryError, ChangesetError
 
from vcs.nodes import FileNode
 
from vcs.utils import diffs as differ
 
import logging
 
import rhodecode.lib.helpers as h
 
import tempfile
 
        
 

	
 
log = logging.getLogger(__name__)
 

	
 
class FilesController(BaseController):
 
    
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')       
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(FilesController, self).__before__()
 
        c.file_size_limit = 250 * 1024 #limit of file size to display
 

	
 
    def index(self, repo_name, revision, f_path):
 
        hg_model = HgModel()
 
        c.repo = repo = hg_model.get_repo(c.repo_name)
 
        revision = request.POST.get('at_rev', None) or revision
 
        
 

	
 
        def get_next_rev(cur):
 
            max_rev = len(c.repo.revisions) - 1
 
            r = cur + 1
 
            if r > max_rev:
 
                r = max_rev
 
            return r
 
            
 

	
 
        def get_prev_rev(cur):
 
            r = cur - 1
 
            return r
 

	
 
        c.f_path = f_path
 
     
 
        
 

	
 

	
 
        try:
 
            cur_rev = repo.get_changeset(revision).revision
 
            prev_rev = repo.get_changeset(get_prev_rev(cur_rev)).short_id
 
            next_rev = repo.get_changeset(get_next_rev(cur_rev)).short_id
 
                    
 
            prev_rev = repo.get_changeset(get_prev_rev(cur_rev)).raw_id
 
            next_rev = repo.get_changeset(get_next_rev(cur_rev)).raw_id
 

	
 
            c.url_prev = url('files_home', repo_name=c.repo_name,
 
                             revision=prev_rev, f_path=f_path) 
 
                             revision=prev_rev, f_path=f_path)
 
            c.url_next = url('files_home', repo_name=c.repo_name,
 
                             revision=next_rev, f_path=f_path)   
 
                    
 
                             revision=next_rev, f_path=f_path)
 

	
 
            c.changeset = repo.get_changeset(revision)
 
                        
 
            c.cur_rev = c.changeset.short_id
 

	
 
            c.cur_rev = c.changeset.raw_id
 
            c.rev_nr = c.changeset.revision
 
            c.files_list = c.changeset.get_node(f_path)
 
            c.file_history = self._get_history(repo, c.files_list, f_path)
 
            
 

	
 
        except (RepositoryError, ChangesetError):
 
            c.files_list = None
 
        
 

	
 
        return render('files/files.html')
 

	
 
    def rawfile(self, repo_name, revision, f_path):
 
        hg_model = HgModel()
 
        c.repo = hg_model.get_repo(c.repo_name)
 
        file_node = c.repo.get_changeset(revision).get_node(f_path)
 
        response.content_type = file_node.mimetype
 
        response.content_disposition = 'attachment; filename=%s' \
 
                                                    % f_path.split('/')[-1] 
 
                                                    % f_path.split('/')[-1]
 
        return file_node.content
 

	
 
    def raw(self, repo_name, revision, f_path):
 
        hg_model = HgModel()
 
        c.repo = hg_model.get_repo(c.repo_name)
 
        file_node = c.repo.get_changeset(revision).get_node(f_path)
 
        response.content_type = 'text/plain'
 
        
 

	
 
        return file_node.content
 
    
 

	
 
    def annotate(self, repo_name, revision, f_path):
 
        hg_model = HgModel()
 
        c.repo = hg_model.get_repo(c.repo_name)
 
        cs = c.repo.get_changeset(revision)
 
        c.file = cs.get_node(f_path)
 
        c.file_msg = cs.get_file_message(f_path)
 
        c.cur_rev = cs.short_id
 
        c.rev_nr = cs.revision        
 
        c.cur_rev = cs.raw_id
 
        c.rev_nr = cs.revision
 
        c.f_path = f_path
 

	
 
        return render('files/files_annotate.html')
 
      
 

	
 
    def archivefile(self, repo_name, revision, fileformat):
 
        archive_specs = {
 
          '.tar.bz2': ('application/x-tar', 'tbz2'),
 
          '.tar.gz': ('application/x-tar', 'tgz'),
 
          '.zip': ('application/zip', 'zip'),
 
        }
 
        if not archive_specs.has_key(fileformat):
 
            return 'Unknown archive type %s' % fileformat
 
                        
 

	
 
        def read_in_chunks(file_object, chunk_size=1024 * 40):
 
            """Lazy function (generator) to read a file piece by piece.
 
            Default chunk size: 40k."""
 
            while True:
 
                data = file_object.read(chunk_size)
 
                if not data:
 
                    break
 
                yield data        
 
            
 
                yield data
 

	
 
        archive = tempfile.TemporaryFile()
 
        repo = HgModel().get_repo(repo_name).repo
 
        fname = '%s-%s%s' % (repo_name, revision, fileformat)
 
        archival.archive(repo, archive, revision, archive_specs[fileformat][1],
 
                         prefix='%s-%s' % (repo_name, revision))
 
        response.content_type = archive_specs[fileformat][0]
 
        response.content_disposition = 'attachment; filename=%s' % fname
 
        archive.seek(0)
 
        return read_in_chunks(archive)
 
    
 

	
 
    def diff(self, repo_name, f_path):
 
        hg_model = HgModel()
 
        diff1 = request.GET.get('diff1')
 
        diff2 = request.GET.get('diff2')
 
        c.action = request.GET.get('diff')
 
        c.no_changes = diff1 == diff2
 
        c.f_path = f_path
 
        c.repo = hg_model.get_repo(c.repo_name)
 

	
 
        try:
 
            if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
 
                c.changeset_1 = c.repo.get_changeset(diff1)
 
                node1 = c.changeset_1.get_node(f_path)
 
            else:
 
                c.changeset_1 = EmptyChangeset()
 
                node1 = FileNode('.', '', changeset=c.changeset_1)
 
                
 

	
 
            if diff2 not in ['', None, 'None', '0' * 12, '0' * 40]:
 
                c.changeset_2 = c.repo.get_changeset(diff2)
 
                node2 = c.changeset_2.get_node(f_path)
 
            else:
 
                c.changeset_2 = EmptyChangeset()
 
                node2 = FileNode('.', '', changeset=c.changeset_2)
 
        except RepositoryError:
 
            return redirect(url('files_home',
 
                                repo_name=c.repo_name, f_path=f_path))
 

	
 
        c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1.short_id)
 
        c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2.short_id)
 
        
 
        f_udiff = differ.get_udiff(node1, node2)
 
        diff = differ.DiffProcessor(f_udiff)
 
                                
 

	
 
        if c.action == 'download':
 
            diff_name = '%s_vs_%s.diff' % (diff1, diff2)
 
            response.content_type = 'text/plain'
 
            response.content_disposition = 'attachment; filename=%s' \
 
                                                    % diff_name             
 
                                                    % diff_name
 
            return diff.raw_diff()
 
        
 

	
 
        elif c.action == 'raw':
 
            c.cur_diff = '<pre class="raw">%s</pre>' % h.escape(diff.raw_diff())
 
        elif c.action == 'diff':
 
            if node1.size > c.file_size_limit or node2.size > c.file_size_limit:
 
                c.cur_diff = _('Diff is to big to display')
 
            else:
 
                c.cur_diff = diff.as_html()
 
        else:
 
            #default option
 
            if node1.size > c.file_size_limit or node2.size > c.file_size_limit:
 
                c.cur_diff = _('Diff is to big to display')
 
            else:
 
                c.cur_diff = diff.as_html()
 
        
 
        if not c.cur_diff: c.no_changes = True    
 

	
 
        if not c.cur_diff: c.no_changes = True
 
        return render('files/file_diff.html')
 
    
 

	
 
    def _get_history(self, repo, node, f_path):
 
        from vcs.nodes import NodeKind
 
        if not node.kind is NodeKind.FILE:
 
            return []
 
        changesets = node.history
 
        hist_l = []
 
        for chs in changesets:
 
            n_desc = 'r%s:%s' % (chs.revision, chs.short_id)
 
            hist_l.append((chs.short_id, n_desc,))
 
            hist_l.append((chs.raw_id, n_desc,))
 
        return hist_l
rhodecode/controllers/home.py
Show inline comments
 
file renamed from rhodecode/controllers/hg.py to rhodecode/controllers/home.py
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# hg controller for pylons
 
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 
# 
 
# 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.
 
"""
 
Created on February 18, 2010
 
hg controller for pylons
 
@author: marcink
 
"""
 
from operator import itemgetter
 
from pylons import tmpl_context as c, request
 
from rhodecode.lib.auth import LoginRequired
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.model.hg import HgModel
 
import logging
 
log = logging.getLogger(__name__)
 

	
 
class HgController(BaseController):
 
class HomeController(BaseController):
 

	
 
    @LoginRequired()
 
    def __before__(self):
 
        super(HgController, self).__before__()
 
        
 
        super(HomeController, self).__before__()
 

	
 
    def index(self):
 
        sortables = ['name', 'description', 'last_change', 'tip', 'contact']
 
        current_sort = request.GET.get('sort', 'name')
 
        current_sort_slug = current_sort.replace('-', '')
 
        
 

	
 
        if current_sort_slug not in sortables:
 
            c.sort_by = 'name'
 
            current_sort_slug = c.sort_by
 
        else:
 
            c.sort_by = current_sort
 
        c.sort_slug = current_sort_slug
 
        cached_repo_list = HgModel().get_repos()
 
        
 

	
 
        sort_key = current_sort_slug + '_sort'
 
        if c.sort_by.startswith('-'):
 
            c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=True)
 
        else:
 
            c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=False)
 
            
 

	
 
        return render('/index.html')
rhodecode/controllers/login.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# login controller for pylons
 
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 
# 
 
# 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.
 

	
 
"""
 
Created on April 22, 2010
 
login controller for pylons
 
@author: marcink
 
"""
 
from formencode import htmlfill
 
from pylons import request, response, session, tmpl_context as c, url
 
from pylons.controllers.util import abort, redirect
 
from rhodecode.lib.auth import AuthUser, HasPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
import rhodecode.lib.helpers as h 
 
import rhodecode.lib.helpers as h
 
from pylons.i18n.translation import _
 
from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm
 
from rhodecode.model.user import UserModel
 
import formencode
 
import logging
 

	
 
log = logging.getLogger(__name__)
 

	
 
class LoginController(BaseController):
 

	
 
    def __before__(self):
 
        super(LoginController, self).__before__()
 

	
 
    def index(self):
 
        #redirect if already logged in
 
        c.came_from = request.GET.get('came_from', None)
 
        
 

	
 
        if c.rhodecode_user.is_authenticated:
 
            return redirect(url('hg_home'))
 
        
 
            return redirect(url('home'))
 

	
 
        if request.POST:
 
            #import Login Form validator class
 
            login_form = LoginForm()
 
            try:
 
                c.form_result = login_form.to_python(dict(request.POST))
 
                username = c.form_result['username']
 
                user = UserModel().get_by_username(username)
 
                auth_user = AuthUser()
 
                auth_user.username = user.username
 
                auth_user.is_authenticated = True
 
                auth_user.is_admin = user.admin
 
                auth_user.user_id = user.user_id
 
                auth_user.name = user.name
 
                auth_user.lastname = user.lastname
 
                session['rhodecode_user'] = auth_user
 
                session.save()
 
                log.info('user %s is now authenticated', username)
 
                
 

	
 
                user.update_lastlogin()
 
                                        
 

	
 
                if c.came_from:
 
                    return redirect(c.came_from)
 
                else:
 
                    return redirect(url('hg_home'))
 
                               
 
                    return redirect(url('home'))
 

	
 
            except formencode.Invalid, errors:
 
                return htmlfill.render(
 
                    render('/login.html'),
 
                    defaults=errors.value,
 
                    errors=errors.error_dict or {},
 
                    prefix_error=False,
 
                    encoding="UTF-8")
 
                        
 

	
 
        return render('/login.html')
 
    
 

	
 
    @HasPermissionAnyDecorator('hg.admin', 'hg.register.auto_activate',
 
                               'hg.register.manual_activate')
 
    def register(self):
 
        user_model = UserModel()
 
        c.auto_active = False
 
        for perm in user_model.get_by_username('default', cache=False).user_perms:
 
            if perm.permission.permission_name == 'hg.register.auto_activate':
 
                c.auto_active = True
 
                break
 
                        
 

	
 
        if request.POST:
 
                
 

	
 
            register_form = RegisterForm()()
 
            try:
 
                form_result = register_form.to_python(dict(request.POST))
 
                form_result['active'] = c.auto_active
 
                user_model.create_registration(form_result)
 
                h.flash(_('You have successfully registered into rhodecode'),
 
                            category='success')                
 
                            category='success')
 
                return redirect(url('login_home'))
 
                               
 

	
 
            except formencode.Invalid, errors:
 
                return htmlfill.render(
 
                    render('/register.html'),
 
                    defaults=errors.value,
 
                    errors=errors.error_dict or {},
 
                    prefix_error=False,
 
                    encoding="UTF-8")
 
        
 

	
 
        return render('/register.html')
 

	
 
    def password_reset(self):
 
        user_model = UserModel()
 
        if request.POST:
 
                
 

	
 
            password_reset_form = PasswordResetForm()()
 
            try:
 
                form_result = password_reset_form.to_python(dict(request.POST))
 
                user_model.reset_password(form_result)
 
                h.flash(_('Your new password was sent'),
 
                            category='success')                 
 
                            category='success')
 
                return redirect(url('login_home'))
 
                               
 

	
 
            except formencode.Invalid, errors:
 
                return htmlfill.render(
 
                    render('/password_reset.html'),
 
                    defaults=errors.value,
 
                    errors=errors.error_dict or {},
 
                    prefix_error=False,
 
                    encoding="UTF-8")
 
        
 

	
 
        return render('/password_reset.html')
 
        
 

	
 
    def logout(self):
 
        session['rhodecode_user'] = AuthUser()
 
        session.save()
 
        log.info('Logging out and setting user as Empty')
 
        redirect(url('hg_home'))
 
        redirect(url('home'))
rhodecode/controllers/settings.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# settings controller for pylons
 
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 
# 
 
# 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.
 
"""
 
Created on June 30, 2010
 
settings controller for pylons
 
@author: marcink
 
"""
 
from formencode import htmlfill
 
from pylons import tmpl_context as c, request, url
 
from pylons.controllers.util import redirect
 
from pylons.i18n.translation import _
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.utils import invalidate_cache, action_logger
 
from rhodecode.model.forms import RepoSettingsForm, RepoForkForm
 
from rhodecode.model.repo import RepoModel
 
import formencode
 
import logging
 
import rhodecode.lib.helpers as h
 
import traceback
 

	
 
log = logging.getLogger(__name__)
 

	
 
class SettingsController(BaseController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAllDecorator('repository.admin')           
 
    @HasRepoPermissionAllDecorator('repository.admin')
 
    def __before__(self):
 
        super(SettingsController, self).__before__()
 
        
 

	
 
    def index(self, repo_name):
 
        repo_model = RepoModel()
 
        c.repo_info = repo = repo_model.get(repo_name)
 
        if not repo:
 
            h.flash(_('%s repository is not mapped to db perhaps' 
 
            h.flash(_('%s repository is not mapped to db perhaps'
 
                      ' it was created or renamed from the filesystem'
 
                      ' please run the application again'
 
                      ' in order to rescan repositories') % repo_name,
 
                      category='error')
 
        
 
            return redirect(url('hg_home'))        
 

	
 
            return redirect(url('home'))
 
        defaults = c.repo_info.__dict__
 
        defaults.update({'user':c.repo_info.user.username})
 
        c.users_array = repo_model.get_users_js()
 
        
 

	
 
        for p in c.repo_info.repo_to_perm:
 
            defaults.update({'perm_%s' % p.user.username: 
 
            defaults.update({'perm_%s' % p.user.username:
 
                             p.permission.permission_name})
 
            
 

	
 
        return htmlfill.render(
 
            render('settings/repo_settings.html'),
 
            defaults=defaults,
 
            encoding="UTF-8",
 
            force_defaults=False
 
        )  
 
        )
 

	
 
    def update(self, repo_name):
 
        repo_model = RepoModel()
 
        changed_name = repo_name
 
        _form = RepoSettingsForm(edit=True, old_data={'repo_name':repo_name})()
 
        try:
 
            form_result = _form.to_python(dict(request.POST))
 
            repo_model.update(repo_name, form_result)
 
            invalidate_cache('cached_repo_list')
 
            h.flash(_('Repository %s updated successfully' % repo_name),
 
                    category='success')
 
            changed_name = form_result['repo_name']               
 
            changed_name = form_result['repo_name']
 
        except formencode.Invalid, errors:
 
            c.repo_info = repo_model.get(repo_name)
 
            c.users_array = repo_model.get_users_js()
 
            errors.value.update({'user':c.repo_info.user.username})
 
            return htmlfill.render(
 
                render('settings/repo_settings.html'),
 
                defaults=errors.value,
 
                errors=errors.error_dict or {},
 
                prefix_error=False,
 
                encoding="UTF-8") 
 
                encoding="UTF-8")
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            h.flash(_('error occured during update of repository %s') \
 
                    % repo_name, category='error')
 
                    
 

	
 
        return redirect(url('repo_settings_home', repo_name=changed_name))
 

	
 

	
 

	
 
    def delete(self, repo_name):    
 
    def delete(self, repo_name):
 
        """DELETE /repos/repo_name: Delete an existing item"""
 
        # Forms posted to this method should contain a hidden field:
 
        #    <input type="hidden" name="_method" value="DELETE" />
 
        # Or using helpers:
 
        #    h.form(url('repo_settings_delete', repo_name=ID),
 
        #           method='delete')
 
        # url('repo_settings_delete', repo_name=ID)
 
        
 

	
 
        repo_model = RepoModel()
 
        repo = repo_model.get(repo_name)
 
        if not repo:
 
            h.flash(_('%s repository is not mapped to db perhaps' 
 
            h.flash(_('%s repository is not mapped to db perhaps'
 
                      ' it was moved or renamed  from the filesystem'
 
                      ' please run the application again'
 
                      ' in order to rescan repositories') % repo_name,
 
                      category='error')
 
        
 
            return redirect(url('hg_home'))
 

	
 
            return redirect(url('home'))
 
        try:
 
            action_logger(self.rhodecode_user, 'user_deleted_repo',
 
                              repo_name, '', self.sa)            
 
            repo_model.delete(repo)            
 
                              repo_name, '', self.sa)
 
            repo_model.delete(repo)
 
            invalidate_cache('cached_repo_list')
 
            h.flash(_('deleted repository %s') % repo_name, category='success')
 
        except Exception:
 
            h.flash(_('An error occurred during deletion of %s') % repo_name,
 
                    category='error')
 
        
 
        return redirect(url('hg_home'))
 
    
 

	
 
        return redirect(url('home'))
 

	
 
    def fork(self, repo_name):
 
        repo_model = RepoModel()
 
        c.repo_info = repo = repo_model.get(repo_name)
 
        if not repo:
 
            h.flash(_('%s repository is not mapped to db perhaps' 
 
            h.flash(_('%s repository is not mapped to db perhaps'
 
                      ' it was created or renamed from the filesystem'
 
                      ' please run the application again'
 
                      ' in order to rescan repositories') % repo_name,
 
                      category='error')
 
        
 
            return redirect(url('hg_home'))
 
        
 

	
 
            return redirect(url('home'))
 

	
 
        return render('settings/repo_fork.html')
 
    
 
    
 
    
 

	
 

	
 

	
 
    def fork_create(self, repo_name):
 
        repo_model = RepoModel()
 
        c.repo_info = repo_model.get(repo_name)
 
        _form = RepoForkForm()()
 
        form_result = {}
 
        try:
 
            form_result = _form.to_python(dict(request.POST))
 
            form_result.update({'repo_name':repo_name})
 
            repo_model.create_fork(form_result, c.rhodecode_user)
 
            h.flash(_('fork %s repository as %s task added') \
 
                      % (repo_name, form_result['fork_name']),
 
                    category='success')
 
            action_logger(self.rhodecode_user, 'user_forked_repo',
 
                            repo_name, '', self.sa)                                                 
 
                            repo_name, '', self.sa)
 
        except formencode.Invalid, errors:
 
            c.new_repo = errors.value['fork_name']
 
            r = render('settings/repo_fork.html')
 
            
 

	
 
            return htmlfill.render(
 
                r,
 
                defaults=errors.value,
 
                errors=errors.error_dict or {},
 
                prefix_error=False,
 
                encoding="UTF-8")   
 
        return redirect(url('hg_home'))
 
                encoding="UTF-8")
 
        return redirect(url('home'))
rhodecode/lib/helpers.py
Show inline comments
 
@@ -179,219 +179,220 @@ class _ToolTip(object):
 
                                break;                             
 
                                 
 
                        }
 

	
 
                        this.cfg.setProperty("xy",xy_pos);
 

	
 
                  });
 
                  
 
            //Mouse out 
 
            myToolTips.contextMouseOutEvent.subscribe(
 
                function(type, args) {
 
                    var context = args[0];
 
                    
 
                });
 
        });
 
        '''
 
        return literal(js)
 

	
 
tooltip = _ToolTip()
 

	
 
class _FilesBreadCrumbs(object):
 

	
 
    def __call__(self, repo_name, rev, paths):
 
        url_l = [link_to(repo_name, url('files_home',
 
                                        repo_name=repo_name,
 
                                        revision=rev, f_path=''))]
 
        paths_l = paths.split('/')
 

	
 
        for cnt, p in enumerate(paths_l, 1):
 
            if p != '':
 
                url_l.append(link_to(p, url('files_home',
 
                                            repo_name=repo_name,
 
                                            revision=rev,
 
                                            f_path='/'.join(paths_l[:cnt]))))
 

	
 
        return literal('/'.join(url_l))
 

	
 
files_breadcrumbs = _FilesBreadCrumbs()
 
class CodeHtmlFormatter(HtmlFormatter):
 

	
 
    def wrap(self, source, outfile):
 
        return self._wrap_div(self._wrap_pre(self._wrap_code(source)))
 

	
 
    def _wrap_code(self, source):
 
        for cnt, it in enumerate(source, 1):
 
            i, t = it
 
            t = '<div id="#S-%s">%s</div>' % (cnt, t)
 
            yield i, t
 
def pygmentize(filenode, **kwargs):
 
    """
 
    pygmentize function using pygments
 
    :param filenode:
 
    """
 
    return literal(code_highlight(filenode.content,
 
                                  filenode.lexer, CodeHtmlFormatter(**kwargs)))
 

	
 
def pygmentize_annotation(filenode, **kwargs):
 
    """
 
    pygmentize function for annotation
 
    :param filenode:
 
    """
 

	
 
    color_dict = {}
 
    def gen_color():
 
        """generator for getting 10k of evenly distibuted colors using hsv color
 
        and golden ratio.
 
        """
 
        import colorsys
 
        n = 10000
 
        golden_ratio = 0.618033988749895
 
        h = 0.22717784590367374
 
        #generate 10k nice web friendly colors in the same order
 
        for c in xrange(n):
 
            h += golden_ratio
 
            h %= 1
 
            HSV_tuple = [h, 0.95, 0.95]
 
            RGB_tuple = colorsys.hsv_to_rgb(*HSV_tuple)
 
            yield map(lambda x:str(int(x * 256)), RGB_tuple)
 

	
 
    cgenerator = gen_color()
 

	
 
    def get_color_string(cs):
 
        if color_dict.has_key(cs):
 
            col = color_dict[cs]
 
        else:
 
            col = color_dict[cs] = cgenerator.next()
 
        return "color: rgb(%s)! important;" % (', '.join(col))
 

	
 
    def url_func(changeset):
 
        tooltip_html = "<div style='font-size:0.8em'><b>Author:</b>" + \
 
        " %s<br/><b>Date:</b> %s</b><br/><b>Message:</b> %s<br/></div>"
 

	
 
        tooltip_html = tooltip_html % (changeset.author,
 
                                               changeset.date,
 
                                               tooltip(changeset.message))
 
        lnk_format = 'r%-5s:%s' % (changeset.revision,
 
                                 changeset.short_id)
 
                                 changeset.raw_id)
 
        uri = link_to(
 
                lnk_format,
 
                url('changeset_home', repo_name=changeset.repository.name,
 
                    revision=changeset.short_id),
 
                style=get_color_string(changeset.short_id),
 
                    revision=changeset.raw_id),
 
                style=get_color_string(changeset.raw_id),
 
                class_='tooltip',
 
                tooltip_title=tooltip_html
 
              )
 

	
 
        uri += '\n'
 
        return uri
 
    return literal(annotate_highlight(filenode, url_func, **kwargs))
 

	
 
def repo_name_slug(value):
 
    """Return slug of name of repository
 
    This function is called on each creation/modification
 
    of repository to prevent bad names in repo
 
    """
 
    slug = remove_formatting(value)
 
    slug = strip_tags(slug)
 

	
 
    for c in """=[]\;'"<>,/~!@#$%^&*()+{}|: """:
 
        slug = slug.replace(c, '-')
 
    slug = recursive_replace(slug, '-')
 
    slug = collapse(slug, '-')
 
    return slug
 

	
 
def get_changeset_safe(repo, rev):
 
    from vcs.backends.base import BaseRepository
 
    from vcs.exceptions import RepositoryError
 
    if not isinstance(repo, BaseRepository):
 
        raise Exception('You must pass an Repository '
 
                        'object as first argument got %s', type(repo))
 

	
 
    try:
 
        cs = repo.get_changeset(rev)
 
    except RepositoryError:
 
        from rhodecode.lib.utils import EmptyChangeset
 
        cs = EmptyChangeset()
 
    return cs
 

	
 

	
 
flash = _Flash()
 

	
 

	
 
#==============================================================================
 
# MERCURIAL FILTERS available via h.
 
#==============================================================================
 
from mercurial import util
 
from mercurial.templatefilters import person as _person
 

	
 

	
 

	
 
def _age(curdate):
 
    """turns a datetime into an age string."""
 

	
 
    from datetime import timedelta, datetime
 
    agescales = [("year", 3600 * 24 * 365),
 
             ("month", 3600 * 24 * 30),
 
             #("week", 3600 * 24 * 7),
 
             ("day", 3600 * 24),
 
             ("hour", 3600),
 
             ("minute", 60),
 
             ("second", 1)]
 

	
 
    age = datetime.now() - curdate
 
    age_seconds = (age.days * agescales[2][1]) + age.seconds
 

	
 
    pos = 1
 
    for scale in agescales:
 
        if scale[1] <= age_seconds:
 
            return time_ago_in_words(curdate, agescales[pos][0])
 
        pos += 1
 

	
 
age = lambda  x:_age(x)
 
capitalize = lambda x: x.capitalize()
 
email = util.email
 
email_or_none = lambda x: util.email(x) if util.email(x) != x else None
 
person = lambda x: _person(x)
 
short_id = lambda x: x[:12]
 

	
 
#==============================================================================
 
# PERMS
 
#==============================================================================
 
from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \
 
HasRepoPermissionAny, HasRepoPermissionAll
 

	
 
#==============================================================================
 
# GRAVATAR URL
 
#==============================================================================
 
import hashlib
 
import urllib
 
from pylons import request
 

	
 
def gravatar_url(email_address, size=30):
 
    ssl_enabled = 'https' == request.environ.get('HTTP_X_URL_SCHEME')
 
    default = 'identicon'
 
    baseurl_nossl = "http://www.gravatar.com/avatar/"
 
    baseurl_ssl = "https://secure.gravatar.com/avatar/"
 
    baseurl = baseurl_ssl if ssl_enabled else baseurl_nossl
 

	
 

	
 
    # construct the url
 
    gravatar_url = baseurl + hashlib.md5(email_address.lower()).hexdigest() + "?"
 
    gravatar_url += urllib.urlencode({'d':default, 's':str(size)})
 

	
 
    return gravatar_url
 

	
 
def safe_unicode(str):
 
    """safe unicode function. In case of UnicodeDecode error we try to return
 
    unicode with errors replace, if this failes we return unicode with 
 
    string_escape decoding """
 

	
 
    try:
 
        u_str = unicode(str)
 
    except UnicodeDecodeError:
 
        try:
 
            u_str = unicode(str, 'utf-8', 'replace')
 
        except UnicodeDecodeError:
 
            #incase we have a decode error just represent as byte string
 
            u_str = unicode(str(str).encode('string_escape'))
 

	
 
    return u_str
rhodecode/lib/utils.py
Show inline comments
 
@@ -210,192 +210,193 @@ def get_hg_ui_settings():
 
        if k == '/':
 
            k = 'root_path'
 

	
 
        if k.find('.') != -1:
 
            k = k.replace('.', '_')
 

	
 
        if each.ui_section == 'hooks':
 
            v = each.ui_active
 

	
 
        settings[each.ui_section + '_' + k] = v
 

	
 
    return settings
 

	
 
#propagated from mercurial documentation
 
ui_sections = ['alias', 'auth',
 
                'decode/encode', 'defaults',
 
                'diff', 'email',
 
                'extensions', 'format',
 
                'merge-patterns', 'merge-tools',
 
                'hooks', 'http_proxy',
 
                'smtp', 'patch',
 
                'paths', 'profiling',
 
                'server', 'trusted',
 
                'ui', 'web', ]
 

	
 
def make_ui(read_from='file', path=None, checkpaths=True):
 
    """
 
    A function that will read python rc files or database
 
    and make an mercurial ui object from read options
 
    
 
    :param path: path to mercurial config file
 
    :param checkpaths: check the path
 
    :param read_from: read from 'file' or 'db'
 
    """
 

	
 
    baseui = ui.ui()
 

	
 
    if read_from == 'file':
 
        if not os.path.isfile(path):
 
            log.warning('Unable to read config file %s' % path)
 
            return False
 
        log.debug('reading hgrc from %s', path)
 
        cfg = config.config()
 
        cfg.read(path)
 
        for section in ui_sections:
 
            for k, v in cfg.items(section):
 
                baseui.setconfig(section, k, v)
 
                log.debug('settings ui from file[%s]%s:%s', section, k, v)
 

	
 
    elif read_from == 'db':
 
        hg_ui = get_hg_ui_cached()
 
        for ui_ in hg_ui:
 
            if ui_.ui_active:
 
                log.debug('settings ui from db[%s]%s:%s', ui_.ui_section, ui_.ui_key, ui_.ui_value)
 
                baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value)
 

	
 

	
 
    return baseui
 

	
 

	
 
def set_rhodecode_config(config):
 
    hgsettings = get_hg_settings()
 

	
 
    for k, v in hgsettings.items():
 
        config[k] = v
 

	
 
def invalidate_cache(name, *args):
 
    """Invalidates given name cache"""
 

	
 
    from beaker.cache import region_invalidate
 
    log.info('INVALIDATING CACHE FOR %s', name)
 

	
 
    """propagate our arguments to make sure invalidation works. First
 
    argument has to be the name of cached func name give to cache decorator
 
    without that the invalidation would not work"""
 
    tmp = [name]
 
    tmp.extend(args)
 
    args = tuple(tmp)
 

	
 
    if name == 'cached_repo_list':
 
        from rhodecode.model.hg import _get_repos_cached
 
        region_invalidate(_get_repos_cached, None, *args)
 

	
 
    if name == 'full_changelog':
 
        from rhodecode.model.hg import _full_changelog_cached
 
        region_invalidate(_full_changelog_cached, None, *args)
 

	
 
class EmptyChangeset(BaseChangeset):
 
    """
 
    An dummy empty changeset.
 
    """
 

	
 
    revision = -1
 
    message = ''
 
    author = ''
 
    date = ''
 

	
 
    @LazyProperty
 
    def raw_id(self):
 
        """
 
        Returns raw string identifying this changeset, useful for web
 
        representation.
 
        """
 
        return '0' * 40
 

	
 
    @LazyProperty
 
    def short_id(self):
 
        return self.raw_id[:12]
 

	
 
    def get_file_changeset(self, path):
 
        return self
 

	
 
    def get_file_content(self, path):
 
        return u''
 

	
 
    def get_file_size(self, path):
 
        return 0
 

	
 
def repo2db_mapper(initial_repo_list, remove_obsolete=False):
 
    """
 
    maps all found repositories into db
 
    """
 

	
 
    sa = meta.Session()
 
    rm = RepoModel(sa)
 
    user = sa.query(User).filter(User.admin == True).first()
 

	
 
    for name, repo in initial_repo_list.items():
 
        if not rm.get(name, cache=False):
 
            log.info('repository %s not found creating default', name)
 

	
 
            if isinstance(repo, MercurialRepository):
 
                repo_type = 'hg'
 
            if isinstance(repo, GitRepository):
 
                repo_type = 'git'
 

	
 
            form_data = {
 
                         'repo_name':name,
 
                         'repo_type':repo_type,
 
                         'description':repo.description if repo.description != 'unknown' else \
 
                                        'auto description for %s' % name,
 
                         'private':False
 
                         }
 
            rm.create(form_data, user, just_db=True)
 

	
 

	
 
    if remove_obsolete:
 
        #remove from database those repositories that are not in the filesystem
 
        for repo in sa.query(Repository).all():
 
            if repo.repo_name not in initial_repo_list.keys():
 
                sa.delete(repo)
 
                sa.commit()
 

	
 

	
 
    meta.Session.remove()
 

	
 

	
 
class OrderedDict(dict, DictMixin):
 

	
 
    def __init__(self, *args, **kwds):
 
        if len(args) > 1:
 
            raise TypeError('expected at most 1 arguments, got %d' % len(args))
 
        try:
 
            self.__end
 
        except AttributeError:
 
            self.clear()
 
        self.update(*args, **kwds)
 

	
 
    def clear(self):
 
        self.__end = end = []
 
        end += [None, end, end]         # sentinel node for doubly linked list
 
        self.__map = {}                 # key --> [key, prev, next]
 
        dict.clear(self)
 

	
 
    def __setitem__(self, key, value):
 
        if key not in self:
 
            end = self.__end
 
            curr = end[1]
 
            curr[2] = end[1] = self.__map[key] = [key, curr, end]
 
        dict.__setitem__(self, key, value)
 

	
 
    def __delitem__(self, key):
 
        dict.__delitem__(self, key)
 
        key, prev, next = self.__map.pop(key)
 
        prev[2] = next
 
        next[1] = prev
 

	
 
    def __iter__(self):
 
        end = self.__end
 
        curr = end[2]
 
        while curr is not end:
 
            yield curr[0]
 
            curr = curr[2]
rhodecode/model/hg.py
Show inline comments
 
@@ -65,119 +65,119 @@ def _get_repos_switcher_cached(cached_re
 
        if HasRepoPermissionAny('repository.write', 'repository.read',
 
                    'repository.admin')(repo.name, 'main page check'):
 
            repos_lst.append((repo.name, repo.dbrepo.private,))
 

	
 
    return sorted(repos_lst, key=lambda k:k[0].lower())
 

	
 
@cache_region('long_term', 'full_changelog')
 
def _full_changelog_cached(repo_name):
 
    log.info('getting full changelog for %s', repo_name)
 
    return list(reversed(list(HgModel().get_repo(repo_name))))
 

	
 
class HgModel(object):
 
    """
 
    Mercurial Model
 
    """
 

	
 
    def __init__(self, sa=None):
 
        if not sa:
 
            self.sa = meta.Session()
 
        else:
 
            self.sa = sa
 

	
 
    def repo_scan(self, repos_path, baseui, initial=False):
 
        """
 
        Listing of repositories in given path. This path should not be a 
 
        repository itself. Return a dictionary of repository objects
 
        
 
        :param repos_path: path to directory containing repositories
 
        :param baseui
 
        :param initial: initial scann
 
        """
 
        log.info('scanning for repositories in %s', repos_path)
 

	
 
        if not isinstance(baseui, ui.ui):
 
            baseui = ui.ui()
 

	
 
        from rhodecode.lib.utils import get_repos
 
        repos = get_repos(repos_path)
 

	
 

	
 
        repos_list = {}
 
        for name, path in repos:
 
            try:
 
                #name = name.split('/')[-1]
 
                if repos_list.has_key(name):
 
                    raise RepositoryError('Duplicate repository name %s found in'
 
                                    ' %s' % (name, path))
 
                else:
 
                    if path[0] == 'hg':
 
                        repos_list[name] = MercurialRepository(path[1], baseui=baseui)
 
                        repos_list[name].name = name
 

	
 
                    if path[0] == 'git':
 
                        repos_list[name] = GitRepository(path[1])
 
                        repos_list[name].name = name
 

	
 
                    dbrepo = None
 
                    if not initial:
 
                        #for initial scann on application first run we don't
 
                        #have db repos yet.
 
                        dbrepo = self.sa.query(Repository)\
 
                            .options(joinedload(Repository.fork))\
 
                            .filter(Repository.repo_name == name)\
 
                            .scalar()
 

	
 
                    if dbrepo:
 
                        log.info('Adding db instance to cached list')
 
                        repos_list[name].dbrepo = dbrepo
 
                        repos_list[name].description = dbrepo.description
 
                        if dbrepo.user:
 
                            repos_list[name].contact = dbrepo.user.full_contact
 
                        else:
 
                            repos_list[name].contact = self.sa.query(User)\
 
                            .filter(User.admin == True).first().full_contact
 
            except OSError:
 
                continue
 

	
 
        return repos_list
 

	
 
    def get_repos(self):
 
        for name, repo in _get_repos_cached().items():
 

	
 
            if isinstance(repo, MercurialRepository) and repo._get_hidden():
 
                #skip hidden web repository
 
                continue
 

	
 
            last_change = repo.last_change
 
            tip = h.get_changeset_safe(repo, 'tip')
 

	
 
            tmp_d = {}
 
            tmp_d['name'] = repo.name
 
            tmp_d['name_sort'] = tmp_d['name'].lower()
 
            tmp_d['description'] = repo.description
 
            tmp_d['description_sort'] = tmp_d['description']
 
            tmp_d['last_change'] = last_change
 
            tmp_d['last_change_sort'] = time.mktime(last_change.timetuple())
 
            tmp_d['tip'] = tip.short_id
 
            tmp_d['tip'] = tip.raw_id
 
            tmp_d['tip_sort'] = tip.revision
 
            tmp_d['rev'] = tip.revision
 
            tmp_d['contact'] = repo.contact
 
            tmp_d['contact_sort'] = tmp_d['contact']
 
            tmp_d['repo_archives'] = list(repo._get_archives())
 
            tmp_d['last_msg'] = tip.message
 
            tmp_d['repo'] = repo
 
            yield tmp_d
 

	
 
    def get_repo(self, repo_name):
 
        try:
 
            repo = _get_repos_cached()[repo_name]
 
            return repo
 
        except KeyError:
 
            #i we're here and we got key errors let's try to invalidate the
 
            #cahce and try again
 
            invalidate_cache('cached_repo_list')
 
            repo = _get_repos_cached()[repo_name]
 
            return repo
 

	
 

	
 

	
rhodecode/public/css/style.css
Show inline comments
 
@@ -1608,192 +1608,193 @@ padding-left:10px;
 
 
table.code-browser tbody td {
 
padding-left:10px;
 
height:20px;
 
}
 
 
table.code-browser .browser-file {
 
background:url("../images/icons/document_16.png") no-repeat scroll 3px;
 
height:16px;
 
padding-left:20px;
 
text-align:left;
 
}
 
 
table.code-browser .browser-dir {
 
background:url("../images/icons/folder_16.png") no-repeat scroll 3px;
 
height:16px;
 
padding-left:20px;
 
text-align:left;
 
}
 
 
.box .search {
 
clear:both;
 
overflow:hidden;
 
margin:0;
 
padding:0 20px 10px;
 
}
 
 
.box .search div.search_path {
 
background:none repeat scroll 0 0 #EEE;
 
border:1px solid #CCC;
 
color:blue;
 
margin-bottom:10px;
 
padding:10px 0;
 
}
 
 
.box .search div.search_path div.link {
 
font-weight:700;
 
margin-left:25px;
 
}
 
 
.box .search div.search_path div.link a {
 
color:#003367;
 
cursor:pointer;
 
text-decoration:none;
 
}
 
 
#path_unlock {
 
color:red;
 
font-size:1.2em;
 
padding-left:4px;
 
}
 
 
.info_box * {
 
background:url("../../images/pager.png") repeat-x scroll 0 0 #EBEBEB;
 
color:#4A4A4A;
 
font-weight:700;
 
height:1%;
 
display:inline;
 
border-color:#DEDEDE #C4C4C4 #C4C4C4 #CFCFCF;
 
border-style:solid;
 
border-width:1px;
 
padding:4px 6px;
 
}
 
 
.info_box span {
 
margin-left:3px;
 
margin-right:3px;
 
}
 
 
.info_box input#at_rev {
 
text-align:center;
 
padding:5px 3px 3px 2px;
 
}
 
 
.info_box input#view {
 
text-align:center;
 
padding:4px 3px 2px 2px;
 
}
 
 
.yui-overlay,.yui-panel-container {
 
visibility:hidden;
 
position:absolute;
 
z-index:2;
 
}
 
 
.yui-tt {
 
visibility:hidden;
 
position:absolute;
 
color:#666;
 
background-color:#FFF;
 
font-family:arial, helvetica, verdana, sans-serif;
 
border:2px solid #003367;
 
font:100% sans-serif;
 
width:auto;
 
opacity:1px;
 
padding:8px;
 
white-space: pre;
 
}
 
 
.ac {
 
vertical-align:top;
 
}
 
 
.ac .yui-ac {
 
position:relative;
 
font-family:arial;
 
font-size:100%;
 
}
 
 
.ac .perm_ac {
 
width:15em;
 
}
 
 
.ac .yui-ac-input {
 
width:100%;
 
}
 
 
.ac .yui-ac-container {
 
position:absolute;
 
top:1.6em;
 
width:100%;
 
}
 
 
.ac .yui-ac-content {
 
position:absolute;
 
width:100%;
 
border:1px solid gray;
 
background:#fff;
 
overflow:hidden;
 
z-index:9050;
 
}
 
 
.ac .yui-ac-shadow {
 
position:absolute;
 
width:100%;
 
background:#000;
 
-moz-opacity:0.1px;
 
opacity:.10;
 
filter:alpha(opacity =   10);
 
z-index:9049;
 
margin:.3em;
 
}
 
 
.ac .yui-ac-content ul {
 
width:100%;
 
margin:0;
 
padding:0;
 
}
 
 
.ac .yui-ac-content li {
 
cursor:default;
 
white-space:nowrap;
 
margin:0;
 
padding:2px 5px;
 
}
 
 
.ac .yui-ac-content li.yui-ac-prehighlight {
 
background:#B3D4FF;
 
}
 
 
.ac .yui-ac-content li.yui-ac-highlight {
 
background:#556CB5;
 
color:#FFF;
 
}
 
 
.add_icon {
 
background:url("../images/icons/add.png") no-repeat scroll 3px;
 
height:16px;
 
padding-left:20px;
 
padding-top:1px;
 
text-align:left;
 
}
 
 
.edit_icon {
 
background:url("../images/icons/folder_edit.png") no-repeat scroll 3px;
 
height:16px;
 
padding-left:20px;
 
padding-top:1px;
 
text-align:left;
 
}
 
 
.delete_icon {
 
background:url("../images/icons/delete.png") no-repeat scroll 3px;
 
height:16px;
 
padding-left:20px;
 
padding-top:1px;
 
text-align:left;
 
}
 
 
.rss_icon {
 
background:url("../images/icons/rss_16.png") no-repeat scroll 3px;
 
height:16px;
 
padding-left:20px;
rhodecode/templates/base/base.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<!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" id="mainhtml">
 
<head>
 
    <title>${next.title()}</title>
 
    <link rel="icon" href="/images/hgicon.png" type="image/png" />
 
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 
    <meta name="robots" content="index, nofollow"/>
 
    <!-- stylesheets -->
 
    ${self.css()}
 
    <!-- scripts -->
 
    ${self.js()}
 
</head>
 
<body>
 
    <!-- header -->
 
    <div id="header">
 
        <!-- user -->
 
        <ul id="logged-user">
 
            <li class="first">
 
	            <div class="gravatar">
 
	            	<img alt="gravatar" src="${h.gravatar_url(c.rhodecode_user.email,24)}" />
 
	            </div>
 
	            <div class="account">
 
	            	${h.link_to('%s %s'%(c.rhodecode_user.name,c.rhodecode_user.lastname),h.url('admin_settings_my_account'))}<br/>
 
	            	${h.link_to(c.rhodecode_user.username,h.url('admin_settings_my_account'))}
 
	            </div>	
 
            </li>
 
            <li class="last highlight">${h.link_to(u'Logout',h.url('logout_home'))}</li>
 
        </ul>
 
        <!-- end user -->
 
        <div id="header-inner" class="title top-left-rounded-corner top-right-rounded-corner">
 
            <!-- logo -->
 
            <div id="logo">
 
                <h1><a href="${h.url('hg_home')}">${c.rhodecode_name}</a></h1>
 
                <h1><a href="${h.url('home')}">${c.rhodecode_name}</a></h1>
 
            </div>
 
            <!-- end logo -->
 
            <!-- menu -->
 
            ${self.page_nav()}
 
            <!-- quick -->
 
        </div>
 
    </div>     
 
    <!-- end header -->
 
    
 
	<!-- CONTENT -->
 
	<div id="content"> 
 
        <div class="flash_msg">
 
            <% 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>
 
	</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">
 
                        <img src="/images/icons/database.png" alt="${_('Products')}" />
 
                    </span>
 
                    <span>&darr;</span>					
 
					</a>
 
					<ul class="repo_switcher">
 
                        %for repo,private in c.repo_switcher_list:
 
                          %if private:
 
                             <li>${h.link_to(repo,h.url('summary_home',repo_name=repo),class_="private_repo")}</li>
 
                          %else:
 
                             <li>${h.link_to(repo,h.url('summary_home',repo_name=repo),class_="public_repo")}</li>
 
                          %endif  
 
                        %endfor					
 
					</ul>			
 
				</li>
 
				
 
	            <li ${is_current('summary')}>
 
	               <a title="${_('Summary')}" href="${h.url('summary_home',repo_name=c.repo_name)}">
 
	               <span class="icon">
 
	                   <img src="/images/icons/clipboard_16.png" alt="${_('Summary')}" />
 
	               </span>
 
	               <span>${_('Summary')}</span>                 
 
	               </a>	            
 
	            </li>
 
                <li ${is_current('shortlog')}>
 
                   <a title="${_('Shortlog')}" href="${h.url('shortlog_home',repo_name=c.repo_name)}">
 
                   <span class="icon">
 
                       <img src="/images/icons/application_view_list.png" alt="${_('Shortlog')}" />
 
                   </span>
 
                   <span>${_('Shortlog')}</span>                 
 
                   </a>             
 
                </li>	            
 
                <li ${is_current('changelog')}>
 
                   <a title="${_('Changelog')}" href="${h.url('changelog_home',repo_name=c.repo_name)}">
 
                   <span class="icon">
 
                       <img src="/images/icons/time.png" alt="${_('Changelog')}" />
 
                   </span>
 
                   <span>${_('Changelog')}</span>                 
 
                   </a>             
 
                </li>   	
 
                
 
                <li ${is_current('switch_to')}>
 
                   <a title="${_('Switch to')}" href="#">
 
                   <span class="icon">
 
                       <img src="/images/icons/arrow_switch.png" alt="${_('Switch to')}" />
 
                   </span>
 
                   <span>${_('Switch to')}</span>                 
 
                   </a>    
 
                    <ul>
 
                        <li>
 
                            ${h.link_to(_('branches'),h.url('branches_home',repo_name=c.repo_name),class_='branches childs')}
 
                            <ul>
 
                            %if c.repository_branches.values():
 
						        %for cnt,branch in enumerate(c.repository_branches.items()):
 
						            <li>${h.link_to('%s - %s' % (branch[0],branch[1]),h.url('files_home',repo_name=c.repo_name,revision=branch[1]))}</li>
 
						            <li>${h.link_to('%s - %s' % (branch[0],h.short_id(branch[1])),h.url('files_home',repo_name=c.repo_name,revision=branch[1]))}</li>
 
						        %endfor
 
						    %else:
 
						    	<li>${h.link_to(_('There are no branches yet'),'#')}</li>
 
						    %endif
 
                            </ul>                        
 
                        </li>
 
                        <li>
 
                            ${h.link_to(_('tags'),h.url('tags_home',repo_name=c.repo_name),class_='tags childs')}
 
                            <ul>
 
                            %if c.repository_tags.values():
 
                                %for cnt,tag in enumerate(c.repository_tags.items()):
 
                                 <li>${h.link_to('%s - %s' % (tag[0],tag[1]),h.url('files_home',repo_name=c.repo_name,revision=tag[1]))}</li>
 
                                 <li>${h.link_to('%s - %s' % (tag[0],h.short_id(tag[1])),h.url('files_home',repo_name=c.repo_name,revision=tag[1]))}</li>
 
                                %endfor
 
                            %else:
 
                            	<li>${h.link_to(_('There are no tags yet'),'#')}</li>
 
                            %endif
 
                            </ul>                        
 
                        </li>                        
 
                    </ul>
 
                </li>
 
                <li ${is_current('files')}>
 
                   <a title="${_('Files')}" href="${h.url('files_home',repo_name=c.repo_name)}">
 
                   <span class="icon">
 
                       <img src="/images/icons/file.png" alt="${_('Files')}" />
 
                   </span>
 
                   <span>${_('Files')}</span>                 
 
                   </a>             
 
                </li>                            
 
				
 
                <li ${is_current('options')}>
 
                   <a title="${_('Options')}" href="#">
 
                   <span class="icon">
 
                       <img src="/images/icons/table_gear.png" alt="${_('Admin')}" />
 
                   </span>
 
                   <span>${_('Options')}</span>                 
 
                   </a>
 
                   <ul>
 
                   %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
 
                   	<li>${h.link_to(_('settings'),h.url('repo_settings_home',repo_name=c.repo_name),class_='settings')}</li>
 
                   %endif	
 
                   	<li>${h.link_to(_('fork'),h.url('repo_fork_home',repo_name=c.repo_name),class_='fork')}</li>
 
                   	<li>${h.link_to(_('search'),h.url('search_repo',search_repo=c.repo_name),class_='search')}</li>
 
                    
 
                    %if h.HasPermissionAll('hg.admin')('access admin main page'):
 
                    <li>
 
                       ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')}  
 
                        <ul>
 
                            <li>${h.link_to(_('journal'),h.url('admin_home'),class_='journal')}</li>
 
                            <li>${h.link_to(_('repositories'),h.url('repos'),class_='repos')}</li>
 
                            <li>${h.link_to(_('users'),h.url('users'),class_='users')}</li>
 
                            <li>${h.link_to(_('permissions'),h.url('edit_permission',id='default'),class_='permissions')}</li>
 
                            <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li>        
 
                        </ul>
 
                    </li>
 
                    %endif                    
 

	
 
                
 
##                   %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
 
##                   	<li class="last">
 
##                   	${h.link_to(_('delete'),'#',class_='delete')}
 
##	                  ${h.form(url('repo_settings_delete', repo_name=c.repo_name),method='delete')}
 
##	                    ${h.submit('remove_%s' % c.repo_name,'delete',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
 
##	                  ${h.end_form()}
 
##                   	</li>
 
##                   	%endif
 
                   </ul>             
 
                </li>
 
	        </ul>
 
		%else:
 
		    ##ROOT MENU
 
            <ul id="quick">
 
                <li>
 
                    <a title="${_('Home')}"  href="${h.url('hg_home')}">
 
                    <a title="${_('Home')}"  href="${h.url('home')}">
 
                    <span class="icon">
 
                        <img src="/images/icons/home_16.png" alt="${_('Home')}" />
 
                    </span>
 
                    <span>${_('Home')}</span>                 
 
                    </a>        
 
                </li>
 
                
 
                <li>
 
                    <a title="${_('Search')}"  href="${h.url('search')}">
 
                    <span class="icon">
 
                        <img src="/images/icons/search_16.png" alt="${_('Search')}" />
 
                    </span>
 
                    <span>${_('Search')}</span>                 
 
                    </a>        
 
                </li>
 
                
 
				%if h.HasPermissionAll('hg.admin')('access admin main page'):
 
                <li ${is_current('admin')}>
 
                   <a title="${_('Admin')}" href="${h.url('admin_home')}">
 
                   <span class="icon">
 
                       <img src="/images/icons/cog_edit.png" alt="${_('Admin')}" />
 
                   </span>
 
                   <span>${_('Admin')}</span>                 
 
                   </a>    
 
				    <ul>
 
				        <li>${h.link_to(_('journal'),h.url('admin_home'),class_='journal')}</li>
 
				        <li>${h.link_to(_('repositories'),h.url('repos'),class_='repos')}</li>
 
				        <li>${h.link_to(_('users'),h.url('users'),class_='users')}</li>
 
				        <li>${h.link_to(_('permissions'),h.url('edit_permission',id='default'),class_='permissions')}</li>
 
				        <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li>        
 
				    </ul>
 
                </li>
 
				%endif
 
				
 
			</ul>
 
		%endif    
 
</%def>
 

	
 

	
 
<%def name="css()">
 
<link rel="stylesheet" type="text/css" href="/css/style.css" media="screen" />
 
<link rel="stylesheet" type="text/css" href="/css/pygments.css"  />
 
<link rel="stylesheet" type="text/css" href="/css/diff.css"  />
 
</%def>
 

	
 
<%def name="js()">
 
##<script type="text/javascript" src="/js/yui/utilities/utilities.js"></script>
 
##<script type="text/javascript" src="/js/yui/container/container.js"></script>
 
##<script type="text/javascript" src="/js/yui/datasource/datasource.js"></script>
 
##<script type="text/javascript" src="/js/yui/autocomplete/autocomplete.js"></script>
 

	
 
<script type="text/javascript" src="/js/yui2.js"></script>
 
<!--[if IE]><script language="javascript" type="text/javascript" src="/js/excanvas.min.js"></script><![endif]-->
 
<script type="text/javascript" src="/js/yui.flot.js"></script>
 
</%def>
 

	
 
<%def name="breadcrumbs()">
 
    <div class="breadcrumbs">
 
    ${self.breadcrumbs_links()}
 
    </div>
 
</%def>
 
\ No newline at end of file
rhodecode/templates/branches/branches_data.html
Show inline comments
 
% if c.repo_branches:
 
    <table class="table_disp">
 
        <tr>
 
            <th class="left">${_('date')}</th>
 
            <th class="left">${_('name')}</th>
 
            <th class="left">${_('author')}</th>
 
            <th class="left">${_('revision')}</th>
 
            <th class="left">${_('name')}</th>
 
            <th class="left">${_('links')}</th>
 
        </tr>
 
		%for cnt,branch in enumerate(c.repo_branches.items()):
 
		<tr class="parity${cnt%2}">
 
			<td>${h.age(branch[1].date)}</td>
 
			<td>r${branch[1].revision}:${branch[1].short_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].short_id))}</span>
 
				</span>			
 
			</td>
 
            <td>${branch[1].date} - ${h.age(branch[1].date)}</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 title="${branch[1].author}">${h.person(branch[1].author)}</td>
 
            <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].short_id))}
 
			${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].short_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
 

	
rhodecode/templates/changelog/changelog.html
Show inline comments
 
## -*- coding: utf-8 -*-
 

	
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
${c.repo_name} ${_('Changelog')} - ${c.rhodecode_name}
 
</%def>
 

	
 
<%def name="breadcrumbs_links()">
 
    ${h.link_to(u'Home',h.url('/'))}
 
    &raquo;
 
    ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
 
    &raquo;
 
    ${_('Changelog')} - ${_('showing ')} ${c.size if c.size <= c.total_cs else c.total_cs} ${_('out of')} ${c.total_cs} ${_('revisions')}  
 
</%def>
 

	
 
<%def name="page_nav()">
 
	${self.menu('changelog')}     
 
</%def>
 

	
 
<%def name="main()">
 
<div class="box">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <div class="table">
 
		% if c.pagination:
 
			<div id="graph">
 
				<div id="graph_nodes">
 
					<canvas id="graph_canvas"></canvas>
 
				</div>
 
				<div id="graph_content">
 
					<div class="container_header">
 
						
 
        ${h.form(h.url.current(),method='get')}
 
        <div class="info_box">
 
          <span>${_('Show')}:</span>
 
          ${h.text('size',size=1,value=c.size)}
 
          <span>${_('revisions')}</span>
 
          ${h.submit('set',_('set'))}
 
        </div>
 
        ${h.end_form()}
 
						
 
					</div>
 
				%for cnt,cs in enumerate(c.pagination):
 
					<div id="chg_${cnt+1}" class="container">
 
						<div class="left">
 
							<div class="date">${_('commit')} ${cs.revision}: ${cs.short_id}@${cs.date}</div>
 
							<div class="date">${_('commit')} ${cs.revision}: ${cs.raw_id}@${cs.date}</div>
 
							<div class="author">
 
								<div class="gravatar">
 
									<img alt="gravatar" src="${h.gravatar_url(h.email(cs.author),20)}"/>
 
								</div>
 
								<span>${h.person(cs.author)}</span><br/>
 
								<span><a href="mailto:${h.email_or_none(cs.author)}">${h.email_or_none(cs.author)}</a></span><br/>
 
							</div>
 
							<div class="message">${h.link_to(h.wrap_paragraphs(cs.message),h.url('changeset_home',repo_name=c.repo_name,revision=cs.short_id))}</div>
 
							<div class="message">${h.link_to(h.wrap_paragraphs(cs.message),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</div>
 
						</div>	
 
						<div class="right">
 
									<div class="changes">
 
										<span class="removed" title="${_('removed')}">${len(cs.removed)}</span>
 
										<span class="changed" title="${_('changed')}">${len(cs.changed)}</span>
 
										<span class="added" title="${_('added')}">${len(cs.added)}</span>
 
									</div>					
 
										%if len(cs.parents)>1:
 
										<div class="merge">
 
											${_('merge')}<img alt="merge" src="/images/icons/arrow_join.png"/>
 
										</div>
 
										%endif
 
								   %if cs.parents:							
 
									%for p_cs in reversed(cs.parents):
 
										<div class="parent">${_('Parent')} ${p_cs.revision}: ${h.link_to(p_cs.short_id,
 
											h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.short_id),title=p_cs.message)}
 
										<div class="parent">${_('Parent')} ${p_cs.revision}: ${h.link_to(p_cs.raw_id,
 
											h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}
 
										</div>
 
									%endfor
 
								   %else:	
 
                                        <div class="parent">${_('No parents')}</div>   
 
                                   %endif  
 
                    									
 
								<span class="logtags">
 
									<span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}">
 
									${h.link_to(cs.branch,h.url('files_home',repo_name=c.repo_name,revision=cs.short_id))}</span>
 
									${h.link_to(cs.branch,h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
 
									%for tag in cs.tags:
 
										<span class="tagtag"  title="${'%s %s' % (_('tag'),tag)}">
 
										${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=cs.short_id))}</span>
 
										${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
 
									%endfor
 
								</span>																	
 
						</div>				
 
					</div>
 
					
 
				%endfor
 
				<div class="pagination-wh pagination-left">
 
					${c.pagination.pager('$link_previous ~2~ $link_next')}
 
				</div>			
 
				</div>
 
			</div>
 
			
 
			<script type="text/javascript" src="/js/graph.js"></script>
 
			<script type="text/javascript">
 
				YAHOO.util.Event.onDOMReady(function(){
 
					function set_canvas() {
 
						var c = document.getElementById('graph_nodes');
 
						var t = document.getElementById('graph_content');
 
						canvas = document.getElementById('graph_canvas');
 
						var div_h = t.clientHeight;
 
						c.style.height=div_h+'px';
 
						canvas.setAttribute('height',div_h);
 
						canvas.setAttribute('width',160);
 
					};
 
					set_canvas();
 
					var jsdata = ${c.jsdata|n};
 
					var r = new BranchRenderer();
 
					r.render(jsdata); 
 
				});
 
			</script>
 
		%else:
 
			${_('There are no changes yet')}
 
		%endif  
 
    </div>
 
</div>    
 
</%def>
 
\ No newline at end of file
rhodecode/templates/changeset/changeset.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
    ${c.repo_name} ${_('Changeset')} - r${c.changeset.revision}:${c.changeset.short_id}  - ${c.rhodecode_name}
 
    ${c.repo_name} ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} - ${c.rhodecode_name}
 
</%def>
 

	
 
<%def name="breadcrumbs_links()">
 
    ${h.link_to(u'Home',h.url('/'))}
 
    &raquo;
 
    ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
 
    &raquo;
 
    ${_('Changeset')} - r${c.changeset.revision}:${c.changeset.short_id}
 
    ${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)}
 
</%def>
 

	
 
<%def name="page_nav()">
 
    ${self.menu('changelog')}     
 
</%def>
 

	
 
<%def name="main()">
 
<div class="box">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <div class="table">
 
		<div id="body" class="diffblock">
 
			<div class="code-header">
 
				<div>
 
				${_('Changeset')} - r${c.changeset.revision}:${c.changeset.short_id}
 
				${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)}
 
				 &raquo; <span>${h.link_to(_('raw diff'),
 
				h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.short_id,diff='show'))}</span>
 
				h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='show'))}</span>
 
				 &raquo; <span>${h.link_to(_('download diff'),
 
				h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.short_id,diff='download'))}</span>
 
				h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download'))}</span>
 
				</div>
 
			</div>
 
		</div>
 
	    <div id="changeset_content">
 
			<div class="container">
 
	             <div class="left">
 
	                 <div class="date">${_('commit')} ${c.changeset.revision}: ${c.changeset.short_id}@${c.changeset.date}</div>
 
	                 <div class="date">${_('commit')} ${c.changeset.revision}: ${h.short_id(c.changeset.raw_id)}@${c.changeset.date}</div>
 
	                 <div class="author">
 
	                     <div class="gravatar">
 
	                         <img alt="gravatar" src="${h.gravatar_url(h.email(c.changeset.author),20)}"/>
 
	                     </div>
 
	                     <span>${h.person(c.changeset.author)}</span><br/>
 
	                     <span><a href="mailto:${h.email_or_none(c.changeset.author)}">${h.email_or_none(c.changeset.author)}</a></span><br/>
 
	                 </div>
 
	                 <div class="message">${h.link_to(h.wrap_paragraphs(c.changeset.message),h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.short_id))}</div>
 
	                 <div class="message">${h.link_to(h.wrap_paragraphs(c.changeset.message),h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</div>
 
	             </div>
 
	             <div class="right">
 
		             <div class="changes">
 
		                 <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span>
 
		                 <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span>
 
		                 <span class="added" title="${_('added')}">${len(c.changeset.added)}</span>
 
		             </div>                  
 
		                 %if len(c.changeset.parents)>1:
 
		                 <div class="merge">
 
		                     ${_('merge')}<img alt="merge" src="/images/icons/arrow_join.png"/>
 
		                 </div>
 
		                 %endif
 
		                 
 
		            %if c.changeset.parents:
 
		             %for p_cs in reversed(c.changeset.parents):
 
		                 <div class="parent">${_('Parent')} ${p_cs.revision}: ${h.link_to(p_cs.short_id,
 
		                     h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.short_id),title=p_cs.message)}
 
		                 <div class="parent">${_('Parent')} ${p_cs.revision}: ${h.link_to(h.short_id(p_cs.raw_id),
 
		                     h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}
 
		                 </div>
 
		             %endfor
 
                    %else: 
 
                        <div class="parent">${_('No parents')}</div>   
 
                    %endif		             
 
		         <span class="logtags">
 
		             <span class="branchtag" title="${'%s %s' % (_('branch'),c.changeset.branch)}">
 
		             ${h.link_to(c.changeset.branch,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.short_id))}</span>
 
		             ${h.link_to(c.changeset.branch,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span>
 
		             %for tag in c.changeset.tags:
 
		                 <span class="tagtag"  title="${'%s %s' % (_('tag'),tag)}">
 
		                 ${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.short_id))}</span>
 
		                 ${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span>
 
		             %endfor
 
		         </span>                                                                 
 
	                </div>              
 
	        </div>
 
	        <span style="font-size:1.1em;font-weight: bold">${_('Files affected')}</span>
 
	        <div class="cs_files">
 
	                %for change,filenode,diff,cs1,cs2 in c.changes:
 
	                    <div class="cs_${change}">${h.link_to(filenode.path,h.url.current(anchor='CHANGE-%s'%filenode.path))}</div>
 
	                %endfor
 
	        </div>         
 
	    </div>
 
	    
 
    </div>
 
    	
 
	%for change,filenode,diff,cs1,cs2 in c.changes:
 
		%if change !='removed':
 
		<div style="clear:both;height:10px"></div>
 
		<div id="body" class="diffblock">
 
			<div id="${'CHANGE-%s'%filenode.path}" class="code-header">
 
				<div>
 
					<span>
 
						${h.link_to_if(change!='removed',filenode.path,h.url('files_home',repo_name=c.repo_name,
 
						revision=filenode.changeset.short_id,f_path=filenode.path))}
 
						revision=filenode.changeset.raw_id,f_path=filenode.path))}
 
					</span>
 
					%if 1:
 
					&raquo; <span>${h.link_to(_('diff'),
 
					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='diff'))}</span>
 
					&raquo; <span>${h.link_to(_('raw diff'),
 
					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='raw'))}</span>
 
					&raquo; <span>${h.link_to(_('download diff'),
 
					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='download'))}</span>
 
					%endif
 
				</div>
 
			</div>
 
			<div class="code-body">        
 
					%if diff:
 
						${diff|n}
 
					%else:
 
						${_('No changes in this file')}
 
					%endif
 
			</div>
 
		</div>
 
		%endif
 
	%endfor 
 
    </div>
 
</div>    
 
	
 
</%def>
 
\ No newline at end of file
rhodecode/templates/errors/error_404.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%inherit file="./../base/base.html"/>
 
            
 
<%def name="title()">
 
    ${_('Repository not found')}
 
</%def>
 

	
 
<%def name="breadcrumbs()">
 
	${h.link_to(u'Home',h.url('hg_home'))}
 
	${h.link_to(u'Home',h.url('home'))}
 
	 / 
 
	${h.link_to(u'Admin',h.url('admin_home'))}
 
</%def>
 

	
 
<%def name="page_nav()">
 
	${self.menu('admin')}
 
</%def>
 
<%def name="js()">
 

	
 
</%def>
 
<%def name="main()">
 

	
 
    <h2 class="no-link no-border">${_('Not Found')}</h2>
 
    <p class="normal">${_('The specified repository "%s" is unknown, sorry.') % c.repo_name}</p>
 
    <p class="normal">
 
    <a href="${h.url('new_repo',repo=c.repo_name_cleaned)}">
 
    ${_('Create "%s" repository as %s' % (c.repo_name,c.repo_name_cleaned))}</a>
 

	
 
    </p>
 
    <p class="normal">${h.link_to(_('Go back to the main repository list page'),h.url('hg_home'))}</p>
 
    <p class="normal">${h.link_to(_('Go back to the main repository list page'),h.url('home'))}</p>
 
    <div class="page-footer">
 
    </div>
 
</%def>
 
\ No newline at end of file
rhodecode/templates/files/file_diff.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
    ${c.repo_name} ${_('File diff')} - ${c.rhodecode_name}
 
</%def>
 

	
 
<%def name="breadcrumbs_links()">
 
    ${h.link_to(u'Home',h.url('/'))}
 
    &raquo;
 
    ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
 
    &raquo;
 
    ${'%s:  %s %s %s' % (_('File diff'),c.diff2,'&rarr;',c.diff1)|n}
 
    ${_('File diff')} r${c.changeset_1.revision}:${h.short_id(c.changeset_1.raw_id)} &rarr; r${c.changeset_2.revision}:${h.short_id(c.changeset_2.raw_id)}
 
</%def>
 

	
 
<%def name="page_nav()">
 
    ${self.menu('files')}     
 
</%def>
 
<%def name="main()">
 
<div class="box">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <div class="table">
 
		<div id="body" class="diffblock">
 
			<div class="code-header">
 
				<div>
 
				<span>${h.link_to(c.f_path,h.url('files_home',repo_name=c.repo_name,
 
				revision=c.diff2.split(':')[1],f_path=c.f_path))}</span>
 
				revision=c.changeset_2.raw_id,f_path=c.f_path))}</span>
 
				 &raquo; <span>${h.link_to(_('diff'),
 
				h.url.current(diff2=c.diff2.split(':')[-1],diff1=c.diff1.split(':')[-1],diff='diff'))}</span>
 
				h.url.current(diff2=c.changeset_2.raw_id,diff1=c.changeset_1.raw_id,diff='diff'))}</span>
 
				 &raquo; <span>${h.link_to(_('raw diff'),
 
				h.url.current(diff2=c.diff2.split(':')[-1],diff1=c.diff1.split(':')[-1],diff='raw'))}</span>
 
				h.url.current(diff2=c.changeset_2.raw_id,diff1=c.changeset_1.raw_id,diff='raw'))}</span>
 
				 &raquo; <span>${h.link_to(_('download diff'),
 
				h.url.current(diff2=c.diff2.split(':')[-1],diff1=c.diff1.split(':')[-1],diff='download'))}</span>
 
				h.url.current(diff2=c.changeset_2.raw_id,diff1=c.changeset_1.raw_id,diff='download'))}</span>
 
				</div>
 
			</div>
 
			<div class="code-body">
 
		 			%if c.no_changes:
 
		            	${_('No changes')}
 
		            %else:        
 
						${c.cur_diff|n}
 
		            %endif
 
			</div>
 
		</div>   
 
    </div>
 
</div>    
 
</%def>  
 

	
 
   
 
\ No newline at end of file
rhodecode/templates/files/files.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
    ${c.repo_name} ${_('Files')} - ${c.rhodecode_name}
 
</%def>
 

	
 
<%def name="breadcrumbs_links()">
 
    ${h.link_to(u'Home',h.url('/'))}
 
    &raquo;
 
    ${h.link_to(c.repo_name,h.url('files_home',repo_name=c.repo_name))}
 
    &raquo;
 
    ${_('files')}
 
    %if c.files_list:
 
        @ R${c.rev_nr}:${c.cur_rev}
 
        @ R${c.rev_nr}:${h.short_id(c.cur_rev)}
 
    %endif        
 
</%def>
 

	
 
<%def name="page_nav()">
 
    ${self.menu('files')}     
 
</%def>
 

	
 
<%def name="main()">
 
<div class="box">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}     
 
    </div>
 
    <div class="table">
 
		<div id="files_data">
 
			%if c.files_list:
 
				<h3 class="files_location">${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cur_rev,c.files_list.path)}</h3>
 
					%if c.files_list.is_dir():
 
						<%include file='files_browser.html'/>
 
					%else:
 
						<%include file='files_source.html'/>			
 
					%endif	
 
			%else:
 
				<h2>
 
					<a href="#" onClick="javascript:parent.history.back();" target="main">${_('Go back')}</a> 
 
					${_('No files at given path')}: "${c.f_path or "/"}" 
 
				</h2>
 
			%endif
 
		
 
		</div>    
 
    </div>
 
</div>    
 
	
 
</%def>    
 
\ No newline at end of file
rhodecode/templates/files/files_annotate.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
    ${c.repo_name} ${_('File annotate')} - ${c.rhodecode_name}
 
</%def>
 

	
 
<%def name="breadcrumbs_links()">
 
    ${h.link_to(u'Home',h.url('/'))}
 
    &raquo;
 
    ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
 
    &raquo;
 
    ${_('annotate')} @ R${c.rev_nr}:${c.cur_rev}
 
</%def>
 

	
 
<%def name="page_nav()">
 
		${self.menu('files')}     
 
</%def>
 
<%def name="main()">
 
<div class="box">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <div class="table">
 
		<div id="files_data">
 
			<h3 class="files_location">${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cur_rev,c.file.path)}</h3>
 
			<dl class="overview">
 
				<dt>${_('Last revision')}</dt>
 
				<dd>${h.link_to("r%s:%s" % (c.file.last_changeset.revision,c.file.last_changeset.short_id),
 
						h.url('files_annotate_home',repo_name=c.repo_name,revision=c.file.last_changeset.short_id,f_path=c.f_path))} </dd>
 
				<dd>${h.link_to("r%s:%s" % (c.file.last_changeset.revision,c.file.last_changeset.raw_id),
 
						h.url('files_annotate_home',repo_name=c.repo_name,revision=c.file.last_changeset.raw_id,f_path=c.f_path))} </dd>
 
				<dt>${_('Size')}</dt>
 
				<dd>${h.format_byte_size(c.file.size,binary=True)}</dd>
 
    			<dt>${_('Mimetype')}</dt>
 
				<dd>${c.file.mimetype}</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(_('show as raw'),
 
						h.url('files_raw_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.f_path))}
 
					/ ${h.link_to(_('download as raw'),
 
						h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.f_path))}
 
				</dd>				
 
			</dl>
 
			<div id="body" class="codeblock">
 
				<div class="code-header">
 
					<div class="revision">${c.file.name}@r${c.file.last_changeset.revision}:${c.file.last_changeset.short_id}</div>
 
					<div class="revision">${c.file.name}@r${c.file.last_changeset.revision}:${c.file.last_changeset.raw_id}</div>
 
					<div class="commit">"${c.file_msg}"</div>
 
				</div>
 
				<div class="code-body">
 
					% if c.file.size < c.file_size_limit:
 
						${h.pygmentize_annotation(c.file,linenos=True,anchorlinenos=True,lineanchors='S',cssclass="code-highlight")}
 
					%else:
 
						${_('File is to big to display')} ${h.link_to(_('show as raw'),
 
						h.url('files_raw_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.f_path))}
 
					%endif				
 
				</div>
 
			</div>
 
		</div>    
 
    </div>
 
</div>    
 
</%def>   
 
\ No newline at end of file
rhodecode/templates/files/files_source.html
Show inline comments
 
<dl>
 
	<dt>${_('Last revision')}</dt>
 
	<dd>
 
		${h.link_to("r%s:%s" % (c.files_list.last_changeset.revision,c.files_list.last_changeset.short_id),
 
						h.url('files_home',repo_name=c.repo_name,revision=c.files_list.last_changeset.short_id,f_path=c.f_path))} 
 
		${h.link_to("r%s:%s" % (c.files_list.last_changeset.revision,h.short_id(c.files_list.last_changeset.raw_id)),
 
						h.url('files_home',repo_name=c.repo_name,revision=c.files_list.last_changeset.raw_id,f_path=c.f_path))} 
 
	</dd>
 
	<dt>${_('Size')}</dt>
 
	<dd>${h.format_byte_size(c.files_list.size,binary=True)}</dd>
 
	<dt>${_('Mimetype')}</dt>
 
	<dd>${c.files_list.mimetype}</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(_('show as raw'),
 
			h.url('files_raw_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.f_path))}			
 
		 / ${h.link_to(_('download as raw'),
 
			h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.f_path))}
 
	</dd>
 
	<dt>${_('History')}</dt>
 
	<dd>
 
		<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_id)}
 
		${h.select('diff1',c.files_list.last_changeset.short_id,c.file_history)}
 
		${h.hidden('diff2',c.files_list.last_changeset.raw_id)}
 
		${h.select('diff1',c.files_list.last_changeset.raw_id,c.file_history)}
 
		${h.submit('diff','diff to revision',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
		${h.submit('show_rev','show at revision',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">
 
		<div class="revision">${c.files_list.name}@r${c.files_list.last_changeset.revision}:${c.files_list.last_changeset.short_id}</div>
 
		<div class="revision">${c.files_list.name}@r${c.files_list.last_changeset.revision}:${h.short_id(c.files_list.last_changeset.raw_id)}</div>
 
		<div class="commit">"${c.files_list.last_changeset.message}"</div>
 
	</div>
 
	<div class="code-body">
 
		% if c.files_list.size < c.file_size_limit:
 
			${h.pygmentize(c.files_list,linenos=True,anchorlinenos=True,lineanchors='S',cssclass="code-highlight")}
 
		%else:
 
			${_('File is to big to display')} ${h.link_to(_('show as raw'),
 
			h.url('files_raw_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.f_path))}
 
		%endif
 
	</div>
 
</div>
 

	
 
<script type="text/javascript">
 
YAHOO.util.Event.onDOMReady(function(){
 
    YAHOO.util.Event.addListener('show_rev','click',function(e){
 
    	YAHOO.util.Event.preventDefault(e);
 
        var cs = YAHOO.util.Dom.get('diff1').value;
 
        var url = "${h.url('files_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs);
 
        window.location = url;
 
        });
 
   });
 
</script>
 
\ No newline at end of file
rhodecode/templates/index.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%inherit file="base/base.html"/>
 
<%def name="title()">
 
    ${_('Dashboard')} - ${c.rhodecode_name}
 
</%def>
 
<%def name="breadcrumbs()">
 
	${c.rhodecode_name}
 
</%def>
 
<%def name="page_nav()">
 
	${self.menu('home')}
 
</%def>
 
<%def name="main()">
 
	<%def name="get_sort(name)">
 
		<%name_slug = name.lower().replace(' ','_') %>
 
		
 
		%if name_slug == c.sort_slug:
 
		  %if c.sort_by.startswith('-'):
 
		    <a href="?sort=${name_slug}">${name}&uarr;</a>
 
		  %else:
 
		    <a href="?sort=-${name_slug}">${name}&darr;</a>
 
		  %endif:
 
		%else:
 
		    <a href="?sort=${name_slug}">${name}</a>
 
		%endif
 
	</%def>
 
	
 
    <div class="box">
 
	    <!-- box / title -->
 
	    <div class="title">
 
	        <h5>${_('Dashboard')}</h5>
 
	        %if h.HasPermissionAny('hg.admin','hg.create.repository')():
 
	        <ul class="links">
 
	          <li>
 
	            <span>${h.link_to(_('ADD NEW REPOSITORY'),h.url('admin_settings_create_repository'))}</span>
 
	          </li>          
 
	        </ul>  	        
 
	        %endif
 
	    </div>
 
	    <!-- end box / title -->
 
        <div class="table">
 
                    <table>
 
            <thead>
 
	            <tr>
 
			        <th class="left">${get_sort(_('Name'))}</th>
 
			        <th class="left">${get_sort(_('Description'))}</th>
 
			        <th class="left">${get_sort(_('Last change'))}</th>
 
			        <th class="left">${get_sort(_('Tip'))}</th>
 
			        <th class="left">${get_sort(_('Owner'))}</th>
 
			        <th class="left">${_('RSS')}</th>
 
			        <th class="left">${_('Atom')}</th>
 
	            </tr>
 
            </thead>
 
                        <tbody>
 
					    %for cnt,repo in enumerate(c.repos_list):
 
					        %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(repo['name'],'main page check'):
 
					        <tr class="parity${cnt%2}">
 
					            <td>
 
					             %if repo['repo'].dbrepo.repo_type =='hg':
 
					               <img class="icon" alt="${_('Mercurial repository')}" src="/images/icons/hgicon.png"/>
 
					               <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="/images/icons/hgicon.png"/>
 
					             %elif repo['repo'].dbrepo.repo_type =='git':
 
					               <img class="icon" alt="${_('Git repository')}" src="/images/icons/giticon.png"/>
 
					               <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="/images/icons/giticon.png"/>
 
					             %else:
 
					               
 
					             %endif 
 
					            
 
					             %if repo['repo'].dbrepo.private:
 
					                <img class="icon" alt="${_('private')}" src="/images/icons/lock.png"/>
 
					                <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="/images/icons/lock.png"/>
 
					             %else:
 
					                <img class="icon" alt="${_('public')}" src="/images/icons/lock_open.png"/>
 
					                <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="/images/icons/lock_open.png"/>
 
					             %endif  
 
					            ${h.link_to(repo['name'],
 
					                h.url('summary_home',repo_name=repo['name']))}
 
					            %if repo['repo'].dbrepo.fork:
 
					            	<a href="${h.url('summary_home',repo_name=repo['repo'].dbrepo.fork.repo_name)}">
 
					            	<img class="icon" alt="${_('public')}"
 
					            	<img class="icon" alt="${_('fork')}"
 
					            	title="${_('Fork of')} ${repo['repo'].dbrepo.fork.repo_name}" 
 
					            	src="/images/icons/arrow_divide.png"/></a>
 
					            %endif
 
					            </td>
 
					            <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
 
					            <td><span class="tooltip" tooltip_title="${repo['description']}">
 
					               ${h.truncate(repo['description'],60)}</span>
 
					            </td>
 
					            <td><span class="tooltip" tooltip_title="${repo['last_change']}">
 
					                ${h.age(repo['last_change'])} </span></td>
 
					                ${h.age(repo['last_change'])} </span>
 
					            </td>
 
					            <td>
 
					            	%if repo['rev']>=0:
 
					            	${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),
 
					            	${h.link_to('r%s:%s' % (repo['rev'],h.short_id(repo['tip'])),
 
					                h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
 
					                class_="tooltip",
 
					                tooltip_title=h.tooltip(repo['last_msg']))}
 
					            	%else:
 
					            		${_('No changesets yet')}
 
					            	%endif    
 
					            </td>
 
					            <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
 
					            <td>
 
					                <a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_icon"  href="${h.url('rss_feed_home',repo_name=repo['name'])}"></a>
 
					            </td>        
 
					            <td>
 
					                <a title="${_('Subscribe to %s atom feed')%repo['name']}"  class="atom_icon" href="${h.url('atom_feed_home',repo_name=repo['name'])}"></a>
 
					            </td>
 
					        </tr>
 
					        %endif
 
					    %endfor
 
                        </tbody>
 
                    </table>
 
            </div>
 
    </div>	
 
</%def>    
rhodecode/templates/shortlog/shortlog_data.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
% if c.repo_changesets:
 
<table>
 
	<tr>
 
		<th class="left">${_('date')}</th>
 
		<th class="left">${_('commit message')}</th>
 
		<th class="left">${_('author')}</th>
 
		<th class="left">${_('revision')}</th>
 
		<th class="left">${_('commit message')}</th>
 
		<th class="left">${_('branch')}</th>
 
		<th class="left">${_('tags')}</th>
 
		<th class="left">${_('links')}</th>
 
		
 
	</tr>
 
%for cnt,cs in enumerate(c.repo_changesets):
 
	<tr class="parity${cnt%2}">
 
		<td>${h.age(cs.date)} - ${cs.date} </td>
 
		<td>${cs.date} - ${h.age(cs.date)}</td>
 
        <td>
 
            ${h.link_to(h.truncate(cs.message,60),
 
            h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id),
 
            title=cs.message)}
 
        </td>		
 
		<td title="${cs.author}">${h.person(cs.author)}</td>
 
		<td>r${cs.revision}:${cs.short_id}</td>
 
		<td>
 
			${h.link_to(h.truncate(cs.message,60),
 
			h.url('changeset_home',repo_name=c.repo_name,revision=cs.short_id),
 
			title=cs.message)}
 
		</td>
 
		<td>r${cs.revision}:${h.short_id(cs.raw_id)}</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_id))}
 
		${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.short_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');});});
 
</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(){
 
        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
rhodecode/templates/summary/summary.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
    ${c.repo_name} ${_('Summary')} - ${c.rhodecode_name}
 
</%def>
 

	
 
<%def name="breadcrumbs_links()">
 
    ${h.link_to(u'Home',h.url('/'))}
 
    &raquo; 
 
    ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
 
    &raquo;
 
    ${_('summary')}
 
</%def>
 

	
 
<%def name="page_nav()">
 
	${self.menu('summary')}    
 
</%def>
 

	
 
<%def name="main()">
 
<script type="text/javascript">
 
var E = YAHOO.util.Event;
 
var D = YAHOO.util.Dom;
 

	
 
E.onDOMReady(function(e){
 
    id = 'clone_url';
 
    E.addListener(id,'click',function(e){
 
        D.get('clone_url').select();
 
    })
 
})
 
</script>
 
<div class="box box-left">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <!-- end box / title -->
 
	<div class="form">
 
	  <div class="fields">
 
		 
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Name')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			  
 
		          %if c.repo_info.dbrepo.repo_type =='hg':
 
		            <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="/images/icons/hgicon.png"/>
 
		          %elif c.repo_info.dbrepo.repo_type =='git':
 
		            <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="/images/icons/giticon.png"/>
 
		          %else:
 
		            
 
		          %endif 
 
                                 			  
 
	             %if c.repo_info.dbrepo.private:
 
	                <img style="margin-bottom:2px" class="icon" title="${_('private repository')}" alt="${_('private')}" src="/images/icons/lock.png"/>
 
	                <img style="margin-bottom:2px" class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="/images/icons/lock.png"/>
 
	             %else:
 
	                <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public')}" src="/images/icons/lock_open.png"/>
 
	                <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="/images/icons/lock_open.png"/>
 
	             %endif
 
			      <span style="font-size: 1.6em;font-weight: bold;vertical-align: baseline;">${c.repo_info.name}</span>
 
			      <br/>
 
		            %if c.repo_info.dbrepo.fork:
 
		            	<span style="margin-top:5px">
 
		            	<a href="${h.url('summary_home',repo_name=c.repo_info.dbrepo.fork.repo_name)}">
 
		            	<img class="icon" alt="${_('public')}"
 
		            	title="${_('Fork of')} ${c.repo_info.dbrepo.fork.repo_name}" 
 
		            	src="/images/icons/arrow_divide.png"/>
 
		            	${_('Fork of')} ${c.repo_info.dbrepo.fork.repo_name}
 
		            	</a>
 
		            	</span>
 
		            %endif			      
 
			  </div>
 
			 </div>
 
			
 
			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Description')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			      ${c.repo_info.description}
 
			  </div>
 
			 </div>
 
			
 
			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Contact')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			  	<div class="gravatar">
 
			  		<img alt="gravatar" src="${h.gravatar_url(c.repo_info.dbrepo.user.email)}"/>
 
			  	</div>
 
			  		${_('Username')}: ${c.repo_info.dbrepo.user.username}<br/>
 
			  		${_('Name')}: ${c.repo_info.dbrepo.user.name} ${c.repo_info.dbrepo.user.lastname}<br/>
 
			  		${_('Email')}: <a href="mailto:${c.repo_info.dbrepo.user.email}">${c.repo_info.dbrepo.user.email}</a>
 
			  </div>
 
			 </div>
 
			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Last change')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			      ${h.age(c.repo_info.last_change)} - ${c.repo_info.last_change} 
 
			      ${_('by')} ${h.get_changeset_safe(c.repo_info,'tip').author} 
 
			      
 
			  </div>
 
			 </div>
 
			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Clone url')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			      <input type="text" id="clone_url" readonly="readonly" value="hg clone ${c.clone_repo_url}" size="70"/>
 
			  </div>
 
			 </div>
 
			 
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Trending languages')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			    <div id="lang_stats">
 
			    
 
			    </div> 			  
 
			  	<script type="text/javascript">
 
			  		var data = ${c.trending_languages|n};
 
			  		var total = 0;
 
			  		var no_data = true;
 
			  		for (k in data){
 
			  		    total += data[k];
 
			  		    no_data = false;
 
			  		} 
 
					var tbl = document.createElement('table');
 
					tbl.setAttribute('class','trending_language_tbl');
 
			  		for (k in data){
 
				  		var tr = document.createElement('tr');
 
				  		var percentage = Math.round((data[k]/total*100),2);
 
						var value = data[k];
 
				  		var td1 = document.createElement('td');
 
				  		td1.width=150;
 
				  		var trending_language_label = document.createElement('div');
 
				  		trending_language_label.innerHTML = k;
 
				  		td1.appendChild(trending_language_label);
 

	
 
				  		var td2 = document.createElement('td');
 
			  		    var trending_language = document.createElement('div');
 
			  		    trending_language.title = k;
 
			  		    trending_language.innerHTML = "<b>"+percentage+"% "+value+" ${_('files')}</b>";
 
			  		    trending_language.setAttribute("class", 'trending_language top-right-rounded-corner bottom-right-rounded-corner');
 
			  		    trending_language.style.width=percentage+"%";
 
						td2.appendChild(trending_language);
rhodecode/templates/tags/tags_data.html
Show inline comments
 
%if c.repo_tags:    
 
    <table>
 
    	<tr>
 
			<th class="left">${_('date')}</th>
 
			<th class="left">${_('revision')}</th>
 
			<th class="left">${_('name')}</th>
 
	        <th class="left">${_('date')}</th>
 
	        <th class="left">${_('name')}</th>
 
	        <th class="left">${_('author')}</th>
 
	        <th class="left">${_('revision')}</th>
 
			<th class="left">${_('links')}</th>
 
    	</tr>
 
		%for cnt,tag in enumerate(c.repo_tags.items()):
 
		<tr class="parity${cnt%2}">
 
			<td>${h.age(tag[1].date)}</td>
 
			<td>r${tag[1].revision}:${tag[1].short_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].short_id))}</span>
 
				</span>
 
			</td>
 
		<tr class="parity${cnt%2}">		
 
	        <td>${tag[1].date} - ${h.age(tag[1].date)}</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 title="${tag[1].author}">${h.person(tag[1].author)}</td>
 
	        <td>r${tag[1].revision}:${h.short_id(tag[1].raw_id)}</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].short_id))}
 
			${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].short_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)