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