Changeset - 2f89beda06a1
[Not reviewed]
beta
0 4 0
Marcin Kuzminski - 15 years ago 2010-11-23 23:49:12
marcin@python-works.com
Added icons with numbers of followers and number of forks
4 files changed with 54 insertions and 17 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/base.py
Show inline comments
 
"""The base Controller API
 

	
 
Provides the BaseController class for subclassing.
 
"""
 
from pylons import config, tmpl_context as c, request, session
 
from pylons.controllers import WSGIController
 
from pylons.templating import render_mako as render
 
from rhodecode import __version__
 
from rhodecode.lib import auth
 
from rhodecode.lib.utils import get_repo_slug
 
from rhodecode.model import meta
 
from rhodecode.model.scm import ScmModel
 
from rhodecode import BACKENDS
 

	
 
class BaseController(WSGIController):
 

	
 
    def __before__(self):
 
        c.rhodecode_version = __version__
 
        c.rhodecode_name = config['rhodecode_title']
 
        c.repo_name = get_repo_slug(request)
 
        c.cached_repo_list = ScmModel().get_repos()
 
        c.backends = BACKENDS.keys()
 

	
 
        if c.repo_name:
 
            cached_repo = ScmModel().get(c.repo_name)
 
            scm_model = ScmModel()
 
            cached_repo = scm_model.get(c.repo_name)
 

	
 
            if cached_repo:
 
                c.repository_tags = cached_repo.tags
 
                c.repository_branches = cached_repo.branches
 
                c.repository_followers = scm_model.get_followers(cached_repo.dbrepo.repo_id)
 
                c.repository_forks = scm_model.get_forks(cached_repo.dbrepo.repo_id)
 
            else:
 
                c.repository_tags = {}
 
                c.repository_branches = {}
 
                c.repository_followers = 0
 
                c.repository_forks = 0
 

	
 
        self.sa = meta.Session()
 

	
 
    def __call__(self, environ, start_response):
 
        """Invoke the Controller"""
 
        # WSGIController.__call__ dispatches to the Controller method
 
        # the request is routed to. This routing information is
 
        # available in environ['pylons.routes_dict']
 
        try:
 
            #putting this here makes sure that we update permissions every time
 
            self.rhodecode_user = c.rhodecode_user = auth.get_user(session)
 
            return WSGIController.__call__(self, environ, start_response)
 
        finally:
 
            meta.Session.remove()
rhodecode/model/scm.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# Model for RhodeCode
 
# 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 9, 2010
 
Model for RhodeCode
 
@author: marcink
 
