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