Show More
@@ -1,324 +1,324 b'' | |||||
1 | <%inherit file="/base/base.mako"/> |
|
1 | <%inherit file="/base/base.mako"/> | |
2 |
|
2 | |||
3 | <%def name="title(*args)"> |
|
3 | <%def name="title(*args)"> | |
4 | ${_('%s Files') % c.repo_name} |
|
4 | ${_('%s Files') % c.repo_name} | |
5 | %if hasattr(c,'file'): |
|
5 | %if hasattr(c,'file'): | |
6 | · ${h.safe_unicode(c.file.path) or '\\'} |
|
6 | · ${h.safe_unicode(c.file.path) or '\\'} | |
7 | %endif |
|
7 | %endif | |
8 |
|
8 | |||
9 | %if c.rhodecode_name: |
|
9 | %if c.rhodecode_name: | |
10 | · ${h.branding(c.rhodecode_name)} |
|
10 | · ${h.branding(c.rhodecode_name)} | |
11 | %endif |
|
11 | %endif | |
12 | </%def> |
|
12 | </%def> | |
13 |
|
13 | |||
14 | <%def name="breadcrumbs_links()"> |
|
14 | <%def name="breadcrumbs_links()"> | |
15 | ${_('Files')} |
|
15 | ${_('Files')} | |
16 | %if c.file: |
|
16 | %if c.file: | |
17 | @ ${h.show_id(c.commit)} |
|
17 | @ ${h.show_id(c.commit)} | |
18 | %endif |
|
18 | %endif | |
19 | </%def> |
|
19 | </%def> | |
20 |
|
20 | |||
21 | <%def name="menu_bar_nav()"> |
|
21 | <%def name="menu_bar_nav()"> | |
22 | ${self.menu_items(active='repositories')} |
|
22 | ${self.menu_items(active='repositories')} | |
23 | </%def> |
|
23 | </%def> | |
24 |
|
24 | |||
25 | <%def name="menu_bar_subnav()"> |
|
25 | <%def name="menu_bar_subnav()"> | |
26 | ${self.repo_menu(active='files')} |
|
26 | ${self.repo_menu(active='files')} | |
27 | </%def> |
|
27 | </%def> | |
28 |
|
28 | |||
29 | <%def name="main()"> |
|
29 | <%def name="main()"> | |
30 | <div class="title"> |
|
30 | <div class="title"> | |
31 | ${self.repo_page_title(c.rhodecode_db_repo)} |
|
31 | ${self.repo_page_title(c.rhodecode_db_repo)} | |
32 | </div> |
|
32 | </div> | |
33 |
|
33 | |||
34 | <div id="pjax-container" class="summary"> |
|
34 | <div id="pjax-container" class="summary"> | |
35 | <div id="files_data"> |
|
35 | <div id="files_data"> | |
36 | <%include file='files_pjax.mako'/> |
|
36 | <%include file='files_pjax.mako'/> | |
37 | </div> |
|
37 | </div> | |
38 | </div> |
|
38 | </div> | |
39 | <script> |
|
39 | <script> | |
40 | var curState = { |
|
40 | var curState = { | |
41 | commit_id: "${c.commit.raw_id}" |
|
41 | commit_id: "${c.commit.raw_id}" | |
42 | }; |
|
42 | }; | |
43 |
|
43 | |||
44 | var getState = function(context) { |
|
44 | var getState = function(context) { | |
45 | var url = $(location).attr('href'); |
|
45 | var url = $(location).attr('href'); | |
46 | var _base_url = '${h.route_path("repo_files",repo_name=c.repo_name,commit_id='',f_path='')}'; |
|
46 | var _base_url = '${h.route_path("repo_files",repo_name=c.repo_name,commit_id='',f_path='')}'; | |
47 | var _annotate_url = '${h.route_path("repo_files:annotated",repo_name=c.repo_name,commit_id='',f_path='')}'; |
|
47 | var _annotate_url = '${h.route_path("repo_files:annotated",repo_name=c.repo_name,commit_id='',f_path='')}'; | |
48 | _base_url = _base_url.replace('//', '/'); |
|
48 | _base_url = _base_url.replace('//', '/'); | |
49 | _annotate_url = _annotate_url.replace('//', '/'); |
|
49 | _annotate_url = _annotate_url.replace('//', '/'); | |
50 |
|
50 | |||
51 | //extract f_path from url. |
|
51 | //extract f_path from url. | |
52 | var parts = url.split(_base_url); |
|
52 | var parts = url.split(_base_url); | |
53 | if (parts.length != 2) { |
|
53 | if (parts.length != 2) { | |
54 | parts = url.split(_annotate_url); |
|
54 | parts = url.split(_annotate_url); | |
55 | if (parts.length != 2) { |
|
55 | if (parts.length != 2) { | |
56 | var rev = "tip"; |
|
56 | var rev = "tip"; | |
57 | var f_path = ""; |
|
57 | var f_path = ""; | |
58 | } else { |
|
58 | } else { | |
59 | var parts2 = parts[1].split('/'); |
|
59 | var parts2 = parts[1].split('/'); | |
60 | var rev = parts2.shift(); // pop the first element which is the revision |
|
60 | var rev = parts2.shift(); // pop the first element which is the revision | |
61 | var f_path = parts2.join('/'); |
|
61 | var f_path = parts2.join('/'); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | } else { |
|
64 | } else { | |
65 | var parts2 = parts[1].split('/'); |
|
65 | var parts2 = parts[1].split('/'); | |
66 | var rev = parts2.shift(); // pop the first element which is the revision |
|
66 | var rev = parts2.shift(); // pop the first element which is the revision | |
67 | var f_path = parts2.join('/'); |
|
67 | var f_path = parts2.join('/'); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | var _node_list_url = pyroutes.url('repo_files_nodelist', |
|
70 | var _node_list_url = pyroutes.url('repo_files_nodelist', | |
71 | {repo_name: templateContext.repo_name, |
|
71 | {repo_name: templateContext.repo_name, | |
72 | commit_id: rev, f_path: f_path}); |
|
72 | commit_id: rev, f_path: f_path}); | |
73 | var _url_base = pyroutes.url('repo_files', |
|
73 | var _url_base = pyroutes.url('repo_files', | |
74 | {repo_name: templateContext.repo_name, |
|
74 | {repo_name: templateContext.repo_name, | |
75 | commit_id: rev, f_path:'__FPATH__'}); |
|
75 | commit_id: rev, f_path:'__FPATH__'}); | |
76 | return { |
|
76 | return { | |
77 | url: url, |
|
77 | url: url, | |
78 | f_path: f_path, |
|
78 | f_path: f_path, | |
79 | rev: rev, |
|
79 | rev: rev, | |
80 | commit_id: curState.commit_id, |
|
80 | commit_id: curState.commit_id, | |
81 | node_list_url: _node_list_url, |
|
81 | node_list_url: _node_list_url, | |
82 | url_base: _url_base |
|
82 | url_base: _url_base | |
83 | }; |
|
83 | }; | |
84 | }; |
|
84 | }; | |
85 |
|
85 | |||
86 | var metadataRequest = null; |
|
86 | var metadataRequest = null; | |
87 | var getFilesMetadata = function() { |
|
87 | var getFilesMetadata = function() { | |
88 | if (metadataRequest && metadataRequest.readyState != 4) { |
|
88 | if (metadataRequest && metadataRequest.readyState != 4) { | |
89 | metadataRequest.abort(); |
|
89 | metadataRequest.abort(); | |
90 | } |
|
90 | } | |
91 | if (fileSourcePage) { |
|
91 | if (fileSourcePage) { | |
92 | return false; |
|
92 | return false; | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | if ($('#file-tree-wrapper').hasClass('full-load')) { |
|
95 | if ($('#file-tree-wrapper').hasClass('full-load')) { | |
96 | // in case our HTML wrapper has full-load class we don't |
|
96 | // in case our HTML wrapper has full-load class we don't | |
97 | // trigger the async load of metadata |
|
97 | // trigger the async load of metadata | |
98 | return false; |
|
98 | return false; | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | var state = getState('metadata'); |
|
101 | var state = getState('metadata'); | |
102 | var url_data = { |
|
102 | var url_data = { | |
103 | 'repo_name': templateContext.repo_name, |
|
103 | 'repo_name': templateContext.repo_name, | |
104 | 'commit_id': state.commit_id, |
|
104 | 'commit_id': state.commit_id, | |
105 | 'f_path': state.f_path |
|
105 | 'f_path': state.f_path | |
106 | }; |
|
106 | }; | |
107 |
|
107 | |||
108 | var url = pyroutes.url('repo_nodetree_full', url_data); |
|
108 | var url = pyroutes.url('repo_nodetree_full', url_data); | |
109 |
|
109 | |||
110 | metadataRequest = $.ajax({url: url}); |
|
110 | metadataRequest = $.ajax({url: url}); | |
111 |
|
111 | |||
112 | metadataRequest.done(function(data) { |
|
112 | metadataRequest.done(function(data) { | |
113 | $('#file-tree').html(data); |
|
113 | $('#file-tree').html(data); | |
114 | timeagoActivate(); |
|
114 | timeagoActivate(); | |
115 | }); |
|
115 | }); | |
116 | metadataRequest.fail(function (data, textStatus, errorThrown) { |
|
116 | metadataRequest.fail(function (data, textStatus, errorThrown) { | |
117 | console.log(data); |
|
117 | console.log(data); | |
118 | if (data.status != 0) { |
|
118 | if (data.status != 0) { | |
119 | alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText)); |
|
119 | alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText)); | |
120 | } |
|
120 | } | |
121 | }); |
|
121 | }); | |
122 | }; |
|
122 | }; | |
123 |
|
123 | |||
124 | var callbacks = function() { |
|
124 | var callbacks = function() { | |
125 | var state = getState('callbacks'); |
|
125 | var state = getState('callbacks'); | |
126 | timeagoActivate(); |
|
126 | timeagoActivate(); | |
127 |
|
127 | |||
128 | // used for history, and switch to |
|
128 | // used for history, and switch to | |
129 | var initialCommitData = { |
|
129 | var initialCommitData = { | |
130 | id: null, |
|
130 | id: null, | |
131 | text: '${_("Pick Commit")}', |
|
131 | text: '${_("Pick Commit")}', | |
132 | type: 'sha', |
|
132 | type: 'sha', | |
133 | raw_id: null, |
|
133 | raw_id: null, | |
134 | files_url: null |
|
134 | files_url: null | |
135 | }; |
|
135 | }; | |
136 |
|
136 | |||
137 | if ($('#trimmed_message_box').height() < 50) { |
|
137 | if ($('#trimmed_message_box').height() < 50) { | |
138 | $('#message_expand').hide(); |
|
138 | $('#message_expand').hide(); | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | $('#message_expand').on('click', function(e) { |
|
141 | $('#message_expand').on('click', function(e) { | |
142 | $('#trimmed_message_box').css('max-height', 'none'); |
|
142 | $('#trimmed_message_box').css('max-height', 'none'); | |
143 | $(this).hide(); |
|
143 | $(this).hide(); | |
144 | }); |
|
144 | }); | |
145 |
|
145 | |||
146 | if (fileSourcePage) { |
|
146 | if (fileSourcePage) { | |
147 | // variants for with source code, not tree view |
|
147 | // variants for with source code, not tree view | |
148 |
|
148 | |||
149 | // select code link event |
|
149 | // select code link event | |
150 | $("#hlcode").mouseup(getSelectionLink); |
|
150 | $("#hlcode").mouseup(getSelectionLink); | |
151 |
|
151 | |||
152 | // file history select2 |
|
152 | // file history select2 | |
153 | select2FileHistorySwitcher('#diff1', initialCommitData, state); |
|
153 | select2FileHistorySwitcher('#diff1', initialCommitData, state); | |
154 |
|
154 | |||
155 | // show at, diff to actions handlers |
|
155 | // show at, diff to actions handlers | |
156 | $('#diff1').on('change', function(e) { |
|
156 | $('#diff1').on('change', function(e) { | |
157 | $('#diff_to_commit').removeClass('disabled').removeAttr("disabled"); |
|
157 | $('#diff_to_commit').removeClass('disabled').removeAttr("disabled"); | |
158 | $('#diff_to_commit').val(_gettext('Diff to Commit ') + e.val.truncateAfter(8, '...')); |
|
158 | $('#diff_to_commit').val(_gettext('Diff to Commit ') + e.val.truncateAfter(8, '...')); | |
159 |
|
159 | |||
160 | $('#show_at_commit').removeClass('disabled').removeAttr("disabled"); |
|
160 | $('#show_at_commit').removeClass('disabled').removeAttr("disabled"); | |
161 | $('#show_at_commit').val(_gettext('Show at Commit ') + e.val.truncateAfter(8, '...')); |
|
161 | $('#show_at_commit').val(_gettext('Show at Commit ') + e.val.truncateAfter(8, '...')); | |
162 | }); |
|
162 | }); | |
163 |
|
163 | |||
164 | $('#diff_to_commit').on('click', function(e) { |
|
164 | $('#diff_to_commit').on('click', function(e) { | |
165 | var diff1 = $('#diff1').val(); |
|
165 | var diff1 = $('#diff1').val(); | |
166 | var diff2 = $('#diff2').val(); |
|
166 | var diff2 = $('#diff2').val(); | |
167 |
|
167 | |||
168 | var url_data = { |
|
168 | var url_data = { | |
169 | repo_name: templateContext.repo_name, |
|
169 | repo_name: templateContext.repo_name, | |
170 | source_ref: diff1, |
|
170 | source_ref: diff1, | |
171 | source_ref_type: 'rev', |
|
171 | source_ref_type: 'rev', | |
172 | target_ref: diff2, |
|
172 | target_ref: diff2, | |
173 | target_ref_type: 'rev', |
|
173 | target_ref_type: 'rev', | |
174 | merge: 1, |
|
174 | merge: 1, | |
175 | f_path: state.f_path |
|
175 | f_path: state.f_path | |
176 | }; |
|
176 | }; | |
177 | window.location = pyroutes.url('repo_compare', url_data); |
|
177 | window.location = pyroutes.url('repo_compare', url_data); | |
178 | }); |
|
178 | }); | |
179 |
|
179 | |||
180 | $('#show_at_commit').on('click', function(e) { |
|
180 | $('#show_at_commit').on('click', function(e) { | |
181 | var diff1 = $('#diff1').val(); |
|
181 | var diff1 = $('#diff1').val(); | |
182 |
|
182 | |||
183 | var annotate = $('#annotate').val(); |
|
183 | var annotate = $('#annotate').val(); | |
184 | if (annotate === "True") { |
|
184 | if (annotate === "True") { | |
185 | var url = pyroutes.url('repo_files:annotated', |
|
185 | var url = pyroutes.url('repo_files:annotated', | |
186 | {'repo_name': templateContext.repo_name, |
|
186 | {'repo_name': templateContext.repo_name, | |
187 | 'commit_id': diff1, 'f_path': state.f_path}); |
|
187 | 'commit_id': diff1, 'f_path': state.f_path}); | |
188 | } else { |
|
188 | } else { | |
189 | var url = pyroutes.url('repo_files', |
|
189 | var url = pyroutes.url('repo_files', | |
190 | {'repo_name': templateContext.repo_name, |
|
190 | {'repo_name': templateContext.repo_name, | |
191 | 'commit_id': diff1, 'f_path': state.f_path}); |
|
191 | 'commit_id': diff1, 'f_path': state.f_path}); | |
192 | } |
|
192 | } | |
193 | window.location = url; |
|
193 | window.location = url; | |
194 |
|
194 | |||
195 | }); |
|
195 | }); | |
196 |
|
196 | |||
197 | // show more authors |
|
197 | // show more authors | |
198 | $('#show_authors').on('click', function(e) { |
|
198 | $('#show_authors').on('click', function(e) { | |
199 | e.preventDefault(); |
|
199 | e.preventDefault(); | |
200 | var url = pyroutes.url('repo_file_authors', |
|
200 | var url = pyroutes.url('repo_file_authors', | |
201 | {'repo_name': templateContext.repo_name, |
|
201 | {'repo_name': templateContext.repo_name, | |
202 | 'commit_id': state.rev, 'f_path': state.f_path}); |
|
202 | 'commit_id': state.rev, 'f_path': state.f_path}); | |
203 |
|
203 | |||
204 | $.pjax({ |
|
204 | $.pjax({ | |
205 | url: url, |
|
205 | url: url, | |
206 | data: 'annotate=${"1" if c.annotate else "0"}', |
|
206 | data: 'annotate=${"1" if c.annotate else "0"}', | |
207 | container: '#file_authors', |
|
207 | container: '#file_authors', | |
208 | push: false, |
|
208 | push: false, | |
209 | timeout: pjaxTimeout |
|
209 | timeout: pjaxTimeout | |
210 | }).complete(function(){ |
|
210 | }).complete(function(){ | |
211 | $('#show_authors').hide(); |
|
211 | $('#show_authors').hide(); | |
212 | }) |
|
212 | }) | |
213 | }); |
|
213 | }); | |
214 |
|
214 | |||
215 | // load file short history |
|
215 | // load file short history | |
216 | $('#file_history_overview').on('click', function(e) { |
|
216 | $('#file_history_overview').on('click', function(e) { | |
217 | e.preventDefault(); |
|
217 | e.preventDefault(); | |
218 | path = state.f_path; |
|
218 | path = state.f_path; | |
219 | if (path.indexOf("#") >= 0) { |
|
219 | if (path.indexOf("#") >= 0) { | |
220 | path = path.slice(0, path.indexOf("#")); |
|
220 | path = path.slice(0, path.indexOf("#")); | |
221 | } |
|
221 | } | |
222 | var url = pyroutes.url('repo_changelog_file', |
|
222 | var url = pyroutes.url('repo_changelog_file', | |
223 | {'repo_name': templateContext.repo_name, |
|
223 | {'repo_name': templateContext.repo_name, | |
224 | 'commit_id': state.rev, 'f_path': path, 'limit': 6}); |
|
224 | 'commit_id': state.rev, 'f_path': path, 'limit': 6}); | |
225 | $('#file_history_container').show(); |
|
225 | $('#file_history_container').show(); | |
226 | $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...'))); |
|
226 | $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...'))); | |
227 |
|
227 | |||
228 | $.pjax({ |
|
228 | $.pjax({ | |
229 | url: url, |
|
229 | url: url, | |
230 | container: '#file_history_container', |
|
230 | container: '#file_history_container', | |
231 | push: false, |
|
231 | push: false, | |
232 | timeout: pjaxTimeout |
|
232 | timeout: pjaxTimeout | |
233 | }) |
|
233 | }) | |
234 | }); |
|
234 | }); | |
235 |
|
235 | |||
236 | } |
|
236 | } | |
237 | else { |
|
237 | else { | |
238 | getFilesMetadata(); |
|
238 | getFilesMetadata(); | |
239 |
|
239 | |||
240 | // fuzzy file filter |
|
240 | // fuzzy file filter | |
241 | fileBrowserListeners(state.node_list_url, state.url_base); |
|
241 | fileBrowserListeners(state.node_list_url, state.url_base); | |
242 |
|
242 | |||
243 | // switch to widget |
|
243 | // switch to widget | |
244 | select2RefSwitcher('#refs_filter', initialCommitData); |
|
244 | select2RefSwitcher('#refs_filter', initialCommitData); | |
245 | $('#refs_filter').on('change', function(e) { |
|
245 | $('#refs_filter').on('change', function(e) { | |
246 | var data = $('#refs_filter').select2('data'); |
|
246 | var data = $('#refs_filter').select2('data'); | |
247 | curState.commit_id = data.raw_id; |
|
247 | curState.commit_id = data.raw_id; | |
248 | $.pjax({url: data.files_url, container: '#pjax-container', timeout: pjaxTimeout}); |
|
248 | $.pjax({url: data.files_url, container: '#pjax-container', timeout: pjaxTimeout}); | |
249 | }); |
|
249 | }); | |
250 |
|
250 | |||
251 | $("#prev_commit_link").on('click', function(e) { |
|
251 | $("#prev_commit_link").on('click', function(e) { | |
252 | var data = $(this).data(); |
|
252 | var data = $(this).data(); | |
253 | curState.commit_id = data.commitId; |
|
253 | curState.commit_id = data.commitId; | |
254 | }); |
|
254 | }); | |
255 |
|
255 | |||
256 | $("#next_commit_link").on('click', function(e) { |
|
256 | $("#next_commit_link").on('click', function(e) { | |
257 | var data = $(this).data(); |
|
257 | var data = $(this).data(); | |
258 | curState.commit_id = data.commitId; |
|
258 | curState.commit_id = data.commitId; | |
259 | }); |
|
259 | }); | |
260 |
|
260 | |||
261 | $('#at_rev').on("keypress", function(e) { |
|
261 | $('#at_rev').on("keypress", function(e) { | |
262 | /* ENTER PRESSED */ |
|
262 | /* ENTER PRESSED */ | |
263 | if (e.keyCode === 13) { |
|
263 | if (e.keyCode === 13) { | |
264 | var rev = $('#at_rev').val(); |
|
264 | var rev = $('#at_rev').val(); | |
265 | // explicit reload page here. with pjax entering bad input |
|
265 | // explicit reload page here. with pjax entering bad input | |
266 | // produces not so nice results |
|
266 | // produces not so nice results | |
267 | window.location = pyroutes.url('repo_files', |
|
267 | window.location = pyroutes.url('repo_files', | |
268 | {'repo_name': templateContext.repo_name, |
|
268 | {'repo_name': templateContext.repo_name, | |
269 | 'commit_id': rev, 'f_path': state.f_path}); |
|
269 | 'commit_id': rev, 'f_path': state.f_path}); | |
270 | } |
|
270 | } | |
271 | }); |
|
271 | }); | |
272 | } |
|
272 | } | |
273 | }; |
|
273 | }; | |
274 |
|
274 | |||
275 | var pjaxTimeout = 5000; |
|
275 | var pjaxTimeout = 5000; | |
276 |
|
276 | |||
277 | $(document).pjax(".pjax-link", "#pjax-container", { |
|
277 | $(document).pjax(".pjax-link", "#pjax-container", { | |
278 | "fragment": "#pjax-content", |
|
278 | "fragment": "#pjax-content", | |
279 | "maxCacheLength": 1000, |
|
279 | "maxCacheLength": 1000, | |
280 | "timeout": pjaxTimeout |
|
280 | "timeout": pjaxTimeout | |
281 | }); |
|
281 | }); | |
282 |
|
282 | |||
283 | // define global back/forward states |
|
283 | // define global back/forward states | |
284 | var isPjaxPopState = false; |
|
284 | var isPjaxPopState = false; | |
285 | $(document).on('pjax:popstate', function() { |
|
285 | $(document).on('pjax:popstate', function() { | |
286 | isPjaxPopState = true; |
|
286 | isPjaxPopState = true; | |
287 | }); |
|
287 | }); | |
288 |
|
288 | |||
289 | $(document).on('pjax:end', function(xhr, options) { |
|
289 | $(document).on('pjax:end', function(xhr, options) { | |
290 | if (isPjaxPopState) { |
|
290 | if (isPjaxPopState) { | |
291 | isPjaxPopState = false; |
|
291 | isPjaxPopState = false; | |
292 | callbacks(); |
|
292 | callbacks(); | |
293 | _NODEFILTER.resetFilter(); |
|
293 | _NODEFILTER.resetFilter(); | |
294 | } |
|
294 | } | |
295 |
|
295 | |||
296 | // run callback for tracking if defined for google analytics etc. |
|
296 | // run callback for tracking if defined for google analytics etc. | |
297 | // this is used to trigger tracking on pjax |
|
297 | // this is used to trigger tracking on pjax | |
298 | if (typeof window.rhodecode_statechange_callback !== 'undefined') { |
|
298 | if (typeof window.rhodecode_statechange_callback !== 'undefined') { | |
299 | var state = getState('statechange'); |
|
299 | var state = getState('statechange'); | |
300 | rhodecode_statechange_callback(state.url, null) |
|
300 | rhodecode_statechange_callback(state.url, null) | |
301 | } |
|
301 | } | |
302 | }); |
|
302 | }); | |
303 |
|
303 | |||
304 | $(document).on('pjax:success', function(event, xhr, options) { |
|
304 | $(document).on('pjax:success', function(event, xhr, options) { | |
305 | if (event.target.id == "file_history_container") { |
|
305 | if (event.target.id == "file_history_container") { | |
306 | $('#file_history_overview').hide(); |
|
306 | $('#file_history_overview').hide(); | |
307 | $('#file_history_overview_full').show(); |
|
307 | $('#file_history_overview_full').show(); | |
308 | timeagoActivate(); |
|
308 | timeagoActivate(); | |
309 | } else { |
|
309 | } else { | |
310 | callbacks(); |
|
310 | callbacks(); | |
311 | } |
|
311 | } | |
312 | }); |
|
312 | }); | |
313 |
|
313 | |||
314 | $(document).ready(function() { |
|
314 | $(document).ready(function() { | |
315 | callbacks(); |
|
315 | callbacks(); | |
316 | var search_GET = "${request.GET.get('search','')}"; |
|
316 | var search_GET = "${request.GET.get('search','')}"; | |
317 | if (search_GET == "1") { |
|
317 | if (search_GET === "1") { | |
318 | _NODEFILTER.initFilter(); |
|
318 | _NODEFILTER.initFilter(); | |
319 | } |
|
319 | } | |
320 | }); |
|
320 | }); | |
321 |
|
321 | |||
322 | </script> |
|
322 | </script> | |
323 |
|
323 | |||
324 | </%def> |
|
324 | </%def> |
@@ -1,109 +1,130 b'' | |||||
1 | <%namespace name="sourceblock" file="/codeblocks/source.mako"/> |
|
1 | <%namespace name="sourceblock" file="/codeblocks/source.mako"/> | |
2 |
|
2 | |||
3 | <div id="codeblock" class="codeblock"> |
|
3 | <div id="codeblock" class="codeblock"> | |
4 | <div class="codeblock-header"> |
|
4 | <div class="codeblock-header"> | |
5 | <div class="stats"> |
|
5 | <div class="stats"> | |
6 | <span class="stats-filename"> |
|
6 | <span class="stats-filename"> | |
7 | <strong> |
|
7 | <strong> | |
8 | <i class="icon-file-text"></i> |
|
8 | <i class="icon-file-text"></i> | |
9 | ${c.file.unicode_path_safe} |
|
9 | ${c.file.unicode_path_safe} | |
10 | </strong> |
|
10 | </strong> | |
11 | </span> |
|
11 | </span> | |
12 | <span class="item last"><i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.f_path}" title="${_('Copy the full path')}"></i></span> |
|
12 | <span class="item last"><i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.f_path}" title="${_('Copy the full path')}"></i></span> | |
13 | <br/> |
|
13 | <br/> | |
14 |
|
14 | |||
15 | % if c.lf_node: |
|
15 | % if c.lf_node: | |
16 | <span title="${_('This file is a pointer to large binary file')}"> | ${_('LargeFile')} ${h.format_byte_size_binary(c.lf_node.size)} </span> |
|
16 | <span title="${_('This file is a pointer to large binary file')}"> | ${_('LargeFile')} ${h.format_byte_size_binary(c.lf_node.size)} </span> | |
17 | % endif |
|
17 | % endif | |
18 |
|
18 | |||
19 | <span class="stats-first-item">${c.file.lines()[0]} ${_ungettext('line', 'lines', c.file.lines()[0])}</span> |
|
19 | <span class="stats-first-item">${c.file.lines()[0]} ${_ungettext('line', 'lines', c.file.lines()[0])}</span> | |
20 | <span> | ${h.format_byte_size_binary(c.file.size)}</span> |
|
20 | <span> | ${h.format_byte_size_binary(c.file.size)}</span> | |
21 | <span> | ${c.file.mimetype} </span> |
|
21 | <span> | ${c.file.mimetype} </span> | |
22 | <span> | ${h.get_lexer_for_filenode(c.file).__class__.__name__}</span> |
|
22 | <span> | ${h.get_lexer_for_filenode(c.file).__class__.__name__}</span> | |
23 |
|
23 | |||
24 | </div> |
|
24 | </div> | |
25 | <div class="buttons"> |
|
25 | <div class="buttons"> | |
26 | <a id="file_history_overview" href="#"> |
|
26 | <a id="file_history_overview" href="#"> | |
27 | ${_('History')} |
|
27 | ${_('History')} | |
28 | </a> |
|
28 | </a> | |
29 | <a id="file_history_overview_full" style="display: none" href="${h.route_path('repo_changelog_file',repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path)}"> |
|
29 | <a id="file_history_overview_full" style="display: none" href="${h.route_path('repo_changelog_file',repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path)}"> | |
30 | ${_('Show Full History')} |
|
30 | ${_('Show Full History')} | |
31 | </a> | |
|
31 | </a> | | |
32 | %if c.annotate: |
|
32 | %if c.annotate: | |
33 | ${h.link_to(_('Source'), h.route_path('repo_files', repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))} |
|
33 | ${h.link_to(_('Source'), h.route_path('repo_files', repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))} | |
34 | %else: |
|
34 | %else: | |
35 | ${h.link_to(_('Annotation'), h.route_path('repo_files:annotated',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))} |
|
35 | ${h.link_to(_('Annotation'), h.route_path('repo_files:annotated',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))} | |
36 | %endif |
|
36 | %endif | |
37 | | ${h.link_to(_('Raw'), h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))} |
|
37 | | ${h.link_to(_('Raw'), h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))} | |
38 | | |
|
38 | | | |
39 | % if c.lf_node: |
|
39 | % if c.lf_node: | |
40 | <a href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path, _query=dict(lf=1))}"> |
|
40 | <a href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path, _query=dict(lf=1))}"> | |
41 | ${_('Download largefile')} |
|
41 | ${_('Download largefile')} | |
42 | </a> |
|
42 | </a> | |
43 | % else: |
|
43 | % else: | |
44 | <a href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}"> |
|
44 | <a href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}"> | |
45 | ${_('Download')} |
|
45 | ${_('Download')} | |
46 | </a> |
|
46 | </a> | |
47 | % endif |
|
47 | % endif | |
48 |
|
48 | |||
49 | %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name): |
|
49 | %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name): | |
50 | | |
|
50 | | | |
51 | %if c.on_branch_head and c.branch_or_raw_id and not c.file.is_binary: |
|
51 | %if c.on_branch_head and c.branch_or_raw_id and not c.file.is_binary: | |
52 | <a href="${h.route_path('repo_files_edit_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _anchor='edit')}"> |
|
52 | <a href="${h.route_path('repo_files_edit_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _anchor='edit')}"> | |
53 | ${_('Edit on Branch:{}').format(c.branch_name)} |
|
53 | ${_('Edit on Branch:{}').format(c.branch_name)} | |
54 | </a> |
|
54 | </a> | |
55 | | <a class="btn-danger btn-link" href="${h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _anchor='edit')}">${_('Delete')} |
|
55 | | <a class="btn-danger btn-link" href="${h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _anchor='edit')}">${_('Delete')} | |
56 | </a> |
|
56 | </a> | |
57 | %elif c.on_branch_head and c.branch_or_raw_id and c.file.is_binary: |
|
57 | %elif c.on_branch_head and c.branch_or_raw_id and c.file.is_binary: | |
58 | ${h.link_to(_('Edit'), '#', class_="btn btn-link disabled tooltip", title=_('Editing binary files not allowed'))} |
|
58 | ${h.link_to(_('Edit'), '#', class_="btn btn-link disabled tooltip", title=_('Editing binary files not allowed'))} | |
59 | | ${h.link_to(_('Delete'), h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _anchor='edit'),class_="btn-danger btn-link")} |
|
59 | | ${h.link_to(_('Delete'), h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _anchor='edit'),class_="btn-danger btn-link")} | |
60 | %else: |
|
60 | %else: | |
61 | ${h.link_to(_('Edit'), '#', class_="btn btn-link disabled tooltip", title=_('Editing files allowed only when on branch head commit'))} |
|
61 | ${h.link_to(_('Edit'), '#', class_="btn btn-link disabled tooltip", title=_('Editing files allowed only when on branch head commit'))} | |
62 | | ${h.link_to(_('Delete'), '#', class_="btn btn-danger btn-link disabled tooltip", title=_('Deleting files allowed only when on branch head commit'))} |
|
62 | | ${h.link_to(_('Delete'), '#', class_="btn btn-danger btn-link disabled tooltip", title=_('Deleting files allowed only when on branch head commit'))} | |
63 | %endif |
|
63 | %endif | |
64 | %endif |
|
64 | %endif | |
65 | </div> |
|
65 | </div> | |
66 | </div> |
|
66 | </div> | |
67 | <div id="file_history_container"></div> |
|
67 | <div id="file_history_container"></div> | |
68 | <div class="code-body"> |
|
68 | <div class="code-body"> | |
69 | %if c.file.is_binary: |
|
69 | %if c.file.is_binary: | |
70 | <% rendered_binary = h.render_binary(c.repo_name, c.file)%> |
|
70 | <% rendered_binary = h.render_binary(c.repo_name, c.file)%> | |
71 | % if rendered_binary: |
|
71 | % if rendered_binary: | |
72 | ${rendered_binary} |
|
72 | ${rendered_binary} | |
73 | % else: |
|
73 | % else: | |
74 | <div> |
|
74 | <div> | |
75 | ${_('Binary file (%s)') % c.file.mimetype} |
|
75 | ${_('Binary file (%s)') % c.file.mimetype} | |
76 | </div> |
|
76 | </div> | |
77 | % endif |
|
77 | % endif | |
78 | %else: |
|
78 | %else: | |
79 | % if c.file.size < c.visual.cut_off_limit_file: |
|
79 | % if c.file.size < c.visual.cut_off_limit_file: | |
80 | %if c.renderer and not c.annotate: |
|
80 | %if c.renderer and not c.annotate: | |
81 | ## pick relative url based on renderer |
|
81 | ## pick relative url based on renderer | |
82 | <% |
|
82 | <% | |
83 | relative_urls = { |
|
83 | relative_urls = { | |
84 | 'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path), |
|
84 | 'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path), | |
85 | 'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path), |
|
85 | 'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path), | |
86 | } |
|
86 | } | |
87 | %> |
|
87 | %> | |
88 | ${h.render(c.file.content, renderer=c.renderer, relative_urls=relative_urls)} |
|
88 | ${h.render(c.file.content, renderer=c.renderer, relative_urls=relative_urls)} | |
89 | %else: |
|
89 | %else: | |
90 | <table class="cb codehilite"> |
|
90 | <table class="cb codehilite"> | |
91 | %if c.annotate: |
|
91 | %if c.annotate: | |
92 | <% color_hasher = h.color_hasher() %> |
|
92 | <% color_hasher = h.color_hasher() %> | |
93 | %for annotation, lines in c.annotated_lines: |
|
93 | %for annotation, lines in c.annotated_lines: | |
94 | ${sourceblock.render_annotation_lines(annotation, lines, color_hasher)} |
|
94 | ${sourceblock.render_annotation_lines(annotation, lines, color_hasher)} | |
95 | %endfor |
|
95 | %endfor | |
96 | %else: |
|
96 | %else: | |
97 | %for line_num, tokens in enumerate(c.lines, 1): |
|
97 | %for line_num, tokens in enumerate(c.lines, 1): | |
98 | ${sourceblock.render_line(line_num, tokens)} |
|
98 | ${sourceblock.render_line(line_num, tokens)} | |
99 | %endfor |
|
99 | %endfor | |
100 | %endif |
|
100 | %endif | |
101 | </table> |
|
101 | </table> | |
102 | %endif |
|
102 | %endif | |
103 | %else: |
|
103 | %else: | |
104 | ${_('File size {} is bigger then allowed limit {}. ').format(h.format_byte_size_binary(c.file.size), h.format_byte_size_binary(c.visual.cut_off_limit_file))} ${h.link_to(_('Show as raw'), |
|
104 | ${_('File size {} is bigger then allowed limit {}. ').format(h.format_byte_size_binary(c.file.size), h.format_byte_size_binary(c.visual.cut_off_limit_file))} ${h.link_to(_('Show as raw'), | |
105 | h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))} |
|
105 | h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))} | |
106 | %endif |
|
106 | %endif | |
107 | %endif |
|
107 | %endif | |
108 | </div> |
|
108 | </div> | |
109 | </div> No newline at end of file |
|
109 | </div> | |
|
110 | ||||
|
111 | <script type="text/javascript"> | |||
|
112 | % if request.GET.get('mark'): | |||
|
113 | ||||
|
114 | $(function(){ | |||
|
115 | $(".codehilite").mark( | |||
|
116 | "${request.GET.get('mark')}", | |||
|
117 | { | |||
|
118 | "className": 'match', | |||
|
119 | "accuracy": "complementary", | |||
|
120 | "ignorePunctuation": ":._(){}[]!'+=".split(""), | |||
|
121 | "each": function(el) { | |||
|
122 | // and also highlight lines ! | |||
|
123 | $($(el).closest('tr')).find('td.cb-lineno').addClass('cb-line-selected'); | |||
|
124 | } | |||
|
125 | } | |||
|
126 | ); | |||
|
127 | ||||
|
128 | }); | |||
|
129 | % endif | |||
|
130 | </script> |
General Comments 0
You need to be logged in to leave comments.
Login now