Show More
@@ -5,11 +5,12 b' Provides the BaseController class for su' | |||
|
5 | 5 | from pylons import config, tmpl_context as c, request, session |
|
6 | 6 | from pylons.controllers import WSGIController |
|
7 | 7 | from pylons.templating import render_mako as render |
|
8 | from pylons_app import __version__ | |
|
8 | 9 | from pylons_app.lib import auth |
|
9 | 10 | from pylons_app.lib.utils import get_repo_slug |
|
10 | 11 | from pylons_app.model import meta |
|
11 | from pylons_app.model.hg_model import _get_repos_cached | |
|
12 | from pylons_app import __version__ | |
|
12 | from pylons_app.model.hg_model import _get_repos_cached, \ | |
|
13 | _get_repos_switcher_cached | |
|
13 | 14 | |
|
14 | 15 | class BaseController(WSGIController): |
|
15 | 16 | |
@@ -18,6 +19,7 b' class BaseController(WSGIController):' | |||
|
18 | 19 | c.hg_app_name = config['hg_app_name'] |
|
19 | 20 | c.repo_name = get_repo_slug(request) |
|
20 | 21 | c.cached_repo_list = _get_repos_cached() |
|
22 | c.repo_switcher_list = _get_repos_switcher_cached(c.cached_repo_list) | |
|
21 | 23 | self.sa = meta.Session |
|
22 | 24 | |
|
23 | 25 | def __call__(self, environ, start_response): |
@@ -2,7 +2,7 b'' | |||
|
2 | 2 | # encoding: utf-8 |
|
3 | 3 | # Model for hg app |
|
4 | 4 | # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
|
5 | ||
|
5 | # | |
|
6 | 6 | # This program is free software; you can redistribute it and/or |
|
7 | 7 | # modify it under the terms of the GNU General Public License |
|
8 | 8 | # as published by the Free Software Foundation; version 2 |
@@ -25,10 +25,12 b' Model for hg app' | |||
|
25 | 25 | from beaker.cache import cache_region |
|
26 | 26 | from mercurial import ui |
|
27 | 27 | from mercurial.hgweb.hgwebdir_mod import findrepos |
|
28 | from vcs.exceptions import RepositoryError, VCSError | |
|
28 | from pylons.i18n.translation import _ | |
|
29 | from pylons_app.lib.auth import HasRepoPermissionAny | |
|
29 | 30 | from pylons_app.model import meta |
|
30 | 31 | from pylons_app.model.db import Repository |
|
31 | 32 | from sqlalchemy.orm import joinedload |
|
33 | from vcs.exceptions import RepositoryError, VCSError | |
|
32 | 34 | import logging |
|
33 | 35 | import os |
|
34 | 36 | import sys |
@@ -56,6 +58,15 b' def _get_repos_cached():' | |||
|
56 | 58 | from pylons import app_globals as g |
|
57 | 59 | return HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui) |
|
58 | 60 | |
|
61 | @cache_region('super_short_term', 'cached_repos_switcher_list') | |
|
62 | def _get_repos_switcher_cached(cached_repo_list): | |
|
63 | repos_lst = [] | |
|
64 | for repo in sorted(x.name.lower() for x in cached_repo_list.values()): | |
|
65 | if HasRepoPermissionAny('repository.write', 'repository.read', 'repository.admin')(repo, 'main page check'): | |
|
66 | repos_lst.append(repo) | |
|
67 | ||
|
68 | return repos_lst | |
|
69 | ||
|
59 | 70 | @cache_region('long_term', 'full_changelog') |
|
60 | 71 | def _full_changelog_cached(repo_name): |
|
61 | 72 | log.info('getting full changelog for %s', repo_name) |
@@ -3197,6 +3197,15 b' table.code-browser .browser-dir {' | |||
|
3197 | 3197 | } |
|
3198 | 3198 | |
|
3199 | 3199 | /* ----------------------------------------------------------- |
|
3200 | REPO SWITCHER | |
|
3201 | ----------------------------------------------------------- */ | |
|
3202 | ||
|
3203 | #switch_repos{ | |
|
3204 | position: absolute; | |
|
3205 | height: 25px; | |
|
3206 | z-index: 1; | |
|
3207 | } | |
|
3208 | /* ----------------------------------------------------------- | |
|
3200 | 3209 | BREADCRUMBS |
|
3201 | 3210 | ----------------------------------------------------------- */ |
|
3202 | 3211 |
@@ -91,15 +91,13 b'' | |||
|
91 | 91 | } |
|
92 | 92 | else{ |
|
93 | 93 | YAHOO.util.Dom.setStyle('switch_repos','display',''); |
|
94 | //YAHOO.util.Dom.setStyle('repo_switcher','background','#FFFFFF'); | |
|
95 | //YAHOO.util.Dom.setStyle('repo_switcher','color','#556CB5'); | |
|
96 | 94 | YAHOO.util.Dom.addClass('repo_switcher','selected'); |
|
97 | 95 | } |
|
98 | 96 | }); |
|
99 | 97 | YAHOO.util.Event.addListener('repos_list','change',function(e){ |
|
100 | 98 | var wa = YAHOO.util.Dom.get('repos_list').value; |
|
101 | 99 | |
|
102 |
var url = "${h.url('summary_home',repo_name='__REP |
|
|
100 | var url = "${h.url('summary_home',repo_name='__REPO__')}".replace('__REPO__',wa); | |
|
103 | 101 | window.location = url; |
|
104 | 102 | }) |
|
105 | 103 | }); |
@@ -115,9 +113,9 b'' | |||
|
115 | 113 | </span> |
|
116 | 114 | <span>↓</span> |
|
117 | 115 | </a> |
|
118 |
<div id="switch_repos" style="display:none; |
|
|
119 |
<select id="repos_list" size=" |
|
|
120 | %for repo in sorted(x.name.lower() for x in c.cached_repo_list.values()): | |
|
116 | <div id="switch_repos" style="display:none;"> | |
|
117 | <select id="repos_list" size="10"> | |
|
118 | %for repo in c.repo_switcher_list: | |
|
121 | 119 | <option value="${repo}">${repo}</option> |
|
122 | 120 | %endfor |
|
123 | 121 | </select> |
@@ -51,7 +51,7 b'' | |||
|
51 | 51 | </thead> |
|
52 | 52 | <tbody> |
|
53 | 53 | %for cnt,repo in enumerate(c.repos_list): |
|
54 | %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(repo['name'],'main page check'): | |
|
54 | %if repo['name'] in c.repo_switcher_list: | |
|
55 | 55 | <tr class="parity${cnt%2}"> |
|
56 | 56 | <td> |
|
57 | 57 | %if repo['repo'].dbrepo.private: |
General Comments 0
You need to be logged in to leave comments.
Login now