diff --git a/rhodecode/apps/hovercards/__init__.py b/rhodecode/apps/hovercards/__init__.py --- a/rhodecode/apps/hovercards/__init__.py +++ b/rhodecode/apps/hovercards/__init__.py @@ -17,7 +17,6 @@ # This program is dual-licensed. If you wish to learn more about the # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ -from rhodecode.config import routing_links def includeme(config): @@ -31,8 +30,8 @@ def includeme(config): pattern='/_hovercard/user_group/{user_group_id}') config.add_route( - name='hovercard_commit', - pattern='/_hovercard/commit/{repo_name}/{user_id}') + name='hovercard_repo_commit', + pattern='/_hovercard/commit/{repo_name:.*?[^/]}/{commit_id}', repo_route=True) # Scan module for configuration decorators. config.scan('.views', ignore='.tests') diff --git a/rhodecode/apps/hovercards/views.py b/rhodecode/apps/hovercards/views.py --- a/rhodecode/apps/hovercards/views.py +++ b/rhodecode/apps/hovercards/views.py @@ -24,10 +24,11 @@ import collections from pyramid.view import view_config -from rhodecode.apps._base import BaseAppView +from rhodecode.apps._base import BaseAppView, RepoAppView from rhodecode.lib import helpers as h from rhodecode.lib.auth import ( - LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator, CSRFRequired) + LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator, CSRFRequired, + HasRepoPermissionAnyDecorator) from rhodecode.lib.codeblocks import filenode_as_lines_tokens from rhodecode.lib.index import searcher_from_config from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int @@ -69,3 +70,21 @@ class HoverCardsView(BaseAppView): user_group_id = self.request.matchdict['user_group_id'] c.user_group = UserGroup.get_or_404(user_group_id) return self._get_template_context(c) + + +class HoverCardsRepoView(RepoAppView): + def load_default_context(self): + c = self._get_local_tmpl_context() + return c + + @LoginRequired() + @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin') + @view_config( + route_name='hovercard_repo_commit', request_method='GET', xhr=True, + renderer='rhodecode:templates/hovercards/hovercard_repo_commit.mako') + def hovercard_repo_commit(self): + c = self.load_default_context() + commit_id = self.request.matchdict['commit_id'] + pre_load = ['author', 'branch', 'date', 'message'] + c.commit = self.rhodecode_vcs_repo.get_commit(commit_id=commit_id, pre_load=pre_load) + return self._get_template_context(c) diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1690,8 +1690,9 @@ def process_patterns(text_string, repo_n active_entries = active_entries or get_active_pattern_entries(repo_name) issues_data = [] - newtext = text_string + new_text = text_string + log.debug('Got %s entries to process', len(active_entries)) for uid, entry in active_entries.items(): log.debug('found issue tracker entry with uid %s', uid) @@ -1705,9 +1706,7 @@ def process_patterns(text_string, repo_n try: pattern = re.compile(r'%s' % entry['pat']) except re.error: - log.exception( - 'issue tracker pattern: `%s` failed to compile', - entry['pat']) + log.exception('issue tracker pattern: `%s` failed to compile', entry['pat']) continue data_func = partial( @@ -1721,10 +1720,10 @@ def process_patterns(text_string, repo_n _process_url_func, repo_name=repo_name, entry=entry, uid=uid, link_format=link_format) - newtext = pattern.sub(url_func, newtext) + new_text = pattern.sub(url_func, new_text) log.debug('processed prefix:uid `%s`', uid) - return newtext, issues_data + return new_text, issues_data def urlify_commit_message(commit_text, repository=None, active_pattern_entries=None): diff --git a/rhodecode/public/js/rhodecode/routes.js b/rhodecode/public/js/rhodecode/routes.js --- a/rhodecode/public/js/rhodecode/routes.js +++ b/rhodecode/public/js/rhodecode/routes.js @@ -32,7 +32,7 @@ function registerRCRoutes() { pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']); pyroutes.register('hovercard_user', '/_hovercard/user/%(user_id)s', ['user_id']); pyroutes.register('hovercard_user_group', '/_hovercard/user_group/%(user_group_id)s', ['user_group_id']); - pyroutes.register('hovercard_commit', '/_hovercard/commit/%(repo_name)s/%(user_id)s', ['repo_name', 'user_id']); + pyroutes.register('hovercard_repo_commit', '/_hovercard/commit/%(repo_name)s/%(commit_id)s', ['repo_name', 'commit_id']); pyroutes.register('ops_ping', '/_admin/ops/ping', []); pyroutes.register('ops_error_test', '/_admin/ops/error', []); pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []); diff --git a/rhodecode/public/js/src/rhodecode.js b/rhodecode/public/js/src/rhodecode.js --- a/rhodecode/public/js/src/rhodecode.js +++ b/rhodecode/public/js/src/rhodecode.js @@ -248,16 +248,18 @@ var tooltipActivate = function () { if (hovercardCache[id] !== undefined) { callback(hovercardCache[id]); - return; + return true; } hovercardCache[id] = undefined; $.get(url, function (data) { hovercardCache[id] = data; callback(hovercardCache[id]); + return true; }).fail(function (data, textStatus, errorThrown) { - var msg = "Error while fetching hovercard.\nError code {0} ({1}).".format(data.status,data.statusText); + var msg = "

