Show More
@@ -1,217 +1,219 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 | * Pull request reviewers |
|
20 | * Pull request reviewers | |
21 | */ |
|
21 | */ | |
22 | var removeReviewMember = function(reviewer_id, mark_delete){ |
|
22 | var removeReviewMember = function(reviewer_id, mark_delete){ | |
23 | var reviewer = $('#reviewer_{0}'.format(reviewer_id)); |
|
23 | var reviewer = $('#reviewer_{0}'.format(reviewer_id)); | |
24 |
|
24 | |||
25 | if(typeof(mark_delete) === undefined){ |
|
25 | if(typeof(mark_delete) === undefined){ | |
26 | mark_delete = false; |
|
26 | mark_delete = false; | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 | if(mark_delete === true){ |
|
29 | if(mark_delete === true){ | |
30 | if (reviewer){ |
|
30 | if (reviewer){ | |
31 | // mark as to-remove |
|
31 | // mark as to-remove | |
32 | var obj = $('#reviewer_{0}_name'.format(reviewer_id)); |
|
32 | var obj = $('#reviewer_{0}_name'.format(reviewer_id)); | |
33 | obj.addClass('to-delete'); |
|
33 | obj.addClass('to-delete'); | |
34 | // now delete the input |
|
34 | // now delete the input | |
35 | $('#reviewer_{0} input'.format(reviewer_id)).remove(); |
|
35 | $('#reviewer_{0} input'.format(reviewer_id)).remove(); | |
36 | } |
|
36 | } | |
37 | } |
|
37 | } | |
38 | else{ |
|
38 | else{ | |
39 | $('#reviewer_{0}'.format(reviewer_id)).remove(); |
|
39 | $('#reviewer_{0}'.format(reviewer_id)).remove(); | |
40 | } |
|
40 | } | |
41 | }; |
|
41 | }; | |
42 |
|
42 | |||
43 | var addReviewMember = function(id, fname, lname, nname, gravatar_link, reasons) { |
|
43 | var addReviewMember = function(id, fname, lname, nname, gravatar_link, reasons) { | |
44 | var members = $('#review_members').get(0); |
|
44 | var members = $('#review_members').get(0); | |
45 | var reasons_html = ''; |
|
45 | var reasons_html = ''; | |
46 | var reasons_inputs = ''; |
|
46 | var reasons_inputs = ''; | |
47 | var reasons = reasons || []; |
|
47 | var reasons = reasons || []; | |
48 | if (reasons) { |
|
48 | if (reasons) { | |
49 | for (var i = 0; i < reasons.length; i++) { |
|
49 | for (var i = 0; i < reasons.length; i++) { | |
50 | reasons_html += '<div class="reviewer_reason">- {0}</div>'.format(reasons[i]); |
|
50 | reasons_html += '<div class="reviewer_reason">- {0}</div>'.format(reasons[i]); | |
51 | reasons_inputs += '<input type="hidden" name="reason" value="' + escapeHtml(reasons[i]) + '">'; |
|
51 | reasons_inputs += '<input type="hidden" name="reason" value="' + escapeHtml(reasons[i]) + '">'; | |
52 | } |
|
52 | } | |
53 | } |
|
53 | } | |
54 | var tmpl = '<li id="reviewer_{2}">'+ |
|
54 | var tmpl = '<li id="reviewer_{2}">'+ | |
55 | '<input type="hidden" name="__start__" value="reviewer:mapping">'+ |
|
55 | '<input type="hidden" name="__start__" value="reviewer:mapping">'+ | |
56 | '<div class="reviewer_status">'+ |
|
56 | '<div class="reviewer_status">'+ | |
57 | '<div class="flag_status not_reviewed pull-left reviewer_member_status"></div>'+ |
|
57 | '<div class="flag_status not_reviewed pull-left reviewer_member_status"></div>'+ | |
58 | '</div>'+ |
|
58 | '</div>'+ | |
59 | '<img alt="gravatar" class="gravatar" src="{0}"/>'+ |
|
59 | '<img alt="gravatar" class="gravatar" src="{0}"/>'+ | |
60 | '<span class="reviewer_name user">{1}</span>'+ |
|
60 | '<span class="reviewer_name user">{1}</span>'+ | |
61 | reasons_html + |
|
61 | reasons_html + | |
62 | '<input type="hidden" name="user_id" value="{2}">'+ |
|
62 | '<input type="hidden" name="user_id" value="{2}">'+ | |
63 | '<input type="hidden" name="__start__" value="reasons:sequence">'+ |
|
63 | '<input type="hidden" name="__start__" value="reasons:sequence">'+ | |
64 | '{3}'+ |
|
64 | '{3}'+ | |
65 | '<input type="hidden" name="__end__" value="reasons:sequence">'+ |
|
65 | '<input type="hidden" name="__end__" value="reasons:sequence">'+ | |
66 | '<div class="reviewer_member_remove action_button" onclick="removeReviewMember({2})">' + |
|
66 | '<div class="reviewer_member_remove action_button" onclick="removeReviewMember({2})">' + | |
67 | '<i class="icon-remove-sign"></i>'+ |
|
67 | '<i class="icon-remove-sign"></i>'+ | |
68 | '</div>'+ |
|
68 | '</div>'+ | |
69 | '</div>'+ |
|
69 | '</div>'+ | |
70 | '<input type="hidden" name="__end__" value="reviewer:mapping">'+ |
|
70 | '<input type="hidden" name="__end__" value="reviewer:mapping">'+ | |
71 | '</li>' ; |
|
71 | '</li>' ; | |
72 |
|
72 | |||
73 | var displayname = "{0} ({1} {2})".format( |
|
73 | var displayname = "{0} ({1} {2})".format( | |
74 | nname, escapeHtml(fname), escapeHtml(lname)); |
|
74 | nname, escapeHtml(fname), escapeHtml(lname)); | |
75 | var element = tmpl.format(gravatar_link,displayname,id,reasons_inputs); |
|
75 | var element = tmpl.format(gravatar_link,displayname,id,reasons_inputs); | |
76 | // check if we don't have this ID already in |
|
76 | // check if we don't have this ID already in | |
77 | var ids = []; |
|
77 | var ids = []; | |
78 | var _els = $('#review_members li').toArray(); |
|
78 | var _els = $('#review_members li').toArray(); | |
79 | for (el in _els){ |
|
79 | for (el in _els){ | |
80 | ids.push(_els[el].id) |
|
80 | ids.push(_els[el].id) | |
81 | } |
|
81 | } | |
82 | if(ids.indexOf('reviewer_'+id) == -1){ |
|
82 | if(ids.indexOf('reviewer_'+id) == -1){ | |
83 | // only add if it's not there |
|
83 | // only add if it's not there | |
84 | members.innerHTML += element; |
|
84 | members.innerHTML += element; | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | }; |
|
87 | }; | |
88 |
|
88 | |||
89 | var _updatePullRequest = function(repo_name, pull_request_id, postData) { |
|
89 | var _updatePullRequest = function(repo_name, pull_request_id, postData) { | |
90 | var url = pyroutes.url( |
|
90 | var url = pyroutes.url( | |
91 | 'pullrequest_update', |
|
91 | 'pullrequest_update', | |
92 | {"repo_name": repo_name, "pull_request_id": pull_request_id}); |
|
92 | {"repo_name": repo_name, "pull_request_id": pull_request_id}); | |
93 | if (typeof postData === 'string' ) { |
|
93 | if (typeof postData === 'string' ) { | |
94 | postData += '&csrf_token=' + CSRF_TOKEN; |
|
94 | postData += '&csrf_token=' + CSRF_TOKEN; | |
95 | } else { |
|
95 | } else { | |
96 | postData.csrf_token = CSRF_TOKEN; |
|
96 | postData.csrf_token = CSRF_TOKEN; | |
97 | } |
|
97 | } | |
98 | var success = function(o) { |
|
98 | var success = function(o) { | |
99 | window.location.reload(); |
|
99 | window.location.reload(); | |
100 | }; |
|
100 | }; | |
101 | ajaxPOST(url, postData, success); |
|
101 | ajaxPOST(url, postData, success); | |
102 | }; |
|
102 | }; | |
103 |
|
103 | |||
104 | var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){ |
|
104 | var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){ | |
105 | if (reviewers_ids === undefined){ |
|
105 | if (reviewers_ids === undefined){ | |
106 | var postData = '_method=put&' + $('#reviewers input').serialize(); |
|
106 | var postData = '_method=put&' + $('#reviewers input').serialize(); | |
107 | _updatePullRequest(repo_name, pull_request_id, postData); |
|
107 | _updatePullRequest(repo_name, pull_request_id, postData); | |
108 | } |
|
108 | } | |
109 | }; |
|
109 | }; | |
110 |
|
110 | |||
111 | /** |
|
111 | /** | |
112 | * PULL REQUEST reject & close |
|
112 | * PULL REQUEST reject & close | |
113 | */ |
|
113 | */ | |
114 | var closePullRequest = function(repo_name, pull_request_id) { |
|
114 | var closePullRequest = function(repo_name, pull_request_id) { | |
115 | var postData = { |
|
115 | var postData = { | |
116 | '_method': 'put', |
|
116 | '_method': 'put', | |
117 | 'close_pull_request': true}; |
|
117 | 'close_pull_request': true}; | |
118 | _updatePullRequest(repo_name, pull_request_id, postData); |
|
118 | _updatePullRequest(repo_name, pull_request_id, postData); | |
119 | }; |
|
119 | }; | |
120 |
|
120 | |||
121 | /** |
|
121 | /** | |
122 | * PULL REQUEST update commits |
|
122 | * PULL REQUEST update commits | |
123 | */ |
|
123 | */ | |
124 | var updateCommits = function(repo_name, pull_request_id) { |
|
124 | var updateCommits = function(repo_name, pull_request_id) { | |
125 | var postData = { |
|
125 | var postData = { | |
126 | '_method': 'put', |
|
126 | '_method': 'put', | |
127 | 'update_commits': true}; |
|
127 | 'update_commits': true}; | |
128 | _updatePullRequest(repo_name, pull_request_id, postData); |
|
128 | _updatePullRequest(repo_name, pull_request_id, postData); | |
129 | }; |
|
129 | }; | |
130 |
|
130 | |||
131 |
|
131 | |||
132 | /** |
|
132 | /** | |
133 | * PULL REQUEST edit info |
|
133 | * PULL REQUEST edit info | |
134 | */ |
|
134 | */ | |
135 | var editPullRequest = function(repo_name, pull_request_id, title, description) { |
|
135 | var editPullRequest = function(repo_name, pull_request_id, title, description) { | |
136 | var url = pyroutes.url( |
|
136 | var url = pyroutes.url( | |
137 | 'pullrequest_update', |
|
137 | 'pullrequest_update', | |
138 | {"repo_name": repo_name, "pull_request_id": pull_request_id}); |
|
138 | {"repo_name": repo_name, "pull_request_id": pull_request_id}); | |
139 |
|
139 | |||
140 | var postData = { |
|
140 | var postData = { | |
141 | '_method': 'put', |
|
141 | '_method': 'put', | |
142 | 'title': title, |
|
142 | 'title': title, | |
143 | 'description': description, |
|
143 | 'description': description, | |
144 | 'edit_pull_request': true, |
|
144 | 'edit_pull_request': true, | |
145 | 'csrf_token': CSRF_TOKEN |
|
145 | 'csrf_token': CSRF_TOKEN | |
146 | }; |
|
146 | }; | |
147 | var success = function(o) { |
|
147 | var success = function(o) { | |
148 | window.location.reload(); |
|
148 | window.location.reload(); | |
149 | }; |
|
149 | }; | |
150 | ajaxPOST(url, postData, success); |
|
150 | ajaxPOST(url, postData, success); | |
151 | }; |
|
151 | }; | |
152 |
|
152 | |||
153 | var initPullRequestsCodeMirror = function (textAreaId) { |
|
153 | var initPullRequestsCodeMirror = function (textAreaId) { | |
154 | var ta = $(textAreaId).get(0); |
|
154 | var ta = $(textAreaId).get(0); | |
155 | var initialHeight = '100px'; |
|
155 | var initialHeight = '100px'; | |
156 |
|
156 | |||
157 | // default options |
|
157 | // default options | |
158 | var codeMirrorOptions = { |
|
158 | var codeMirrorOptions = { | |
159 | mode: "text", |
|
159 | mode: "text", | |
160 | lineNumbers: false, |
|
160 | lineNumbers: false, | |
161 | indentUnit: 4, |
|
161 | indentUnit: 4, | |
162 | theme: 'rc-input' |
|
162 | theme: 'rc-input' | |
163 | }; |
|
163 | }; | |
164 |
|
164 | |||
165 | var codeMirrorInstance = CodeMirror.fromTextArea(ta, codeMirrorOptions); |
|
165 | var codeMirrorInstance = CodeMirror.fromTextArea(ta, codeMirrorOptions); | |
166 | // marker for manually set description |
|
166 | // marker for manually set description | |
167 | codeMirrorInstance._userDefinedDesc = false; |
|
167 | codeMirrorInstance._userDefinedDesc = false; | |
168 | codeMirrorInstance.setSize(null, initialHeight); |
|
168 | codeMirrorInstance.setSize(null, initialHeight); | |
169 | codeMirrorInstance.on("change", function(instance, changeObj) { |
|
169 | codeMirrorInstance.on("change", function(instance, changeObj) { | |
170 | var height = initialHeight; |
|
170 | var height = initialHeight; | |
171 | var lines = instance.lineCount(); |
|
171 | var lines = instance.lineCount(); | |
172 | if (lines > 6 && lines < 20) { |
|
172 | if (lines > 6 && lines < 20) { | |
173 | height = "auto" |
|
173 | height = "auto" | |
174 | } |
|
174 | } | |
175 | else if (lines >= 20) { |
|
175 | else if (lines >= 20) { | |
176 | height = 20 * 15; |
|
176 | height = 20 * 15; | |
177 | } |
|
177 | } | |
178 | instance.setSize(null, height); |
|
178 | instance.setSize(null, height); | |
179 |
|
179 | |||
180 | // detect if the change was trigger by auto desc, or user input |
|
180 | // detect if the change was trigger by auto desc, or user input | |
181 | changeOrigin = changeObj.origin; |
|
181 | changeOrigin = changeObj.origin; | |
182 |
|
182 | |||
183 | if (changeOrigin === "setValue") { |
|
183 | if (changeOrigin === "setValue") { | |
184 | cmLog.debug('Change triggered by setValue'); |
|
184 | cmLog.debug('Change triggered by setValue'); | |
185 | } |
|
185 | } | |
186 | else { |
|
186 | else { | |
187 | cmLog.debug('user triggered change !'); |
|
187 | cmLog.debug('user triggered change !'); | |
188 | // set special marker to indicate user has created an input. |
|
188 | // set special marker to indicate user has created an input. | |
189 | instance._userDefinedDesc = true; |
|
189 | instance._userDefinedDesc = true; | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | }); |
|
192 | }); | |
193 |
|
193 | |||
194 | return codeMirrorInstance |
|
194 | return codeMirrorInstance | |
195 | }; |
|
195 | }; | |
196 |
|
196 | |||
197 | /** |
|
197 | /** | |
198 | * Reviewer autocomplete |
|
198 | * Reviewer autocomplete | |
199 | */ |
|
199 | */ | |
200 | var ReviewerAutoComplete = function(input_id) { |
|
200 | var ReviewerAutoComplete = function(input_id) { | |
201 | $('#'+input_id).autocomplete({ |
|
201 | $('#'+input_id).autocomplete({ | |
202 | serviceUrl: pyroutes.url('user_autocomplete_data'), |
|
202 | serviceUrl: pyroutes.url('user_autocomplete_data'), | |
203 | minChars:2, |
|
203 | minChars:2, | |
204 | maxHeight:400, |
|
204 | maxHeight:400, | |
205 | deferRequestBy: 300, //miliseconds |
|
205 | deferRequestBy: 300, //miliseconds | |
206 | showNoSuggestionNotice: true, |
|
206 | showNoSuggestionNotice: true, | |
207 | tabDisabled: true, |
|
207 | tabDisabled: true, | |
208 | autoSelectFirst: true, |
|
208 | autoSelectFirst: true, | |
209 | formatResult: autocompleteFormatResult, |
|
209 | formatResult: autocompleteFormatResult, | |
210 | lookupFilter: autocompleteFilterResult, |
|
210 | lookupFilter: autocompleteFilterResult, | |
211 | onSelect: function(suggestion, data){ |
|
211 | onSelect: function(suggestion, data){ | |
|
212 | var msg = _gettext('added manually by "{0}"'); | |||
|
213 | var reasons = [msg.format(templateContext.rhodecode_user.username)]; | |||
212 | addReviewMember(data.id, data.first_name, data.last_name, |
|
214 | addReviewMember(data.id, data.first_name, data.last_name, | |
213 | data.username, data.icon_link); |
|
215 | data.username, data.icon_link, reasons); | |
214 | $('#'+input_id).val(''); |
|
216 | $('#'+input_id).val(''); | |
215 | } |
|
217 | } | |
216 | }); |
|
218 | }); | |
217 | }; |
|
219 | }; |
@@ -1,173 +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 | |||
|
16 | c.template_context['rhodecode_user']['last_name'] = c.rhodecode_user.lastname | |||
15 |
|
17 | |||
16 | 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') | |
17 | %> |
|
19 | %> | |
18 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
20 | <html xmlns="http://www.w3.org/1999/xhtml"> | |
19 | <head> |
|
21 | <head> | |
20 | <script src="${h.asset('js/vendors/webcomponentsjs/webcomponents-lite.min.js', ver=c.rhodecode_version_hash)}"></script> |
|
22 | <script src="${h.asset('js/vendors/webcomponentsjs/webcomponents-lite.min.js', ver=c.rhodecode_version_hash)}"></script> | |
21 | <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}"> |
|
23 | <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}"> | |
22 | <title>${self.title()}</title> |
|
24 | <title>${self.title()}</title> | |
23 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
|
25 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |
24 | <%def name="robots()"> |
|
26 | <%def name="robots()"> | |
25 | <meta name="robots" content="index, nofollow"/> |
|
27 | <meta name="robots" content="index, nofollow"/> | |
26 | </%def> |
|
28 | </%def> | |
27 | ${self.robots()} |
|
29 | ${self.robots()} | |
28 | <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" /> |
|
30 | <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" /> | |
29 |
|
31 | |||
30 | ## CSS definitions |
|
32 | ## CSS definitions | |
31 | <%def name="css()"> |
|
33 | <%def name="css()"> | |
32 | <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
34 | <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/> | |
33 | <!--[if lt IE 9]> |
|
35 | <!--[if lt IE 9]> | |
34 | <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
36 | <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/> | |
35 | <![endif]--> |
|
37 | <![endif]--> | |
36 | ## EXTRA FOR CSS |
|
38 | ## EXTRA FOR CSS | |
37 | ${self.css_extra()} |
|
39 | ${self.css_extra()} | |
38 | </%def> |
|
40 | </%def> | |
39 | ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites |
|
41 | ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites | |
40 | <%def name="css_extra()"> |
|
42 | <%def name="css_extra()"> | |
41 | </%def> |
|
43 | </%def> | |
42 |
|
44 | |||
43 | ${self.css()} |
|
45 | ${self.css()} | |
44 |
|
46 | |||
45 | ## JAVASCRIPT |
|
47 | ## JAVASCRIPT | |
46 | <%def name="js()"> |
|
48 | <%def name="js()"> | |
47 | <script> |
|
49 | <script> | |
48 | // setup Polymer options |
|
50 | // setup Polymer options | |
49 | window.Polymer = {lazyRegister: true, dom: 'shadow'}; |
|
51 | window.Polymer = {lazyRegister: true, dom: 'shadow'}; | |
50 |
|
52 | |||
51 | // Load webcomponentsjs polyfill if browser does not support native Web Components |
|
53 | // Load webcomponentsjs polyfill if browser does not support native Web Components | |
52 | (function() { |
|
54 | (function() { | |
53 | 'use strict'; |
|
55 | 'use strict'; | |
54 | var onload = function() { |
|
56 | var onload = function() { | |
55 | // For native Imports, manually fire WebComponentsReady so user code |
|
57 | // For native Imports, manually fire WebComponentsReady so user code | |
56 | // can use the same code path for native and polyfill'd imports. |
|
58 | // can use the same code path for native and polyfill'd imports. | |
57 | if (!window.HTMLImports) { |
|
59 | if (!window.HTMLImports) { | |
58 | document.dispatchEvent( |
|
60 | document.dispatchEvent( | |
59 | new CustomEvent('WebComponentsReady', {bubbles: true}) |
|
61 | new CustomEvent('WebComponentsReady', {bubbles: true}) | |
60 | ); |
|
62 | ); | |
61 | } |
|
63 | } | |
62 | }; |
|
64 | }; | |
63 | var webComponentsSupported = ( |
|
65 | var webComponentsSupported = ( | |
64 | 'registerElement' in document |
|
66 | 'registerElement' in document | |
65 | && 'import' in document.createElement('link') |
|
67 | && 'import' in document.createElement('link') | |
66 | && 'content' in document.createElement('template') |
|
68 | && 'content' in document.createElement('template') | |
67 | ); |
|
69 | ); | |
68 | if (!webComponentsSupported) { |
|
70 | if (!webComponentsSupported) { | |
69 | } else { |
|
71 | } else { | |
70 | onload(); |
|
72 | onload(); | |
71 | } |
|
73 | } | |
72 | })(); |
|
74 | })(); | |
73 | </script> |
|
75 | </script> | |
74 |
|
76 | |||
75 | <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script> |
|
77 | <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script> | |
76 | <script type="text/javascript"> |
|
78 | <script type="text/javascript"> | |
77 | // register templateContext to pass template variables to JS |
|
79 | // register templateContext to pass template variables to JS | |
78 | var templateContext = ${h.json.dumps(c.template_context)|n}; |
|
80 | var templateContext = ${h.json.dumps(c.template_context)|n}; | |
79 |
|
81 | |||
80 | var REPO_NAME = "${getattr(c, 'repo_name', '')}"; |
|
82 | var REPO_NAME = "${getattr(c, 'repo_name', '')}"; | |
81 | %if hasattr(c, 'rhodecode_db_repo'): |
|
83 | %if hasattr(c, 'rhodecode_db_repo'): | |
82 | var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}'; |
|
84 | var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}'; | |
83 | var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}'; |
|
85 | var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}'; | |
84 | %else: |
|
86 | %else: | |
85 | var REPO_LANDING_REV = ''; |
|
87 | var REPO_LANDING_REV = ''; | |
86 | var REPO_TYPE = ''; |
|
88 | var REPO_TYPE = ''; | |
87 | %endif |
|
89 | %endif | |
88 | var APPLICATION_URL = "${h.url('home').rstrip('/')}"; |
|
90 | var APPLICATION_URL = "${h.url('home').rstrip('/')}"; | |
89 | var ASSET_URL = "${h.asset('')}"; |
|
91 | var ASSET_URL = "${h.asset('')}"; | |
90 | var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}"; |
|
92 | var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}"; | |
91 | var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}"; |
|
93 | var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}"; | |
92 | % if getattr(c, 'rhodecode_user', None): |
|
94 | % if getattr(c, 'rhodecode_user', None): | |
93 | var USER = {name:'${c.rhodecode_user.username}'}; |
|
95 | var USER = {name:'${c.rhodecode_user.username}'}; | |
94 | % else: |
|
96 | % else: | |
95 | var USER = {name:null}; |
|
97 | var USER = {name:null}; | |
96 | % endif |
|
98 | % endif | |
97 |
|
99 | |||
98 | var APPENLIGHT = { |
|
100 | var APPENLIGHT = { | |
99 | enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'}, |
|
101 | enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'}, | |
100 | key: '${getattr(c, "appenlight_api_public_key", "")}', |
|
102 | key: '${getattr(c, "appenlight_api_public_key", "")}', | |
101 | % if getattr(c, 'appenlight_server_url', None): |
|
103 | % if getattr(c, 'appenlight_server_url', None): | |
102 | serverUrl: '${getattr(c, "appenlight_server_url", "")}', |
|
104 | serverUrl: '${getattr(c, "appenlight_server_url", "")}', | |
103 | % endif |
|
105 | % endif | |
104 | requestInfo: { |
|
106 | requestInfo: { | |
105 | % if getattr(c, 'rhodecode_user', None): |
|
107 | % if getattr(c, 'rhodecode_user', None): | |
106 | ip: '${c.rhodecode_user.ip_addr}', |
|
108 | ip: '${c.rhodecode_user.ip_addr}', | |
107 | username: '${c.rhodecode_user.username}' |
|
109 | username: '${c.rhodecode_user.username}' | |
108 | % endif |
|
110 | % endif | |
109 | }, |
|
111 | }, | |
110 | tags: { |
|
112 | tags: { | |
111 | rhodecode_version: '${c.rhodecode_version}', |
|
113 | rhodecode_version: '${c.rhodecode_version}', | |
112 | rhodecode_edition: '${c.rhodecode_edition}' |
|
114 | rhodecode_edition: '${c.rhodecode_edition}' | |
113 | } |
|
115 | } | |
114 | }; |
|
116 | }; | |
115 | </script> |
|
117 | </script> | |
116 | <%include file="/base/plugins_base.html"/> |
|
118 | <%include file="/base/plugins_base.html"/> | |
117 | <!--[if lt IE 9]> |
|
119 | <!--[if lt IE 9]> | |
118 | <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> | |
119 | <![endif]--> |
|
121 | <![endif]--> | |
120 | <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> | |
121 | <script> var alertMessagePayloads = ${h.flash.json_alerts()|n}; </script> |
|
123 | <script> var alertMessagePayloads = ${h.flash.json_alerts()|n}; </script> | |
122 | ## avoide escaping the %N |
|
124 | ## avoide escaping the %N | |
123 | <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> | |
124 | <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> | |
125 |
|
127 | |||
126 |
|
128 | |||
127 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
129 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates | |
128 | ${self.js_extra()} |
|
130 | ${self.js_extra()} | |
129 |
|
131 | |||
130 | <script type="text/javascript"> |
|
132 | <script type="text/javascript"> | |
131 | $(document).ready(function(){ |
|
133 | $(document).ready(function(){ | |
132 | show_more_event(); |
|
134 | show_more_event(); | |
133 | timeagoActivate(); |
|
135 | timeagoActivate(); | |
134 | }) |
|
136 | }) | |
135 | </script> |
|
137 | </script> | |
136 |
|
138 | |||
137 | </%def> |
|
139 | </%def> | |
138 |
|
140 | |||
139 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
141 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates | |
140 | <%def name="js_extra()"></%def> |
|
142 | <%def name="js_extra()"></%def> | |
141 | ${self.js()} |
|
143 | ${self.js()} | |
142 |
|
144 | |||
143 | <%def name="head_extra()"></%def> |
|
145 | <%def name="head_extra()"></%def> | |
144 | ${self.head_extra()} |
|
146 | ${self.head_extra()} | |
145 | ## extra stuff |
|
147 | ## extra stuff | |
146 | %if c.pre_code: |
|
148 | %if c.pre_code: | |
147 | ${c.pre_code|n} |
|
149 | ${c.pre_code|n} | |
148 | %endif |
|
150 | %endif | |
149 | </head> |
|
151 | </head> | |
150 | <body id="body"> |
|
152 | <body id="body"> | |
151 | <noscript> |
|
153 | <noscript> | |
152 | <div class="noscript-error"> |
|
154 | <div class="noscript-error"> | |
153 | ${_('Please enable JavaScript to use RhodeCode Enterprise')} |
|
155 | ${_('Please enable JavaScript to use RhodeCode Enterprise')} | |
154 | </div> |
|
156 | </div> | |
155 | </noscript> |
|
157 | </noscript> | |
156 | ## IE hacks |
|
158 | ## IE hacks | |
157 | <!--[if IE 7]> |
|
159 | <!--[if IE 7]> | |
158 | <script>$(document.body).addClass('ie7')</script> |
|
160 | <script>$(document.body).addClass('ie7')</script> | |
159 | <![endif]--> |
|
161 | <![endif]--> | |
160 | <!--[if IE 8]> |
|
162 | <!--[if IE 8]> | |
161 | <script>$(document.body).addClass('ie8')</script> |
|
163 | <script>$(document.body).addClass('ie8')</script> | |
162 | <![endif]--> |
|
164 | <![endif]--> | |
163 | <!--[if IE 9]> |
|
165 | <!--[if IE 9]> | |
164 | <script>$(document.body).addClass('ie9')</script> |
|
166 | <script>$(document.body).addClass('ie9')</script> | |
165 | <![endif]--> |
|
167 | <![endif]--> | |
166 |
|
168 | |||
167 | ${next.body()} |
|
169 | ${next.body()} | |
168 | %if c.post_code: |
|
170 | %if c.post_code: | |
169 | ${c.post_code|n} |
|
171 | ${c.post_code|n} | |
170 | %endif |
|
172 | %endif | |
171 | <rhodecode-app></rhodecode-app> |
|
173 | <rhodecode-app></rhodecode-app> | |
172 | </body> |
|
174 | </body> | |
173 | </html> |
|
175 | </html> |
General Comments 0
You need to be logged in to leave comments.
Login now