##// END OF EJS Templates
templates: expose default user data into templates for JS usage.
marcink -
r1763:45ee44d8 default
parent child Browse files
Show More
@@ -1,170 +1,175 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <!DOCTYPE html>
3 3
4 4 <%
5 5 c.template_context['repo_name'] = getattr(c, 'repo_name', '')
6 6
7 7 if hasattr(c, 'rhodecode_db_repo'):
8 8 c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type
9 9 c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1]
10 10
11 11 if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id:
12 12 c.template_context['rhodecode_user']['username'] = c.rhodecode_user.username
13 13 c.template_context['rhodecode_user']['email'] = c.rhodecode_user.email
14 14 c.template_context['rhodecode_user']['notification_status'] = c.rhodecode_user.get_instance().user_data.get('notification_status', True)
15 15 c.template_context['rhodecode_user']['first_name'] = c.rhodecode_user.name
16 16 c.template_context['rhodecode_user']['last_name'] = c.rhodecode_user.lastname
17 17
18 18 c.template_context['visual']['default_renderer'] = h.get_visual_attr(c, 'default_renderer')
19 c.template_context['default_user'] = {
20 'username': h.DEFAULT_USER,
21 'user_id': 1
22 }
23
19 24 %>
20 25 <html xmlns="http://www.w3.org/1999/xhtml">
21 26 <head>
22 27 <script src="${h.asset('js/vendors/webcomponentsjs/webcomponents-lite.min.js', ver=c.rhodecode_version_hash)}"></script>
23 28 <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}">
24 29 <title>${self.title()}</title>
25 30 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
26 31 <%def name="robots()">
27 32 <meta name="robots" content="index, nofollow"/>
28 33 </%def>
29 34 ${self.robots()}
30 35 <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" />
31 36
32 37 ## CSS definitions
33 38 <%def name="css()">
34 39 <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/>
35 40 <!--[if lt IE 9]>
36 41 <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/>
37 42 <![endif]-->
38 43 ## EXTRA FOR CSS
39 44 ${self.css_extra()}
40 45 </%def>
41 46 ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites
42 47 <%def name="css_extra()">
43 48 </%def>
44 49
45 50 ${self.css()}
46 51
47 52 ## JAVASCRIPT
48 53 <%def name="js()">
49 54 <script>
50 55 // setup Polymer options
51 56 window.Polymer = {lazyRegister: true, dom: 'shadow'};
52 57
53 58 // Load webcomponentsjs polyfill if browser does not support native Web Components
54 59 (function() {
55 60 'use strict';
56 61 var onload = function() {
57 62 // For native Imports, manually fire WebComponentsReady so user code
58 63 // can use the same code path for native and polyfill'd imports.
59 64 if (!window.HTMLImports) {
60 65 document.dispatchEvent(
61 66 new CustomEvent('WebComponentsReady', {bubbles: true})
62 67 );
63 68 }
64 69 };
65 70 var webComponentsSupported = (
66 71 'registerElement' in document
67 72 && 'import' in document.createElement('link')
68 73 && 'content' in document.createElement('template')
69 74 );
70 75 if (!webComponentsSupported) {
71 76 } else {
72 77 onload();
73 78 }
74 79 })();
75 80 </script>
76 81
77 82 <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script>
78 83 <script type="text/javascript">
79 84 // register templateContext to pass template variables to JS
80 85 var templateContext = ${h.json.dumps(c.template_context)|n};
81 86
82 87 var APPLICATION_URL = "${h.url('home').rstrip('/')}";
83 88 var ASSET_URL = "${h.asset('')}";
84 89 var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}";
85 90 var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}";
86 91
87 92 var APPENLIGHT = {
88 93 enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'},
89 94 key: '${getattr(c, "appenlight_api_public_key", "")}',
90 95 % if getattr(c, 'appenlight_server_url', None):
91 96 serverUrl: '${getattr(c, "appenlight_server_url", "")}',
92 97 % endif
93 98 requestInfo: {
94 99 % if getattr(c, 'rhodecode_user', None):
95 100 ip: '${c.rhodecode_user.ip_addr}',
96 101 username: '${c.rhodecode_user.username}'
97 102 % endif
98 103 },
99 104 tags: {
100 105 rhodecode_version: '${c.rhodecode_version}',
101 106 rhodecode_edition: '${c.rhodecode_edition}'
102 107 }
103 108 };
104 109
105 110 </script>
106 111 <%include file="/base/plugins_base.mako"/>
107 112 <!--[if lt IE 9]>
108 113 <script language="javascript" type="text/javascript" src="${h.asset('js/excanvas.min.js')}"></script>
109 114 <![endif]-->
110 115 <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode/routes.js', ver=c.rhodecode_version_hash)}"></script>
111 116 <script> var alertMessagePayloads = ${h.flash.json_alerts()|n}; </script>
112 117 ## avoide escaping the %N
113 118 <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode-components.js', ver=c.rhodecode_version_hash)}"></script>
114 119 <script>CodeMirror.modeURL = "${h.asset('') + 'js/mode/%N/%N.js?ver='+c.rhodecode_version_hash}";</script>
115 120
116 121
117 122 ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates
118 123 ${self.js_extra()}
119 124
120 125 <script type="text/javascript">
121 126 Rhodecode = (function() {
122 127 function _Rhodecode() {
123 128 this.comments = new CommentsController();
124 129 }
125 130 return new _Rhodecode();
126 131 })();
127 132
128 133 $(document).ready(function(){
129 134 show_more_event();
130 135 timeagoActivate();
131 136 })
132 137 </script>
133 138
134 139 </%def>
135 140
136 141 ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates
137 142 <%def name="js_extra()"></%def>
138 143 ${self.js()}
139 144
140 145 <%def name="head_extra()"></%def>
141 146 ${self.head_extra()}
142 147 ## extra stuff
143 148 %if c.pre_code:
144 149 ${c.pre_code|n}
145 150 %endif
146 151 </head>
147 152 <body id="body">
148 153 <noscript>
149 154 <div class="noscript-error">
150 155 ${_('Please enable JavaScript to use RhodeCode Enterprise')}
151 156 </div>
152 157 </noscript>
153 158 ## IE hacks
154 159 <!--[if IE 7]>
155 160 <script>$(document.body).addClass('ie7')</script>
156 161 <![endif]-->
157 162 <!--[if IE 8]>
158 163 <script>$(document.body).addClass('ie8')</script>
159 164 <![endif]-->
160 165 <!--[if IE 9]>
161 166 <script>$(document.body).addClass('ie9')</script>
162 167 <![endif]-->
163 168
164 169 ${next.body()}
165 170 %if c.post_code:
166 171 ${c.post_code|n}
167 172 %endif
168 173 <rhodecode-app></rhodecode-app>
169 174 </body>
170 175 </html>
General Comments 0
You need to be logged in to leave comments. Login now