"""
 
from beaker.cache import cache_region, region_invalidate
 
from mercurial import ui
 
from rhodecode import BACKENDS
 
from rhodecode.lib import helpers as h
 
from rhodecode.lib.auth import HasRepoPermissionAny
 
from rhodecode.lib.utils import get_repos, make_ui, action_logger
 
from rhodecode.model import meta
 
from rhodecode.model.db import Repository, User, RhodeCodeUi, CacheInvalidation, \
 
    UserFollowing
 
from rhodecode.model.caching_query import FromCache
 
from sqlalchemy.orm import joinedload
 
from sqlalchemy.orm.session import make_transient
 
from vcs import get_backend
 
from vcs.utils.helpers import get_scm
 
from vcs.exceptions import RepositoryError, VCSError
 
from vcs.utils.lazy import LazyProperty
 
import traceback
 
import logging
 
import os
 
import time
 

	
 
log = logging.getLogger(__name__)
 

	
 
class UserTemp(object):
 
    def __init__(self, user_id):
 
        self.user_id = user_id
 

	
 
class RepoTemp(object):
 
    def __init__(self, repo_id):
 
        self.repo_id = repo_id
 
        
 
           
 

	
 

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

	
 
    def __init__(self):
 
        self.sa = meta.Session()
 

	
 
    @LazyProperty
 
    def repos_path(self):
 
        """
 
        Get's the repositories root path from database
 
        """
 
        q = self.sa.query(RhodeCodeUi).filter(RhodeCodeUi.ui_key == '/').one()
 

	
 
        return q.ui_value
 

	
 
    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 scan
 
        """
 
        log.info('scanning for repositories in %s', repos_path)
 

	
 
        if not isinstance(baseui, ui.ui):
 
            baseui = make_ui('db')
 
        repos_list = {}
 

	
 
        for name, path in get_repos(repos_path):
 
            try:
 
                if repos_list.has_key(name):
 
                    raise RepositoryError('Duplicate repository name %s '
 
                                    'found in %s' % (name, path))
 
                else:
 

	
 
                    klass = get_backend(path[0])
 

	
 
                    if path[0] == 'hg' and path[0] in BACKENDS.keys():
 
                        repos_list[name] = klass(path[1], baseui=baseui)
 

	
 
                    if path[0] == 'git' and path[0] in BACKENDS.keys():
 
                        repos_list[name] = klass(path[1])
 
            except OSError:
 
                continue
 

	
 
        return repos_list
 

	
 
    def get_repos(self, all_repos=None):
 
        """
 
        Get all repos from db and for each repo create it's backend instance.
 
        and fill that backed with information from database
 
        
 
        :param all_repos: give specific repositories list, good for filtering
 
        """
 
        if not all_repos:
 
            all_repos = self.sa.query(Repository)\
 
                .order_by(Repository.repo_name).all()
 

	
 
        invalidation_list = [str(x.cache_key) for x in \
 
                             self.sa.query(CacheInvalidation.cache_key)\
 
                             .filter(CacheInvalidation.cache_active == False)\
 
                             .all()]
 

	
 
        for r in all_repos:
 

	
 
            repo = self.get(r.repo_name, invalidation_list)
 

	
 
            if repo is not None:
 
                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.dbrepo.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.raw_id
 
                tmp_d['tip_sort'] = tip.revision
 
                tmp_d['rev'] = tip.revision
 
                tmp_d['contact'] = repo.dbrepo.user.full_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):
 
        return self.get(repo_name)
 

	
 
    def get(self, repo_name, invalidation_list=None):
 
        """
 
        Get's repository from given name, creates BackendInstance and
 
        propagates it's data from database with all additional information
 
        :param repo_name:
 
        """
 
        if not HasRepoPermissionAny('repository.read', 'repository.write',
 
                            'repository.admin')(repo_name, 'get repo check'):
 
            return
 

	
 
        @cache_region('long_term')
 
        def _get_repo(repo_name):
 

	
 
            repo_path = os.path.join(self.repos_path, repo_name)
 
            alias = get_scm(repo_path)[0]
 

	
 
            log.debug('Creating instance of %s repository', alias)
 
            backend = get_backend(alias)
 

	
 
            #TODO: get the baseui from somewhere for this
 
            if alias == 'hg':
 
                from pylons import app_globals as g
 
                repo = backend(repo_path, create=False, baseui=g.baseui)
 
                #skip hidden web repository
 
                if repo._get_hidden():
 
                    return
 
            else:
 
                repo = backend(repo_path, create=False)
 

	
 
            dbrepo = self.sa.query(Repository)\
 
                .options(joinedload(Repository.fork))\
 
                .options(joinedload(Repository.user))\
 
                .filter(Repository.repo_name == repo_name)\
 
                .scalar()
 
            make_transient(dbrepo)
 
            repo.dbrepo = dbrepo
 
            return repo
 

	
 
        pre_invalidate = True
 
        if invalidation_list:
 
            pre_invalidate = repo_name in invalidation_list
 

	
 
        if pre_invalidate:
 
            invalidate = self._should_invalidate(repo_name)
 

	
 
            if invalidate:
 
                log.info('invalidating cache for repository %s', repo_name)
 
                region_invalidate(_get_repo, None, repo_name)
 
                self._mark_invalidated(invalidate)
 

	
 
        return _get_repo(repo_name)
 

	
 

	
 

	
 
    def mark_for_invalidation(self, repo_name):
 
        """
 
        Puts cache invalidation task into db for 
 
        further global cache invalidation
 
        
 
        :param repo_name: this repo that should invalidation take place
 
        """
 
        log.debug('marking %s for invalidation', repo_name)
 
        cache = self.sa.query(CacheInvalidation)\
 
            .filter(CacheInvalidation.cache_key == repo_name).scalar()
 

	
 
        if cache:
 
            #mark this cache as inactive
 
            cache.cache_active = False
 
        else:
 
            log.debug('cache key not found in invalidation db -> creating one')
 
            cache = CacheInvalidation(repo_name)
 

	
 
        try:
 
            self.sa.add(cache)
 
            self.sa.commit()
 
        except:
 
            log.error(traceback.format_exc())
 
            self.sa.rollback()
 

	
 

	
 
    def toggle_following_repo(self, follow_repo_id, user_id):
 

	
 
        f = self.sa.query(UserFollowing)\
 
            .filter(UserFollowing.follows_repo_id == follow_repo_id)\
 
            .filter(UserFollowing.user_id == user_id).scalar()
 

	
 
        if f is not None:
 
                    
 

	
 
            try:
 
                self.sa.delete(f)
 
                self.sa.commit()
 
                action_logger(UserTemp(user_id),
 
                              'stopped_following_repo',
 
                              RepoTemp(follow_repo_id))                
 
                              RepoTemp(follow_repo_id))
 
                return
 
            except:
 
                log.error(traceback.format_exc())
 
                self.sa.rollback()
 
                raise
 

	
 

	
 
        try:
 
            f = UserFollowing()
 
            f.user_id = user_id
 
            f.follows_repo_id = follow_repo_id
 
            self.sa.add(f)
 
            self.sa.commit()
 
            action_logger(UserTemp(user_id),
 
                          'started_following_repo',
 
                          RepoTemp(follow_repo_id))             
 
                          RepoTemp(follow_repo_id))
 
        except:
 
            log.error(traceback.format_exc())
 
            self.sa.rollback()
 
            raise
 

	
 
    def toggle_following_user(self, follow_user_id , user_id):
 
        f = self.sa.query(UserFollowing)\
 
            .filter(UserFollowing.follows_user_id == follow_user_id)\
 
            .filter(UserFollowing.user_id == user_id).scalar()
 

	
 
        if f is not None:
 
            try:
 
                self.sa.delete(f)
 
                self.sa.commit()
 
                return
 
            except:
 
                log.error(traceback.format_exc())
 
                self.sa.rollback()
 
                raise
 

	
 
        try:
 
            f = UserFollowing()
 
            f.user_id = user_id
 
            f.follows_user_id = follow_user_id
 
            self.sa.add(f)
 
            self.sa.commit()
 
        except:
 
            log.error(traceback.format_exc())
 
            self.sa.rollback()
 
            raise
 

	
 
    def is_following_repo(self, repo_name, user_id):
 
        r = self.sa.query(Repository)\
 
            .filter(Repository.repo_name == repo_name).scalar()
 

	
 
        f = self.sa.query(UserFollowing)\
 
            .filter(UserFollowing.follows_repository == r)\
 
            .filter(UserFollowing.user_id == user_id).scalar()
 

	
 
        return f is not None
 

	
 
    def is_following_user(self, username, user_id):
 
        u = self.sa.query(User)\
 
            .filter(User.username == username).scalar()
 

	
 
        f = self.sa.query(UserFollowing)\
 
            .filter(UserFollowing.follows_user == u)\
 
            .filter(UserFollowing.user_id == user_id).scalar()
 

	
 
        return f is not None
 

	
 
    def get_followers(self, repo_id):
 
        return self.sa.query(UserFollowing)\
 
                .filter(UserFollowing.follows_repo_id == repo_id).count()
 

	
 
    def get_forks(self, repo_id):
 
        return self.sa.query(Repository)\
 
                .filter(Repository.fork_id == repo_id).count()
 

	
 
    def _should_invalidate(self, repo_name):
 
        """
 
        Looks up database for invalidation signals for this repo_name
 
        :param repo_name:
 
        """
 

	
 
        ret = self.sa.query(CacheInvalidation)\
 
            .options(FromCache('sql_cache_short',
 
                           'get_invalidation_%s' % repo_name))\
 
            .filter(CacheInvalidation.cache_key == repo_name)\
 
            .filter(CacheInvalidation.cache_active == False)\
 
            .scalar()
 

	
 
        return ret
 

	
 
    def _mark_invalidated(self, cache_key):
 
        """
 
        Marks all occurences of cache to invaldation as already invalidated
 
        @param repo_name:
 
        """
 
        if cache_key:
 
            log.debug('marking %s as already invalidated', cache_key)
 
        try:
 
            cache_key.cache_active = True
 
            self.sa.add(cache_key)
 
            self.sa.commit()
 
        except:
 
            log.error(traceback.format_exc())
 
            self.sa.rollback()
 

	
