Files @ d1923cd0521c
Branch filter:

Location: kallithea/kallithea/templates/base/base.html - annotation

Mads Kiilerich
style: refactor form label styling to prepare for Bootstrap and get rid of wrapping with 'label' class

Based on work by Dominik Ruf.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
7436b88cbd89
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
fe982e5c086c
d1addaf7a91e
fe982e5c086c
d1addaf7a91e
d1addaf7a91e
5c7b177d70ff
da9aca2f4aef
da9aca2f4aef
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
3a3ec35466e7
3a3ec35466e7
3a3ec35466e7
3a3ec35466e7
3a3ec35466e7
3a3ec35466e7
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
c1af4d89a737
dacdea9fda2a
dc5abab268dc
b126bcaad922
d1addaf7a91e
9930f77b6a79
06e4f5c6ec98
d1addaf7a91e
99cec44b48c0
25c91454b60d
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
c1af4d89a737
d1addaf7a91e
dc5abab268dc
d1addaf7a91e
d1addaf7a91e
b126bcaad922
d1addaf7a91e
d1addaf7a91e
9930f77b6a79
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
8924172b07ff
8924172b07ff
8924172b07ff
8924172b07ff
8924172b07ff
8924172b07ff
8924172b07ff
8924172b07ff
8924172b07ff
432e86d1e555
432e86d1e555
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
80a15e10857a
d1addaf7a91e
8924172b07ff
d1addaf7a91e
d1addaf7a91e
9581233e9275
4cd73f922f85
d1addaf7a91e
961ef96fcc65
d1addaf7a91e
44e6e66c1855
44e6e66c1855
44e6e66c1855
44e6e66c1855
44e6e66c1855
d1addaf7a91e
d1addaf7a91e
dacdea9fda2a
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
a33448d81f70
432e86d1e555
a33448d81f70
432e86d1e555
a33448d81f70
432e86d1e555
a33448d81f70
a33448d81f70
a33448d81f70
d1addaf7a91e
3e46e6b6a27a
09bcde0eee6d
24a0c176a63d
d1addaf7a91e
24a0c176a63d
d1addaf7a91e
24a0c176a63d
09bcde0eee6d
25c91454b60d
d1addaf7a91e
9581233e9275
c2e3923eebe4
be3823704f21
d1addaf7a91e
be3823704f21
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
9581233e9275
9581233e9275
7f8f576dc0b5
d1addaf7a91e
7f8f576dc0b5
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d208416c84c6
d1addaf7a91e
d2b9788d2760
d1addaf7a91e
d1addaf7a91e
d2b9788d2760
d1addaf7a91e
23ca3c74abf1
23ca3c74abf1
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
a33448d81f70
23ca3c74abf1
d1addaf7a91e
3578484a86d2
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
3578484a86d2
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
d1addaf7a91e
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
c6dcda2c9402
c6dcda2c9402
5dfe741d2b0a
c6dcda2c9402
c6dcda2c9402
c6dcda2c9402
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
a33448d81f70
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
3578484a86d2
c1af4d89a737
3578484a86d2
6564d82e1469
c1af4d89a737
42dee5e09af0
2d996411b292
6564d82e1469
de7520c2c1cf
0cb87808da03
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
09bcde0eee6d
3578484a86d2
c1af4d89a737
3578484a86d2
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
3578484a86d2
c1af4d89a737
25c91454b60d
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
23ca3c74abf1
6564d82e1469
3578484a86d2
6564d82e1469
6564d82e1469
6564d82e1469
6564d82e1469
d1addaf7a91e
3578484a86d2
c1af4d89a737
24a0c176a63d
a78503ebf512
a78503ebf512
f3acdc61e7f5
f3acdc61e7f5
a78503ebf512
a78503ebf512
24a0c176a63d
d208416c84c6
d208416c84c6
d1addaf7a91e
3578484a86d2
d1addaf7a91e
d1addaf7a91e
dacdea9fda2a
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
24a0c176a63d
24a0c176a63d
4ec7189bb164
24a0c176a63d
b537babcf966
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1923cd0521c
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1923cd0521c
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
b7654d1675da
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
6564d82e1469
d1addaf7a91e
f287754980cc
d208416c84c6
d208416c84c6
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
fa8b8df51ad0
f103b1a2383b
f103b1a2383b
fa8b8df51ad0
f103b1a2383b
d1addaf7a91e
d1addaf7a91e
6564d82e1469
6564d82e1469
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
d1addaf7a91e
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
d1addaf7a91e
21f80c6cdf0c
21f80c6cdf0c
d1addaf7a91e
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
d1addaf7a91e
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
d1addaf7a91e
21f80c6cdf0c
3578484a86d2
21f80c6cdf0c
bfde3237d6ad
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
d1addaf7a91e
d1addaf7a91e
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
d1addaf7a91e
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
21f80c6cdf0c
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
24a0c176a63d
df5b6fc6c518
d1addaf7a91e
d1addaf7a91e
## -*- coding: utf-8 -*-
<%inherit file="root.html"/>

