##// END OF EJS Templates
hovercards: added commit hovercard for files, and dashboard views.
marcink -
r4032:07c1bd09 default
parent child Browse files
Show More
@@ -0,0 +1,8 b''
1 <%namespace name="base" file="/base/base.mako"/>
2 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
3
4 <div class="clear-fix">${base.gravatar_with_user(c.commit.author, tooltip=True)}</div>
5 <br/>
6 <a href="${h.route_path('repo_commit', repo_name=c.repo_name, commit_id=c.commit.raw_id)}">${h.show_id(c.commit)}</a> - ${c.commit.date}
7 <br/><br/>
8 <pre>${h.urlify_commit_message(c.commit.message, c.repo_name)}</pre>
@@ -17,7 +17,6 b''
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 from rhodecode.config import routing_links
21
20
22
21
23 def includeme(config):
22 def includeme(config):
@@ -31,8 +30,8 b' def includeme(config):'
31 pattern='/_hovercard/user_group/{user_group_id}')
30 pattern='/_hovercard/user_group/{user_group_id}')
32
31
33 config.add_route(
32 config.add_route(
34 name='hovercard_commit',
33 name='hovercard_repo_commit',
35 pattern='/_hovercard/commit/{repo_name}/{user_id}')
34 pattern='/_hovercard/commit/{repo_name:.*?[^/]}/{commit_id}', repo_route=True)
36
35
37 # Scan module for configuration decorators.
36 # Scan module for configuration decorators.
38 config.scan('.views', ignore='.tests')
37 config.scan('.views', ignore='.tests')
@@ -24,10 +24,11 b' import collections'
24
24
25 from pyramid.view import view_config
25 from pyramid.view import view_config
26
26
27 from rhodecode.apps._base import BaseAppView
27 from rhodecode.apps._base import BaseAppView, RepoAppView
28 from rhodecode.lib import helpers as h
28 from rhodecode.lib import helpers as h
29 from rhodecode.lib.auth import (
29 from rhodecode.lib.auth import (
30 LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator, CSRFRequired)
30 LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator, CSRFRequired,
31 HasRepoPermissionAnyDecorator)
31 from rhodecode.lib.codeblocks import filenode_as_lines_tokens
32 from rhodecode.lib.codeblocks import filenode_as_lines_tokens
32 from rhodecode.lib.index import searcher_from_config
33 from rhodecode.lib.index import searcher_from_config
33 from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int
34 from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int
@@ -69,3 +70,21 b' class HoverCardsView(BaseAppView):'
69 user_group_id = self.request.matchdict['user_group_id']
70 user_group_id = self.request.matchdict['user_group_id']
70 c.user_group = UserGroup.get_or_404(user_group_id)
71 c.user_group = UserGroup.get_or_404(user_group_id)
71 return self._get_template_context(c)
72 return self._get_template_context(c)
73
74
75 class HoverCardsRepoView(RepoAppView):
76 def load_default_context(self):
77 c = self._get_local_tmpl_context()
78 return c
79
80 @LoginRequired()
81 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin')
82 @view_config(
83 route_name='hovercard_repo_commit', request_method='GET', xhr=True,
84 renderer='rhodecode:templates/hovercards/hovercard_repo_commit.mako')
85 def hovercard_repo_commit(self):
86 c = self.load_default_context()
87 commit_id = self.request.matchdict['commit_id']
88 pre_load = ['author', 'branch', 'date', 'message']
89 c.commit = self.rhodecode_vcs_repo.get_commit(commit_id=commit_id, pre_load=pre_load)
90 return self._get_template_context(c)
@@ -1690,8 +1690,9 b' def process_patterns(text_string, repo_n'
1690
1690
1691 active_entries = active_entries or get_active_pattern_entries(repo_name)
1691 active_entries = active_entries or get_active_pattern_entries(repo_name)
1692 issues_data = []
1692 issues_data = []
1693 newtext = text_string
1693 new_text = text_string
1694
1694
1695 log.debug('Got %s entries to process', len(active_entries))
1695 for uid, entry in active_entries.items():
1696 for uid, entry in active_entries.items():
1696 log.debug('found issue tracker entry with uid %s', uid)
1697 log.debug('found issue tracker entry with uid %s', uid)
1697
1698
@@ -1705,9 +1706,7 b' def process_patterns(text_string, repo_n'
1705 try:
1706 try:
1706 pattern = re.compile(r'%s' % entry['pat'])
1707 pattern = re.compile(r'%s' % entry['pat'])
1707 except re.error:
1708 except re.error:
1708 log.exception(
1709 log.exception('issue tracker pattern: `%s` failed to compile', entry['pat'])
1709 'issue tracker pattern: `%s` failed to compile',
1710 entry['pat'])
1711 continue
1710 continue
1712
1711
1713 data_func = partial(
1712 data_func = partial(
@@ -1721,10 +1720,10 b' def process_patterns(text_string, repo_n'
1721 _process_url_func, repo_name=repo_name, entry=entry, uid=uid,
1720 _process_url_func, repo_name=repo_name, entry=entry, uid=uid,
1722 link_format=link_format)
1721 link_format=link_format)
1723
1722
1724 newtext = pattern.sub(url_func, newtext)
1723 new_text = pattern.sub(url_func, new_text)
1725 log.debug('processed prefix:uid `%s`', uid)
1724 log.debug('processed prefix:uid `%s`', uid)
1726
1725
1727 return newtext, issues_data
1726 return new_text, issues_data
1728
1727
1729
1728
1730 def urlify_commit_message(commit_text, repository=None, active_pattern_entries=None):
1729 def urlify_commit_message(commit_text, repository=None, active_pattern_entries=None):
@@ -32,7 +32,7 b' function registerRCRoutes() {'
32 pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']);
32 pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']);
33 pyroutes.register('hovercard_user', '/_hovercard/user/%(user_id)s', ['user_id']);
33 pyroutes.register('hovercard_user', '/_hovercard/user/%(user_id)s', ['user_id']);
34 pyroutes.register('hovercard_user_group', '/_hovercard/user_group/%(user_group_id)s', ['user_group_id']);
34 pyroutes.register('hovercard_user_group', '/_hovercard/user_group/%(user_group_id)s', ['user_group_id']);
35 pyroutes.register('hovercard_commit', '/_hovercard/commit/%(repo_name)s/%(user_id)s', ['repo_name', 'user_id']);
35 pyroutes.register('hovercard_repo_commit', '/_hovercard/commit/%(repo_name)s/%(commit_id)s', ['repo_name', 'commit_id']);
36 pyroutes.register('ops_ping', '/_admin/ops/ping', []);
36 pyroutes.register('ops_ping', '/_admin/ops/ping', []);
37 pyroutes.register('ops_error_test', '/_admin/ops/error', []);
37 pyroutes.register('ops_error_test', '/_admin/ops/error', []);
38 pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []);
38 pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []);
@@ -248,16 +248,18 b' var tooltipActivate = function () {'
248
248
249 if (hovercardCache[id] !== undefined) {
249 if (hovercardCache[id] !== undefined) {
250 callback(hovercardCache[id]);
250 callback(hovercardCache[id]);
251 return;
251 return true;
252 }
252 }
253
253
254 hovercardCache[id] = undefined;
254 hovercardCache[id] = undefined;
255 $.get(url, function (data) {
255 $.get(url, function (data) {
256 hovercardCache[id] = data;
256 hovercardCache[id] = data;
257 callback(hovercardCache[id]);
257 callback(hovercardCache[id]);
258 return true;
258 }).fail(function (data, textStatus, errorThrown) {
259 }).fail(function (data, textStatus, errorThrown) {
259 var msg = "Error while fetching hovercard.\nError code {0} ({1}).".format(data.status,data.statusText);
260 var msg = "<p class='error-message'>Error while fetching hovercard.\nError code {0} ({1}).</p>".format(data.status,data.statusText);
260 callback(msg);
261 callback(msg);
262 return false
261 });
263 });
262 };
264 };
263
265
@@ -291,7 +293,7 b' var tooltipActivate = function () {'
291 var hovercardUrl = $origin.data('hovercardUrl');
293 var hovercardUrl = $origin.data('hovercardUrl');
292
294
293 if (hovercardUrl !== undefined && hovercardUrl !== "") {
295 if (hovercardUrl !== undefined && hovercardUrl !== "") {
294 loadHoverCard(hovercardUrl, function (data) {
296 var loaded = loadHoverCard(hovercardUrl, function (data) {
295 instance.content(data);
297 instance.content(data);
296 })
298 })
297 } else {
299 } else {
@@ -300,12 +302,12 b' var tooltipActivate = function () {'
300 } else {
302 } else {
301 var data = '<div style="white-space: pre-wrap">{0}</div>'.format($origin.data('hovercardAlt'))
303 var data = '<div style="white-space: pre-wrap">{0}</div>'.format($origin.data('hovercardAlt'))
302 }
304 }
303
305 var loaded = true;
304 instance.content(data);
306 instance.content(data);
305 }
307 }
306
308
307 // to remember that the data has been loaded
309 // to remember that the data has been loaded
308 $origin.data('loaded', true);
310 $origin.data('loaded', loaded);
309 }
311 }
310 }
312 }
311 })
313 })
@@ -141,10 +141,10 b''
141 ${h.age_component(last_change, time_is_local=True)}
141 ${h.age_component(last_change, time_is_local=True)}
142 </%def>
142 </%def>
143
143
144 <%def name="revision(name,rev,tip,author,last_msg, commit_date)">
144 <%def name="revision(repo_name, rev, commit_id, author, last_msg, commit_date)">
145 <div>
145 <div>
146 %if rev >= 0:
146 %if rev >= 0:
147 <code><a title="${h.tooltip('%s\n%s\n\n%s' % (author, commit_date, last_msg))}" class="tooltip" href="${h.route_path('repo_commit',repo_name=name,commit_id=tip)}">${'r%s:%s' % (rev,h.short_id(tip))}</a></code>
147 <code><a class="tooltip-hovercard" data-hovercard-alt="${last_msg}" data-hovercard-url="${h.route_path('hovercard_repo_commit', repo_name=repo_name, commit_id=commit_id)}" href="${h.route_path('repo_commit',repo_name=repo_name,commit_id=commit_id)}">${'r{}:{}'.format(rev,h.short_id(commit_id))}</a></code>
148 %else:
148 %else:
149 ${_('No commits yet')}
149 ${_('No commits yet')}
150 %endif
150 %endif
@@ -1,3 +1,5 b''
1 <%namespace name="base" file="/base/base.mako"/>
2
1 <%
3 <%
2 if request.GET.get('at'):
4 if request.GET.get('at'):
3 query={'at': request.GET.get('at')}
5 query={'at': request.GET.get('at')}
@@ -60,7 +62,7 b''
60 </td>
62 </td>
61 <td class="td-hash" data-attr-name="commit_id">
63 <td class="td-hash" data-attr-name="commit_id">
62 % if c.full_load:
64 % if c.full_load:
63 <div class="tooltip" title="${h.tooltip(node.last_commit.message)}">
65 <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)}">
64 <pre data-commit-id="${node.last_commit.raw_id}">r${node.last_commit.idx}:${node.last_commit.short_id}</pre>
66 <pre data-commit-id="${node.last_commit.raw_id}">r${node.last_commit.idx}:${node.last_commit.short_id}</pre>
65 </div>
67 </div>
66 % endif
68 % endif
General Comments 0
You need to be logged in to leave comments. Login now