##// END OF EJS Templates
files: updated based on new design
marcink -
r3706:9aa2b595 new-ui
parent child Browse files
Show More
@@ -873,18 +873,17 b' class RepoFilesView(RepoAppView):'
873 873 self.db_repo_name, self.db_repo.repo_id, commit.raw_id, f_path)
874 874 return {'nodes': metadata}
875 875
876 def _create_references(
877 self, branches_or_tags, symbolic_reference, f_path):
876 def _create_references(self, branches_or_tags, symbolic_reference, f_path, ref_type):
878 877 items = []
879 878 for name, commit_id in branches_or_tags.items():
880 sym_ref = symbolic_reference(commit_id, name, f_path)
881 items.append((sym_ref, name))
879 sym_ref = symbolic_reference(commit_id, name, f_path, ref_type)
880 items.append((sym_ref, name, ref_type))
882 881 return items
883 882
884 def _symbolic_reference(self, commit_id, name, f_path):
883 def _symbolic_reference(self, commit_id, name, f_path, ref_type):
885 884 return commit_id
886 885
887 def _symbolic_reference_svn(self, commit_id, name, f_path):
886 def _symbolic_reference_svn(self, commit_id, name, f_path, ref_type):
888 887 new_f_path = vcspath.join(name, f_path)
889 888 return u'%s@%s' % (new_f_path, commit_id)
890 889
@@ -914,7 +913,7 b' class RepoFilesView(RepoAppView):'
914 913 for commit in commits:
915 914 branch = ' (%s)' % commit.branch if commit.branch else ''
916 915 n_desc = 'r%s:%s%s' % (commit.idx, commit.short_id, branch)
917 commits_group[0].append((commit.raw_id, n_desc,))
916 commits_group[0].append((commit.raw_id, n_desc, 'sha'))
918 917 history.append(commits_group)
919 918
920 919 symbolic_reference = self._symbolic_reference
@@ -930,11 +929,11 b' class RepoFilesView(RepoAppView):'
930 929 symbolic_reference = self._symbolic_reference_svn
931 930
932 931 branches = self._create_references(
933 self.rhodecode_vcs_repo.branches, symbolic_reference, f_path)
932 self.rhodecode_vcs_repo.branches, symbolic_reference, f_path, 'branch')
934 933 branches_group = (branches, _("Branches"))
935 934
936 935 tags = self._create_references(
937 self.rhodecode_vcs_repo.tags, symbolic_reference, f_path)
936 self.rhodecode_vcs_repo.tags, symbolic_reference, f_path, 'tag')
938 937 tags_group = (tags, _("Tags"))
939 938
940 939 history.append(branches_group)
@@ -962,7 +961,7 b' class RepoFilesView(RepoAppView):'
962 961 for obj in file_history:
963 962 res.append({
964 963 'text': obj[1],
965 'children': [{'id': o[0], 'text': o[1]} for o in obj[0]]
964 'children': [{'id': o[0], 'text': o[1], 'type': o[2]} for o in obj[0]]
966 965 })
967 966
968 967 data = {
@@ -199,6 +199,7 b' class _GetError(object):'
199 199 if form_errors and field_name in form_errors:
200 200 return literal(tmpl % form_errors.get(field_name))
201 201
202
202 203 get_error = _GetError()
203 204
204 205
@@ -215,33 +216,30 b' class _ToolTip(object):'
215 216 tooltip_title = tooltip_title.replace('<', '&lt;').replace('>', '&gt;')
216 217 return tooltip_title
217 218
219
218 220 tooltip = _ToolTip()
219 221
220 222
221 def files_breadcrumbs(repo_name, commit_id, file_path, at_ref=None):
223 def files_breadcrumbs(repo_name, commit_id, file_path, at_ref=None, limit_items=False):
222 224 if isinstance(file_path, str):
223 225 file_path = safe_unicode(file_path)
226
224 227 route_qry = {'at': at_ref} if at_ref else None
225 228
226 # TODO: johbo: Is this always a url like path, or is this operating
227 # system dependent?
228 path_segments = file_path.split('/')
229 # first segment is a `..` link to repo files
230 root_name = literal(u'<i class="icon-home"></i>')
231 url_segments = [
232 link_to(
233 root_name,
234 route_path(
235 'repo_files',
236 repo_name=repo_name,
237 commit_id=commit_id,
238 f_path='',
239 _query=route_qry),
240 )]
229 241
230 repo_name_html = escape(repo_name)
231 if len(path_segments) == 1 and path_segments[0] == '':
232 url_segments = [repo_name_html]
233 else:
234 url_segments = [
235 link_to(
236 repo_name_html,
237 route_path(
238 'repo_files',
239 repo_name=repo_name,
240 commit_id=commit_id,
241 f_path='',
242 _query=route_qry),
243 )]
244
242 path_segments = file_path.split('/')
245 243 last_cnt = len(path_segments) - 1
246 244 for cnt, segment in enumerate(path_segments):
247 245 if not segment:
@@ -262,7 +260,16 b' def files_breadcrumbs(repo_name, commit_'
262 260 else:
263 261 url_segments.append(segment_html)
264 262
265 return literal('/'.join(url_segments))
263 limited_url_segments = url_segments[:1] + ['...'] + url_segments[-5:]
264 if limit_items and len(limited_url_segments) < len(url_segments):
265 url_segments = limited_url_segments
266
267 full_path = file_path
268 icon = '<i class="file-breadcrumb-copy tooltip icon-clipboard clipboard-action" data-clipboard-text="{}" title="Copy the full path"></i>'.format(full_path)
269 if file_path == '':
270 return root_name
271 else:
272 return literal(' / '.join(url_segments) + icon)
266 273
267 274
268 275 def code_highlight(code, lexer, formatter, use_hl_filter=False):
@@ -2192,12 +2192,13 b' h3.files_location{'
2192 2192 }
2193 2193 }
2194 2194
2195 .select-index-number {
2196 margin: 0 0 0 20px;
2197 color: @grey3;
2198 }
2199 2195 }
2200 2196
2197 .select-index-number {
2198 margin: 0 0 0 20px;
2199 color: @grey3;
2200 }
2201
2201 2202 .search_activate {
2202 2203 display: table-cell;
2203 2204 vertical-align: middle;
@@ -1,12 +1,12 b''
1 1 @font-face {
2 2 font-family: 'rcicons';
3 3
4 src: url('../fonts/RCIcons/rcicons.eot?73199028');
5 src: url('../fonts/RCIcons/rcicons.eot?73199028#iefix') format('embedded-opentype'),
6 url('../fonts/RCIcons/rcicons.woff2?73199028') format('woff2'),
7 url('../fonts/RCIcons/rcicons.woff?73199028') format('woff'),
8 url('../fonts/RCIconst/rcicons.ttf?73199028') format('truetype'),
9 url('../fonts/RCIcons/rcicons.svg?73199028#rcicons') format('svg');
4 src: url('../fonts/RCIcons/rcicons.eot?9641970');
5 src: url('../fonts/RCIcons/rcicons.eot?9641970#iefix') format('embedded-opentype'),
6 url('../fonts/RCIcons/rcicons.woff2?9641970') format('woff2'),
7 url('../fonts/RCIcons/rcicons.woff?9641970') format('woff'),
8 url('../fonts/RCIcons/rcicons.ttf?9641970') format('truetype'),
9 url('../fonts/RCIcons/rcicons.svg?9641970#rcicons') format('svg');
10 10
11 11 font-weight: normal;
12 12 font-style: normal;
@@ -186,6 +186,7 b''
186 186 .icon-minus:before { content: '\e820'; } /* '' */
187 187 .icon-info-circled:before { content: '\e821'; } /* '' */
188 188 .icon-upload:before { content: '\e822'; } /* '' */
189 .icon-home:before { content: '\e823'; } /* '' */
189 190 .icon-git:before { content: '\e82a'; } /* '' */
190 191 .icon-hg:before { content: '\e82d'; } /* '' */
191 192 .icon-svn:before { content: '\e82e'; } /* '' */
@@ -425,7 +425,6 b''
425 425 }
426 426
427 427 .stats-info {
428 margin-top: 5px;
429 428 color: @grey4;
430 429 }
431 430
@@ -434,7 +433,6 b''
434 433 text-align: right;
435 434 color: @grey4;
436 435 padding: 10px;
437 margin-top: 15px;
438 436 }
439 437
440 438 .file-container {
@@ -552,6 +552,12 b''
552 552 "src": "fontelico"
553 553 },
554 554 {
555 "uid": "513ac180ff85bd275f2b736720cbbf5e",
556 "css": "home",
557 "code": 59427,
558 "src": "entypo"
559 },
560 {
555 561 "uid": "c43db6645e7515889fc2193294f50767",
556 562 "css": "plus",
557 563 "code": 59411,
1 NO CONTENT: modified file, binary diff hidden
@@ -76,6 +76,8 b''
76 76
77 77 <glyph glyph-name="upload" unicode="&#xe822;" d="M714 29q0 14-10 25t-25 10-25-10-11-25 11-25 25-11 25 11 10 25z m143 0q0 14-10 25t-26 10-25-10-10-25 10-25 25-11 26 11 10 25z m72 125v-179q0-22-16-38t-38-16h-821q-23 0-38 16t-16 38v179q0 22 16 38t38 15h238q12-31 39-51t62-20h143q34 0 61 20t40 51h238q22 0 38-15t16-38z m-182 361q-9-22-33-22h-143v-250q0-15-10-25t-25-11h-143q-15 0-25 11t-11 25v250h-143q-23 0-33 22-9 22 8 39l250 250q10 10 25 10t25-10l250-250q18-17 8-39z" horiz-adv-x="928.6" />
78 78
79 <glyph glyph-name="home" unicode="&#xe823;" d="M888 336q16-16 11-27t-27-11l-84 0 0-310q0-14-1-21t-8-13-23-6l-204 0 0 310-204 0 0-310-194 0q-28 0-35 10t-7 30l0 310-84 0q-22 0-27 11t11 27l400 402q16 16 38 16t38-16z" horiz-adv-x="900" />
80
79 81 <glyph glyph-name="git" unicode="&#xe82a;" d="M929 844h-858c-36 0-65-30-65-65v-857c0-36 30-65 65-65h857c36 0 65 30 65 65v857c1 35-29 65-64 65z m-729-549c4-11 9-20 14-27 6-8 14-14 22-18 9-4 19-6 29-6 9 0 16 1 24 2 7 2 14 4 20 7l6 51h-27c-4 0-8 1-10 4-2 1-3 5-3 7l5 39h105l-16-131c-8-7-16-12-25-15-9-4-18-8-28-10-10-3-18-5-30-7-10-1-21-2-33-2-20 0-38 4-54 11-16 8-30 18-41 30-12 13-20 28-27 45-6 18-10 36-10 56 0 18 3 34 7 50 3 17 10 30 17 44 8 14 16 25 26 36 10 12 22 20 34 28 13 7 26 14 41 17 15 4 30 7 47 7 13 0 25-2 36-4 11-3 21-6 29-10 8-4 16-9 22-14 6-5 13-11 18-16l-20-31c-4-5-9-8-14-9-5-1-10 0-16 4-5 3-10 6-14 8-5 3-9 5-14 7-5 1-10 2-15 3-5 2-11 2-17 2-14 0-27-3-38-9-11-6-21-14-29-25-8-10-15-24-18-38-5-15-7-31-7-48-1-14 2-27 4-38z m336-102h-71l39 315h71l-39-315z m343 258h-80l-33-258h-70l32 258h-80l7 57h231l-7-57z" horiz-adv-x="1000" />
80 82
81 83 <glyph glyph-name="hg" unicode="&#xe82d;" d="M927 841h-853c-36 0-65-29-65-65v-853c0-36 29-65 65-65h853c36 0 65 29 65 65v853c0 36-29 65-65 65z m-483-648h-70l16 133h-113l-17-133h-70l39 313h70l-16-132h113l16 132h71l-39-313z m177 101c3-11 8-20 14-27 7-8 14-14 23-18 8-4 18-6 28-6 9 0 16 1 23 3 7 1 14 3 20 6l6 51h-27c-4 0-7 1-9 3-3 3-3 6-3 9l5 39h104l-16-131c-8-6-16-11-25-15-9-5-18-8-27-11-9-2-19-4-30-6-10-1-21-2-33-2-19 0-37 4-53 11-16 7-30 17-41 29-11 13-20 28-26 45-7 17-10 35-10 55 0 17 2 34 6 50 4 15 10 30 17 43 7 14 16 26 26 36 10 11 22 20 34 28 13 7 27 13 41 17 14 4 30 7 46 7 13 0 25-2 36-4 11-3 20-6 29-10 8-4 16-9 23-14 7-5 13-11 18-17l-23-28c-4-5-8-8-13-9-5-1-11 0-16 3-5 4-10 7-14 9-5 3-9 5-14 6-4 2-9 3-14 4-5 1-11 1-17 1-14 0-27-3-38-8-11-6-21-14-29-25-8-10-15-23-19-38-5-15-7-31-7-49 0-13 2-26 5-37z" horiz-adv-x="1000" />
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -73,10 +73,3 b' var select2RefSwitcher = function(target'
73 73 {'repo_name': templateContext.repo_name});
74 74 select2RefBaseSwitcher(targetElement, loadUrl, initialData);
75 75 };
76
77 var select2FileHistorySwitcher = function(targetElement, initialData, state) {
78 var loadUrl = pyroutes.url('repo_file_history',
79 {'repo_name': templateContext.repo_name, 'commit_id': state.rev,
80 'f_path': state.f_path});
81 select2RefBaseSwitcher(targetElement, loadUrl, initialData);
82 };
@@ -3,7 +3,7 b''
3 3
4 4 <table class="table rctable file_history">
5 5 %for cnt,cs in enumerate(c.pagination):
6 <tr id="chg_${cnt+1}" class="${'tablerow%s' % (cnt%2)}">
6 <tr id="chg_${cnt+1}" class="${('tablerow%s' % (cnt%2))}">
7 7 <td class="td-user">
8 8 ${base.gravatar_with_user(cs.author, 16)}
9 9 </td>
@@ -33,7 +33,19 b''
33 33 ${_('Show File')}
34 34 </a>
35 35 </td>
36 <td class="td-actions">
37 <a href="${h.route_path('repo_compare',repo_name=c.repo_name, source_ref_type="rev", source_ref=cs.raw_id,target_ref_type="rev", target_ref=c.commit_id,_query=dict(merge='1',f_path=c.changelog_for_path))}">
38 ${_('Diff File')}
39 </a>
40 </td>
36 41 </tr>
37 42 %endfor
43 <tr>
44 <td colspan="6">
45 <a id="file_history_overview_full" href="${h.route_path('repo_changelog_file',repo_name=c.repo_name, commit_id=c.commit_id, f_path=c.f_path)}">
46 ${_('Show Full History')}
47 </a>
48 </td>
49 </tr>
38 50 </table>
39 51 </div>
@@ -10,6 +10,7 b''
10 10 <span class="user commit-author">${h.link_to_user(user)}</span>
11 11 % if c.file_author:
12 12 <span class="commit-date">- ${h.age_component(c.file_last_commit.date)}</span>
13 <a href="#ShowAuthors" id="show_authors" class="action_link"> - ${_('Load All Authors')}</a>
13 14 % elif c.file_last_commit.author_email==email:
14 15 <span> (${_('last author')})</span>
15 16 % endif
@@ -27,13 +28,7 b''
27 28 % endif
28 29 </td>
29 30 </tr>
30 <tr>
31 <td colspan="2">
32 % if c.file_author:
33 <a href="#ShowAuthors" id="show_authors" class="action_link">${_('Show Authors')}</a>
34 % endif
35 </td>
36 </tr>
31
37 32 % endfor
38 33 </table>
39 34 % endif
This diff has been collapsed as it changes many lines, (556 lines changed) Show them Hide them
@@ -118,14 +118,322 b''
118 118 timeagoActivate();
119 119 });
120 120 metadataRequest.fail(function (data, textStatus, errorThrown) {
121 console.log(data);
122 121 if (data.status != 0) {
123 122 alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText));
124 123 }
125 124 });
126 125 };
127 126
128 var callbacks = function() {
127 var initFileJS = function () {
128 var state = getState('callbacks');
129
130 // select code link event
131 $("#hlcode").mouseup(getSelectionLink);
132
133 // file history select2 used for history of file, and switch to
134 var initialCommitData = {
135 at_ref: atRef,
136 id: null,
137 text: '${c.commit.raw_id}',
138 type: 'sha',
139 raw_id: '${c.commit.raw_id}',
140 idx: ${c.commit.idx},
141 files_url: null,
142 };
143
144 // check if we have ref info.
145 var selectedRef = fileTreeRefs[atRef];
146 if (selectedRef !== undefined) {
147 $.extend(initialCommitData, selectedRef)
148 }
149
150 var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.rev,'f_path': state.f_path});
151 var cacheKey = '__SINGLE_FILE_REFS__';
152 var cachedDataSource = {};
153
154 var loadRefsData = function (query) {
155 $.ajax({
156 url: loadUrl,
157 data: {},
158 dataType: 'json',
159 type: 'GET',
160 success: function (data) {
161 cachedDataSource[cacheKey] = data;
162 query.callback({results: data.results});
163 }
164 });
165 };
166
167 var feedRefsData = function (query, cachedData) {
168 var data = {results: []};
169 //filter results
170 $.each(cachedData.results, function () {
171 var section = this.text;
172 var children = [];
173 $.each(this.children, function () {
174 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
175 children.push(this)
176 }
177 });
178 data.results.push({
179 'text': section,
180 'children': children
181 })
182 });
183
184 query.callback(data);
185 };
186
187 var select2FileHistorySwitcher = function (targetElement, loadUrl, initialData) {
188 var formatResult = function (result, container, query) {
189 return formatSelect2SelectionRefs(result);
190 };
191
192 var formatSelection = function (data, container) {
193 var commit_ref = data;
194
195 var tmpl = '';
196 if (commit_ref.type === 'sha') {
197 tmpl = (commit_ref.raw_id || "").substr(0,8);
198 } else if (commit_ref.type === 'branch') {
199 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
200 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
201 } else if (commit_ref.type === 'tag') {
202 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
203 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
204 } else if (commit_ref.type === 'book') {
205 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
206 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
207 }
208 var idx = commit_ref.idx || 0;
209 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
210 return tmpl
211 };
212
213 $(targetElement).select2({
214 dropdownAutoWidth: true,
215 width: "resolve",
216 containerCssClass: "drop-menu",
217 dropdownCssClass: "drop-menu-dropdown",
218 query: function(query) {
219 var cachedData = cachedDataSource[cacheKey];
220 if (cachedData) {
221 feedRefsData(query, cachedData)
222 } else {
223 loadRefsData(query)
224 }
225 },
226 initSelection: function(element, callback) {
227 callback(initialData);
228 },
229 formatResult: formatResult,
230 formatSelection: formatSelection
231 });
232
233 };
234
235 select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData);
236
237 $('#file_refs_filter').on('change', function(e) {
238 var data = $('#file_refs_filter').select2('data');
239 var commit_id = data.id;
240
241 if ("${c.annotate}" === "True") {
242 var url = pyroutes.url('repo_files:annotated',
243 {'repo_name': templateContext.repo_name,
244 'commit_id': commit_id, 'f_path': state.f_path});
245 } else {
246 var url = pyroutes.url('repo_files',
247 {'repo_name': templateContext.repo_name,
248 'commit_id': commit_id, 'f_path': state.f_path});
249 }
250 window.location = url;
251
252 });
253
254 // show more authors
255 $('#show_authors').on('click', function(e) {
256 e.preventDefault();
257 var url = pyroutes.url('repo_file_authors',
258 {'repo_name': templateContext.repo_name,
259 'commit_id': state.rev, 'f_path': state.f_path});
260
261 $.pjax({
262 url: url,
263 data: 'annotate=${("1" if c.annotate else "0")}',
264 container: '#file_authors',
265 push: false,
266 timeout: 5000
267 }).complete(function(){
268 $('#show_authors').hide();
269 $('#file_authors_title').html(_gettext('All Authors'))
270 })
271 });
272
273 // load file short history
274 $('#file_history_overview').on('click', function(e) {
275 e.preventDefault();
276 path = state.f_path;
277 if (path.indexOf("#") >= 0) {
278 path = path.slice(0, path.indexOf("#"));
279 }
280 var url = pyroutes.url('repo_changelog_file',
281 {'repo_name': templateContext.repo_name,
282 'commit_id': state.rev, 'f_path': path, 'limit': 6});
283 $('#file_history_container').show();
284 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
285
286 $.pjax({
287 url: url,
288 container: '#file_history_container',
289 push: false,
290 timeout: 5000
291 });
292 });
293
294
295 };
296
297 var initTreeJS = function () {
298 var state = getState('callbacks');
299 getFilesMetadata();
300
301 // fuzzy file filter
302 fileBrowserListeners(state.node_list_url, state.url_base);
303
304 // switch to widget
305 var initialCommitData = {
306 at_ref: atRef,
307 id: null,
308 text: '${c.commit.raw_id}',
309 type: 'sha',
310 raw_id: '${c.commit.raw_id}',
311 idx: ${c.commit.idx},
312 files_url: null,
313 };
314
315 // check if we have ref info.
316 var selectedRef = fileTreeRefs[atRef];
317 if (selectedRef !== undefined) {
318 $.extend(initialCommitData, selectedRef)
319 }
320
321 var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name});
322 var cacheKey = '__ALL_FILE_REFS__';
323 var cachedDataSource = {};
324
325 var loadRefsData = function (query) {
326 $.ajax({
327 url: loadUrl,
328 data: {},
329 dataType: 'json',
330 type: 'GET',
331 success: function (data) {
332 cachedDataSource[cacheKey] = data;
333 query.callback({results: data.results});
334 }
335 });
336 };
337
338 var feedRefsData = function (query, cachedData) {
339 var data = {results: []};
340 //filter results
341 $.each(cachedData.results, function () {
342 var section = this.text;
343 var children = [];
344 $.each(this.children, function () {
345 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
346 children.push(this)
347 }
348 });
349 data.results.push({
350 'text': section,
351 'children': children
352 })
353 });
354
355 //push the typed in commit idx
356 if (!isNaN(query.term)) {
357 var files_url = pyroutes.url('repo_files',
358 {'repo_name': templateContext.repo_name,
359 'commit_id': query.term, 'f_path': state.f_path});
360
361 data.results.push({
362 'text': _gettext('go to numeric commit'),
363 'children': [{
364 at_ref: null,
365 id: null,
366 text: 'r{0}'.format(query.term),
367 type: 'sha',
368 raw_id: query.term,
369 idx: query.term,
370 files_url: files_url,
371 }]
372 });
373 }
374 query.callback(data);
375 };
376
377 var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) {
378 var formatResult = function (result, container, query) {
379 return formatSelect2SelectionRefs(result);
380 };
381
382 var formatSelection = function (data, container) {
383 var commit_ref = data;
384
385 var tmpl = '';
386 if (commit_ref.type === 'sha') {
387 tmpl = (commit_ref.raw_id || "").substr(0,8);
388 } else if (commit_ref.type === 'branch') {
389 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
390 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
391 } else if (commit_ref.type === 'tag') {
392 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
393 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
394 } else if (commit_ref.type === 'book') {
395 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
396 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
397 }
398
399 var idx = commit_ref.idx || 0;
400 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
401 return tmpl
402 };
403
404 $(targetElement).select2({
405 dropdownAutoWidth: true,
406 width: "resolve",
407 containerCssClass: "drop-menu",
408 dropdownCssClass: "drop-menu-dropdown",
409 query: function(query) {
410
411 var cachedData = cachedDataSource[cacheKey];
412 if (cachedData) {
413 feedRefsData(query, cachedData)
414 } else {
415 loadRefsData(query)
416 }
417 },
418 initSelection: function(element, callback) {
419 callback(initialData);
420 },
421 formatResult: formatResult,
422 formatSelection: formatSelection
423 });
424
425 };
426
427 select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData);
428
429 $('#refs_filter').on('change', function(e) {
430 var data = $('#refs_filter').select2('data');
431 window.location = data.files_url
432 });
433
434 };
435
436 $(document).ready(function() {
129 437 timeagoActivate();
130 438
131 439 if ($('#trimmed_message_box').height() < 50) {
@@ -137,250 +445,12 b''
137 445 $(this).hide();
138 446 });
139 447
140 var state = getState('callbacks');
141
142 // VIEW FOR FILE SOURCE
143 448 if (fileSourcePage) {
144 // variants for with source code, not tree view
145
146 // select code link event
147 $("#hlcode").mouseup(getSelectionLink);
148
149 // file history select2 used for history, and switch to
150 var initialCommitData = {
151 id: null,
152 text: '${_("Pick Commit")}',
153 type: 'sha',
154 raw_id: null,
155 files_url: null
156 };
157
158 select2FileHistorySwitcher('#diff1', initialCommitData, state);
159
160 // show at, diff to actions handlers
161 $('#diff1').on('change', function(e) {
162 $('#diff_to_commit').removeClass('disabled').removeAttr("disabled");
163 $('#diff_to_commit').val(_gettext('Diff to Commit ') + e.val.truncateAfter(8, '...'));
164
165 $('#show_at_commit').removeClass('disabled').removeAttr("disabled");
166 $('#show_at_commit').val(_gettext('Show at Commit ') + e.val.truncateAfter(8, '...'));
167 });
168
169 $('#diff_to_commit').on('click', function(e) {
170 var diff1 = $('#diff1').val();
171 var diff2 = $('#diff2').val();
172
173 var url_data = {
174 repo_name: templateContext.repo_name,
175 source_ref: diff1,
176 source_ref_type: 'rev',
177 target_ref: diff2,
178 target_ref_type: 'rev',
179 merge: 1,
180 f_path: state.f_path
181 };
182 window.location = pyroutes.url('repo_compare', url_data);
183 });
184
185 $('#show_at_commit').on('click', function(e) {
186 var diff1 = $('#diff1').val();
187
188 var annotate = $('#annotate').val();
189 if (annotate === "True") {
190 var url = pyroutes.url('repo_files:annotated',
191 {'repo_name': templateContext.repo_name,
192 'commit_id': diff1, 'f_path': state.f_path});
193 } else {
194 var url = pyroutes.url('repo_files',
195 {'repo_name': templateContext.repo_name,
196 'commit_id': diff1, 'f_path': state.f_path});
197 }
198 window.location = url;
199
200 });
201
202 // show more authors
203 $('#show_authors').on('click', function(e) {
204 e.preventDefault();
205 var url = pyroutes.url('repo_file_authors',
206 {'repo_name': templateContext.repo_name,
207 'commit_id': state.rev, 'f_path': state.f_path});
208
209 $.pjax({
210 url: url,
211 data: 'annotate=${("1" if c.annotate else "0")}',
212 container: '#file_authors',
213 push: false,
214 timeout: 5000
215 }).complete(function(){
216 $('#show_authors').hide();
217 $('#file_authors_title').html(_gettext('All Authors'))
218 })
219 });
220
221 // load file short history
222 $('#file_history_overview').on('click', function(e) {
223 e.preventDefault();
224 path = state.f_path;
225 if (path.indexOf("#") >= 0) {
226 path = path.slice(0, path.indexOf("#"));
227 }
228 var url = pyroutes.url('repo_changelog_file',
229 {'repo_name': templateContext.repo_name,
230 'commit_id': state.rev, 'f_path': path, 'limit': 6});
231 $('#file_history_container').show();
232 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
233
234 $.pjax({
235 url: url,
236 container: '#file_history_container',
237 push: false,
238 timeout: 5000
239 })
240 });
241
449 initFileJS()
450 } else {
451 initTreeJS()
242 452 }
243 // VIEW FOR FILE TREE BROWSER
244 else {
245 getFilesMetadata();
246
247 // fuzzy file filter
248 fileBrowserListeners(state.node_list_url, state.url_base);
249
250 // switch to widget
251 var initialCommitData = {
252 at_ref: atRef,
253 id: null,
254 text: '${c.commit.raw_id}',
255 type: 'sha',
256 raw_id: '${c.commit.raw_id}',
257 idx: ${c.commit.idx},
258 files_url: null,
259 };
260 453
261 // check if we have ref info.
262 var selectedRef = fileTreeRefs[atRef];
263 if (selectedRef !== undefined) {
264 $.extend(initialCommitData, selectedRef)
265 }
266
267 var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name});
268 var cacheKey = '__ALL_FILE_REFS__';
269 var cachedDataSource = {};
270
271 var loadRefsData = function (query) {
272 $.ajax({
273 url: loadUrl,
274 data: {},
275 dataType: 'json',
276 type: 'GET',
277 success: function (data) {
278 cachedDataSource[cacheKey] = data;
279 query.callback({results: data.results});
280 }
281 });
282 };
283
284 var feedRefsData = function (query, cachedData) {
285 var data = {results: []};
286 //filter results
287 $.each(cachedData.results, function () {
288 var section = this.text;
289 var children = [];
290 $.each(this.children, function () {
291 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
292 children.push(this)
293 }
294 });
295 data.results.push({
296 'text': section,
297 'children': children
298 })
299 });
300
301 //push the typed in commit idx
302 if (!isNaN(query.term)) {
303 var files_url = pyroutes.url('repo_files',
304 {'repo_name': templateContext.repo_name,
305 'commit_id': query.term, 'f_path': state.f_path});
306
307 data.results.push({
308 'text': _gettext('go to numeric commit'),
309 'children': [{
310 at_ref: null,
311 id: null,
312 text: 'r{0}'.format(query.term),
313 type: 'sha',
314 raw_id: query.term,
315 idx: query.term,
316 files_url: files_url,
317 }]
318 });
319 }
320 query.callback(data);
321 };
322
323 var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) {
324 var formatResult = function (result, container, query) {
325 return formatSelect2SelectionRefs(result);
326 };
327
328 var formatSelection = function (data, container) {
329 var commit_ref = data;
330
331 var tmpl = '';
332 if (commit_ref.type === 'sha') {
333 tmpl = commit_ref.raw_id.substr(0,8);
334 } else if (commit_ref.type === 'branch') {
335 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
336 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
337 } else if (commit_ref.type === 'tag') {
338 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
339 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
340 } else if (commit_ref.type === 'book') {
341 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
342 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
343 }
344
345 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(commit_ref.idx));
346 return tmpl
347 };
348
349 $(targetElement).select2({
350 dropdownAutoWidth: true,
351 width: "resolve",
352 containerCssClass: "drop-menu",
353 dropdownCssClass: "drop-menu-dropdown",
354 query: function(query) {
355
356 var cachedData = cachedDataSource[cacheKey];
357 if (cachedData) {
358 feedRefsData(query, cachedData)
359 } else {
360 loadRefsData(query)
361 }
362 },
363 initSelection: function(element, callback) {
364 callback(initialData);
365 },
366 formatResult: formatResult,
367 formatSelection: formatSelection
368 });
369
370 };
371
372 select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData);
373
374 $('#refs_filter').on('change', function(e) {
375 var data = $('#refs_filter').select2('data');
376 window.location = data.files_url
377 });
378
379 }
380 };
381
382 $(document).ready(function() {
383 callbacks();
384 454 var search_GET = "${request.GET.get('search','')}";
385 455 if (search_GET === "1") {
386 456 NodeFilter.initFilter();
@@ -17,18 +17,28 b''
17 17 </div>
18 18
19 19 % if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
20 <div title="${_('Add New File')}" class="btn btn-primary new-file">
21 <a href="${h.route_path('repo_files_add_file',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path, _anchor='edit')}">
22 ${_('Add File')}</a>
20 <div>
21 <a class="btn btn-primary new-file" href="${h.route_path('repo_files_add_file',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path, _anchor='edit')}">
22 ${_('Upload File')}
23 </a>
24 <a class="btn btn-primary new-file" href="${h.route_path('repo_files_add_file',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path, _anchor='edit')}">
25 ${_('Add File')}
26 </a>
23 27 </div>
24 28 % endif
25 29
26 30 % if c.enable_downloads:
27 31 <% at_path = '{}'.format(request.GET.get('at') or c.commit.raw_id[:6]) %>
28 32 <div class="btn btn-default new-file">
29 <a href="${h.route_path('repo_archivefile',repo_name=c.repo_name, fname='{}.zip'.format(c.commit.raw_id))}">
30 ${_('Download ZIP @ ')} <code>${at_path}</code>
31 </a>
33 % if c.f_path == '/':
34 <a href="${h.route_path('repo_archivefile',repo_name=c.repo_name, fname='{}.zip'.format(c.commit.raw_id))}">
35 ${_('Download full tree ZIP')}
36 </a>
37 % else:
38 <a href="${h.route_path('repo_archivefile',repo_name=c.repo_name, fname='{}.zip'.format(c.commit.raw_id))}">
39 ${_('Download this tree ZIP')}
40 </a>
41 % endif
32 42 </div>
33 43 % endif
34 44
@@ -45,6 +55,7 b''
45 55 </div>
46 56
47 57 </div>
58
48 59 ## file tree is computed from caches, and filled in
49 60 <div id="file-tree">
50 61 ${c.file_tree |n}
@@ -17,19 +17,13 b''
17 17 </thead>
18 18
19 19 <tbody id="tbody">
20 %if c.file.parent:
21 <tr class="parity0">
22 <td class="td-componentname">
23 <a href="${h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.file.parent.path, _query=query)}">
24 <i class="icon-directory"></i>..
25 </a>
20 <tr>
21 <td colspan="5">
22
23 ${h.files_breadcrumbs(c.repo_name,c.commit.raw_id,c.file.path, request.GET.get('at'), limit_items=True)}
24
26 25 </td>
27 <td></td>
28 <td></td>
29 <td></td>
30 <td></td>
31 </tr>
32 %endif
26 </tr>
33 27 %for cnt,node in enumerate(c.file):
34 28 <tr class="parity${cnt%2}">
35 29 <td class="td-componentname">
@@ -13,14 +13,7 b''
13 13
14 14 <div class="summary-detail">
15 15 <div class="summary-detail-header">
16 <div class="breadcrumbs files_location">
17 <h4>
18 ${h.files_breadcrumbs(c.repo_name,c.commit.raw_id,c.file.path, request.GET.get('at'))}
19 %if c.annotate:
20 - ${_('annotation')}
21 %endif
22 </h4>
23 </div>
16
24 17 </div><!--end summary-detail-header-->
25 18
26 19 % if c.file.is_submodule():
@@ -1,16 +1,61 b''
1 1 <%namespace name="sourceblock" file="/codeblocks/source.mako"/>
2 2
3 <div id="codeblock" class="codeblock">
4 <div class="codeblock-header">
3 <div id="codeblock" class="browserblock">
4 <div class="browser-header">
5 <div class="browser-nav">
6 <div class="pull-left">
7 ## loads the history for a file
8 ${h.hidden('file_refs_filter')}
9 </div>
10
11 <div class="pull-right">
12
13 ## Download
14 % if c.lf_node:
15 <a class="btn btn-default" 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))}">
16 ${_('Download largefile')}
17 </a>
18 % else:
19 <a class="btn btn-default" href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}">
20 ${_('Download file')}
21 </a>
22 % endif
23
24 %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
25 ## on branch head, can edit files
26 %if c.on_branch_head and c.branch_or_raw_id and not c.file.is_binary:
27 ## binary files are delete only
28 % if c.file.is_binary:
29 ${h.link_to(_('Edit'), '#Edit', class_="btn btn-default disabled tooltip", title=_('Editing binary files not allowed'))}
30 ${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 btn-danger")}
31 % else:
32 <a class="btn btn-default" 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')}">
33 ${_('Edit on branch: ')}<code>${c.branch_name}</code>
34 </a>
35
36 <a class="btn btn-danger" 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')}">
37 ${_('Delete')}
38 </a>
39 % endif
40 ## not on head, forbid all
41 % else:
42 ${h.link_to(_('Edit'), '#Edit', class_="btn btn-default disabled tooltip", title=_('Editing files allowed only when on branch head commit'))}
43 ${h.link_to(_('Delete'), '#Delete', class_="btn btn-default btn-danger disabled tooltip", title=_('Deleting files allowed only when on branch head commit'))}
44 % endif
45 %endif
46
47 </div>
48 </div>
49 <div id="file_history_container"></div>
50
51 </div>
52 </div>
53
54 <div class="codeblock codeblock-header">
55 <div>
56 ${h.files_breadcrumbs(c.repo_name,c.commit.raw_id,c.file.path, request.GET.get('at'))}
57 </div>
5 58 <div class="stats">
6 <span class="stats-filename">
7 <strong>
8 <i class="icon-file-text"></i>
9 ${c.file.unicode_path_safe}
10 </strong>
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>
13 <br/>
14 59
15 60 % if c.lf_node:
16 61 <span title="${_('This file is a pointer to large binary file')}"> | ${_('LargeFile')} ${h.format_byte_size_binary(c.lf_node.size)} </span>
@@ -22,50 +67,22 b''
22 67 <span> | ${c.file.mimetype} </span>
23 68 <span> | ${h.get_lexer_for_filenode(c.file).__class__.__name__}</span>
24 69 </div>
70
25 71 </div>
26 <div class="buttons">
27 <a id="file_history_overview" href="#">
28 ${_('History')}
29 </a>
30 <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)}">
31 ${_('Show Full History')}
32 </a> |
33 %if c.annotate:
34 ${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))}
35 %else:
36 ${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))}
37 %endif
38 | ${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))}
39 |
40 % if c.lf_node:
41 <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))}">
42 ${_('Download largefile')}
43 </a>
44 % else:
45 <a href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}">
46 ${_('Download')}
47 </a>
48 % endif
72 <div class="pull-right">
73 <a id="file_history_overview" href="#loadHistory">
74 ${_('History')}
75 </a>
76 |
77 %if c.annotate:
78 ${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))}
79 %else:
80 ${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))}
81 %endif
82 | ${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))}
49 83
50 %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
51 |
52 %if c.on_branch_head and c.branch_or_raw_id and not c.file.is_binary:
53 <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')}">
54 ${_('Edit on Branch:{}').format(c.branch_name)}
55 </a>
56 | <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')}
57 </a>
58 %elif c.on_branch_head and c.branch_or_raw_id and c.file.is_binary:
59 ${h.link_to(_('Edit'), '#', class_="btn btn-link disabled tooltip", title=_('Editing binary files not allowed'))}
60 | ${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")}
61 %else:
62 ${h.link_to(_('Edit'), '#', class_="btn btn-link disabled tooltip", title=_('Editing files allowed only when on branch head commit'))}
63 | ${h.link_to(_('Delete'), '#', class_="btn btn-danger btn-link disabled tooltip", title=_('Deleting files allowed only when on branch head commit'))}
64 %endif
65 %endif
66 84 </div>
67 </div>
68 <div id="file_history_container"></div>
85
69 86 <div class="code-body">
70 87 %if c.file.is_binary:
71 88 <% rendered_binary = h.render_binary(c.repo_name, c.file)%>
@@ -36,29 +36,6 b''
36 36 </div>
37 37 </div>
38 38 </div>
39
40
41 <div class="fieldset collapsable-content" data-toggle="summary-details">
42 <div class="left-label-summary-files">
43 <p class="spacing">${_('Show/Diff file')}</p>
44 <div class="right-label-summary">
45 ${h.hidden('diff1')}
46 ${h.hidden('diff2',c.commit.raw_id)}
47 ${h.hidden('annotate', c.annotate)}
48 </div>
49 </div>
50 </div>
51
52
53 <div class="fieldset collapsable-content" data-toggle="summary-details">
54 <div class="left-label-summary-files">
55 <p>${_('Action')}</p>
56 <div class="right-label-summary">
57 ${h.submit('diff_to_commit',_('Diff to Commit'),class_="btn disabled",disabled="true")}
58 ${h.submit('show_at_commit',_('Show at Commit'),class_="btn disabled",disabled="true")}
59 </div>
60 </div>
61 </div>
62 39 </div>
63 40
64 41 <div class="right-content">
General Comments 0
You need to be logged in to leave comments. Login now