<!-- CONTENT -->
<div id="content">
    ${self.flash_msg()}
    <div id="main">
        ${next.main()}
    </div>
</div>
<!-- END CONTENT -->

<!-- FOOTER -->
<div id="footer">
   <div id="footer-inner" class="title">
       <div>
           <p class="footer-link">
               ${_('Server instance: %s') % c.instance_id if c.instance_id else ''}
           </p>
           <p class="footer-link-right">
               This site is powered by
               %if c.visual.show_version:
                   <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a> ${c.kallithea_version},
               %else:
                   <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a>,
               %endif
               which is
               <a href="${h.canonical_url('about')}#copyright">&copy; 2010&ndash;2016 by various authors &amp; licensed under GPLv3</a>.
               %if c.issues_url:
                   &ndash; <a href="${c.issues_url}" target="_blank">${_('Support')}</a>
               %endif
           </p>
       </div>
   </div>
</div>

<!-- END FOOTER -->

### MAKO DEFS ###

<%block name="branding_title">
    %if c.site_name:
    &middot; ${c.site_name}
    %endif
</%block>

<%def name="flash_msg()">
    <%include file="/base/flash_msg.html"/>
</%def>

<%def name="breadcrumbs()">
    <div class="breadcrumbs">
    ${self.breadcrumbs_links()}
    </div>
</%def>

<%def name="admin_menu()">
  <ul class="dropdown-menu" role="menu">
      <li><a href="${h.url('admin_home')}"><i class="icon-book"></i> ${_('Admin Journal')}</a></li>
      <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li>
      <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li>
      <li><a href="${h.url('users')}"><i class="icon-user"></i> ${_('Users')}</a></li>
      <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li>
      <li><a href="${h.url('admin_permissions')}"><i class="icon-block"></i> ${_('Default Permissions')}</a></li>
      <li><a href="${h.url('auth_home')}"><i class="icon-key"></i> ${_('Authentication')}</a></li>
      <li><a href="${h.url('defaults')}"><i class="icon-wrench"></i> ${_('Repository Defaults')}</a></li>
      <li class="last"><a href="${h.url('admin_settings')}"><i class="icon-gear"></i> ${_('Settings')}</a></li>
  </ul>

</%def>


## admin menu used for people that have some admin resources
<%def name="admin_menu_simple(repositories=None, repository_groups=None, user_groups=None)">
  <ul class="dropdown-menu" role="menu">
   %if repositories:
      <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li>
   %endif
   %if repository_groups:
      <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li>
   %endif
   %if user_groups:
      <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li>
   %endif
  </ul>
</%def>

<%def name="repotag(repo)">
  %if h.is_hg(repo):
    <span class="repotag" title="${_('Mercurial repository')}">hg</span>
  %endif
  %if h.is_git(repo):
    <span class="repotag" title="${_('Git repository')}">git</span>
  %endif
</%def>

