Show More
@@ -1,227 +1,235 b'' | |||||
1 | // # Copyright (C) 2010-2016 RhodeCode GmbH |
|
1 | // # Copyright (C) 2010-2016 RhodeCode GmbH | |
2 | // # |
|
2 | // # | |
3 | // # This program is free software: you can redistribute it and/or modify |
|
3 | // # This program is free software: you can redistribute it and/or modify | |
4 | // # it under the terms of the GNU Affero General Public License, version 3 |
|
4 | // # it under the terms of the GNU Affero General Public License, version 3 | |
5 | // # (only), as published by the Free Software Foundation. |
|
5 | // # (only), as published by the Free Software Foundation. | |
6 | // # |
|
6 | // # | |
7 | // # This program is distributed in the hope that it will be useful, |
|
7 | // # This program is distributed in the hope that it will be useful, | |
8 | // # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
8 | // # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 | // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
9 | // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 | // # GNU General Public License for more details. |
|
10 | // # GNU General Public License for more details. | |
11 | // # |
|
11 | // # | |
12 | // # You should have received a copy of the GNU Affero General Public License |
|
12 | // # You should have received a copy of the GNU Affero General Public License | |
13 | // # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
13 | // # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
14 | // # |
|
14 | // # | |
15 | // # This program is dual-licensed. If you wish to learn more about the |
|
15 | // # This program is dual-licensed. If you wish to learn more about the | |
16 | // # RhodeCode Enterprise Edition, including its added features, Support services, |
|
16 | // # RhodeCode Enterprise Edition, including its added features, Support services, | |
17 | // # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
17 | // # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
18 |
|
18 | |||
19 | /** |
|
19 | /** | |
20 | * Object holding the registered pyroutes. |
|
20 | * Object holding the registered pyroutes. | |
21 | * Routes will be registered with the generated script |
|
21 | * Routes will be registered with the generated script | |
22 | * rhodecode/public/js/rhodecode/base/pyroutes.js |
|
22 | * rhodecode/public/js/rhodecode/base/pyroutes.js | |
23 | */ |
|
23 | */ | |
24 | var PROUTES_MAP = {}; |
|
24 | var PROUTES_MAP = {}; | |
25 |
|
25 | |||
26 | /** |
|
26 | /** | |
27 | * PyRoutesJS |
|
27 | * PyRoutesJS | |
28 | * |
|
28 | * | |
29 | * Usage pyroutes.url('mark_error_fixed',{"error_id":error_id}) // /mark_error_fixed/<error_id> |
|
29 | * Usage pyroutes.url('mark_error_fixed',{"error_id":error_id}) // /mark_error_fixed/<error_id> | |
30 | */ |
|
30 | */ | |
31 | var pyroutes = (function() { |
|
31 | var pyroutes = (function() { | |
32 | // access global map defined in special file pyroutes |
|
32 | // access global map defined in special file pyroutes | |
33 | var matchlist = PROUTES_MAP; |
|
33 | var matchlist = PROUTES_MAP; | |
34 | var sprintf = (function() { |
|
34 | var sprintf = (function() { | |
35 | function get_type(variable) { |
|
35 | function get_type(variable) { | |
36 | return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); |
|
36 | return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); | |
37 | } |
|
37 | } | |
38 | function str_repeat(input, multiplier) { |
|
38 | function str_repeat(input, multiplier) { | |
39 | for (var output = []; multiplier > 0; output[--multiplier] = input) { |
|
39 | for (var output = []; multiplier > 0; output[--multiplier] = input) { | |
40 | /* do nothing */ |
|
40 | /* do nothing */ | |
41 | } |
|
41 | } | |
42 | return output.join(''); |
|
42 | return output.join(''); | |
43 | } |
|
43 | } | |
44 | var str_format = function() { |
|
44 | var str_format = function() { | |
45 | if (!str_format.cache.hasOwnProperty(arguments[0])) { |
|
45 | if (!str_format.cache.hasOwnProperty(arguments[0])) { | |
46 | str_format.cache[arguments[0]] = str_format.parse(arguments[0]); |
|
46 | str_format.cache[arguments[0]] = str_format.parse(arguments[0]); | |
47 | } |
|
47 | } | |
48 | return str_format.format.call(null, str_format.cache[arguments[0]], arguments); |
|
48 | return str_format.format.call(null, str_format.cache[arguments[0]], arguments); | |
49 | }; |
|
49 | }; | |
50 |
|
50 | |||
51 | str_format.format = function(parse_tree, argv) { |
|
51 | str_format.format = function(parse_tree, argv) { | |
52 | var cursor = 1, |
|
52 | var cursor = 1, | |
53 | tree_length = parse_tree.length, |
|
53 | tree_length = parse_tree.length, | |
54 | node_type = '', |
|
54 | node_type = '', | |
55 | arg, |
|
55 | arg, | |
56 | output = [], |
|
56 | output = [], | |
57 | i, k, |
|
57 | i, k, | |
58 | match, |
|
58 | match, | |
59 | pad, |
|
59 | pad, | |
60 | pad_character, |
|
60 | pad_character, | |
61 | pad_length; |
|
61 | pad_length; | |
62 | for (i = 0; i < tree_length; i++) { |
|
62 | for (i = 0; i < tree_length; i++) { | |
63 | node_type = get_type(parse_tree[i]); |
|
63 | node_type = get_type(parse_tree[i]); | |
64 | if (node_type === 'string') { |
|
64 | if (node_type === 'string') { | |
65 | output.push(parse_tree[i]); |
|
65 | output.push(parse_tree[i]); | |
66 | } |
|
66 | } | |
67 | else if (node_type === 'array') { |
|
67 | else if (node_type === 'array') { | |
68 | match = parse_tree[i]; // convenience purposes only |
|
68 | match = parse_tree[i]; // convenience purposes only | |
69 | if (match[2]) { // keyword argument |
|
69 | if (match[2]) { // keyword argument | |
70 | arg = argv[cursor]; |
|
70 | arg = argv[cursor]; | |
71 | for (k = 0; k < match[2].length; k++) { |
|
71 | for (k = 0; k < match[2].length; k++) { | |
72 | if (!arg.hasOwnProperty(match[2][k])) { |
|
72 | if (!arg.hasOwnProperty(match[2][k])) { | |
73 | throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); |
|
73 | throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); | |
74 | } |
|
74 | } | |
75 | arg = arg[match[2][k]]; |
|
75 | arg = arg[match[2][k]]; | |
76 | } |
|
76 | } | |
77 | } |
|
77 | } | |
78 | else if (match[1]) { // positional argument (explicit) |
|
78 | else if (match[1]) { // positional argument (explicit) | |
79 | arg = argv[match[1]]; |
|
79 | arg = argv[match[1]]; | |
80 | } |
|
80 | } | |
81 | else { // positional argument (implicit) |
|
81 | else { // positional argument (implicit) | |
82 | arg = argv[cursor++]; |
|
82 | arg = argv[cursor++]; | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | if (/[^s]/.test(match[8]) && (get_type(arg) !== 'number')) { |
|
85 | if (/[^s]/.test(match[8]) && (get_type(arg) !== 'number')) { | |
86 | throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); |
|
86 | throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); | |
87 | } |
|
87 | } | |
88 | switch (match[8]) { |
|
88 | switch (match[8]) { | |
89 | case 'b': arg = arg.toString(2); break; |
|
89 | case 'b': arg = arg.toString(2); break; | |
90 | case 'c': arg = String.fromCharCode(arg); break; |
|
90 | case 'c': arg = String.fromCharCode(arg); break; | |
91 | case 'd': arg = parseInt(arg, 10); break; |
|
91 | case 'd': arg = parseInt(arg, 10); break; | |
92 | case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; |
|
92 | case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; | |
93 | case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; |
|
93 | case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; | |
94 | case 'o': arg = arg.toString(8); break; |
|
94 | case 'o': arg = arg.toString(8); break; | |
95 | case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); |
|
95 | case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); | |
96 | break; |
|
96 | break; | |
97 | case 'u': arg = Math.abs(arg); break; |
|
97 | case 'u': arg = Math.abs(arg); break; | |
98 | case 'x': arg = arg.toString(16); break; |
|
98 | case 'x': arg = arg.toString(16); break; | |
99 | case 'X': arg = arg.toString(16).toUpperCase(); break; |
|
99 | case 'X': arg = arg.toString(16).toUpperCase(); break; | |
100 | } |
|
100 | } | |
101 | arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); |
|
101 | arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); | |
102 | pad_character = |
|
102 | pad_character = | |
103 | match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' '; |
|
103 | match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' '; | |
104 | pad_length = match[6] - String(arg).length; |
|
104 | pad_length = match[6] - String(arg).length; | |
105 | pad = match[6] ? str_repeat(pad_character, pad_length) : ''; |
|
105 | pad = match[6] ? str_repeat(pad_character, pad_length) : ''; | |
106 | output.push(match[5] ? arg + pad : pad + arg); |
|
106 | output.push(match[5] ? arg + pad : pad + arg); | |
107 | } |
|
107 | } | |
108 | } |
|
108 | } | |
109 | return output.join(''); |
|
109 | return output.join(''); | |
110 | }; |
|
110 | }; | |
111 |
|
111 | |||
112 | str_format.cache = {}; |
|
112 | str_format.cache = {}; | |
113 |
|
113 | |||
114 | str_format.parse = function(fmt) { |
|
114 | str_format.parse = function(fmt) { | |
115 | var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; |
|
115 | var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; | |
116 | while (_fmt) { |
|
116 | while (_fmt) { | |
117 | if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { |
|
117 | if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { | |
118 | parse_tree.push(match[0]); |
|
118 | parse_tree.push(match[0]); | |
119 | } |
|
119 | } | |
120 | else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { |
|
120 | else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { | |
121 | parse_tree.push('%'); |
|
121 | parse_tree.push('%'); | |
122 | } |
|
122 | } | |
123 | else if ( |
|
123 | else if ( | |
124 | (match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { |
|
124 | (match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { | |
125 | if (match[2]) { |
|
125 | if (match[2]) { | |
126 | arg_names |= 1; |
|
126 | arg_names |= 1; | |
127 | var field_list = [], replacement_field = match[2], field_match = []; |
|
127 | var field_list = [], replacement_field = match[2], field_match = []; | |
128 | if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { |
|
128 | if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { | |
129 | field_list.push(field_match[1]); |
|
129 | field_list.push(field_match[1]); | |
130 | while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { |
|
130 | while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { | |
131 | if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { |
|
131 | if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { | |
132 | field_list.push(field_match[1]); |
|
132 | field_list.push(field_match[1]); | |
133 | } |
|
133 | } | |
134 | else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { |
|
134 | else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { | |
135 | field_list.push(field_match[1]); |
|
135 | field_list.push(field_match[1]); | |
136 | } |
|
136 | } | |
137 | else { |
|
137 | else { | |
138 | throw('[sprintf] huh?'); |
|
138 | throw('[sprintf] huh?'); | |
139 | } |
|
139 | } | |
140 | } |
|
140 | } | |
141 | } |
|
141 | } | |
142 | else { |
|
142 | else { | |
143 | throw('[sprintf] huh?'); |
|
143 | throw('[sprintf] huh?'); | |
144 | } |
|
144 | } | |
145 | match[2] = field_list; |
|
145 | match[2] = field_list; | |
146 | } |
|
146 | } | |
147 | else { |
|
147 | else { | |
148 | arg_names |= 2; |
|
148 | arg_names |= 2; | |
149 | } |
|
149 | } | |
150 | if (arg_names === 3) { |
|
150 | if (arg_names === 3) { | |
151 | throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); |
|
151 | throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); | |
152 | } |
|
152 | } | |
153 | parse_tree.push(match); |
|
153 | parse_tree.push(match); | |
154 | } |
|
154 | } | |
155 | else { |
|
155 | else { | |
156 | throw('[sprintf] huh?'); |
|
156 | throw('[sprintf] huh?'); | |
157 | } |
|
157 | } | |
158 | _fmt = _fmt.substring(match[0].length); |
|
158 | _fmt = _fmt.substring(match[0].length); | |
159 | } |
|
159 | } | |
160 | return parse_tree; |
|
160 | return parse_tree; | |
161 | }; |
|
161 | }; | |
162 | return str_format; |
|
162 | return str_format; | |
163 | })(); |
|
163 | })(); | |
164 |
|
164 | |||
165 | var vsprintf = function(fmt, argv) { |
|
165 | var vsprintf = function(fmt, argv) { | |
166 | argv.unshift(fmt); |
|
166 | argv.unshift(fmt); | |
167 | return sprintf.apply(null, argv); |
|
167 | return sprintf.apply(null, argv); | |
168 | }; |
|
168 | }; | |
169 | return { |
|
169 | return { | |
|
170 | 'asset': function(path, ver) { | |||
|
171 | var asset_url = ASSET_URL || '/_static/'; | |||
|
172 | var ret = asset_url + path; | |||
|
173 | if (ver !== undefined) { | |||
|
174 | ret += '?ver=' + ver; | |||
|
175 | } | |||
|
176 | return ret; | |||
|
177 | }, | |||
170 | 'url': function(route_name, params) { |
|
178 | 'url': function(route_name, params) { | |
171 | var result = route_name; |
|
179 | var result = route_name; | |
172 | if (typeof(params) !== 'object'){ |
|
180 | if (typeof(params) !== 'object'){ | |
173 | params = {}; |
|
181 | params = {}; | |
174 | } |
|
182 | } | |
175 | if (matchlist.hasOwnProperty(route_name)) { |
|
183 | if (matchlist.hasOwnProperty(route_name)) { | |
176 | var route = matchlist[route_name]; |
|
184 | var route = matchlist[route_name]; | |
177 | // param substitution |
|
185 | // param substitution | |
178 | for(var i=0; i < route[1].length; i++) { |
|
186 | for(var i=0; i < route[1].length; i++) { | |
179 | var param_name = route[1][i]; |
|
187 | var param_name = route[1][i]; | |
180 | if (!params.hasOwnProperty(param_name)) |
|
188 | if (!params.hasOwnProperty(param_name)) | |
181 | throw new Error( |
|
189 | throw new Error( | |
182 |
'parameter '+ |
|
190 | 'parameter '+ | |
183 |
param_name + |
|
191 | param_name + | |
184 |
' is missing in route"' + |
|
192 | ' is missing in route"' + | |
185 | route_name + '" generation'); |
|
193 | route_name + '" generation'); | |
186 | } |
|
194 | } | |
187 | result = sprintf(route[0], params); |
|
195 | result = sprintf(route[0], params); | |
188 |
|
196 | |||
189 | var ret = []; |
|
197 | var ret = []; | |
190 | // extra params => GET |
|
198 | // extra params => GET | |
191 | for (var param in params){ |
|
199 | for (var param in params){ | |
192 | if (route[1].indexOf(param) === -1){ |
|
200 | if (route[1].indexOf(param) === -1){ | |
193 |
ret.push(encodeURIComponent(param) + "=" + |
|
201 | ret.push(encodeURIComponent(param) + "=" + | |
194 | encodeURIComponent(params[param])); |
|
202 | encodeURIComponent(params[param])); | |
195 | } |
|
203 | } | |
196 | } |
|
204 | } | |
197 | var _parts = ret.join("&"); |
|
205 | var _parts = ret.join("&"); | |
198 | if(_parts){ |
|
206 | if(_parts){ | |
199 | result = result +'?'+ _parts; |
|
207 | result = result +'?'+ _parts; | |
200 | } |
|
208 | } | |
201 | if(APPLICATION_URL) { |
|
209 | if(APPLICATION_URL) { | |
202 | result = APPLICATION_URL + result; |
|
210 | result = APPLICATION_URL + result; | |
203 | } |
|
211 | } | |
204 | } |
|
212 | } | |
205 |
|
213 | |||
206 | return result; |
|
214 | return result; | |
207 | }, |
|
215 | }, | |
208 | 'register': function(route_name, route_tmpl, req_params) { |
|
216 | 'register': function(route_name, route_tmpl, req_params) { | |
209 | if (typeof(req_params) !== 'object') { |
|
217 | if (typeof(req_params) !== 'object') { | |
210 | req_params = []; |
|
218 | req_params = []; | |
211 | } |
|
219 | } | |
212 | // fix escape |
|
220 | // fix escape | |
213 | route_tmpl = unescape(route_tmpl); |
|
221 | route_tmpl = unescape(route_tmpl); | |
214 | keys = []; |
|
222 | keys = []; | |
215 | for(var i=0; i < req_params.length; i++) { |
|
223 | for(var i=0; i < req_params.length; i++) { | |
216 | keys.push(req_params[i]); |
|
224 | keys.push(req_params[i]); | |
217 | } |
|
225 | } | |
218 | matchlist[route_name] = [ |
|
226 | matchlist[route_name] = [ | |
219 | route_tmpl, |
|
227 | route_tmpl, | |
220 | keys |
|
228 | keys | |
221 | ]; |
|
229 | ]; | |
222 | }, |
|
230 | }, | |
223 | '_routes': function(){ |
|
231 | '_routes': function(){ | |
224 | return matchlist; |
|
232 | return matchlist; | |
225 | } |
|
233 | } | |
226 | }; |
|
234 | }; | |
227 | })(); |
|
235 | })(); |
@@ -1,135 +1,136 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 |
|
14 | |||
15 | c.template_context['visual']['default_renderer'] = h.get_visual_attr(c, 'default_renderer') |
|
15 | c.template_context['visual']['default_renderer'] = h.get_visual_attr(c, 'default_renderer') | |
16 | %> |
|
16 | %> | |
17 |
|
17 | |||
18 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
18 | <html xmlns="http://www.w3.org/1999/xhtml"> | |
19 | <head> |
|
19 | <head> | |
20 | <title>${self.title()}</title> |
|
20 | <title>${self.title()}</title> | |
21 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
|
21 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |
22 | <%def name="robots()"> |
|
22 | <%def name="robots()"> | |
23 | <meta name="robots" content="index, nofollow"/> |
|
23 | <meta name="robots" content="index, nofollow"/> | |
24 | </%def> |
|
24 | </%def> | |
25 | ${self.robots()} |
|
25 | ${self.robots()} | |
26 | <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" /> |
|
26 | <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" /> | |
27 |
|
27 | |||
28 | ## CSS definitions |
|
28 | ## CSS definitions | |
29 | <%def name="css()"> |
|
29 | <%def name="css()"> | |
30 | <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
30 | <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/> | |
31 | <!--[if lt IE 9]> |
|
31 | <!--[if lt IE 9]> | |
32 | <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
32 | <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/> | |
33 | <![endif]--> |
|
33 | <![endif]--> | |
34 | ## EXTRA FOR CSS |
|
34 | ## EXTRA FOR CSS | |
35 | ${self.css_extra()} |
|
35 | ${self.css_extra()} | |
36 | </%def> |
|
36 | </%def> | |
37 | ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites |
|
37 | ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites | |
38 | <%def name="css_extra()"> |
|
38 | <%def name="css_extra()"> | |
39 | </%def> |
|
39 | </%def> | |
40 |
|
40 | |||
41 | ${self.css()} |
|
41 | ${self.css()} | |
42 |
|
42 | |||
43 | ## JAVASCRIPT |
|
43 | ## JAVASCRIPT | |
44 | <%def name="js()"> |
|
44 | <%def name="js()"> | |
45 | <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script> |
|
45 | <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script> | |
46 | <script type="text/javascript"> |
|
46 | <script type="text/javascript"> | |
47 | // register templateContext to pass template variables to JS |
|
47 | // register templateContext to pass template variables to JS | |
48 | var templateContext = ${h.json.dumps(c.template_context)|n}; |
|
48 | var templateContext = ${h.json.dumps(c.template_context)|n}; | |
49 |
|
49 | |||
50 | var REPO_NAME = "${getattr(c, 'repo_name', '')}"; |
|
50 | var REPO_NAME = "${getattr(c, 'repo_name', '')}"; | |
51 | %if hasattr(c, 'rhodecode_db_repo'): |
|
51 | %if hasattr(c, 'rhodecode_db_repo'): | |
52 | var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}'; |
|
52 | var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}'; | |
53 | var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}'; |
|
53 | var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}'; | |
54 | %else: |
|
54 | %else: | |
55 | var REPO_LANDING_REV = ''; |
|
55 | var REPO_LANDING_REV = ''; | |
56 | var REPO_TYPE = ''; |
|
56 | var REPO_TYPE = ''; | |
57 | %endif |
|
57 | %endif | |
58 | var APPLICATION_URL = "${h.url('home').rstrip('/')}"; |
|
58 | var APPLICATION_URL = "${h.url('home').rstrip('/')}"; | |
|
59 | var ASSET_URL = "${h.asset('')}"; | |||
59 | var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}"; |
|
60 | var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}"; | |
60 | var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}"; |
|
61 | var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}"; | |
61 | % if getattr(c, 'rhodecode_user', None): |
|
62 | % if getattr(c, 'rhodecode_user', None): | |
62 | var USER = {name:'${c.rhodecode_user.username}'}; |
|
63 | var USER = {name:'${c.rhodecode_user.username}'}; | |
63 | % else: |
|
64 | % else: | |
64 | var USER = {name:null}; |
|
65 | var USER = {name:null}; | |
65 | % endif |
|
66 | % endif | |
66 |
|
67 | |||
67 | var APPENLIGHT = { |
|
68 | var APPENLIGHT = { | |
68 | enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'}, |
|
69 | enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'}, | |
69 | key: '${getattr(c, "appenlight_api_public_key", "")}', |
|
70 | key: '${getattr(c, "appenlight_api_public_key", "")}', | |
70 | serverUrl: '${getattr(c, "appenlight_server_url", "")}', |
|
71 | serverUrl: '${getattr(c, "appenlight_server_url", "")}', | |
71 | requestInfo: { |
|
72 | requestInfo: { | |
72 | % if getattr(c, 'rhodecode_user', None): |
|
73 | % if getattr(c, 'rhodecode_user', None): | |
73 | ip: '${c.rhodecode_user.ip_addr}', |
|
74 | ip: '${c.rhodecode_user.ip_addr}', | |
74 | username: '${c.rhodecode_user.username}' |
|
75 | username: '${c.rhodecode_user.username}' | |
75 | % endif |
|
76 | % endif | |
76 | } |
|
77 | } | |
77 | }; |
|
78 | }; | |
78 | </script> |
|
79 | </script> | |
79 |
|
80 | |||
80 | <!--[if lt IE 9]> |
|
81 | <!--[if lt IE 9]> | |
81 | <script language="javascript" type="text/javascript" src="${h.asset('js/excanvas.min.js')}"></script> |
|
82 | <script language="javascript" type="text/javascript" src="${h.asset('js/excanvas.min.js')}"></script> | |
82 | <![endif]--> |
|
83 | <![endif]--> | |
83 | <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode/routes.js', ver=c.rhodecode_version_hash)}"></script> |
|
84 | <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode/routes.js', ver=c.rhodecode_version_hash)}"></script> | |
84 | <script language="javascript" type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script> |
|
85 | <script language="javascript" type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script> | |
85 | <script>CodeMirror.modeURL = "${h.asset('js/mode/%N/%N.js')}";</script> |
|
86 | <script>CodeMirror.modeURL = "${h.asset('js/mode/%N/%N.js')}";</script> | |
86 |
|
87 | |||
87 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
88 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates | |
88 | ${self.js_extra()} |
|
89 | ${self.js_extra()} | |
89 |
|
90 | |||
90 | <script type="text/javascript"> |
|
91 | <script type="text/javascript"> | |
91 | $(document).ready(function(){ |
|
92 | $(document).ready(function(){ | |
92 | show_more_event(); |
|
93 | show_more_event(); | |
93 | timeagoActivate(); |
|
94 | timeagoActivate(); | |
94 | }) |
|
95 | }) | |
95 | </script> |
|
96 | </script> | |
96 |
|
97 | |||
97 | </%def> |
|
98 | </%def> | |
98 |
|
99 | |||
99 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
100 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates | |
100 | <%def name="js_extra()"></%def> |
|
101 | <%def name="js_extra()"></%def> | |
101 | ${self.js()} |
|
102 | ${self.js()} | |
102 |
|
103 | |||
103 | <%def name="head_extra()"></%def> |
|
104 | <%def name="head_extra()"></%def> | |
104 | ${self.head_extra()} |
|
105 | ${self.head_extra()} | |
105 |
|
106 | |||
106 | <%include file="/base/plugins_base.html"/> |
|
107 | <%include file="/base/plugins_base.html"/> | |
107 |
|
108 | |||
108 | ## extra stuff |
|
109 | ## extra stuff | |
109 | %if c.pre_code: |
|
110 | %if c.pre_code: | |
110 | ${c.pre_code|n} |
|
111 | ${c.pre_code|n} | |
111 | %endif |
|
112 | %endif | |
112 | </head> |
|
113 | </head> | |
113 | <body id="body"> |
|
114 | <body id="body"> | |
114 | <noscript> |
|
115 | <noscript> | |
115 | <div class="noscript-error"> |
|
116 | <div class="noscript-error"> | |
116 | ${_('Please enable JavaScript to use RhodeCode Enterprise')} |
|
117 | ${_('Please enable JavaScript to use RhodeCode Enterprise')} | |
117 | </div> |
|
118 | </div> | |
118 | </noscript> |
|
119 | </noscript> | |
119 | ## IE hacks |
|
120 | ## IE hacks | |
120 | <!--[if IE 7]> |
|
121 | <!--[if IE 7]> | |
121 | <script>$(document.body).addClass('ie7')</script> |
|
122 | <script>$(document.body).addClass('ie7')</script> | |
122 | <![endif]--> |
|
123 | <![endif]--> | |
123 | <!--[if IE 8]> |
|
124 | <!--[if IE 8]> | |
124 | <script>$(document.body).addClass('ie8')</script> |
|
125 | <script>$(document.body).addClass('ie8')</script> | |
125 | <![endif]--> |
|
126 | <![endif]--> | |
126 | <!--[if IE 9]> |
|
127 | <!--[if IE 9]> | |
127 | <script>$(document.body).addClass('ie9')</script> |
|
128 | <script>$(document.body).addClass('ie9')</script> | |
128 | <![endif]--> |
|
129 | <![endif]--> | |
129 |
|
130 | |||
130 | ${next.body()} |
|
131 | ${next.body()} | |
131 | %if c.post_code: |
|
132 | %if c.post_code: | |
132 | ${c.post_code|n} |
|
133 | ${c.post_code|n} | |
133 | %endif |
|
134 | %endif | |
134 | </body> |
|
135 | </body> | |
135 | </html> |
|
136 | </html> |
General Comments 0
You need to be logged in to leave comments.
Login now