Show More
@@ -1,379 +1,379 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 | ${_('{} Files').format(c.repo_name)} |
|
4 | ${_('{} Files').format(c.repo_name)} | |
5 | %if hasattr(c,'file'): |
|
5 | %if hasattr(c,'file'): | |
6 |
· ${(h.safe_ |
|
6 | · ${(h.safe_str(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 | <script type="text/javascript"> |
|
30 | <script type="text/javascript"> | |
31 | var fileSourcePage = ${c.file_source_page}; |
|
31 | var fileSourcePage = ${c.file_source_page}; | |
32 | var atRef = '${request.GET.get('at', '')}'; |
|
32 | var atRef = '${request.GET.get('at', '')}'; | |
33 |
|
33 | |||
34 | // global state for fetching metadata |
|
34 | // global state for fetching metadata | |
35 | metadataRequest = null; |
|
35 | metadataRequest = null; | |
36 |
|
36 | |||
37 | // global metadata about URL |
|
37 | // global metadata about URL | |
38 | filesUrlData = ${h.files_url_data(request)|n}; |
|
38 | filesUrlData = ${h.files_url_data(request)|n}; | |
39 | </script> |
|
39 | </script> | |
40 |
|
40 | |||
41 | <div> |
|
41 | <div> | |
42 | <div> |
|
42 | <div> | |
43 | <%include file='files_pjax.mako'/> |
|
43 | <%include file='files_pjax.mako'/> | |
44 | </div> |
|
44 | </div> | |
45 | </div> |
|
45 | </div> | |
46 |
|
46 | |||
47 | <script type="text/javascript"> |
|
47 | <script type="text/javascript"> | |
48 |
|
48 | |||
49 | var initFileJS = function () { |
|
49 | var initFileJS = function () { | |
50 | var state = getFileState(); |
|
50 | var state = getFileState(); | |
51 |
|
51 | |||
52 | // select code link event |
|
52 | // select code link event | |
53 | $("#hlcode").mouseup(getSelectionLink); |
|
53 | $("#hlcode").mouseup(getSelectionLink); | |
54 |
|
54 | |||
55 | // file history select2 used for history of file, and switch to |
|
55 | // file history select2 used for history of file, and switch to | |
56 | var initialCommitData = { |
|
56 | var initialCommitData = { | |
57 | at_ref: atRef, |
|
57 | at_ref: atRef, | |
58 | id: null, |
|
58 | id: null, | |
59 | text: '${c.commit.raw_id}', |
|
59 | text: '${c.commit.raw_id}', | |
60 | type: 'sha', |
|
60 | type: 'sha', | |
61 | raw_id: '${c.commit.raw_id}', |
|
61 | raw_id: '${c.commit.raw_id}', | |
62 | idx: ${c.commit.idx}, |
|
62 | idx: ${c.commit.idx}, | |
63 | files_url: null, |
|
63 | files_url: null, | |
64 | }; |
|
64 | }; | |
65 |
|
65 | |||
66 | // check if we have ref info. |
|
66 | // check if we have ref info. | |
67 | var selectedRef = fileTreeRefs[atRef]; |
|
67 | var selectedRef = fileTreeRefs[atRef]; | |
68 | if (selectedRef !== undefined) { |
|
68 | if (selectedRef !== undefined) { | |
69 | $.extend(initialCommitData, selectedRef) |
|
69 | $.extend(initialCommitData, selectedRef) | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.commit_id,'f_path': state.f_path}); |
|
72 | var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.commit_id,'f_path': state.f_path}); | |
73 | var cacheKey = '__SINGLE_FILE_REFS__'; |
|
73 | var cacheKey = '__SINGLE_FILE_REFS__'; | |
74 | var cachedDataSource = {}; |
|
74 | var cachedDataSource = {}; | |
75 |
|
75 | |||
76 | var loadRefsData = function (query) { |
|
76 | var loadRefsData = function (query) { | |
77 | $.ajax({ |
|
77 | $.ajax({ | |
78 | url: loadUrl, |
|
78 | url: loadUrl, | |
79 | data: {}, |
|
79 | data: {}, | |
80 | dataType: 'json', |
|
80 | dataType: 'json', | |
81 | type: 'GET', |
|
81 | type: 'GET', | |
82 | success: function (data) { |
|
82 | success: function (data) { | |
83 | cachedDataSource[cacheKey] = data; |
|
83 | cachedDataSource[cacheKey] = data; | |
84 | query.callback({results: data.results}); |
|
84 | query.callback({results: data.results}); | |
85 | } |
|
85 | } | |
86 | }); |
|
86 | }); | |
87 | }; |
|
87 | }; | |
88 |
|
88 | |||
89 | var feedRefsData = function (query, cachedData) { |
|
89 | var feedRefsData = function (query, cachedData) { | |
90 | var data = {results: []}; |
|
90 | var data = {results: []}; | |
91 | //filter results |
|
91 | //filter results | |
92 | $.each(cachedData.results, function () { |
|
92 | $.each(cachedData.results, function () { | |
93 | var section = this.text; |
|
93 | var section = this.text; | |
94 | var children = []; |
|
94 | var children = []; | |
95 | $.each(this.children, function () { |
|
95 | $.each(this.children, function () { | |
96 | if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) { |
|
96 | if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) { | |
97 | children.push(this) |
|
97 | children.push(this) | |
98 | } |
|
98 | } | |
99 | }); |
|
99 | }); | |
100 | data.results.push({ |
|
100 | data.results.push({ | |
101 | 'text': section, |
|
101 | 'text': section, | |
102 | 'children': children |
|
102 | 'children': children | |
103 | }) |
|
103 | }) | |
104 | }); |
|
104 | }); | |
105 |
|
105 | |||
106 | query.callback(data); |
|
106 | query.callback(data); | |
107 | }; |
|
107 | }; | |
108 |
|
108 | |||
109 | var select2FileHistorySwitcher = function (targetElement, loadUrl, initialData) { |
|
109 | var select2FileHistorySwitcher = function (targetElement, loadUrl, initialData) { | |
110 | var formatResult = function (result, container, query) { |
|
110 | var formatResult = function (result, container, query) { | |
111 | return formatSelect2SelectionRefs(result); |
|
111 | return formatSelect2SelectionRefs(result); | |
112 | }; |
|
112 | }; | |
113 |
|
113 | |||
114 | var formatSelection = function (data, container) { |
|
114 | var formatSelection = function (data, container) { | |
115 | var commit_ref = data; |
|
115 | var commit_ref = data; | |
116 |
|
116 | |||
117 | var tmpl = ''; |
|
117 | var tmpl = ''; | |
118 | if (commit_ref.type === 'sha') { |
|
118 | if (commit_ref.type === 'sha') { | |
119 | tmpl = (commit_ref.raw_id || "").substr(0,8); |
|
119 | tmpl = (commit_ref.raw_id || "").substr(0,8); | |
120 | } else if (commit_ref.type === 'branch') { |
|
120 | } else if (commit_ref.type === 'branch') { | |
121 | tmpl = tmpl.concat('<i class="icon-branch"></i> '); |
|
121 | tmpl = tmpl.concat('<i class="icon-branch"></i> '); | |
122 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); |
|
122 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); | |
123 | } else if (commit_ref.type === 'tag') { |
|
123 | } else if (commit_ref.type === 'tag') { | |
124 | tmpl = tmpl.concat('<i class="icon-tag"></i> '); |
|
124 | tmpl = tmpl.concat('<i class="icon-tag"></i> '); | |
125 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); |
|
125 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); | |
126 | } else if (commit_ref.type === 'book') { |
|
126 | } else if (commit_ref.type === 'book') { | |
127 | tmpl = tmpl.concat('<i class="icon-bookmark"></i> '); |
|
127 | tmpl = tmpl.concat('<i class="icon-bookmark"></i> '); | |
128 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); |
|
128 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); | |
129 | } |
|
129 | } | |
130 | var idx = commit_ref.idx || 0; |
|
130 | var idx = commit_ref.idx || 0; | |
131 | if (idx !== 0) { |
|
131 | if (idx !== 0) { | |
132 | tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx)); |
|
132 | tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx)); | |
133 | } |
|
133 | } | |
134 | return tmpl |
|
134 | return tmpl | |
135 | }; |
|
135 | }; | |
136 |
|
136 | |||
137 | $(targetElement).select2({ |
|
137 | $(targetElement).select2({ | |
138 | dropdownAutoWidth: true, |
|
138 | dropdownAutoWidth: true, | |
139 | width: "resolve", |
|
139 | width: "resolve", | |
140 | containerCssClass: "drop-menu", |
|
140 | containerCssClass: "drop-menu", | |
141 | dropdownCssClass: "drop-menu-dropdown", |
|
141 | dropdownCssClass: "drop-menu-dropdown", | |
142 | query: function(query) { |
|
142 | query: function(query) { | |
143 | var cachedData = cachedDataSource[cacheKey]; |
|
143 | var cachedData = cachedDataSource[cacheKey]; | |
144 | if (cachedData) { |
|
144 | if (cachedData) { | |
145 | feedRefsData(query, cachedData) |
|
145 | feedRefsData(query, cachedData) | |
146 | } else { |
|
146 | } else { | |
147 | loadRefsData(query) |
|
147 | loadRefsData(query) | |
148 | } |
|
148 | } | |
149 | }, |
|
149 | }, | |
150 | initSelection: function(element, callback) { |
|
150 | initSelection: function(element, callback) { | |
151 | callback(initialData); |
|
151 | callback(initialData); | |
152 | }, |
|
152 | }, | |
153 | formatResult: formatResult, |
|
153 | formatResult: formatResult, | |
154 | formatSelection: formatSelection |
|
154 | formatSelection: formatSelection | |
155 | }); |
|
155 | }); | |
156 |
|
156 | |||
157 | }; |
|
157 | }; | |
158 |
|
158 | |||
159 | select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData); |
|
159 | select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData); | |
160 |
|
160 | |||
161 | // switcher for files |
|
161 | // switcher for files | |
162 | $('#file_refs_filter').on('change', function(e) { |
|
162 | $('#file_refs_filter').on('change', function(e) { | |
163 | var data = $('#file_refs_filter').select2('data'); |
|
163 | var data = $('#file_refs_filter').select2('data'); | |
164 | var commit_id = data.id; |
|
164 | var commit_id = data.id; | |
165 | var params = { |
|
165 | var params = { | |
166 | 'repo_name': templateContext.repo_name, |
|
166 | 'repo_name': templateContext.repo_name, | |
167 | 'commit_id': commit_id, |
|
167 | 'commit_id': commit_id, | |
168 | 'f_path': state.f_path |
|
168 | 'f_path': state.f_path | |
169 | }; |
|
169 | }; | |
170 |
|
170 | |||
171 | if(data.at_rev !== undefined && data.at_rev !== "") { |
|
171 | if(data.at_rev !== undefined && data.at_rev !== "") { | |
172 | params['at'] = data.at_rev; |
|
172 | params['at'] = data.at_rev; | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | if ("${c.annotate}" === "True") { |
|
175 | if ("${c.annotate}" === "True") { | |
176 | var url = pyroutes.url('repo_files:annotated', params); |
|
176 | var url = pyroutes.url('repo_files:annotated', params); | |
177 | } else { |
|
177 | } else { | |
178 | var url = pyroutes.url('repo_files', params); |
|
178 | var url = pyroutes.url('repo_files', params); | |
179 | } |
|
179 | } | |
180 | window.location = url; |
|
180 | window.location = url; | |
181 |
|
181 | |||
182 | }); |
|
182 | }); | |
183 |
|
183 | |||
184 | // load file short history |
|
184 | // load file short history | |
185 | $('#file_history_overview').on('click', function(e) { |
|
185 | $('#file_history_overview').on('click', function(e) { | |
186 | e.preventDefault(); |
|
186 | e.preventDefault(); | |
187 | path = state.f_path; |
|
187 | path = state.f_path; | |
188 | if (path.indexOf("#") >= 0) { |
|
188 | if (path.indexOf("#") >= 0) { | |
189 | path = path.slice(0, path.indexOf("#")); |
|
189 | path = path.slice(0, path.indexOf("#")); | |
190 | } |
|
190 | } | |
191 | var url = pyroutes.url('repo_commits_file', |
|
191 | var url = pyroutes.url('repo_commits_file', | |
192 | {'repo_name': templateContext.repo_name, |
|
192 | {'repo_name': templateContext.repo_name, | |
193 | 'commit_id': state.commit_id, 'f_path': path, 'limit': 6}); |
|
193 | 'commit_id': state.commit_id, 'f_path': path, 'limit': 6}); | |
194 | $('#file_history_container').show(); |
|
194 | $('#file_history_container').show(); | |
195 | $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...'))); |
|
195 | $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...'))); | |
196 |
|
196 | |||
197 | $.pjax({ |
|
197 | $.pjax({ | |
198 | url: url, |
|
198 | url: url, | |
199 | container: '#file_history_container', |
|
199 | container: '#file_history_container', | |
200 | push: false, |
|
200 | push: false, | |
201 | timeout: 5000 |
|
201 | timeout: 5000 | |
202 | }).complete(function () { |
|
202 | }).complete(function () { | |
203 | tooltipActivate(); |
|
203 | tooltipActivate(); | |
204 | }); |
|
204 | }); | |
205 | }); |
|
205 | }); | |
206 |
|
206 | |||
207 | }; |
|
207 | }; | |
208 |
|
208 | |||
209 | var initTreeJS = function () { |
|
209 | var initTreeJS = function () { | |
210 | var state = getFileState(); |
|
210 | var state = getFileState(); | |
211 | getFilesMetadata(); |
|
211 | getFilesMetadata(); | |
212 |
|
212 | |||
213 | // fuzzy file filter |
|
213 | // fuzzy file filter | |
214 | fileBrowserListeners(state.node_list_url, state.url_base); |
|
214 | fileBrowserListeners(state.node_list_url, state.url_base); | |
215 |
|
215 | |||
216 | // switch to widget |
|
216 | // switch to widget | |
217 | var initialCommitData = { |
|
217 | var initialCommitData = { | |
218 | at_ref: atRef, |
|
218 | at_ref: atRef, | |
219 | id: null, |
|
219 | id: null, | |
220 | text: '${c.commit.raw_id}', |
|
220 | text: '${c.commit.raw_id}', | |
221 | type: 'sha', |
|
221 | type: 'sha', | |
222 | raw_id: '${c.commit.raw_id}', |
|
222 | raw_id: '${c.commit.raw_id}', | |
223 | idx: ${c.commit.idx}, |
|
223 | idx: ${c.commit.idx}, | |
224 | files_url: null, |
|
224 | files_url: null, | |
225 | }; |
|
225 | }; | |
226 |
|
226 | |||
227 | // check if we have ref info. |
|
227 | // check if we have ref info. | |
228 | var selectedRef = fileTreeRefs[atRef]; |
|
228 | var selectedRef = fileTreeRefs[atRef]; | |
229 | if (selectedRef !== undefined) { |
|
229 | if (selectedRef !== undefined) { | |
230 | $.extend(initialCommitData, selectedRef) |
|
230 | $.extend(initialCommitData, selectedRef) | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name}); |
|
233 | var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name}); | |
234 | var cacheKey = '__ALL_FILE_REFS__'; |
|
234 | var cacheKey = '__ALL_FILE_REFS__'; | |
235 | var cachedDataSource = {}; |
|
235 | var cachedDataSource = {}; | |
236 |
|
236 | |||
237 | var loadRefsData = function (query) { |
|
237 | var loadRefsData = function (query) { | |
238 | $.ajax({ |
|
238 | $.ajax({ | |
239 | url: loadUrl, |
|
239 | url: loadUrl, | |
240 | data: {}, |
|
240 | data: {}, | |
241 | dataType: 'json', |
|
241 | dataType: 'json', | |
242 | type: 'GET', |
|
242 | type: 'GET', | |
243 | success: function (data) { |
|
243 | success: function (data) { | |
244 | cachedDataSource[cacheKey] = data; |
|
244 | cachedDataSource[cacheKey] = data; | |
245 | query.callback({results: data.results}); |
|
245 | query.callback({results: data.results}); | |
246 | } |
|
246 | } | |
247 | }); |
|
247 | }); | |
248 | }; |
|
248 | }; | |
249 |
|
249 | |||
250 | var feedRefsData = function (query, cachedData) { |
|
250 | var feedRefsData = function (query, cachedData) { | |
251 | var data = {results: []}; |
|
251 | var data = {results: []}; | |
252 | //filter results |
|
252 | //filter results | |
253 | $.each(cachedData.results, function () { |
|
253 | $.each(cachedData.results, function () { | |
254 | var section = this.text; |
|
254 | var section = this.text; | |
255 | var children = []; |
|
255 | var children = []; | |
256 | $.each(this.children, function () { |
|
256 | $.each(this.children, function () { | |
257 | if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) { |
|
257 | if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) { | |
258 | children.push(this) |
|
258 | children.push(this) | |
259 | } |
|
259 | } | |
260 | }); |
|
260 | }); | |
261 | data.results.push({ |
|
261 | data.results.push({ | |
262 | 'text': section, |
|
262 | 'text': section, | |
263 | 'children': children |
|
263 | 'children': children | |
264 | }) |
|
264 | }) | |
265 | }); |
|
265 | }); | |
266 |
|
266 | |||
267 | //push the typed in commit idx |
|
267 | //push the typed in commit idx | |
268 | if (!isNaN(query.term)) { |
|
268 | if (!isNaN(query.term)) { | |
269 | var files_url = pyroutes.url('repo_files', |
|
269 | var files_url = pyroutes.url('repo_files', | |
270 | {'repo_name': templateContext.repo_name, |
|
270 | {'repo_name': templateContext.repo_name, | |
271 | 'commit_id': query.term, 'f_path': state.f_path}); |
|
271 | 'commit_id': query.term, 'f_path': state.f_path}); | |
272 |
|
272 | |||
273 | data.results.push({ |
|
273 | data.results.push({ | |
274 | 'text': _gettext('go to numeric commit'), |
|
274 | 'text': _gettext('go to numeric commit'), | |
275 | 'children': [{ |
|
275 | 'children': [{ | |
276 | at_ref: null, |
|
276 | at_ref: null, | |
277 | id: null, |
|
277 | id: null, | |
278 | text: 'r{0}'.format(query.term), |
|
278 | text: 'r{0}'.format(query.term), | |
279 | type: 'sha', |
|
279 | type: 'sha', | |
280 | raw_id: query.term, |
|
280 | raw_id: query.term, | |
281 | idx: query.term, |
|
281 | idx: query.term, | |
282 | files_url: files_url, |
|
282 | files_url: files_url, | |
283 | }] |
|
283 | }] | |
284 | }); |
|
284 | }); | |
285 | } |
|
285 | } | |
286 | query.callback(data); |
|
286 | query.callback(data); | |
287 | }; |
|
287 | }; | |
288 |
|
288 | |||
289 | var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) { |
|
289 | var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) { | |
290 | var formatResult = function (result, container, query) { |
|
290 | var formatResult = function (result, container, query) { | |
291 | return formatSelect2SelectionRefs(result); |
|
291 | return formatSelect2SelectionRefs(result); | |
292 | }; |
|
292 | }; | |
293 |
|
293 | |||
294 | var formatSelection = function (data, container) { |
|
294 | var formatSelection = function (data, container) { | |
295 | var commit_ref = data; |
|
295 | var commit_ref = data; | |
296 |
|
296 | |||
297 | var tmpl = ''; |
|
297 | var tmpl = ''; | |
298 | if (commit_ref.type === 'sha') { |
|
298 | if (commit_ref.type === 'sha') { | |
299 | tmpl = (commit_ref.raw_id || "").substr(0,8); |
|
299 | tmpl = (commit_ref.raw_id || "").substr(0,8); | |
300 | } else if (commit_ref.type === 'branch') { |
|
300 | } else if (commit_ref.type === 'branch') { | |
301 | tmpl = tmpl.concat('<i class="icon-branch"></i> '); |
|
301 | tmpl = tmpl.concat('<i class="icon-branch"></i> '); | |
302 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); |
|
302 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); | |
303 | } else if (commit_ref.type === 'tag') { |
|
303 | } else if (commit_ref.type === 'tag') { | |
304 | tmpl = tmpl.concat('<i class="icon-tag"></i> '); |
|
304 | tmpl = tmpl.concat('<i class="icon-tag"></i> '); | |
305 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); |
|
305 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); | |
306 | } else if (commit_ref.type === 'book') { |
|
306 | } else if (commit_ref.type === 'book') { | |
307 | tmpl = tmpl.concat('<i class="icon-bookmark"></i> '); |
|
307 | tmpl = tmpl.concat('<i class="icon-bookmark"></i> '); | |
308 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); |
|
308 | tmpl = tmpl.concat(escapeHtml(commit_ref.text)); | |
309 | } |
|
309 | } | |
310 |
|
310 | |||
311 | var idx = commit_ref.idx || 0; |
|
311 | var idx = commit_ref.idx || 0; | |
312 | if (idx !== 0) { |
|
312 | if (idx !== 0) { | |
313 | tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx)); |
|
313 | tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx)); | |
314 | } |
|
314 | } | |
315 | return tmpl |
|
315 | return tmpl | |
316 | }; |
|
316 | }; | |
317 |
|
317 | |||
318 | $(targetElement).select2({ |
|
318 | $(targetElement).select2({ | |
319 | dropdownAutoWidth: true, |
|
319 | dropdownAutoWidth: true, | |
320 | width: "resolve", |
|
320 | width: "resolve", | |
321 | containerCssClass: "drop-menu", |
|
321 | containerCssClass: "drop-menu", | |
322 | dropdownCssClass: "drop-menu-dropdown", |
|
322 | dropdownCssClass: "drop-menu-dropdown", | |
323 | query: function(query) { |
|
323 | query: function(query) { | |
324 |
|
324 | |||
325 | var cachedData = cachedDataSource[cacheKey]; |
|
325 | var cachedData = cachedDataSource[cacheKey]; | |
326 | if (cachedData) { |
|
326 | if (cachedData) { | |
327 | feedRefsData(query, cachedData) |
|
327 | feedRefsData(query, cachedData) | |
328 | } else { |
|
328 | } else { | |
329 | loadRefsData(query) |
|
329 | loadRefsData(query) | |
330 | } |
|
330 | } | |
331 | }, |
|
331 | }, | |
332 | initSelection: function(element, callback) { |
|
332 | initSelection: function(element, callback) { | |
333 | callback(initialData); |
|
333 | callback(initialData); | |
334 | }, |
|
334 | }, | |
335 | formatResult: formatResult, |
|
335 | formatResult: formatResult, | |
336 | formatSelection: formatSelection |
|
336 | formatSelection: formatSelection | |
337 | }); |
|
337 | }); | |
338 |
|
338 | |||
339 | }; |
|
339 | }; | |
340 |
|
340 | |||
341 | select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData); |
|
341 | select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData); | |
342 |
|
342 | |||
343 | // switcher for file tree |
|
343 | // switcher for file tree | |
344 | $('#refs_filter').on('change', function(e) { |
|
344 | $('#refs_filter').on('change', function(e) { | |
345 | var data = $('#refs_filter').select2('data'); |
|
345 | var data = $('#refs_filter').select2('data'); | |
346 | window.location = data.files_url |
|
346 | window.location = data.files_url | |
347 | }); |
|
347 | }); | |
348 |
|
348 | |||
349 | }; |
|
349 | }; | |
350 |
|
350 | |||
351 | $(document).ready(function() { |
|
351 | $(document).ready(function() { | |
352 | timeagoActivate(); |
|
352 | timeagoActivate(); | |
353 | tooltipActivate(); |
|
353 | tooltipActivate(); | |
354 |
|
354 | |||
355 | if ($('#trimmed_message_box').height() < 50) { |
|
355 | if ($('#trimmed_message_box').height() < 50) { | |
356 | $('#message_expand').hide(); |
|
356 | $('#message_expand').hide(); | |
357 | } |
|
357 | } | |
358 |
|
358 | |||
359 | $('#message_expand').on('click', function(e) { |
|
359 | $('#message_expand').on('click', function(e) { | |
360 | $('#trimmed_message_box').css('max-height', 'none'); |
|
360 | $('#trimmed_message_box').css('max-height', 'none'); | |
361 | $(this).hide(); |
|
361 | $(this).hide(); | |
362 | }); |
|
362 | }); | |
363 |
|
363 | |||
364 | if (fileSourcePage) { |
|
364 | if (fileSourcePage) { | |
365 | initFileJS() |
|
365 | initFileJS() | |
366 | } else { |
|
366 | } else { | |
367 | initTreeJS() |
|
367 | initTreeJS() | |
368 | } |
|
368 | } | |
369 |
|
369 | |||
370 | var search_GET = "${request.GET.get('search','')}"; |
|
370 | var search_GET = "${request.GET.get('search','')}"; | |
371 | if (search_GET === "1") { |
|
371 | if (search_GET === "1") { | |
372 | NodeFilter.initFilter(); |
|
372 | NodeFilter.initFilter(); | |
373 | NodeFilter.focus(); |
|
373 | NodeFilter.focus(); | |
374 | } |
|
374 | } | |
375 | }); |
|
375 | }); | |
376 |
|
376 | |||
377 | </script> |
|
377 | </script> | |
378 |
|
378 | |||
379 | </%def> No newline at end of file |
|
379 | </%def> |
@@ -1,98 +1,98 b'' | |||||
1 | <%namespace name="base" file="/base/base.mako"/> |
|
1 | <%namespace name="base" file="/base/base.mako"/> | |
2 |
|
2 | |||
3 | <% |
|
3 | <% | |
4 | at_ref = request.GET.get('at') |
|
4 | at_ref = request.GET.get('at') | |
5 | if at_ref: |
|
5 | if at_ref: | |
6 | query={'at': at_ref} |
|
6 | query={'at': at_ref} | |
7 | default_landing_ref = at_ref or c.rhodecode_db_repo.landing_ref_name |
|
7 | default_landing_ref = at_ref or c.rhodecode_db_repo.landing_ref_name | |
8 | else: |
|
8 | else: | |
9 | query=None |
|
9 | query=None | |
10 | default_landing_ref = c.commit.raw_id |
|
10 | default_landing_ref = c.commit.raw_id | |
11 | %> |
|
11 | %> | |
12 | <div id="file-tree-wrapper" class="browser-body ${('full-load' if c.full_load else '')}"> |
|
12 | <div id="file-tree-wrapper" class="browser-body ${('full-load' if c.full_load else '')}"> | |
13 | <table class="code-browser rctable table-bordered"> |
|
13 | <table class="code-browser rctable table-bordered"> | |
14 | <thead> |
|
14 | <thead> | |
15 | <tr> |
|
15 | <tr> | |
16 | <th>${_('Name')}</th> |
|
16 | <th>${_('Name')}</th> | |
17 | <th>${_('Size')}</th> |
|
17 | <th>${_('Size')}</th> | |
18 | <th>${_('Modified')}</th> |
|
18 | <th>${_('Modified')}</th> | |
19 | <th>${_('Last Commit')}</th> |
|
19 | <th>${_('Last Commit')}</th> | |
20 | <th>${_('Author')}</th> |
|
20 | <th>${_('Author')}</th> | |
21 | </tr> |
|
21 | </tr> | |
22 | </thead> |
|
22 | </thead> | |
23 |
|
23 | |||
24 | <tbody id="tbody"> |
|
24 | <tbody id="tbody"> | |
25 | <tr> |
|
25 | <tr> | |
26 | <td colspan="5"> |
|
26 | <td colspan="5"> | |
27 | ${h.files_breadcrumbs(c.repo_name, c.rhodecode_db_repo.repo_type, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'), limit_items=True)} |
|
27 | ${h.files_breadcrumbs(c.repo_name, c.rhodecode_db_repo.repo_type, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'), limit_items=True)} | |
28 | </td> |
|
28 | </td> | |
29 | </tr> |
|
29 | </tr> | |
30 |
|
30 | |||
31 | <% has_files = False %> |
|
31 | <% has_files = False %> | |
32 | % for cnt,node in enumerate(c.file): |
|
32 | % for cnt,node in enumerate(c.file): | |
33 | <% has_files = True %> |
|
33 | <% has_files = True %> | |
34 | <tr class="parity${(cnt % 2)}"> |
|
34 | <tr class="parity${(cnt % 2)}"> | |
35 | <td class="td-componentname"> |
|
35 | <td class="td-componentname"> | |
36 | % if node.is_submodule(): |
|
36 | % if node.is_submodule(): | |
37 | <span class="submodule-dir"> |
|
37 | <span class="submodule-dir"> | |
38 | % if node.url.startswith('http://') or node.url.startswith('https://'): |
|
38 | % if node.url.startswith('http://') or node.url.startswith('https://'): | |
39 | <a href="${node.url}"> |
|
39 | <a href="${node.url}"> | |
40 | <i class="icon-directory browser-dir"></i>${node.name} |
|
40 | <i class="icon-directory browser-dir"></i>${node.name} | |
41 | </a> |
|
41 | </a> | |
42 | % else: |
|
42 | % else: | |
43 | <i class="icon-directory browser-dir"></i>${node.name} |
|
43 | <i class="icon-directory browser-dir"></i>${node.name} | |
44 | % endif |
|
44 | % endif | |
45 | </span> |
|
45 | </span> | |
46 | % else: |
|
46 | % else: | |
47 |
<a href="${h.repo_files_by_ref_url(c.repo_name, c.rhodecode_db_repo.repo_type, f_path=h.safe_ |
|
47 | <a href="${h.repo_files_by_ref_url(c.repo_name, c.rhodecode_db_repo.repo_type, f_path=h.safe_str(node.path), ref_name=default_landing_ref, commit_id=c.commit.raw_id, query=query)}"> | |
48 | <i class="${('icon-file-text browser-file' if node.is_file() else 'icon-directory browser-dir')}"></i>${node.name} |
|
48 | <i class="${('icon-file-text browser-file' if node.is_file() else 'icon-directory browser-dir')}"></i>${node.name} | |
49 | </a> |
|
49 | </a> | |
50 | % endif |
|
50 | % endif | |
51 | </td> |
|
51 | </td> | |
52 | %if node.is_file(): |
|
52 | %if node.is_file(): | |
53 | <td class="td-size" data-attr-name="size"> |
|
53 | <td class="td-size" data-attr-name="size"> | |
54 | % if c.full_load: |
|
54 | % if c.full_load: | |
55 | <span data-size="${node.size}">${h.format_byte_size_binary(node.size)}</span> |
|
55 | <span data-size="${node.size}">${h.format_byte_size_binary(node.size)}</span> | |
56 | % else: |
|
56 | % else: | |
57 | ${_('Loading ...')} |
|
57 | ${_('Loading ...')} | |
58 | % endif |
|
58 | % endif | |
59 | </td> |
|
59 | </td> | |
60 | <td class="td-time" data-attr-name="modified_at"> |
|
60 | <td class="td-time" data-attr-name="modified_at"> | |
61 | % if c.full_load: |
|
61 | % if c.full_load: | |
62 | <span data-date="${node.last_commit.date}">${h.age_component(node.last_commit.date)}</span> |
|
62 | <span data-date="${node.last_commit.date}">${h.age_component(node.last_commit.date)}</span> | |
63 | % endif |
|
63 | % endif | |
64 | </td> |
|
64 | </td> | |
65 | <td class="td-hash" data-attr-name="commit_id"> |
|
65 | <td class="td-hash" data-attr-name="commit_id"> | |
66 | % if c.full_load: |
|
66 | % if c.full_load: | |
67 | <div class="tooltip-hovercard" data-hovercard-alt="${node.last_commit.message}" data-hovercard-url="${h.route_path('hovercard_repo_commit', repo_name=c.repo_name, commit_id=node.last_commit.raw_id)}"> |
|
67 | <div class="tooltip-hovercard" data-hovercard-alt="${node.last_commit.message}" data-hovercard-url="${h.route_path('hovercard_repo_commit', repo_name=c.repo_name, commit_id=node.last_commit.raw_id)}"> | |
68 | <pre data-commit-id="${node.last_commit.raw_id}">r${node.last_commit.idx}:${node.last_commit.short_id}</pre> |
|
68 | <pre data-commit-id="${node.last_commit.raw_id}">r${node.last_commit.idx}:${node.last_commit.short_id}</pre> | |
69 | </div> |
|
69 | </div> | |
70 | % endif |
|
70 | % endif | |
71 | </td> |
|
71 | </td> | |
72 | <td class="td-user" data-attr-name="author"> |
|
72 | <td class="td-user" data-attr-name="author"> | |
73 | % if c.full_load: |
|
73 | % if c.full_load: | |
74 | <span data-author="${node.last_commit.author}">${h.gravatar_with_user(request, node.last_commit.author, tooltip=True)|n}</span> |
|
74 | <span data-author="${node.last_commit.author}">${h.gravatar_with_user(request, node.last_commit.author, tooltip=True)|n}</span> | |
75 | % endif |
|
75 | % endif | |
76 | </td> |
|
76 | </td> | |
77 | %else: |
|
77 | %else: | |
78 | <td></td> |
|
78 | <td></td> | |
79 | <td></td> |
|
79 | <td></td> | |
80 | <td></td> |
|
80 | <td></td> | |
81 | <td></td> |
|
81 | <td></td> | |
82 | %endif |
|
82 | %endif | |
83 | </tr> |
|
83 | </tr> | |
84 | % endfor |
|
84 | % endfor | |
85 |
|
85 | |||
86 | % if not has_files: |
|
86 | % if not has_files: | |
87 | <tr> |
|
87 | <tr> | |
88 | <td colspan="5"> |
|
88 | <td colspan="5"> | |
89 | ##empty-dir mostly SVN |
|
89 | ##empty-dir mostly SVN | |
90 | |
|
90 | | |
91 | </td> |
|
91 | </td> | |
92 | </tr> |
|
92 | </tr> | |
93 | % endif |
|
93 | % endif | |
94 |
|
94 | |||
95 | </tbody> |
|
95 | </tbody> | |
96 | <tbody id="tbody_filtered"></tbody> |
|
96 | <tbody id="tbody_filtered"></tbody> | |
97 | </table> |
|
97 | </table> | |
98 | </div> |
|
98 | </div> |
@@ -1,34 +1,34 b'' | |||||
1 | <%def name="title(*args)"> |
|
1 | <%def name="title(*args)"> | |
2 | ${_('{} Files').format(c.repo_name)} |
|
2 | ${_('{} Files').format(c.repo_name)} | |
3 | %if hasattr(c,'file'): |
|
3 | %if hasattr(c,'file'): | |
4 |
· ${(h.safe_ |
|
4 | · ${(h.safe_str(c.file.path) or '\\')} | |
5 | %endif |
|
5 | %endif | |
6 |
|
6 | |||
7 | %if c.rhodecode_name: |
|
7 | %if c.rhodecode_name: | |
8 | · ${h.branding(c.rhodecode_name)} |
|
8 | · ${h.branding(c.rhodecode_name)} | |
9 | %endif |
|
9 | %endif | |
10 | </%def> |
|
10 | </%def> | |
11 |
|
11 | |||
12 | <div> |
|
12 | <div> | |
13 |
|
13 | |||
14 | <div class="summary-detail"> |
|
14 | <div class="summary-detail"> | |
15 | <div class="summary-detail-header"> |
|
15 | <div class="summary-detail-header"> | |
16 |
|
16 | |||
17 | </div><!--end summary-detail-header--> |
|
17 | </div><!--end summary-detail-header--> | |
18 |
|
18 | |||
19 | % if c.file.is_submodule(): |
|
19 | % if c.file.is_submodule(): | |
20 | <span class="submodule-dir">Submodule ${h.escape(c.file.name)}</span> |
|
20 | <span class="submodule-dir">Submodule ${h.escape(c.file.name)}</span> | |
21 | % elif c.file.is_dir(): |
|
21 | % elif c.file.is_dir(): | |
22 | <%include file='files_tree_header.mako'/> |
|
22 | <%include file='files_tree_header.mako'/> | |
23 | % else: |
|
23 | % else: | |
24 | <%include file='files_source_header.mako'/> |
|
24 | <%include file='files_source_header.mako'/> | |
25 | % endif |
|
25 | % endif | |
26 |
|
26 | |||
27 | </div> <!--end summary-detail--> |
|
27 | </div> <!--end summary-detail--> | |
28 | % if c.file.is_dir(): |
|
28 | % if c.file.is_dir(): | |
29 | <%include file='files_browser.mako'/> |
|
29 | <%include file='files_browser.mako'/> | |
30 | % else: |
|
30 | % else: | |
31 | <%include file='files_source.mako'/> |
|
31 | <%include file='files_source.mako'/> | |
32 | % endif |
|
32 | % endif | |
33 |
|
33 | |||
34 | </div> |
|
34 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now