<%def name="repo_context_bar(current=None, rev=None)">
  <% rev = None if rev == 'tip' else rev %>
  <%
    def is_current(selected):
        if selected == current:
            return h.literal('class="current"')
    %>

  <!--- CONTEXT BAR -->
  <div id="context-bar" class="panel panel-primary">
      <h2>
        ${repotag(c.db_repo)}

        ## public/private
        %if c.db_repo.private:
          <i class="icon-keyhole-circled"></i>
        %else:
          <i class="icon-globe"></i>
        %endif
        %for group in c.db_repo.groups_with_parents:
          ${h.link_to(group.name, url('repos_group_home', group_name=group.group_name))}
          &raquo;
        %endfor
        ${h.link_to(c.db_repo.just_name, url('summary_home', repo_name=c.db_repo.repo_name))}

        %if current == 'createfork':
         - ${_('Create Fork')}
        %endif
      </h2>
      <ul id="context-pages" class="horizontal-list">
        <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>
        %if rev:
        <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>
        %else:
        <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>
        %endif
        <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>
        <li ${is_current('switch-to')} data-context="switch-to">
          <input id="branch_switcher" name="branch_switcher" type="hidden">
        </li>
        <li ${is_current('options')} data-context="options" class="dropdown">
             %if h.HasRepoPermissionAny('repository.admin')(c.repo_name):
               <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>
             %else:
               <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>
             %endif
          <ul class="dropdown-menu" role="menu" aria-hidden="yes">
             %if h.HasRepoPermissionAny('repository.admin')(c.repo_name):
                   <li><a href="${h.url('edit_repo',repo_name=c.repo_name)}"><i class="icon-gear"></i> ${_('Settings')}</a></li>
             %endif
              %if c.db_repo.fork:
               <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)}">
                   <i class="icon-git-compare"></i> ${_('Compare Fork')}</a></li>
              %endif
              <li><a href="${h.url('compare_home',repo_name=c.repo_name)}"><i class="icon-git-compare"></i> ${_('Compare')}</a></li>

              <li><a href="${h.url('search_repo',repo_name=c.repo_name)}"><i class="icon-search"></i> ${_('Search')}</a></li>

              %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.db_repo.enable_locking:
                %if c.db_repo.locked[0]:
                  <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock"></i> ${_('Unlock')}</a></li>
                %else:
                  <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock-open-alt"></i> ${_('Lock')}</li>
                %endif
              %endif
              ## TODO: this check feels wrong, it would be better to have a check for permissions
              ## also it feels like a job for the controller
              %if c.authuser.username != 'default':
                  <li>
                   <a class="${'following' if c.repository_following else 'follow'}" onclick="toggleFollowingRepo(this, ${c.db_repo.repo_id});">
                    <span class="show-follow"><i class="icon-heart-empty"></i> ${_('Follow')}</span>
                    <span class="show-following"><i class="icon-heart"></i> ${_('Unfollow')}</span>
                   </a>
                  </li>
                  <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Fork')}</a></li>
                  <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Create Pull Request')}</a></li>
              %endif
             </ul>
        </li>
        <li ${is_current('showpullrequest')} data-context="showpullrequest">
          <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')}
            %if c.repository_pull_requests:
              <span class="badge">${c.repository_pull_requests}</span>
            %endif
          </a>
        </li>
      </ul>
  </div>
  <script type="text/javascript">
    $(document).ready(function() {
      var bcache = {};

      $("#branch_switcher").select2({
          placeholder: '<i class="icon-exchange"></i> ${_('Switch To')} <span class="caret"></span>',
          dropdownAutoWidth: true,
          sortResults: prefixFirstSort,
          formatResult: function(obj) {
              return obj.text;
          },
          formatSelection: function(obj) {
              return obj.text;
          },
          formatNoMatches: function(term) {
              return "${_('No matches found')}";
          },
          escapeMarkup: function(m) {
              // don't escape our custom placeholder
              if (m.substr(0, 29) == '<i class="icon-exchange"></i>') {
                  return m;
              }

              return Select2.util.escapeMarkup(m);
          },
          containerCssClass: "repo-switcher",
          dropdownCssClass: "repo-switcher-dropdown",
          query: function(query) {
              var key = 'cache';
              var cached = bcache[key];
              if (cached) {
                  var data = {
                      results: []
                  };
                  // filter results
                  $.each(cached.results, function() {
                      var section = this.text;
                      var children = [];
                      $.each(this.children, function() {
                          if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
                              children.push({
                                  'id': this.id,
                                  'text': this.text,
                                  'type': this.type,
                                  'obj': this.obj
                              });
                          }
                      });
                      if (children.length !== 0) {
                          data.results.push({
                              'text': section,
                              'children': children
                          });
                      }

                  });
                  query.callback(data);
              } else {
                  $.ajax({
                      url: pyroutes.url('repo_refs_data', {
                          'repo_name': '${c.repo_name}'
                      }),
                      data: {},
                      dataType: 'json',
                      type: 'GET',
                      success: function(data) {
                          bcache[key] = data;
                          query.callback(data);
                      }
                  });
              }
          }
      });

      $("#branch_switcher").on('select2-selecting', function(e) {
          e.preventDefault();
          var context = $('#context-bar .current').data('context');
          if (context == 'files') {
              window.location = pyroutes.url('files_home', {
                  'repo_name': REPO_NAME,
                  'revision': e.choice.id,
                  'f_path': '',
                  'at': e.choice.text
              });
          } else if (context == 'changelog') {
              if (e.choice.type == 'tag' || e.choice.type == 'book') {
                  $("#branch_filter").append($('<'+'option/>').val(e.choice.text));
              }
              $("#branch_filter").val(e.choice.text).change();
          } else {
              window.location = pyroutes.url('changelog_home', {
                  'repo_name': '${c.repo_name}',
                  'branch': e.choice.text
              });
          }
      });
    });
  </script>
  <!--- END CONTEXT BAR -->
