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