Show More
@@ -328,3 +328,84 b' var getSelectionLink = function(e) {' | |||
|
328 | 328 | } |
|
329 | 329 | } |
|
330 | 330 | }; |
|
331 | ||
|
332 | var getFileState = function() { | |
|
333 | // relies on a global set filesUrlData | |
|
334 | var f_path = filesUrlData['f_path']; | |
|
335 | var commit_id = filesUrlData['commit_id']; | |
|
336 | ||
|
337 | var url_params = { | |
|
338 | repo_name: templateContext.repo_name, | |
|
339 | commit_id: commit_id, | |
|
340 | f_path:'__FPATH__' | |
|
341 | }; | |
|
342 | if (atRef !== '') { | |
|
343 | url_params['at'] = atRef | |
|
344 | } | |
|
345 | ||
|
346 | var _url_base = pyroutes.url('repo_files', url_params); | |
|
347 | var _node_list_url = pyroutes.url('repo_files_nodelist', | |
|
348 | {repo_name: templateContext.repo_name, | |
|
349 | commit_id: commit_id, f_path: f_path}); | |
|
350 | ||
|
351 | return { | |
|
352 | f_path: f_path, | |
|
353 | commit_id: commit_id, | |
|
354 | node_list_url: _node_list_url, | |
|
355 | url_base: _url_base | |
|
356 | }; | |
|
357 | }; | |
|
358 | ||
|
359 | var getFilesMetadata = function() { | |
|
360 | // relies on metadataRequest global state | |
|
361 | if (metadataRequest && metadataRequest.readyState != 4) { | |
|
362 | metadataRequest.abort(); | |
|
363 | } | |
|
364 | ||
|
365 | if ($('#file-tree-wrapper').hasClass('full-load')) { | |
|
366 | // in case our HTML wrapper has full-load class we don't | |
|
367 | // trigger the async load of metadata | |
|
368 | return false; | |
|
369 | } | |
|
370 | ||
|
371 | var state = getFileState(); | |
|
372 | var url_data = { | |
|
373 | 'repo_name': templateContext.repo_name, | |
|
374 | 'commit_id': state.commit_id, | |
|
375 | 'f_path': state.f_path | |
|
376 | }; | |
|
377 | ||
|
378 | var url = pyroutes.url('repo_nodetree_full', url_data); | |
|
379 | ||
|
380 | metadataRequest = $.ajax({url: url}); | |
|
381 | ||
|
382 | metadataRequest.done(function(data) { | |
|
383 | $('#file-tree').html(data); | |
|
384 | timeagoActivate(); | |
|
385 | }); | |
|
386 | metadataRequest.fail(function (data, textStatus, errorThrown) { | |
|
387 | if (data.status != 0) { | |
|
388 | alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText)); | |
|
389 | } | |
|
390 | }); | |
|
391 | }; | |
|
392 | ||
|
393 | // show more authors | |
|
394 | var showAuthors = function(elem, annotate) { | |
|
395 | var state = getFileState('callbacks'); | |
|
396 | ||
|
397 | var url = pyroutes.url('repo_file_authors', | |
|
398 | {'repo_name': templateContext.repo_name, | |
|
399 | 'commit_id': state.commit_id, 'f_path': state.f_path}); | |
|
400 | ||
|
401 | $.pjax({ | |
|
402 | url: url, | |
|
403 | data: 'annotate={0}'.format(annotate), | |
|
404 | container: '#file_authors', | |
|
405 | push: false, | |
|
406 | timeout: 5000 | |
|
407 | }).complete(function(){ | |
|
408 | $(elem).hide(); | |
|
409 | $('#file_authors_title').html(_gettext('All Authors')) | |
|
410 | }) | |
|
411 | }; |
@@ -10,7 +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" |
|
|
13 | <a href="#ShowAuthors" onclick="showAuthors(this, ${("1" if c.annotate else "0")}); return false" class="action_link"> - ${_('Load All Authors')}</a> | |
|
14 | 14 | % elif c.file_last_commit.author_email==email: |
|
15 | 15 | <span> (${_('last author')})</span> |
|
16 | 16 | % endif |
@@ -27,105 +27,27 b'' | |||
|
27 | 27 | </%def> |
|
28 | 28 | |
|
29 | 29 | <%def name="main()"> |
|
30 | <script type="text/javascript"> | |
|
31 | var fileSourcePage = ${c.file_source_page}; | |
|
32 | var atRef = '${request.GET.get('at', '')}'; | |
|
33 | ||
|
34 | // global state for fetching metadata | |
|
35 | metadataRequest = null; | |
|
36 | ||
|
37 | // global metadata about URL | |
|
38 | filesUrlData = ${h.json.dumps(request.matchdict)|n}; | |
|
39 | </script> | |
|
40 | ||
|
30 | 41 | <div> |
|
31 | 42 | <div id="files_data"> |
|
32 | 43 | <%include file='files_pjax.mako'/> |
|
33 | 44 | </div> |
|
34 | 45 | </div> |
|
35 | <script> | |
|
36 | 46 | |
|
37 | var metadataRequest = null; | |
|
38 | var fileSourcePage = ${c.file_source_page}; | |
|
39 | var atRef = '${request.GET.get('at', '')}'; | |
|
40 | ||
|
41 | var getState = function(context) { | |
|
42 | var url = $(location).attr('href'); | |
|
43 | var _base_url = '${h.route_path("repo_files",repo_name=c.repo_name,commit_id='',f_path='')}'; | |
|
44 | var _annotate_url = '${h.route_path("repo_files:annotated",repo_name=c.repo_name,commit_id='',f_path='')}'; | |
|
45 | _base_url = _base_url.replace('//', '/'); | |
|
46 | _annotate_url = _annotate_url.replace('//', '/'); | |
|
47 | ||
|
48 | //extract f_path from url. | |
|
49 | var parts = url.split(_base_url); | |
|
50 | if (parts.length != 2) { | |
|
51 | parts = url.split(_annotate_url); | |
|
52 | if (parts.length != 2) { | |
|
53 | var rev = "tip"; | |
|
54 | var f_path = ""; | |
|
55 | } else { | |
|
56 | var parts2 = parts[1].split('/'); | |
|
57 | var rev = parts2.shift(); // pop the first element which is the revision | |
|
58 | var f_path = parts2.join('/'); | |
|
59 | } | |
|
60 | ||
|
61 | } else { | |
|
62 | var parts2 = parts[1].split('/'); | |
|
63 | var rev = parts2.shift(); // pop the first element which is the revision | |
|
64 | var f_path = parts2.join('/'); | |
|
65 | } | |
|
66 | ||
|
67 | var url_params = { | |
|
68 | repo_name: templateContext.repo_name, | |
|
69 | commit_id: rev, | |
|
70 | f_path:'__FPATH__' | |
|
71 | }; | |
|
72 | if (atRef !== '') { | |
|
73 | url_params['at'] = atRef | |
|
74 | } | |
|
75 | ||
|
76 | var _url_base = pyroutes.url('repo_files', url_params); | |
|
77 | var _node_list_url = pyroutes.url('repo_files_nodelist', | |
|
78 | {repo_name: templateContext.repo_name, | |
|
79 | commit_id: rev, f_path: f_path}); | |
|
80 | ||
|
81 | return { | |
|
82 | url: url, | |
|
83 | f_path: f_path, | |
|
84 | rev: rev, | |
|
85 | commit_id: "${c.commit.raw_id}", | |
|
86 | node_list_url: _node_list_url, | |
|
87 | url_base: _url_base | |
|
88 | }; | |
|
89 | }; | |
|
90 | ||
|
91 | var getFilesMetadata = function() { | |
|
92 | if (metadataRequest && metadataRequest.readyState != 4) { | |
|
93 | metadataRequest.abort(); | |
|
94 | } | |
|
95 | if (fileSourcePage) { | |
|
96 | return false; | |
|
97 | } | |
|
98 | ||
|
99 | if ($('#file-tree-wrapper').hasClass('full-load')) { | |
|
100 | // in case our HTML wrapper has full-load class we don't | |
|
101 | // trigger the async load of metadata | |
|
102 | return false; | |
|
103 | } | |
|
104 | ||
|
105 | var state = getState('metadata'); | |
|
106 | var url_data = { | |
|
107 | 'repo_name': templateContext.repo_name, | |
|
108 | 'commit_id': state.commit_id, | |
|
109 | 'f_path': state.f_path | |
|
110 | }; | |
|
111 | ||
|
112 | var url = pyroutes.url('repo_nodetree_full', url_data); | |
|
113 | ||
|
114 | metadataRequest = $.ajax({url: url}); | |
|
115 | ||
|
116 | metadataRequest.done(function(data) { | |
|
117 | $('#file-tree').html(data); | |
|
118 | timeagoActivate(); | |
|
119 | }); | |
|
120 | metadataRequest.fail(function (data, textStatus, errorThrown) { | |
|
121 | if (data.status != 0) { | |
|
122 | alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText)); | |
|
123 | } | |
|
124 | }); | |
|
125 | }; | |
|
47 | <script type="text/javascript"> | |
|
126 | 48 | |
|
127 | 49 | var initFileJS = function () { |
|
128 |
var state = getState( |
|
|
50 | var state = getFileState(); | |
|
129 | 51 | |
|
130 | 52 | // select code link event |
|
131 | 53 | $("#hlcode").mouseup(getSelectionLink); |
@@ -147,7 +69,7 b'' | |||
|
147 | 69 | $.extend(initialCommitData, selectedRef) |
|
148 | 70 | } |
|
149 | 71 | |
|
150 |
var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state. |
|
|
72 | var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.commit_id,'f_path': state.f_path}); | |
|
151 | 73 | var cacheKey = '__SINGLE_FILE_REFS__'; |
|
152 | 74 | var cachedDataSource = {}; |
|
153 | 75 | |
@@ -253,25 +175,6 b'' | |||
|
253 | 175 | |
|
254 | 176 | }); |
|
255 | 177 | |
|
256 | // show more authors | |
|
257 | $('#show_authors').on('click', function(e) { | |
|
258 | e.preventDefault(); | |
|
259 | var url = pyroutes.url('repo_file_authors', | |
|
260 | {'repo_name': templateContext.repo_name, | |
|
261 | 'commit_id': state.rev, 'f_path': state.f_path}); | |
|
262 | ||
|
263 | $.pjax({ | |
|
264 | url: url, | |
|
265 | data: 'annotate=${("1" if c.annotate else "0")}', | |
|
266 | container: '#file_authors', | |
|
267 | push: false, | |
|
268 | timeout: 5000 | |
|
269 | }).complete(function(){ | |
|
270 | $('#show_authors').hide(); | |
|
271 | $('#file_authors_title').html(_gettext('All Authors')) | |
|
272 | }) | |
|
273 | }); | |
|
274 | ||
|
275 | 178 | // load file short history |
|
276 | 179 | $('#file_history_overview').on('click', function(e) { |
|
277 | 180 | e.preventDefault(); |
@@ -281,7 +184,7 b'' | |||
|
281 | 184 | } |
|
282 | 185 | var url = pyroutes.url('repo_changelog_file', |
|
283 | 186 | {'repo_name': templateContext.repo_name, |
|
284 |
'commit_id': state. |
|
|
187 | 'commit_id': state.commit_id, 'f_path': path, 'limit': 6}); | |
|
285 | 188 | $('#file_history_container').show(); |
|
286 | 189 | $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...'))); |
|
287 | 190 | |
@@ -293,11 +196,10 b'' | |||
|
293 | 196 | }); |
|
294 | 197 | }); |
|
295 | 198 | |
|
296 | ||
|
297 | 199 | }; |
|
298 | 200 | |
|
299 | 201 | var initTreeJS = function () { |
|
300 |
var state = getState( |
|
|
202 | var state = getFileState(); | |
|
301 | 203 | getFilesMetadata(); |
|
302 | 204 | |
|
303 | 205 | // fuzzy file filter |
General Comments 0
You need to be logged in to leave comments.
Login now