Error while fetching hovercard.\nError code {0} ({1}).

".format(data.status,data.statusText); callback(msg); + return false }); }; @@ -291,7 +293,7 @@ var tooltipActivate = function () { var hovercardUrl = $origin.data('hovercardUrl'); if (hovercardUrl !== undefined && hovercardUrl !== "") { - loadHoverCard(hovercardUrl, function (data) { + var loaded = loadHoverCard(hovercardUrl, function (data) { instance.content(data); }) } else { @@ -300,12 +302,12 @@ var tooltipActivate = function () { } else { var data = '
{0}
'.format($origin.data('hovercardAlt')) } - + var loaded = true; instance.content(data); } // to remember that the data has been loaded - $origin.data('loaded', true); + $origin.data('loaded', loaded); } } }) diff --git a/rhodecode/templates/data_table/_dt_elements.mako b/rhodecode/templates/data_table/_dt_elements.mako --- a/rhodecode/templates/data_table/_dt_elements.mako +++ b/rhodecode/templates/data_table/_dt_elements.mako @@ -141,10 +141,10 @@ ${h.age_component(last_change, time_is_local=True)} -<%def name="revision(name,rev,tip,author,last_msg, commit_date)"> +<%def name="revision(repo_name, rev, commit_id, author, last_msg, commit_date)">
%if rev >= 0: - ${'r%s:%s' % (rev,h.short_id(tip))} + ${'r{}:{}'.format(rev,h.short_id(commit_id))} %else: ${_('No commits yet')} %endif diff --git a/rhodecode/templates/files/files_browser_tree.mako b/rhodecode/templates/files/files_browser_tree.mako --- a/rhodecode/templates/files/files_browser_tree.mako +++ b/rhodecode/templates/files/files_browser_tree.mako @@ -1,3 +1,5 @@ +<%namespace name="base" file="/base/base.mako"/> + <% if request.GET.get('at'): query={'at': request.GET.get('at')} @@ -60,7 +62,7 @@ % if c.full_load: -
+
r${node.last_commit.idx}:${node.last_commit.short_id}
% endif diff --git a/rhodecode/templates/hovercards/hovercard_repo_commit.mako b/rhodecode/templates/hovercards/hovercard_repo_commit.mako new file mode 100644 --- /dev/null +++ b/rhodecode/templates/hovercards/hovercard_repo_commit.mako @@ -0,0 +1,8 @@ +<%namespace name="base" file="/base/base.mako"/> +<%namespace name="dt" file="/data_table/_dt_elements.mako"/> + +
${base.gravatar_with_user(c.commit.author, tooltip=True)}
+
+${h.show_id(c.commit)} - ${c.commit.date} +

+
${h.urlify_commit_message(c.commit.message, c.repo_name)}