</%def>

<%def name="menu(current=None)">
  <%
  def is_current(selected):
      if selected == current:
          return h.literal('class="current"')
  %>

  <ul id="quick" class="horizontal-list">
    <!-- repo switcher -->
    <li ${is_current('repositories')}>
      <input id="repo_switcher" name="repo_switcher" type="hidden">
    </li>

    ##ROOT MENU
    %if c.authuser.username != 'default':
      <li ${is_current('journal')}>
        <a class="menu_link" title="${_('Show recent activity')}"  href="${h.url('journal')}">
          <i class="icon-book"></i> ${_('Journal')}
        </a>
      </li>
    %else:
      <li ${is_current('journal')}>
        <a class="menu_link" title="${_('Public journal')}"  href="${h.url('public_journal')}">
          <i class="icon-book"></i> ${_('Public journal')}
        </a>
      </li>
    %endif
      <li ${is_current('gists')} class="dropdown">
        <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Show public gists')}"  href="${h.url('gists')}">
          <i class="icon-clippy"></i> ${_('Gists')} <span class="caret"></span>
        </a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="${h.url('new_gist', public=1)}"><i class="icon-paste"></i> ${_('Create New Gist')}</a></li>
            <li><a href="${h.url('gists')}"><i class="icon-globe"></i> ${_('All Public Gists')}</a></li>
            %if c.authuser.username != 'default':
              <li><a href="${h.url('gists', public=1)}"><i class="icon-user"></i> ${_('My Public Gists')}</a></li>
              <li><a href="${h.url('gists', private=1)}"><i class="icon-keyhole-circled"></i> ${_('My Private Gists')}</a></li>
            %endif
          </ul>
      </li>
    <li ${is_current('search')}>
        <a class="menu_link" title="${_('Search in repositories')}"  href="${h.url('search')}">
          <i class="icon-search"></i> ${_('Search')}
        </a>
    </li>
    % if h.HasPermissionAny('hg.admin')('access admin main page'):
      <li ${is_current('admin')} class="dropdown">
        <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}" href="${h.url('admin_home')}">
          <i class="icon-gear"></i> ${_('Admin')} <span class="caret"></span>
        </a>
        ${admin_menu()}
      </li>
    % elif c.authuser.repositories_admin or c.authuser.repository_groups_admin or c.authuser.user_groups_admin:
    <li ${is_current('admin')} class="dropdown">
        <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}">
          <i class="icon-gear"></i> ${_('Admin')}
        </a>
        ${admin_menu_simple(c.authuser.repositories_admin,
                            c.authuser.repository_groups_admin,
                            c.authuser.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')())}
    </li>
    % endif

    <li ${is_current('my_pullrequests')}>
      <a class="menu_link" title="${_('My Pull Requests')}" href="${h.url('my_pullrequests')}">
        <i class="icon-git-pull-request"></i> ${_('My Pull Requests')}
        %if c.my_pr_count != 0:
          <span class="badge">${c.my_pr_count}</span>
        %endif
      </a>
    </li>

    ## USER MENU
    <li class="dropdown">
      <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" id="quick_login_link"
        aria-expanded="false" aria-controls="quick_login"
        %if c.authuser.username != 'default':
          href="${h.url('notifications')}"
        %else:
          href="#"
        %endif
      >
          ${h.gravatar_div(c.authuser.email, size=20, div_class="icon", div_style="display:inline", div_aria_hidden="true")}
          %if c.authuser.username != 'default':
            <span class="menu_link_user">${c.authuser.username}</span>
            %if c.unread_notifications != 0:
              <span class="badge">${c.unread_notifications}</span>
            %endif
          %else:
              <span>${_('Not Logged In')}</span>
          %endif
      </a>

      <div class="user-menu" role="menu">
        <div id="quick_login" role="form" aria-describedby="quick_login_h" aria-hidden="true" class="dropdown-menu">
          %if c.authuser.username == 'default' or c.authuser.user_id is None:
            <h4 id="quick_login_h">${_('Login to Your Account')}</h4>
            ${h.form(h.url('login_home', came_from=request.path_qs))}
            <div class="form">
                <div class="fields">
                    <div class="field">
                        <label for="username">${_('Username')}:</label>
                        <div class="input">
                            ${h.text('username',class_='focus')}
                        </div>

                    </div>
                    <div class="field">
                        <label for="password">${_('Password')}:</label>
                        <div class="input">
                            ${h.password('password',class_='focus')}
                        </div>

                    </div>
                    <div class="buttons">
                        <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div>
                        <div class="register">
                        %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')():
                         ${h.link_to(_("Don't have an account ?"),h.url('register'))}
                        %endif
                        </div>
                        <div class="submit">
                            ${h.submit('sign_in',_('Log In'),class_="btn btn-default btn-xs")}
                        </div>
                    </div>
                </div>
            </div>
            ${h.end_form()}
          %else:
            <div class="links_left">
                ${h.gravatar_div(c.authuser.email, size=48, div_class="big_gravatar")}
                <div class="full_name">${c.authuser.full_name_or_username}</div>
                <div class="email">${c.authuser.email}</div>
            </div>
            <div class="links_right">
            <ol class="links">
              <li><a href="${h.url('notifications')}">${_('Notifications')}: ${c.unread_notifications}</a></li>
              <li>${h.link_to(_('My Account'),h.url('my_account'))}</li>
              %if not c.authuser.is_external_auth:
                ## Cannot log out if using external (container) authentication.
                <li class="logout">${h.link_to(_('Log Out'), h.url('logout_home'))}</li>
              %endif
            </ol>
            </div>
          %endif
        </div>
      </div>
    </li>

    <script type="text/javascript">
        $(document).ready(function(){
            var visual_show_public_icon = "${c.visual.show_public_icon}" == "True";
            var cache = {}
            /*format the look of items in the list*/
            var format = function(state){
                if (!state.id){
                  return state.text; // optgroup
                }
                var obj_dict = state.obj;
                var tmpl = '';

                if(obj_dict && state.type == 'repo'){
                    tmpl += '<span class="repo-icons">';
                    if(obj_dict['repo_type'] === 'hg'){
                        tmpl += '<span class="repotag">hg</span> ';
                    }
                    else if(obj_dict['repo_type'] === 'git'){
                        tmpl += '<span class="repotag">git</span> ';
                    }
                    if(obj_dict['private']){
                        tmpl += '<i class="icon-keyhole-circled"></i> ';
                    }
                    else if(visual_show_public_icon){
                        tmpl += '<i class="icon-globe"></i> ';
                    }
                    tmpl += '</span>';
                }
                if(obj_dict && state.type == 'group'){
                        tmpl += '<i class="icon-folder"></i> ';
                }
                tmpl += state.text;
                return tmpl;
            }

            $("#repo_switcher").select2({
                placeholder: '<i class="icon-database"></i> ${_('Repositories')} <span class="caret"></span>',
                dropdownAutoWidth: true,
                sortResults: prefixFirstSort,
                formatResult: format,
                formatSelection: format,
                formatNoMatches: function(term){
                    return "${_('No matches found')}";
                },
                containerCssClass: "repo-switcher",
                dropdownCssClass: "repo-switcher-dropdown",
                escapeMarkup: function(m){
                    // don't escape our custom placeholder
                    if(m.substr(0,29) == '<i class="icon-database"></i>'){
                        return m;
                    }

                    return Select2.util.escapeMarkup(m);
                },
                query: function(query){
                  var key = 'cache';
                  var cached = cache[key] ;
                  if(cached) {
                    var data = {results: []};
                    //filter results
                    $.each(cached.results, function(){
                        var section = this.text;
                        var children = [];
                        $.each(this.children, function(){
                            if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){
                                children.push({'id': this.id, 'text': this.text, 'type': this.type, 'obj': this.obj});
                            }
                        });
                        if(children.length !== 0){
                            data.results.push({'text': section, 'children': children});
                        }

                    });
                    query.callback(data);
                  }else{
                      $.ajax({
                        url: "${h.url('repo_switcher_data')}",
                        data: {},
                        dataType: 'json',
                        type: 'GET',
                        success: function(data) {
                          cache[key] = data;
                          query.callback({results: data.results});
                        }
                      });
                  }
                }
            });

            $("#repo_switcher").on('select2-selecting', function(e){
                e.preventDefault();
                window.location = pyroutes.url('summary_home', {'repo_name': e.val});
            });

            $(document).on('shown.bs.dropdown', function(event) {
                var dropdown = $(event.target);

                dropdown.attr('aria-expanded', true);
                dropdown.find('.dropdown-menu').attr('aria-hidden', false);
            });

            $(document).on('hidden.bs.dropdown', function(event) {
                var dropdown = $(event.target);

                dropdown.attr('aria-expanded', false);
                dropdown.find('.dropdown-menu').attr('aria-hidden', true);
            });
        });
    </script>
</%def>