##// END OF EJS Templates
annotation: added shortcut links to browse the annotation view with previous commits.
marcink -
r1413:44a048ec default
parent child Browse files
Show More
@@ -1066,6 +1066,12 b' def make_map(config):'
1066 1066 f_path='', annotate=True, conditions={'function': check_repo},
1067 1067 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
1068 1068
1069 rmap.connect('files_annotate_previous',
1070 '/{repo_name}/annotate-previous/{revision}/{f_path}',
1071 controller='files', action='annotate_previous', revision='tip',
1072 f_path='', annotate=True, conditions={'function': check_repo},
1073 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
1074
1069 1075 rmap.connect('files_edit',
1070 1076 '/{repo_name}/edit/{revision}/{f_path}',
1071 1077 controller='files', action='edit', revision='tip',
@@ -260,6 +260,32 b' class FilesController(BaseRepoController'
260 260 return render('files/files.mako')
261 261
262 262 @LoginRequired()
263 @HasRepoPermissionAnyDecorator(
264 'repository.read', 'repository.write', 'repository.admin')
265 def annotate_previous(self, repo_name, revision, f_path):
266
267 commit_id = revision
268 commit = self.__get_commit_or_redirect(commit_id, repo_name)
269 prev_commit_id = commit.raw_id
270
271 f_path = f_path
272 is_file = False
273 try:
274 _file = commit.get_node(f_path)
275 is_file = _file.is_file()
276 except (NodeDoesNotExistError, CommitDoesNotExistError, VCSError):
277 pass
278
279 if is_file:
280 history = commit.get_file_history(f_path)
281 prev_commit_id = history[1].raw_id \
282 if len(history) > 1 else prev_commit_id
283
284 return redirect(h.url(
285 'files_annotate_home', repo_name=repo_name,
286 revision=prev_commit_id, f_path=f_path))
287
288 @LoginRequired()
263 289 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
264 290 'repository.admin')
265 291 @jsonify
@@ -1105,6 +1105,7 b' table.cb {'
1105 1105 }
1106 1106 &.cb-annotate-message-spacer {
1107 1107 width:8px;
1108 padding: 1px 0px 0px 3px;
1108 1109 }
1109 1110 &.cb-annotate-info {
1110 1111 width: 320px;
@@ -49,6 +49,7 b' function registerRCRoutes() {'
49 49 pyroutes.register('files_history_home', '/%(repo_name)s/history/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
50 50 pyroutes.register('files_authors_home', '/%(repo_name)s/authors/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
51 51 pyroutes.register('files_annotate_home', '/%(repo_name)s/annotate/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
52 pyroutes.register('files_annotate_previous', '/%(repo_name)s/annotate-previous/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
52 53 pyroutes.register('files_archive_home', '/%(repo_name)s/archive/%(fname)s', ['repo_name', 'fname']);
53 54 pyroutes.register('files_nodelist_home', '/%(repo_name)s/nodelist/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
54 55 pyroutes.register('files_nodetree_full', '/%(repo_name)s/nodetree_full/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
@@ -20,7 +20,11 b''
20 20 ${h.gravatar_with_user(annotation.author, 16) | n}
21 21 <div class="cb-annotate-message truncate-wrap">${h.chop_at_smart(annotation.message, '\n', suffix_if_chopped='...')}</div>
22 22 </td>
23 <td class="cb-annotate-message-spacer"></td>
23 <td class="cb-annotate-message-spacer">
24 <a class="tooltip" href="#show-previous-annotation" onclick="return annotationController.previousAnnotation('${annotation.raw_id}', '${c.f_path}')" title="${_('view annotation from before this change')}">
25 <i class="icon-left"></i>
26 </a>
27 </td>
24 28 <td
25 29 class="cb-annotate-revision"
26 30 data-revision="${annotation.revision}"
@@ -67,5 +71,20 b''
67 71 annotation=annotation, show_annotation=loop.first
68 72 )}
69 73 % endfor
74 <script>
75 var AnnotationController = function() {
76 var self = this;
70 77
78 this.previousAnnotation = function(commitId, fPath) {
79 var params = {
80 'repo_name': templateContext.repo_name,
81 'revision': commitId,
82 'f_path': fPath
83 };
84 window.location = pyroutes.url('files_annotate_previous', params);
85 return false;
86 };
87 };
88 var annotationController = new AnnotationController();
89 </script>
71 90 </%def>
General Comments 0
You need to be logged in to leave comments. Login now