Show More
@@ -1,190 +1,196 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ |
|
3 | 3 | rhodecode.controllers.admin.gist |
|
4 | 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
5 | 5 | |
|
6 | 6 | gist controller for RhodeCode |
|
7 | 7 | |
|
8 | 8 | :created_on: May 9, 2013 |
|
9 | 9 | :author: marcink |
|
10 | 10 | :copyright: (C) 2010-2013 Marcin Kuzminski <marcin@python-works.com> |
|
11 | 11 | :license: GPLv3, see COPYING for more details. |
|
12 | 12 | """ |
|
13 | 13 | # This program is free software: you can redistribute it and/or modify |
|
14 | 14 | # it under the terms of the GNU General Public License as published by |
|
15 | 15 | # the Free Software Foundation, either version 3 of the License, or |
|
16 | 16 | # (at your option) any later version. |
|
17 | 17 | # |
|
18 | 18 | # This program is distributed in the hope that it will be useful, |
|
19 | 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 | 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 | 21 | # GNU General Public License for more details. |
|
22 | 22 | # |
|
23 | 23 | # You should have received a copy of the GNU General Public License |
|
24 | 24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25 | 25 | import time |
|
26 | 26 | import logging |
|
27 | 27 | import traceback |
|
28 | 28 | import formencode |
|
29 | 29 | from formencode import htmlfill |
|
30 | 30 | |
|
31 | 31 | from pylons import request, tmpl_context as c, url |
|
32 | 32 | from pylons.controllers.util import abort, redirect |
|
33 | 33 | from pylons.i18n.translation import _ |
|
34 | 34 | |
|
35 | 35 | from rhodecode.model.forms import GistForm |
|
36 | 36 | from rhodecode.model.gist import GistModel |
|
37 | 37 | from rhodecode.model.meta import Session |
|
38 | 38 | from rhodecode.model.db import Gist |
|
39 | 39 | from rhodecode.lib import helpers as h |
|
40 | 40 | from rhodecode.lib.base import BaseController, render |
|
41 | 41 | from rhodecode.lib.auth import LoginRequired, NotAnonymous |
|
42 | 42 | from rhodecode.lib.utils2 import safe_str, safe_int, time_to_datetime |
|
43 | 43 | from rhodecode.lib.helpers import Page |
|
44 | 44 | from webob.exc import HTTPNotFound, HTTPForbidden |
|
45 | 45 | from sqlalchemy.sql.expression import or_ |
|
46 | 46 | from rhodecode.lib.vcs.exceptions import VCSError |
|
47 | 47 | |
|
48 | 48 | log = logging.getLogger(__name__) |
|
49 | 49 | |
|
50 | 50 | |
|
51 | 51 | class GistsController(BaseController): |
|
52 | 52 | """REST Controller styled on the Atom Publishing Protocol""" |
|
53 | 53 | |
|
54 | 54 | def __load_defaults(self): |
|
55 | 55 | c.lifetime_values = [ |
|
56 | 56 | (str(-1), _('forever')), |
|
57 | 57 | (str(5), _('5 minutes')), |
|
58 | 58 | (str(60), _('1 hour')), |
|
59 | 59 | (str(60 * 24), _('1 day')), |
|
60 | 60 | (str(60 * 24 * 30), _('1 month')), |
|
61 | 61 | ] |
|
62 | 62 | c.lifetime_options = [(c.lifetime_values, _("Lifetime"))] |
|
63 | 63 | |
|
64 | 64 | @LoginRequired() |
|
65 | 65 | def index(self, format='html'): |
|
66 | 66 | """GET /admin/gists: All items in the collection""" |
|
67 | 67 | # url('gists') |
|
68 | 68 | c.show_private = request.GET.get('private') and c.rhodecode_user.username != 'default' |
|
69 | c.show_public = request.GET.get('public') and c.rhodecode_user.username != 'default' | |
|
70 | ||
|
69 | 71 | gists = Gist().query()\ |
|
70 | 72 | .filter(or_(Gist.gist_expires == -1, Gist.gist_expires >= time.time()))\ |
|
71 | 73 | .order_by(Gist.created_on.desc()) |
|
72 | 74 | if c.show_private: |
|
73 | 75 | c.gists = gists.filter(Gist.gist_type == Gist.GIST_PRIVATE)\ |
|
74 | 76 | .filter(Gist.gist_owner == c.rhodecode_user.user_id) |
|
77 | elif c.show_public: | |
|
78 | c.gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC)\ | |
|
79 | .filter(Gist.gist_owner == c.rhodecode_user.user_id) | |
|
80 | ||
|
75 | 81 | else: |
|
76 | 82 | c.gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC) |
|
77 | 83 | p = safe_int(request.GET.get('page', 1), 1) |
|
78 | 84 | c.gists_pager = Page(c.gists, page=p, items_per_page=10) |
|
79 | 85 | return render('admin/gists/index.html') |
|
80 | 86 | |
|
81 | 87 | @LoginRequired() |
|
82 | 88 | @NotAnonymous() |
|
83 | 89 | def create(self): |
|
84 | 90 | """POST /admin/gists: Create a new item""" |
|
85 | 91 | # url('gists') |
|
86 | 92 | self.__load_defaults() |
|
87 | 93 | gist_form = GistForm([x[0] for x in c.lifetime_values])() |
|
88 | 94 | try: |
|
89 | 95 | form_result = gist_form.to_python(dict(request.POST)) |
|
90 | 96 | #TODO: multiple files support, from the form |
|
91 | 97 | nodes = { |
|
92 | 98 | form_result['filename'] or 'gistfile1.txt': { |
|
93 | 99 | 'content': form_result['content'], |
|
94 | 100 | 'lexer': None # autodetect |
|
95 | 101 | } |
|
96 | 102 | } |
|
97 | 103 | _public = form_result['public'] |
|
98 | 104 | gist_type = Gist.GIST_PUBLIC if _public else Gist.GIST_PRIVATE |
|
99 | 105 | gist = GistModel().create( |
|
100 | 106 | description=form_result['description'], |
|
101 | 107 | owner=c.rhodecode_user, |
|
102 | 108 | gist_mapping=nodes, |
|
103 | 109 | gist_type=gist_type, |
|
104 | 110 | lifetime=form_result['lifetime'] |
|
105 | 111 | ) |
|
106 | 112 | Session().commit() |
|
107 | 113 | new_gist_id = gist.gist_access_id |
|
108 | 114 | except formencode.Invalid, errors: |
|
109 | 115 | defaults = errors.value |
|
110 | 116 | |
|
111 | 117 | return formencode.htmlfill.render( |
|
112 | 118 | render('admin/gists/new.html'), |
|
113 | 119 | defaults=defaults, |
|
114 | 120 | errors=errors.error_dict or {}, |
|
115 | 121 | prefix_error=False, |
|
116 | 122 | encoding="UTF-8" |
|
117 | 123 | ) |
|
118 | 124 | |
|
119 | 125 | except Exception, e: |
|
120 | 126 | log.error(traceback.format_exc()) |
|
121 | 127 | h.flash(_('Error occurred during gist creation'), category='error') |
|
122 | 128 | return redirect(url('new_gist')) |
|
123 | 129 | return redirect(url('gist', id=new_gist_id)) |
|
124 | 130 | |
|
125 | 131 | @LoginRequired() |
|
126 | 132 | @NotAnonymous() |
|
127 | 133 | def new(self, format='html'): |
|
128 | 134 | """GET /admin/gists/new: Form to create a new item""" |
|
129 | 135 | # url('new_gist') |
|
130 | 136 | self.__load_defaults() |
|
131 | 137 | return render('admin/gists/new.html') |
|
132 | 138 | |
|
133 | 139 | @LoginRequired() |
|
134 | 140 | @NotAnonymous() |
|
135 | 141 | def update(self, id): |
|
136 | 142 | """PUT /admin/gists/id: Update an existing item""" |
|
137 | 143 | # Forms posted to this method should contain a hidden field: |
|
138 | 144 | # <input type="hidden" name="_method" value="PUT" /> |
|
139 | 145 | # Or using helpers: |
|
140 | 146 | # h.form(url('gist', id=ID), |
|
141 | 147 | # method='put') |
|
142 | 148 | # url('gist', id=ID) |
|
143 | 149 | |
|
144 | 150 | @LoginRequired() |
|
145 | 151 | @NotAnonymous() |
|
146 | 152 | def delete(self, id): |
|
147 | 153 | """DELETE /admin/gists/id: Delete an existing item""" |
|
148 | 154 | # Forms posted to this method should contain a hidden field: |
|
149 | 155 | # <input type="hidden" name="_method" value="DELETE" /> |
|
150 | 156 | # Or using helpers: |
|
151 | 157 | # h.form(url('gist', id=ID), |
|
152 | 158 | # method='delete') |
|
153 | 159 | # url('gist', id=ID) |
|
154 | 160 | gist = GistModel().get_gist(id) |
|
155 | 161 | owner = gist.gist_owner == c.rhodecode_user.user_id |
|
156 | 162 | if h.HasPermissionAny('hg.admin')() or owner: |
|
157 | 163 | GistModel().delete(gist) |
|
158 | 164 | Session().commit() |
|
159 | 165 | h.flash(_('Deleted gist %s') % gist.gist_access_id, category='success') |
|
160 | 166 | else: |
|
161 | 167 | raise HTTPForbidden() |
|
162 | 168 | |
|
163 | 169 | return redirect(url('gists')) |
|
164 | 170 | |
|
165 | 171 | @LoginRequired() |
|
166 | 172 | def show(self, id, format='html'): |
|
167 | 173 | """GET /admin/gists/id: Show a specific item""" |
|
168 | 174 | # url('gist', id=ID) |
|
169 | 175 | gist_id = id |
|
170 | 176 | c.gist = Gist.get_or_404(gist_id) |
|
171 | 177 | |
|
172 | 178 | #check if this gist is not expired |
|
173 | 179 | if c.gist.gist_expires != -1: |
|
174 | 180 | if time.time() > c.gist.gist_expires: |
|
175 | 181 | log.error('Gist expired at %s' % |
|
176 | 182 | (time_to_datetime(c.gist.gist_expires))) |
|
177 | 183 | raise HTTPNotFound() |
|
178 | 184 | try: |
|
179 | 185 | c.file_changeset, c.files = GistModel().get_gist_files(gist_id) |
|
180 | 186 | except VCSError: |
|
181 | 187 | log.error(traceback.format_exc()) |
|
182 | 188 | raise HTTPNotFound() |
|
183 | 189 | |
|
184 | 190 | return render('admin/gists/show.html') |
|
185 | 191 | |
|
186 | 192 | @LoginRequired() |
|
187 | 193 | @NotAnonymous() |
|
188 | 194 | def edit(self, id, format='html'): |
|
189 | 195 | """GET /admin/gists/id/edit: Form to edit an existing item""" |
|
190 | 196 | # url('edit_gist', id=ID) |
@@ -1,68 +1,70 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="/base/base.html"/> |
|
3 | 3 | |
|
4 | 4 | <%def name="title()"> |
|
5 | 5 | ${_('Gists')} · ${c.rhodecode_name} |
|
6 | 6 | </%def> |
|
7 | 7 | |
|
8 | 8 | <%def name="breadcrumbs_links()"> |
|
9 | 9 | %if c.show_private: |
|
10 | 10 | ${_('Private Gists for user %s') % c.rhodecode_user.username} |
|
11 | %elif c.show_public: | |
|
12 | ${_('Public Gists for user %s') % c.rhodecode_user.username} | |
|
11 | 13 | %else: |
|
12 | 14 | ${_('Public Gists')} |
|
13 | 15 | %endif |
|
14 | 16 | - ${c.gists_pager.item_count} |
|
15 | 17 | </%def> |
|
16 | 18 | |
|
17 | 19 | <%def name="page_nav()"> |
|
18 | 20 | ${self.menu('gists')} |
|
19 | 21 | </%def> |
|
20 | 22 | |
|
21 | 23 | <%def name="main()"> |
|
22 | 24 | <div class="box"> |
|
23 | 25 | <!-- box / title --> |
|
24 | 26 | <div class="title"> |
|
25 | 27 | ${self.breadcrumbs()} |
|
26 | 28 | %if c.rhodecode_user.username != 'default': |
|
27 | 29 | <ul class="links"> |
|
28 | 30 | <li> |
|
29 | 31 | <span>${h.link_to(_(u'Create new gist'), h.url('new_gist'))}</span> |
|
30 | 32 | </li> |
|
31 | 33 | </ul> |
|
32 | 34 | %endif |
|
33 | 35 | </div> |
|
34 | 36 | %if c.gists_pager.item_count>0: |
|
35 | 37 | % for gist in c.gists_pager: |
|
36 | 38 | <div class="gist-item" style="padding:10px 20px 10px 15px"> |
|
37 | 39 | |
|
38 | 40 | <div class="gravatar"> |
|
39 | 41 | <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(gist.owner.full_contact),24)}"/> |
|
40 | 42 | </div> |
|
41 | 43 | <div title="${gist.owner.full_contact}" class="user"> |
|
42 | 44 | <b>${h.person(gist.owner.full_contact)}</b> / |
|
43 | 45 | <b><a href="${h.url('gist',id=gist.gist_access_id)}">gist:${gist.gist_access_id}</a></b> |
|
44 | 46 | <span style="color: #AAA"> |
|
45 | 47 | %if gist.gist_expires == -1: |
|
46 | 48 | ${_('Expires')}: ${_('never')} |
|
47 | 49 | %else: |
|
48 | 50 | ${_('Expires')}: ${h.age(h.time_to_datetime(gist.gist_expires))} |
|
49 | 51 | %endif |
|
50 | 52 | </span> |
|
51 | 53 | </div> |
|
52 | 54 | <div>${_('Created')} ${h.age(gist.created_on)} |
|
53 | 55 | </div> |
|
54 | 56 | |
|
55 | 57 | <div style="border:0px;padding:10px 0px 0px 35px;color:#AAA">${gist.gist_description}</div> |
|
56 | 58 | </div> |
|
57 | 59 | % endfor |
|
58 | 60 | |
|
59 | 61 | <div class="notification-paginator"> |
|
60 | 62 | <div class="pagination-wh pagination-left"> |
|
61 | 63 | ${c.gists_pager.pager('$link_previous ~2~ $link_next')} |
|
62 | 64 | </div> |
|
63 | 65 | </div> |
|
64 | 66 | %else: |
|
65 | 67 | <div class="table">${_('There are no gists yet')}</div> |
|
66 | 68 | %endif |
|
67 | 69 | </div> |
|
68 | 70 | </%def> |
@@ -1,353 +1,354 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="root.html"/> |
|
3 | 3 | |
|
4 | 4 | <!-- HEADER --> |
|
5 | 5 | <div id="header-dd"></div> |
|
6 | 6 | <div id="header"> |
|
7 | 7 | <div id="header-inner" class="title"> |
|
8 | 8 | <div id="logo"> |
|
9 | 9 | <h1><a href="${h.url('home')}">${c.rhodecode_name}</a></h1> |
|
10 | 10 | </div> |
|
11 | 11 | <!-- MENU --> |
|
12 | 12 | ${self.page_nav()} |
|
13 | 13 | <!-- END MENU --> |
|
14 | 14 | ${self.body()} |
|
15 | 15 | </div> |
|
16 | 16 | </div> |
|
17 | 17 | <!-- END HEADER --> |
|
18 | 18 | |
|
19 | 19 | <!-- CONTENT --> |
|
20 | 20 | <div id="content"> |
|
21 | 21 | <div class="flash_msg"> |
|
22 | 22 | <% messages = h.flash.pop_messages() %> |
|
23 | 23 | % if messages: |
|
24 | 24 | <ul id="flash-messages"> |
|
25 | 25 | % for message in messages: |
|
26 | 26 | <li class="${message.category}_msg">${message}</li> |
|
27 | 27 | % endfor |
|
28 | 28 | </ul> |
|
29 | 29 | % endif |
|
30 | 30 | </div> |
|
31 | 31 | <div id="main"> |
|
32 | 32 | ${next.main()} |
|
33 | 33 | </div> |
|
34 | 34 | </div> |
|
35 | 35 | <!-- END CONTENT --> |
|
36 | 36 | |
|
37 | 37 | <!-- FOOTER --> |
|
38 | 38 | <div id="footer"> |
|
39 | 39 | <div id="footer-inner" class="title"> |
|
40 | 40 | <div> |
|
41 | 41 | <p class="footer-link"> |
|
42 | 42 | ${_('Server instance: %s') % c.rhodecode_instanceid if c.rhodecode_instanceid else ''} |
|
43 | 43 | </p> |
|
44 | 44 | <p class="footer-link-right"> |
|
45 | 45 | <a href="${h.url('rhodecode_official')}">RhodeCode ${c.rhodecode_version}</a> |
|
46 | 46 | © 2010-${h.datetime.today().year} by Marcin Kuzminski and others |
|
47 | 47 | – <a href="${h.url('bugtracker')}">${_('Report a bug')}</a> |
|
48 | 48 | </p> |
|
49 | 49 | </div> |
|
50 | 50 | </div> |
|
51 | 51 | </div> |
|
52 | 52 | |
|
53 | 53 | <!-- END FOOTER --> |
|
54 | 54 | |
|
55 | 55 | ### MAKO DEFS ### |
|
56 | 56 | <%def name="breadcrumbs()"> |
|
57 | 57 | <div class="breadcrumbs"> |
|
58 | 58 | ${self.breadcrumbs_links()} |
|
59 | 59 | </div> |
|
60 | 60 | </%def> |
|
61 | 61 | |
|
62 | 62 | <%def name="context_bar(current)"> |
|
63 | 63 | ${repo_context_bar(current)} |
|
64 | 64 | </%def> |
|
65 | 65 | |
|
66 | 66 | <%def name="admin_menu()"> |
|
67 | 67 | <ul class="admin_menu"> |
|
68 | 68 | <li>${h.link_to(_('Admin journal'),h.url('admin_home'),class_='journal ')}</li> |
|
69 | 69 | <li>${h.link_to(_('Repositories'),h.url('repos'),class_='repos')}</li> |
|
70 | 70 | <li>${h.link_to(_('Repository groups'),h.url('repos_groups'),class_='repos_groups')}</li> |
|
71 | 71 | <li>${h.link_to(_('Users'),h.url('users'),class_='users')}</li> |
|
72 | 72 | <li>${h.link_to(_('User groups'),h.url('users_groups'),class_='groups')}</li> |
|
73 | 73 | <li>${h.link_to(_('Permissions'),h.url('edit_permission',id='default'),class_='permissions')}</li> |
|
74 | 74 | <li>${h.link_to(_('LDAP'),h.url('ldap_home'),class_='ldap')}</li> |
|
75 | 75 | <li>${h.link_to(_('Defaults'),h.url('defaults'),class_='defaults')}</li> |
|
76 | 76 | <li class="last">${h.link_to(_('Settings'),h.url('admin_settings'),class_='settings')}</li> |
|
77 | 77 | </ul> |
|
78 | 78 | </%def> |
|
79 | 79 | |
|
80 | 80 | <%def name="admin_menu_simple(repository_groups=None, user_groups=None)"> |
|
81 | 81 | <ul> |
|
82 | 82 | %if repository_groups: |
|
83 | 83 | <li>${h.link_to(_('Repository groups'),h.url('repos_groups'),class_='repos_groups')}</li> |
|
84 | 84 | %endif: |
|
85 | 85 | %if user_groups: |
|
86 | 86 | <li>${h.link_to(_('User groups'),h.url('users_groups'),class_='groups')}</li> |
|
87 | 87 | %endif |
|
88 | 88 | </ul> |
|
89 | 89 | </%def> |
|
90 | 90 | |
|
91 | 91 | <%def name="repo_context_bar(current=None)"> |
|
92 | 92 | <% |
|
93 | 93 | def follow_class(): |
|
94 | 94 | if c.repository_following: |
|
95 | 95 | return h.literal('following') |
|
96 | 96 | else: |
|
97 | 97 | return h.literal('follow') |
|
98 | 98 | %> |
|
99 | 99 | <% |
|
100 | 100 | def is_current(selected): |
|
101 | 101 | if selected == current: |
|
102 | 102 | return h.literal('class="current"') |
|
103 | 103 | %> |
|
104 | 104 | |
|
105 | 105 | <!--- CONTEXT BAR --> |
|
106 | 106 | <div id="context-bar" class="box"> |
|
107 | 107 | <div id="breadcrumbs"> |
|
108 | 108 | ${h.link_to(_(u'Repositories'),h.url('home'))} |
|
109 | 109 | » |
|
110 | 110 | ${h.repo_link(c.rhodecode_db_repo.groups_and_repo)} |
|
111 | 111 | </div> |
|
112 | 112 | <ul id="context-pages" class="horizontal-list"> |
|
113 | 113 | <li ${is_current('summary')}><a href="${h.url('summary_home', repo_name=c.repo_name)}" class="summary">${_('Summary')}</a></li> |
|
114 | 114 | <li ${is_current('changelog')}><a href="${h.url('changelog_home', repo_name=c.repo_name)}" class="changelogs">${_('Changelog')}</a></li> |
|
115 | 115 | <li ${is_current('files')}><a href="${h.url('files_home', repo_name=c.repo_name)}" class="files"></span>${_('Files')}</a></li> |
|
116 | 116 | <li ${is_current('switch-to')}> |
|
117 | 117 | <a href="#" id="branch_tag_switcher_2" class="dropdown switch-to"></span>${_('Switch To')}</a> |
|
118 | 118 | <ul id="switch_to_list_2" class="switch_to submenu"> |
|
119 | 119 | <li><a href="#">${_('loading...')}</a></li> |
|
120 | 120 | </ul> |
|
121 | 121 | </li> |
|
122 | 122 | <li ${is_current('options')}> |
|
123 | 123 | <a href="#" class="dropdown options"></span>${_('Options')}</a> |
|
124 | 124 | <ul> |
|
125 | 125 | %if h.HasRepoPermissionAll('repository.admin')(c.repo_name): |
|
126 | 126 | <li>${h.link_to(_('Settings'),h.url('edit_repo',repo_name=c.repo_name),class_='settings')}</li> |
|
127 | 127 | %endif |
|
128 | 128 | %if c.rhodecode_db_repo.fork: |
|
129 | 129 | <li>${h.link_to(_('Compare fork'),h.url('compare_url',repo_name=c.rhodecode_db_repo.fork.repo_name,org_ref_type='branch',org_ref='default',other_repo=c.repo_name,other_ref_type='branch',other_ref=request.GET.get('branch') or 'default', merge=1),class_='compare_request')}</li> |
|
130 | 130 | %endif |
|
131 | 131 | <li>${h.link_to(_('Search'),h.url('search_repo',repo_name=c.repo_name),class_='search')}</li> |
|
132 | 132 | |
|
133 | 133 | %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.rhodecode_db_repo.enable_locking: |
|
134 | 134 | %if c.rhodecode_db_repo.locked[0]: |
|
135 | 135 | <li>${h.link_to(_('Unlock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_del')}</li> |
|
136 | 136 | %else: |
|
137 | 137 | <li>${h.link_to(_('Lock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_add')}</li> |
|
138 | 138 | %endif |
|
139 | 139 | %endif |
|
140 | 140 | ## TODO: this check feels wrong, it would be better to have a check for permissions |
|
141 | 141 | ## also it feels like a job for the controller |
|
142 | 142 | %if c.rhodecode_user.username != 'default': |
|
143 | 143 | <li> |
|
144 | 144 | <a class="${follow_class()}" onclick="javascript:toggleFollowingRepo(this,${c.rhodecode_db_repo.repo_id},'${str(h.get_token())}');"> |
|
145 | 145 | <span class="show-follow">${_('Follow')}</span> |
|
146 | 146 | <span class="show-following">${_('Unfollow')}</span> |
|
147 | 147 | </a> |
|
148 | 148 | </li> |
|
149 | 149 | <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}" class="fork">${_('Fork')}</a></li> |
|
150 | 150 | %if h.is_hg(c.rhodecode_repo): |
|
151 | 151 | <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="pull-request">${_('Create Pull Request')}</a></li> |
|
152 | 152 | %endif |
|
153 | 153 | %endif |
|
154 | 154 | </ul> |
|
155 | 155 | </li> |
|
156 | 156 | <li ${is_current('showpullrequest')}> |
|
157 | 157 | <a href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests')}" class="pull-request">${_('Pull Requests')} |
|
158 | 158 | %if c.repository_pull_requests: |
|
159 | 159 | <span>${c.repository_pull_requests}</span> |
|
160 | 160 | %endif |
|
161 | 161 | </a> |
|
162 | 162 | </li> |
|
163 | 163 | </ul> |
|
164 | 164 | </div> |
|
165 | 165 | <script type="text/javascript"> |
|
166 | 166 | YUE.on('branch_tag_switcher_2','mouseover',function(){ |
|
167 | 167 | var loaded = YUD.hasClass('branch_tag_switcher_2','loaded'); |
|
168 | 168 | if(!loaded){ |
|
169 | 169 | YUD.addClass('branch_tag_switcher_2','loaded'); |
|
170 | 170 | ypjax("${h.url('branch_tag_switcher',repo_name=c.repo_name)}",'switch_to_list_2', |
|
171 | 171 | function(o){}, |
|
172 | 172 | function(o){YUD.removeClass('branch_tag_switcher_2','loaded');} |
|
173 | 173 | ,null); |
|
174 | 174 | } |
|
175 | 175 | return false; |
|
176 | 176 | }); |
|
177 | 177 | </script> |
|
178 | 178 | <!--- END CONTEXT BAR --> |
|
179 | 179 | </%def> |
|
180 | 180 | |
|
181 | 181 | <%def name="usermenu()"> |
|
182 | 182 | ## USER MENU |
|
183 | 183 | <li> |
|
184 | 184 | <a class="menu_link childs" id="quick_login_link"> |
|
185 | 185 | <span class="icon"> |
|
186 | 186 | <img src="${h.gravatar_url(c.rhodecode_user.email,20)}" alt="avatar"> |
|
187 | 187 | </span> |
|
188 | 188 | %if c.rhodecode_user.username != 'default': |
|
189 | 189 | <span class="menu_link_user">${c.rhodecode_user.username}</span> |
|
190 | 190 | %if c.unread_notifications != 0: |
|
191 | 191 | <span class="menu_link_notifications">${c.unread_notifications}</span> |
|
192 | 192 | %endif |
|
193 | 193 | %else: |
|
194 | 194 | <span>${_('Not logged in')}</span> |
|
195 | 195 | %endif |
|
196 | 196 | </a> |
|
197 | 197 | |
|
198 | 198 | <div class="user-menu"> |
|
199 | 199 | <div id="quick_login"> |
|
200 | 200 | %if c.rhodecode_user.username == 'default': |
|
201 | 201 | <h4>${_('Login to your account')}</h4> |
|
202 | 202 | ${h.form(h.url('login_home',came_from=h.url.current()))} |
|
203 | 203 | <div class="form"> |
|
204 | 204 | <div class="fields"> |
|
205 | 205 | <div class="field"> |
|
206 | 206 | <div class="label"> |
|
207 | 207 | <label for="username">${_('Username')}:</label> |
|
208 | 208 | </div> |
|
209 | 209 | <div class="input"> |
|
210 | 210 | ${h.text('username',class_='focus')} |
|
211 | 211 | </div> |
|
212 | 212 | |
|
213 | 213 | </div> |
|
214 | 214 | <div class="field"> |
|
215 | 215 | <div class="label"> |
|
216 | 216 | <label for="password">${_('Password')}:</label> |
|
217 | 217 | </div> |
|
218 | 218 | <div class="input"> |
|
219 | 219 | ${h.password('password',class_='focus')} |
|
220 | 220 | </div> |
|
221 | 221 | |
|
222 | 222 | </div> |
|
223 | 223 | <div class="buttons"> |
|
224 | 224 | <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div> |
|
225 | 225 | <div class="register"> |
|
226 | 226 | %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')(): |
|
227 | 227 | ${h.link_to(_("Don't have an account ?"),h.url('register'))} |
|
228 | 228 | %endif |
|
229 | 229 | </div> |
|
230 | 230 | <div class="submit"> |
|
231 | 231 | ${h.submit('sign_in',_('Log In'),class_="ui-btn xsmall")} |
|
232 | 232 | </div> |
|
233 | 233 | </div> |
|
234 | 234 | </div> |
|
235 | 235 | </div> |
|
236 | 236 | ${h.end_form()} |
|
237 | 237 | %else: |
|
238 | 238 | <div class="links_left"> |
|
239 | 239 | <div class="big_gravatar"><img alt="gravatar" src="${h.gravatar_url(c.rhodecode_user.email,48)}" /></div> |
|
240 | 240 | <div class="full_name">${c.rhodecode_user.full_name_or_username}</div> |
|
241 | 241 | <div class="email">${c.rhodecode_user.email}</div> |
|
242 | 242 | </div> |
|
243 | 243 | <div class="links_right"> |
|
244 | 244 | <ol class="links"> |
|
245 | 245 | <li><a href="${h.url('notifications')}">${_('Notifications')}: ${c.unread_notifications}</a></li> |
|
246 | 246 | <li>${h.link_to(_(u'My account'),h.url('admin_settings_my_account'))}</li> |
|
247 | 247 | <li class="logout">${h.link_to(_(u'Log Out'),h.url('logout_home'))}</li> |
|
248 | 248 | </ol> |
|
249 | 249 | </div> |
|
250 | 250 | %endif |
|
251 | 251 | </div> |
|
252 | 252 | </div> |
|
253 | 253 | |
|
254 | 254 | </li> |
|
255 | 255 | </%def> |
|
256 | 256 | |
|
257 | 257 | <%def name="menu(current=None)"> |
|
258 | 258 | <% |
|
259 | 259 | def is_current(selected): |
|
260 | 260 | if selected == current: |
|
261 | 261 | return h.literal('class="current"') |
|
262 | 262 | %> |
|
263 | 263 | <ul id="quick" class="horizontal-list"> |
|
264 | 264 | <!-- repo switcher --> |
|
265 | 265 | <li ${is_current('repositories')}> |
|
266 | 266 | <a class="menu_link repo_switcher childs" id="repo_switcher" title="${_('Switch repository')}" href="${h.url('home')}"> |
|
267 | 267 | ${_('Repositories')} |
|
268 | 268 | </a> |
|
269 | 269 | <ul id="repo_switcher_list" class="repo_switcher"> |
|
270 | 270 | <li> |
|
271 | 271 | <a href="#">${_('loading...')}</a> |
|
272 | 272 | </li> |
|
273 | 273 | </ul> |
|
274 | 274 | </li> |
|
275 | 275 | ##ROOT MENU |
|
276 | 276 | %if c.rhodecode_user.username != 'default': |
|
277 | 277 | <li ${is_current('journal')}> |
|
278 | 278 | <a class="menu_link journal" title="${_('Show recent activity')}" href="${h.url('journal')}"> |
|
279 | 279 | ${_('Journal')} |
|
280 | 280 | </a> |
|
281 | 281 | </li> |
|
282 | 282 | %else: |
|
283 | 283 | <li ${is_current('journal')}> |
|
284 | 284 | <a class="menu_link journal" title="${_('Public journal')}" href="${h.url('public_journal')}"> |
|
285 | 285 | ${_('Public journal')} |
|
286 | 286 | </a> |
|
287 | 287 | </li> |
|
288 | 288 | %endif |
|
289 | 289 | <li ${is_current('gists')}> |
|
290 | 290 | <a class="menu_link gists childs" title="${_('Show public gists')}" href="${h.url('gists')}"> |
|
291 | 291 | ${_('Gists')} |
|
292 | 292 | </a> |
|
293 | 293 | <ul class="admin_menu"> |
|
294 | 294 | <li>${h.link_to(_('Create new gist'),h.url('new_gist'),class_='gists-new ')}</li> |
|
295 |
<li>${h.link_to(_(' |
|
|
295 | <li>${h.link_to(_('All public gists'),h.url('gists'),class_='gists ')}</li> | |
|
296 | 296 | %if c.rhodecode_user.username != 'default': |
|
297 | <li>${h.link_to(_('My public gists'),h.url('gists', public=1),class_='gists')}</li> | |
|
297 | 298 | <li>${h.link_to(_('My private gists'),h.url('gists', private=1),class_='gists-private ')}</li> |
|
298 | 299 | %endif |
|
299 | 300 | </ul> |
|
300 | 301 | </li> |
|
301 | 302 | <li ${is_current('search')}> |
|
302 | 303 | <a class="menu_link search" title="${_('Search in repositories')}" href="${h.url('search')}"> |
|
303 | 304 | ${_('Search')} |
|
304 | 305 | </a> |
|
305 | 306 | </li> |
|
306 | 307 | % if h.HasPermissionAll('hg.admin')('access admin main page'): |
|
307 | 308 | <li ${is_current('admin')}> |
|
308 | 309 | <a class="menu_link admin childs" title="${_('Admin')}" href="${h.url('admin_home')}"> |
|
309 | 310 | ${_('Admin')} |
|
310 | 311 | </a> |
|
311 | 312 | ${admin_menu()} |
|
312 | 313 | </li> |
|
313 | 314 | % elif c.rhodecode_user.repository_groups_admin or c.rhodecode_user.user_groups_admin: |
|
314 | 315 | <li ${is_current('admin')}> |
|
315 | 316 | <a class="menu_link admin childs" title="${_('Admin')}"> |
|
316 | 317 | ${_('Admin')} |
|
317 | 318 | </a> |
|
318 | 319 | ${admin_menu_simple(c.rhodecode_user.repository_groups_admin, |
|
319 | 320 | c.rhodecode_user.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')())} |
|
320 | 321 | </li> |
|
321 | 322 | % endif |
|
322 | 323 | ${usermenu()} |
|
323 | 324 | <script type="text/javascript"> |
|
324 | 325 | YUE.on('repo_switcher','mouseover',function(){ |
|
325 | 326 | var target = 'q_filter_rs'; |
|
326 | 327 | var qfilter_activate = function(){ |
|
327 | 328 | var nodes = YUQ('ul#repo_switcher_list li a.repo_name'); |
|
328 | 329 | var func = function(node){ |
|
329 | 330 | return node.parentNode; |
|
330 | 331 | } |
|
331 | 332 | q_filter(target,nodes,func); |
|
332 | 333 | } |
|
333 | 334 | |
|
334 | 335 | var loaded = YUD.hasClass('repo_switcher','loaded'); |
|
335 | 336 | if(!loaded){ |
|
336 | 337 | YUD.addClass('repo_switcher','loaded'); |
|
337 | 338 | ypjax("${h.url('repo_switcher')}",'repo_switcher_list', |
|
338 | 339 | function(o){qfilter_activate();YUD.get(target).focus()}, |
|
339 | 340 | function(o){YUD.removeClass('repo_switcher','loaded');} |
|
340 | 341 | ,null); |
|
341 | 342 | }else{ |
|
342 | 343 | YUD.get(target).focus(); |
|
343 | 344 | } |
|
344 | 345 | return false; |
|
345 | 346 | }); |
|
346 | 347 | |
|
347 | 348 | YUE.on('header-dd', 'click',function(e){ |
|
348 | 349 | YUD.addClass('header-inner', 'hover'); |
|
349 | 350 | YUD.addClass('content', 'hover'); |
|
350 | 351 | }); |
|
351 | 352 | |
|
352 | 353 | </script> |
|
353 | 354 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now