Show More
@@ -1,549 +1,551 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="root.html"/> |
|
3 | 3 | |
|
4 | 4 | <!-- CONTENT --> |
|
5 | 5 | <div id="content"> |
|
6 | 6 | ${self.flash_msg()} |
|
7 | 7 | <div id="main"> |
|
8 | 8 | ${next.main()} |
|
9 | 9 | </div> |
|
10 | 10 | </div> |
|
11 | 11 | <!-- END CONTENT --> |
|
12 | 12 | |
|
13 | 13 | <!-- FOOTER --> |
|
14 | 14 | <div id="footer"> |
|
15 | 15 | <div id="footer-inner" class="title"> |
|
16 | 16 | <div> |
|
17 | 17 | <p class="footer-link"> |
|
18 | 18 | ${_('Server instance: %s') % c.instance_id if c.instance_id else ''} |
|
19 | 19 | </p> |
|
20 | 20 | <p class="footer-link-right"> |
|
21 | 21 | This site is powered by |
|
22 | 22 | %if c.visual.show_version: |
|
23 | 23 | <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a> ${c.kallithea_version}, |
|
24 | 24 | %else: |
|
25 | 25 | <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a>, |
|
26 | 26 | %endif |
|
27 | 27 | which is |
|
28 | 28 | <a href="${h.canonical_url('about')}#copyright">© 2010–2016 by various authors & licensed under GPLv3</a>. |
|
29 | 29 | %if c.issues_url: |
|
30 | 30 | – <a href="${c.issues_url}" target="_blank">${_('Support')}</a> |
|
31 | 31 | %endif |
|
32 | 32 | </p> |
|
33 | 33 | </div> |
|
34 | 34 | </div> |
|
35 | 35 | </div> |
|
36 | 36 | |
|
37 | 37 | <!-- END FOOTER --> |
|
38 | 38 | |
|
39 | 39 | ### MAKO DEFS ### |
|
40 | 40 | |
|
41 | 41 | <%block name="branding_title"> |
|
42 | 42 | %if c.site_name: |
|
43 | 43 | · ${c.site_name} |
|
44 | 44 | %endif |
|
45 | 45 | </%block> |
|
46 | 46 | |
|
47 | 47 | <%def name="flash_msg()"> |
|
48 | 48 | <%include file="/base/flash_msg.html"/> |
|
49 | 49 | </%def> |
|
50 | 50 | |
|
51 | 51 | <%def name="breadcrumbs()"> |
|
52 | 52 | <div class="breadcrumbs"> |
|
53 | 53 | ${self.breadcrumbs_links()} |
|
54 | 54 | </div> |
|
55 | 55 | </%def> |
|
56 | 56 | |
|
57 | 57 | <%def name="admin_menu()"> |
|
58 | 58 | <ul class="dropdown-menu" role="menu"> |
|
59 | 59 | <li><a href="${h.url('admin_home')}"><i class="icon-book"></i> ${_('Admin Journal')}</a></li> |
|
60 | 60 | <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li> |
|
61 | 61 | <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li> |
|
62 | 62 | <li><a href="${h.url('users')}"><i class="icon-user"></i> ${_('Users')}</a></li> |
|
63 | 63 | <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li> |
|
64 | 64 | <li><a href="${h.url('admin_permissions')}"><i class="icon-block"></i> ${_('Default Permissions')}</a></li> |
|
65 | 65 | <li><a href="${h.url('auth_home')}"><i class="icon-key"></i> ${_('Authentication')}</a></li> |
|
66 | 66 | <li><a href="${h.url('defaults')}"><i class="icon-wrench"></i> ${_('Repository Defaults')}</a></li> |
|
67 | 67 | <li class="last"><a href="${h.url('admin_settings')}"><i class="icon-gear"></i> ${_('Settings')}</a></li> |
|
68 | 68 | </ul> |
|
69 | 69 | |
|
70 | 70 | </%def> |
|
71 | 71 | |
|
72 | 72 | |
|
73 | 73 | ## admin menu used for people that have some admin resources |
|
74 | 74 | <%def name="admin_menu_simple(repositories=None, repository_groups=None, user_groups=None)"> |
|
75 | 75 | <ul class="dropdown-menu" role="menu"> |
|
76 | 76 | %if repositories: |
|
77 | 77 | <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li> |
|
78 | 78 | %endif |
|
79 | 79 | %if repository_groups: |
|
80 | 80 | <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li> |
|
81 | 81 | %endif |
|
82 | 82 | %if user_groups: |
|
83 | 83 | <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li> |
|
84 | 84 | %endif |
|
85 | 85 | </ul> |
|
86 | 86 | </%def> |
|
87 | 87 | |
|
88 | 88 | <%def name="repotag(repo)"> |
|
89 | 89 | %if h.is_hg(repo): |
|
90 | 90 | <span class="repotag" title="${_('Mercurial repository')}">hg</span> |
|
91 | 91 | %endif |
|
92 | 92 | %if h.is_git(repo): |
|
93 | 93 | <span class="repotag" title="${_('Git repository')}">git</span> |
|
94 | 94 | %endif |
|
95 | 95 | </%def> |
|
96 | 96 | |
|
97 | 97 | <%def name="repo_context_bar(current=None, rev=None)"> |
|
98 | 98 | <% rev = None if rev == 'tip' else rev %> |
|
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 | <h2> |
|
108 | 108 | ${repotag(c.db_repo)} |
|
109 | 109 | |
|
110 | 110 | ## public/private |
|
111 | 111 | %if c.db_repo.private: |
|
112 | 112 | <i class="icon-keyhole-circled"></i> |
|
113 | 113 | %else: |
|
114 | 114 | <i class="icon-globe"></i> |
|
115 | 115 | %endif |
|
116 | 116 | ${h.repo_breadcrumbs(c.db_repo.groups_and_repo)} |
|
117 | 117 | |
|
118 | 118 | %if current == 'createfork': |
|
119 | 119 | - ${_('Create Fork')} |
|
120 | 120 | %endif |
|
121 | 121 | </h2> |
|
122 | 122 | <!-- |
|
123 | 123 | <div id="breadcrumbs"> |
|
124 | 124 | ${h.link_to(_('Repositories'),h.url('home'))} |
|
125 | 125 | » |
|
126 | 126 | ${h.repo_breadcrumbs(c.db_repo.groups_and_repo)} |
|
127 | 127 | </div> |
|
128 | 128 | --> |
|
129 | 129 | <ul id="context-pages" class="horizontal-list"> |
|
130 | 130 | <li ${is_current('summary')} data-context="summary"><a href="${h.url('summary_home', repo_name=c.repo_name)}"><i class="icon-doc-text"></i> ${_('Summary')}</a></li> |
|
131 | 131 | %if rev: |
|
132 | 132 | <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_file_home', repo_name=c.repo_name, revision=rev, f_path='')}"><i class="icon-clock"></i> ${_('Changelog')}</a></li> |
|
133 | 133 | %else: |
|
134 | 134 | <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_home', repo_name=c.repo_name)}"><i class="icon-clock"></i> ${_('Changelog')}</a></li> |
|
135 | 135 | %endif |
|
136 | 136 | <li ${is_current('files')} data-context="files"><a href="${h.url('files_home', repo_name=c.repo_name, revision=rev or 'tip')}"><i class="icon-doc-inv"></i> ${_('Files')}</a></li> |
|
137 | 137 | <li ${is_current('switch-to')} data-context="switch-to"> |
|
138 | 138 | <input id="branch_switcher" name="branch_switcher" type="hidden"> |
|
139 | 139 | </li> |
|
140 | 140 | <li ${is_current('options')} data-context="options" class="dropdown"> |
|
141 | 141 | %if h.HasRepoPermissionAny('repository.admin')(c.repo_name): |
|
142 | 142 | <a href="${h.url('edit_repo',repo_name=c.repo_name)}" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a> |
|
143 | 143 | %else: |
|
144 | 144 | <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a> |
|
145 | 145 | %endif |
|
146 | 146 | <ul class="dropdown-menu" role="menu" aria-hidden="yes"> |
|
147 | 147 | %if h.HasRepoPermissionAny('repository.admin')(c.repo_name): |
|
148 | 148 | <li><a href="${h.url('edit_repo',repo_name=c.repo_name)}"><i class="icon-gear"></i> ${_('Settings')}</a></li> |
|
149 | 149 | %endif |
|
150 | 150 | %if c.db_repo.fork: |
|
151 | 151 | <li><a href="${h.url('compare_url',repo_name=c.db_repo.fork.repo_name,org_ref_type=c.db_repo.landing_rev[0],org_ref_name=c.db_repo.landing_rev[1], other_repo=c.repo_name,other_ref_type='branch' if request.GET.get('branch') else c.db_repo.landing_rev[0],other_ref_name=request.GET.get('branch') or c.db_repo.landing_rev[1], merge=1)}"> |
|
152 | 152 | <i class="icon-git-compare"></i> ${_('Compare Fork')}</a></li> |
|
153 | 153 | %endif |
|
154 | 154 | <li><a href="${h.url('compare_home',repo_name=c.repo_name)}"><i class="icon-git-compare"></i> ${_('Compare')}</a></li> |
|
155 | 155 | |
|
156 | 156 | <li><a href="${h.url('search_repo',repo_name=c.repo_name)}"><i class="icon-search"></i> ${_('Search')}</a></li> |
|
157 | 157 | |
|
158 | 158 | %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.db_repo.enable_locking: |
|
159 | 159 | %if c.db_repo.locked[0]: |
|
160 | 160 | <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock"></i> ${_('Unlock')}</a></li> |
|
161 | 161 | %else: |
|
162 | 162 | <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock-open-alt"></i> ${_('Lock')}</li> |
|
163 | 163 | %endif |
|
164 | 164 | %endif |
|
165 | 165 | ## TODO: this check feels wrong, it would be better to have a check for permissions |
|
166 | 166 | ## also it feels like a job for the controller |
|
167 | 167 | %if c.authuser.username != 'default': |
|
168 | 168 | <li> |
|
169 | 169 | <a class="${'following' if c.repository_following else 'follow'}" onclick="toggleFollowingRepo(this, ${c.db_repo.repo_id});"> |
|
170 | 170 | <span class="show-follow"><i class="icon-heart-empty"></i> ${_('Follow')}</span> |
|
171 | 171 | <span class="show-following"><i class="icon-heart"></i> ${_('Unfollow')}</span> |
|
172 | 172 | </a> |
|
173 | 173 | </li> |
|
174 | 174 | <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Fork')}</a></li> |
|
175 | 175 | <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Create Pull Request')}</a></li> |
|
176 | 176 | %endif |
|
177 | 177 | </ul> |
|
178 | 178 | </li> |
|
179 | 179 | <li ${is_current('showpullrequest')} data-context="showpullrequest"> |
|
180 | 180 | <a href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests for %s') % c.repo_name}"> <i class="icon-git-pull-request"></i> ${_('Pull Requests')} |
|
181 | 181 | %if c.repository_pull_requests: |
|
182 | 182 | <span class="badge">${c.repository_pull_requests}</span> |
|
183 | 183 | %endif |
|
184 | 184 | </a> |
|
185 | 185 | </li> |
|
186 | 186 | </ul> |
|
187 | 187 | </div> |
|
188 | 188 | <script type="text/javascript"> |
|
189 | 189 | $(document).ready(function() { |
|
190 | 190 | var bcache = {}; |
|
191 | 191 | |
|
192 | 192 | $("#branch_switcher").select2({ |
|
193 | 193 | placeholder: '<i class="icon-exchange"></i> ${_('Switch To')} <span class="caret"></span>', |
|
194 | 194 | dropdownAutoWidth: true, |
|
195 | 195 | sortResults: prefixFirstSort, |
|
196 | 196 | formatResult: function(obj) { |
|
197 | 197 | return obj.text; |
|
198 | 198 | }, |
|
199 | 199 | formatSelection: function(obj) { |
|
200 | 200 | return obj.text; |
|
201 | 201 | }, |
|
202 | 202 | formatNoMatches: function(term) { |
|
203 | 203 | return "${_('No matches found')}"; |
|
204 | 204 | }, |
|
205 | 205 | escapeMarkup: function(m) { |
|
206 | 206 | // don't escape our custom placeholder |
|
207 | 207 | if (m.substr(0, 29) == '<i class="icon-exchange"></i>') { |
|
208 | 208 | return m; |
|
209 | 209 | } |
|
210 | 210 | |
|
211 | 211 | return Select2.util.escapeMarkup(m); |
|
212 | 212 | }, |
|
213 | 213 | containerCssClass: "repo-switcher", |
|
214 | 214 | dropdownCssClass: "repo-switcher-dropdown", |
|
215 | 215 | query: function(query) { |
|
216 | 216 | var key = 'cache'; |
|
217 | 217 | var cached = bcache[key]; |
|
218 | 218 | if (cached) { |
|
219 | 219 | var data = { |
|
220 | 220 | results: [] |
|
221 | 221 | }; |
|
222 | 222 | // filter results |
|
223 | 223 | $.each(cached.results, function() { |
|
224 | 224 | var section = this.text; |
|
225 | 225 | var children = []; |
|
226 | 226 | $.each(this.children, function() { |
|
227 | 227 | if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) { |
|
228 | 228 | children.push({ |
|
229 | 229 | 'id': this.id, |
|
230 | 230 | 'text': this.text, |
|
231 | 231 | 'type': this.type, |
|
232 | 232 | 'obj': this.obj |
|
233 | 233 | }); |
|
234 | 234 | } |
|
235 | 235 | }); |
|
236 | 236 | if (children.length !== 0) { |
|
237 | 237 | data.results.push({ |
|
238 | 238 | 'text': section, |
|
239 | 239 | 'children': children |
|
240 | 240 | }); |
|
241 | 241 | } |
|
242 | 242 | |
|
243 | 243 | }); |
|
244 | 244 | query.callback(data); |
|
245 | 245 | } else { |
|
246 | 246 | $.ajax({ |
|
247 | 247 | url: pyroutes.url('repo_refs_data', { |
|
248 | 248 | 'repo_name': '${c.repo_name}' |
|
249 | 249 | }), |
|
250 | 250 | data: {}, |
|
251 | 251 | dataType: 'json', |
|
252 | 252 | type: 'GET', |
|
253 | 253 | success: function(data) { |
|
254 | 254 | bcache[key] = data; |
|
255 | 255 | query.callback(data); |
|
256 | 256 | } |
|
257 | 257 | }); |
|
258 | 258 | } |
|
259 | 259 | } |
|
260 | 260 | }); |
|
261 | 261 | |
|
262 | 262 | $("#branch_switcher").on('select2-selecting', function(e) { |
|
263 | 263 | e.preventDefault(); |
|
264 | 264 | var context = $('#context-bar .current').data('context'); |
|
265 | 265 | if (context == 'files') { |
|
266 | 266 | window.location = pyroutes.url('files_home', { |
|
267 | 267 | 'repo_name': REPO_NAME, |
|
268 | 268 | 'revision': e.choice.id, |
|
269 | 269 | 'f_path': '', |
|
270 | 270 | 'at': e.choice.text |
|
271 | 271 | }); |
|
272 | 272 | } else if (context == 'changelog') { |
|
273 | 273 | if (e.choice.type == 'tag' || e.choice.type == 'book') { |
|
274 | 274 | $("#branch_filter").append($('<'+'option/>').val(e.choice.text)); |
|
275 | 275 | } |
|
276 | 276 | $("#branch_filter").val(e.choice.text).change(); |
|
277 | 277 | } else { |
|
278 | 278 | window.location = pyroutes.url('changelog_home', { |
|
279 | 279 | 'repo_name': '${c.repo_name}', |
|
280 | 280 | 'branch': e.choice.text |
|
281 | 281 | }); |
|
282 | 282 | } |
|
283 | 283 | }); |
|
284 | 284 | }); |
|
285 | 285 | </script> |
|
286 | 286 | <!--- END CONTEXT BAR --> |
|
287 | 287 | </%def> |
|
288 | 288 | |
|
289 | 289 | <%def name="menu(current=None)"> |
|
290 | 290 | <% |
|
291 | 291 | def is_current(selected): |
|
292 | 292 | if selected == current: |
|
293 | 293 | return h.literal('class="current"') |
|
294 | 294 | %> |
|
295 | 295 | |
|
296 | 296 | <ul id="quick" class="horizontal-list"> |
|
297 | 297 | <!-- repo switcher --> |
|
298 | 298 | <li ${is_current('repositories')}> |
|
299 | 299 | <input id="repo_switcher" name="repo_switcher" type="hidden"> |
|
300 | 300 | </li> |
|
301 | 301 | |
|
302 | 302 | ##ROOT MENU |
|
303 | 303 | %if c.authuser.username != 'default': |
|
304 | 304 | <li ${is_current('journal')}> |
|
305 | 305 | <a class="menu_link" title="${_('Show recent activity')}" href="${h.url('journal')}"> |
|
306 | 306 | <i class="icon-book"></i> ${_('Journal')} |
|
307 | 307 | </a> |
|
308 | 308 | </li> |
|
309 | 309 | %else: |
|
310 | 310 | <li ${is_current('journal')}> |
|
311 | 311 | <a class="menu_link" title="${_('Public journal')}" href="${h.url('public_journal')}"> |
|
312 | 312 | <i class="icon-book"></i> ${_('Public journal')} |
|
313 | 313 | </a> |
|
314 | 314 | </li> |
|
315 | 315 | %endif |
|
316 | 316 | <li ${is_current('gists')} class="dropdown"> |
|
317 | 317 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Show public gists')}" href="${h.url('gists')}"> |
|
318 | 318 | <i class="icon-clippy"></i> ${_('Gists')} <span class="caret"></span> |
|
319 | 319 | </a> |
|
320 | 320 | <ul class="dropdown-menu" role="menu"> |
|
321 | 321 | <li><a href="${h.url('new_gist', public=1)}"><i class="icon-paste"></i> ${_('Create New Gist')}</a></li> |
|
322 | 322 | <li><a href="${h.url('gists')}"><i class="icon-globe"></i> ${_('All Public Gists')}</a></li> |
|
323 | 323 | %if c.authuser.username != 'default': |
|
324 | 324 | <li><a href="${h.url('gists', public=1)}"><i class="icon-user"></i> ${_('My Public Gists')}</a></li> |
|
325 | 325 | <li><a href="${h.url('gists', private=1)}"><i class="icon-keyhole-circled"></i> ${_('My Private Gists')}</a></li> |
|
326 | 326 | %endif |
|
327 | 327 | </ul> |
|
328 | 328 | </li> |
|
329 | 329 | <li ${is_current('search')}> |
|
330 | 330 | <a class="menu_link" title="${_('Search in repositories')}" href="${h.url('search')}"> |
|
331 | 331 | <i class="icon-search"></i> ${_('Search')} |
|
332 | 332 | </a> |
|
333 | 333 | </li> |
|
334 | 334 | % if h.HasPermissionAny('hg.admin')('access admin main page'): |
|
335 | 335 | <li ${is_current('admin')} class="dropdown"> |
|
336 | 336 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}" href="${h.url('admin_home')}"> |
|
337 | 337 | <i class="icon-gear"></i> ${_('Admin')} <span class="caret"></span> |
|
338 | 338 | </a> |
|
339 | 339 | ${admin_menu()} |
|
340 | 340 | </li> |
|
341 | 341 | % elif c.authuser.repositories_admin or c.authuser.repository_groups_admin or c.authuser.user_groups_admin: |
|
342 | 342 | <li ${is_current('admin')} class="dropdown"> |
|
343 | 343 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}"> |
|
344 | 344 | <i class="icon-gear"></i> ${_('Admin')} |
|
345 | 345 | </a> |
|
346 | 346 | ${admin_menu_simple(c.authuser.repositories_admin, |
|
347 | 347 | c.authuser.repository_groups_admin, |
|
348 | 348 | c.authuser.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')())} |
|
349 | 349 | </li> |
|
350 | 350 | % endif |
|
351 | 351 | |
|
352 | 352 | <li ${is_current('my_pullrequests')}> |
|
353 | 353 | <a class="menu_link" title="${_('My Pull Requests')}" href="${h.url('my_pullrequests')}"> |
|
354 | 354 | <i class="icon-git-pull-request"></i> ${_('My Pull Requests')} |
|
355 | 355 | %if c.my_pr_count != 0: |
|
356 | 356 | <span class="badge">${c.my_pr_count}</span> |
|
357 | 357 | %endif |
|
358 | 358 | </a> |
|
359 | 359 | </li> |
|
360 | 360 | |
|
361 | 361 | ## USER MENU |
|
362 | 362 | <li class="dropdown"> |
|
363 | 363 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" id="quick_login_link" |
|
364 | 364 | aria-expanded="false" aria-controls="quick_login" |
|
365 | 365 | %if c.authuser.username != 'default': |
|
366 | 366 | href="${h.url('notifications')}" |
|
367 | %else: | |
|
368 | href="#" | |
|
367 | 369 | %endif |
|
368 | 370 | > |
|
369 | 371 | ${h.gravatar_div(c.authuser.email, size=20, div_class="icon", div_style="display:inline", div_aria_hidden="true")} |
|
370 | 372 | %if c.authuser.username != 'default': |
|
371 | 373 | <span class="menu_link_user">${c.authuser.username}</span> |
|
372 | 374 | %if c.unread_notifications != 0: |
|
373 | 375 | <span class="badge">${c.unread_notifications}</span> |
|
374 | 376 | %endif |
|
375 | 377 | %else: |
|
376 | 378 | <span>${_('Not Logged In')}</span> |
|
377 | 379 | %endif |
|
378 | 380 | </a> |
|
379 | 381 | |
|
380 | 382 | <div class="user-menu" role="menu"> |
|
381 | 383 | <div id="quick_login" role="form" aria-describedby="quick_login_h" aria-hidden="true" class="dropdown-menu"> |
|
382 | 384 | %if c.authuser.username == 'default' or c.authuser.user_id is None: |
|
383 | 385 | <h4 id="quick_login_h">${_('Login to Your Account')}</h4> |
|
384 | 386 | ${h.form(h.url('login_home', came_from=request.path_qs))} |
|
385 | 387 | <div class="form"> |
|
386 | 388 | <div class="fields"> |
|
387 | 389 | <div class="field"> |
|
388 | 390 | <div class="label"> |
|
389 | 391 | <label for="username">${_('Username')}:</label> |
|
390 | 392 | </div> |
|
391 | 393 | <div class="input"> |
|
392 | 394 | ${h.text('username',class_='focus')} |
|
393 | 395 | </div> |
|
394 | 396 | |
|
395 | 397 | </div> |
|
396 | 398 | <div class="field"> |
|
397 | 399 | <div class="label"> |
|
398 | 400 | <label for="password">${_('Password')}:</label> |
|
399 | 401 | </div> |
|
400 | 402 | <div class="input"> |
|
401 | 403 | ${h.password('password',class_='focus')} |
|
402 | 404 | </div> |
|
403 | 405 | |
|
404 | 406 | </div> |
|
405 | 407 | <div class="buttons"> |
|
406 | 408 | <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div> |
|
407 | 409 | <div class="register"> |
|
408 | 410 | %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')(): |
|
409 | 411 | ${h.link_to(_("Don't have an account ?"),h.url('register'))} |
|
410 | 412 | %endif |
|
411 | 413 | </div> |
|
412 | 414 | <div class="submit"> |
|
413 | 415 | ${h.submit('sign_in',_('Log In'),class_="btn btn-mini")} |
|
414 | 416 | </div> |
|
415 | 417 | </div> |
|
416 | 418 | </div> |
|
417 | 419 | </div> |
|
418 | 420 | ${h.end_form()} |
|
419 | 421 | %else: |
|
420 | 422 | <div class="links_left"> |
|
421 | 423 | ${h.gravatar_div(c.authuser.email, size=48, div_class="big_gravatar")} |
|
422 | 424 | <div class="full_name">${c.authuser.full_name_or_username}</div> |
|
423 | 425 | <div class="email">${c.authuser.email}</div> |
|
424 | 426 | </div> |
|
425 | 427 | <div class="links_right"> |
|
426 | 428 | <ol class="links"> |
|
427 | 429 | <li><a href="${h.url('notifications')}">${_('Notifications')}: ${c.unread_notifications}</a></li> |
|
428 | 430 | <li>${h.link_to(_('My Account'),h.url('my_account'))}</li> |
|
429 | 431 | %if not c.authuser.is_external_auth: |
|
430 | 432 | ## Cannot log out if using external (container) authentication. |
|
431 | 433 | <li class="logout">${h.link_to(_('Log Out'), h.url('logout_home'))}</li> |
|
432 | 434 | %endif |
|
433 | 435 | </ol> |
|
434 | 436 | </div> |
|
435 | 437 | %endif |
|
436 | 438 | </div> |
|
437 | 439 | </div> |
|
438 | 440 | </li> |
|
439 | 441 | |
|
440 | 442 | <script type="text/javascript"> |
|
441 | 443 | $(document).ready(function(){ |
|
442 | 444 | var visual_show_public_icon = "${c.visual.show_public_icon}" == "True"; |
|
443 | 445 | var cache = {} |
|
444 | 446 | /*format the look of items in the list*/ |
|
445 | 447 | var format = function(state){ |
|
446 | 448 | if (!state.id){ |
|
447 | 449 | return state.text; // optgroup |
|
448 | 450 | } |
|
449 | 451 | var obj_dict = state.obj; |
|
450 | 452 | var tmpl = ''; |
|
451 | 453 | |
|
452 | 454 | if(obj_dict && state.type == 'repo'){ |
|
453 | 455 | tmpl += '<span class="repo-icons">'; |
|
454 | 456 | if(obj_dict['repo_type'] === 'hg'){ |
|
455 | 457 | tmpl += '<span class="repotag">hg</span> '; |
|
456 | 458 | } |
|
457 | 459 | else if(obj_dict['repo_type'] === 'git'){ |
|
458 | 460 | tmpl += '<span class="repotag">git</span> '; |
|
459 | 461 | } |
|
460 | 462 | if(obj_dict['private']){ |
|
461 | 463 | tmpl += '<i class="icon-keyhole-circled"></i> '; |
|
462 | 464 | } |
|
463 | 465 | else if(visual_show_public_icon){ |
|
464 | 466 | tmpl += '<i class="icon-globe"></i> '; |
|
465 | 467 | } |
|
466 | 468 | tmpl += '</span>'; |
|
467 | 469 | } |
|
468 | 470 | if(obj_dict && state.type == 'group'){ |
|
469 | 471 | tmpl += '<i class="icon-folder"></i> '; |
|
470 | 472 | } |
|
471 | 473 | tmpl += state.text; |
|
472 | 474 | return tmpl; |
|
473 | 475 | } |
|
474 | 476 | |
|
475 | 477 | $("#repo_switcher").select2({ |
|
476 | 478 | placeholder: '<i class="icon-database"></i> ${_('Repositories')} <span class="caret"></span>', |
|
477 | 479 | dropdownAutoWidth: true, |
|
478 | 480 | sortResults: prefixFirstSort, |
|
479 | 481 | formatResult: format, |
|
480 | 482 | formatSelection: format, |
|
481 | 483 | formatNoMatches: function(term){ |
|
482 | 484 | return "${_('No matches found')}"; |
|
483 | 485 | }, |
|
484 | 486 | containerCssClass: "repo-switcher", |
|
485 | 487 | dropdownCssClass: "repo-switcher-dropdown", |
|
486 | 488 | escapeMarkup: function(m){ |
|
487 | 489 | // don't escape our custom placeholder |
|
488 | 490 | if(m.substr(0,29) == '<i class="icon-database"></i>'){ |
|
489 | 491 | return m; |
|
490 | 492 | } |
|
491 | 493 | |
|
492 | 494 | return Select2.util.escapeMarkup(m); |
|
493 | 495 | }, |
|
494 | 496 | query: function(query){ |
|
495 | 497 | var key = 'cache'; |
|
496 | 498 | var cached = cache[key] ; |
|
497 | 499 | if(cached) { |
|
498 | 500 | var data = {results: []}; |
|
499 | 501 | //filter results |
|
500 | 502 | $.each(cached.results, function(){ |
|
501 | 503 | var section = this.text; |
|
502 | 504 | var children = []; |
|
503 | 505 | $.each(this.children, function(){ |
|
504 | 506 | if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){ |
|
505 | 507 | children.push({'id': this.id, 'text': this.text, 'type': this.type, 'obj': this.obj}); |
|
506 | 508 | } |
|
507 | 509 | }); |
|
508 | 510 | if(children.length !== 0){ |
|
509 | 511 | data.results.push({'text': section, 'children': children}); |
|
510 | 512 | } |
|
511 | 513 | |
|
512 | 514 | }); |
|
513 | 515 | query.callback(data); |
|
514 | 516 | }else{ |
|
515 | 517 | $.ajax({ |
|
516 | 518 | url: "${h.url('repo_switcher_data')}", |
|
517 | 519 | data: {}, |
|
518 | 520 | dataType: 'json', |
|
519 | 521 | type: 'GET', |
|
520 | 522 | success: function(data) { |
|
521 | 523 | cache[key] = data; |
|
522 | 524 | query.callback({results: data.results}); |
|
523 | 525 | } |
|
524 | 526 | }); |
|
525 | 527 | } |
|
526 | 528 | } |
|
527 | 529 | }); |
|
528 | 530 | |
|
529 | 531 | $("#repo_switcher").on('select2-selecting', function(e){ |
|
530 | 532 | e.preventDefault(); |
|
531 | 533 | window.location = pyroutes.url('summary_home', {'repo_name': e.val}); |
|
532 | 534 | }); |
|
533 | 535 | |
|
534 | 536 | $(document).on('shown.bs.dropdown', function(event) { |
|
535 | 537 | var dropdown = $(event.target); |
|
536 | 538 | |
|
537 | 539 | dropdown.attr('aria-expanded', true); |
|
538 | 540 | dropdown.find('.dropdown-menu').attr('aria-hidden', false); |
|
539 | 541 | }); |
|
540 | 542 | |
|
541 | 543 | $(document).on('hidden.bs.dropdown', function(event) { |
|
542 | 544 | var dropdown = $(event.target); |
|
543 | 545 | |
|
544 | 546 | dropdown.attr('aria-expanded', false); |
|
545 | 547 | dropdown.find('.dropdown-menu').attr('aria-hidden', true); |
|
546 | 548 | }); |
|
547 | 549 | }); |
|
548 | 550 | </script> |
|
549 | 551 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now