rhodecode/public/css/style.css
Show inline comments
 
@@ -209,233 +209,247 @@ padding-top:4px;
 
float:left;
 
}
 
 
#header ul#logged-user li.last {
 
border-right:none;
 
}
 
 
#header ul#logged-user li a {
 
color:#4e4e4e;
 
font-weight:700;
 
text-decoration:none;
 
}
 
 
#header ul#logged-user li a:hover {
 
color:#376ea6;
 
text-decoration:underline;
 
}
 
 
#header ul#logged-user li.highlight a {
 
color:#fff;
 
}
 
 
#header ul#logged-user li.highlight a:hover {
 
color:#376ea6;
 
}
 
 
#header #header-inner {
 
height:40px;
 
clear:both;
 
position:relative;
 
background:#003367 url("../images/header_inner.png") repeat-x;
 
border-bottom:2px solid #fff;
 
margin:0;
 
padding:0;
 
}
 
 
#header #header-inner #home a {
 
height:40px;
 
width:46px;
 
display:block;
 
background:url("../images/button_home.png");
 
background-position:0 0;
 
margin:0;
 
padding:0;
 
}
 
 
#header #header-inner #home a:hover {
 
background-position:0 -40px;
 
}
 
 
#header #header-inner #logo h1 {
 
color:#FFF;
 
font-size:18px;
 
margin:10px 0 0 13px;
 
padding:0;
 
}
 
 
#header #header-inner #logo a {
 
color:#fff;
 
text-decoration:none;
 
}
 
 
#header #header-inner #logo a:hover {
 
color:#bfe3ff;
 
}
 
 
#header #header-inner #quick,#header #header-inner #quick ul {
 
position:relative;
 
float:right;
 
list-style-type:none;
 
list-style-position:outside;
 
margin:10px 5px 0 0;
 
padding:0;
 
}
 
 
#header #header-inner #quick li {
 
position:relative;
 
float:left;
 
margin:0 5px 0 0;
 
padding:0;
 
}
 
 
#header #header-inner #quick li a {
 
top:0;
 
left:0;
 
height:1%;
 
display:block;
 
clear:both;
 
overflow:hidden;
 
color:#FFF;
 
font-weight:700;
 
text-decoration:none;
 
background:#369 url("../../images/quick_l.png") no-repeat top left;
 
padding:0;
 
}
 
 
#header #header-inner #quick li span.short {
 
padding:9px 6px 8px 6px;
 
}
 
 
#header #header-inner #quick li span {
 
top:0;
 
right:0;
 
height:1%;
 
display:block;
 
float:left;
 
background:url("../../images/quick_r.png") no-repeat top right;
 
border-left:1px solid #3f6f9f;
 
margin:0;
 
padding:10px 12px 8px 10px;
 
}
 
 
#header #header-inner #quick li span.normal {
 
border:none;
 
padding:10px 12px 8px;
 
}
 
 
#header #header-inner #quick li span.icon {
 
top:0;
 
left:0;
 
border-left:none;
 
background:url("../../images/quick_l.png") no-repeat top left;
 
border-right:1px solid #2e5c89;
 
padding:8px 8px 4px;
 
}
 
 
#header #header-inner #quick li span.icon_short {
 
top:0;
 
left:0;
 
border-left:none;
 
background:url("../../images/quick_l.png") no-repeat top left;
 
border-right:1px solid #2e5c89;
 
padding:9px 4px 4px;
 
}
 
 
#header #header-inner #quick li a:hover {
 
background:#4e4e4e url("../../images/quick_l_selected.png") no-repeat top left;
 
}
 
 
#header #header-inner #quick li a:hover span {
 
border-left:1px solid #545454;
 
background:url("../../images/quick_r_selected.png") no-repeat top right;
 
}
 
 
#header #header-inner #quick li a:hover span.icon {
 
#header #header-inner #quick li a:hover span.icon,#header #header-inner #quick li a:hover span.icon_short {
 
border-left:none;
 
border-right:1px solid #464646;
 
background:url("../../images/quick_l_selected.png") no-repeat top left;
 
}
 
 
 
#header #header-inner #quick ul {
 
top:29px;
 
right:0;
 
min-width:200px;
 
display:none;
 
position:absolute;
 
background:#FFF;
 
border:1px solid #666;
 
border-top:1px solid #003367;
 
z-index:100;
 
margin:0;
 
padding:0;
 
}
 
 
#header #header-inner #quick ul.repo_switcher {
 
max-height:275px;
 
overflow-x:hidden;
 
overflow-y:auto;
 
}
 
 
#header #header-inner #quick .repo_switcher_type{
 
position:absolute;
 
left:0;
 
top:9px; 
 
 
}
 
#header #header-inner #quick li ul li {
 
border-bottom:1px solid #ddd;
 
}
 
 
#header #header-inner #quick li ul li a {
 
width:182px;
 
height:auto;
 
display:block;
 
float:left;
 
background:#FFF;
 
color:#003367;
 
font-weight:400;
 
margin:0;
 
padding:7px 9px;
 
}
 
 
#header #header-inner #quick li ul li a:hover {
 
color:#000;
 
background:#FFF;
 
}
 
 
#header #header-inner #quick ul ul {
 
top:auto;
 
}
 
 
#header #header-inner #quick li ul ul {
 
right:200px;
 
max-height:275px;
 
overflow:auto;
 
overflow-x:hidden;
 
white-space:normal;
 
}
 
 
#header #header-inner #quick li ul li a.journal,#header #header-inner #quick li ul li a.journal:hover {
 
background:url("../images/icons/book.png") no-repeat scroll 4px 9px #FFF;
 
width:167px;
 
margin:0;
 
padding:12px 9px 7px 24px;
 
}
 
 
#header #header-inner #quick li ul li a.private_repo,#header #header-inner #quick li ul li a.private_repo:hover {
 
background:url("../images/icons/lock.png") no-repeat scroll 4px 9px #FFF;
 
min-width:167px;
 
margin:0;
 
padding:12px 9px 7px 24px;
 
}
 
 
#header #header-inner #quick li ul li a.public_repo,#header #header-inner #quick li ul li a.public_repo:hover {
 
background:url("../images/icons/lock_open.png") no-repeat scroll 4px 9px #FFF;
 
min-width:167px;
 
margin:0;
 
padding:12px 9px 7px 24px;
 
}
 
 
#header #header-inner #quick li ul li a.hg,#header #header-inner #quick li ul li a.hg:hover {
 
background:url("../images/icons/hgicon.png") no-repeat scroll 4px 9px #FFF;
 
min-width:167px;
 
margin:0 0 0 14px;
 
padding:12px 9px 7px 24px;
 
}
 
 
#header #header-inner #quick li ul li a.git,#header #header-inner #quick li ul li a.git:hover {
 
background:url("../images/icons/giticon.png") no-repeat scroll 4px 9px #FFF;
 
min-width:167px;
 
margin:0 0 0 14px;
 
padding:12px 9px 7px 24px;
 
}
 
 
#header #header-inner #quick li ul li a.repos,#header #header-inner #quick li ul li a.repos:hover {
 
background:url("../images/icons/database_edit.png") no-repeat scroll 4px 9px #FFF;
rhodecode/templates/base/base.html
Show inline comments
 
@@ -119,205 +119,216 @@
 
					</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('%s (%s)' % (_('branches'),len(c.repository_branches.values()),),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],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('%s (%s)' % (_('tags'),len(c.repository_tags.values()),),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],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                    
 
                    %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>
 
                
 
                <li>
 
                    <a title="${_('Followers')}" href="#">
 
                    <span class="icon_short">
 
                        <img src="/images/icons/heart.png" alt="${_('Followers')}" />
 
                    </span>
 
                    <span class="short">${c.repository_followers}</span>
 
                    </a>
 
                </li>
 
                <li>
 
                    <a title="${_('Forks')}" href="#">
 
                    <span class="icon_short">
 
                        <img src="/images/icons/arrow_divide.png" alt="${_('Forks')}" />
 
                    </span>
 
                    <span class="short">${c.repository_forks}</span>
 
                    </a>
 
                </li>                
 
                
 
                
 
                
 
	        </ul>
 
		%else:
 
		    ##ROOT MENU
 
            <ul id="quick">
 
                <li>
 
                    <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="${_('Journal')}"  href="${h.url('journal')}">
 
                    <span class="icon">
 
                        <img src="/images/icons/book.png" alt="${_('Journal')}" />
 
                    </span>
 
                    <span>${_('Journal')}</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/yui/selector/selector-min.js"></script>
 

	
 
<script type="text/javascript" src="/js/yui2a.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>
 

	
 
<script type="text/javascript">
 
var base_url  ='/_admin/toggle_following';
 
var YUC = YAHOO.util.Connect;
 
var YUD = YAHOO.util.Dom;
 

	
 

	
 
function onSuccess(){
 
	
 
	var f = YUD.get('follow_toggle');
 
    if(f.getAttribute('class')=='follow'){
 
        f.setAttribute('class','following');
 
        f.setAttribute('title',"${_('Stop following this repository')}");
 
        
 
    }
 
    else{
 
        f.setAttribute('class','follow');
 
        f.setAttribute('title',"${_('Start following this repository')}");
 
    }
 
}
 

	
 
function toggleFollowingUser(fallows_user_id,token){
 
    args = 'follows_user_id='+fallows_user_id;
 
    args+= '&auth_token='+token;
 
    YUC.asyncRequest('POST',base_url,{
 
        success:function(o){
0 comments (0 inline, 0 general)