diff --git a/rhodecode/controllers/pullrequests.py b/rhodecode/controllers/pullrequests.py --- a/rhodecode/controllers/pullrequests.py +++ b/rhodecode/controllers/pullrequests.py @@ -640,8 +640,8 @@ class PullrequestsController(BaseRepoCon pull_request_id = safe_int(pull_request_id) c.pull_request = PullRequest.get_or_404(pull_request_id) - if hasattr(c, 'pylons_dispatch_info'): - c.pylons_dispatch_info['extra']['pull_request'] = pull_request_id + c.template_context['pull_request_data']['pull_request_id'] = \ + pull_request_id # pull_requests repo_name we opened it against # ie. target_repo must match diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -425,9 +425,29 @@ class BaseController(WSGIController): _route_name = '.'.join([environ['pylons.routes_dict']['controller'], environ['pylons.routes_dict']['action']]) - c.pylons_dispatch_info = { - 'controller': environ['pylons.routes_dict']['controller'], - 'action': environ['pylons.routes_dict']['action'], + c.template_context = { + 'repo_name': None, + 'repo_type': None, + 'repo_landing_commit': None, + 'rhodecode_user': { + 'username': None, + 'email': None, + }, + 'visual': { + 'default_renderer': None + }, + 'commit_data': { + 'commit_id': None + }, + 'pull_request_data': {'pull_request_id': None}, + 'timeago': { + 'refresh_time': 120 * 1000, + 'cutoff_limit': 1000*60*60*24*7 + }, + 'pylons_dispatch':{ + 'controller': environ['pylons.routes_dict']['controller'], + 'action': environ['pylons.routes_dict']['action'], + }, 'extra': {'plugins': {}} } diff --git a/rhodecode/templates/base/root.html b/rhodecode/templates/base/root.html --- a/rhodecode/templates/base/root.html +++ b/rhodecode/templates/base/root.html @@ -1,55 +1,19 @@ ## -*- coding: utf-8 -*- -<%def name="get_template_context()" filter="n, trim">{ - - ## repo data - repo_name: "${getattr(c, 'repo_name', '')}", - % if hasattr(c, 'rhodecode_db_repo'): - repo_type: "${c.rhodecode_db_repo.repo_type}", - repo_landing_commit: "${c.rhodecode_db_repo.landing_rev[1]}", - % else: - repo_type: null, - repo_landing_commit: null, - % endif +<% +c.template_context['repo_name'] = getattr(c, 'repo_name', '') - ## user data - % if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id: - rhodecode_user: { - username: "${c.rhodecode_user.username}", - email: "${c.rhodecode_user.email}", - }, - % else: - rhodecode_user: { - username: null, - email: null, - }, - % endif +if hasattr(c, 'rhodecode_db_repo'): + c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type + c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1] - ## visual settings - visual: { - default_renderer: "${h.get_visual_attr(c, 'default_renderer')}" - }, - - ## current commit context, filled inside templates that expose that - commit_data: { - commit_id: null, - }, +if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id: + c.template_context['rhodecode_user']['username'] = c.rhodecode_user.username + c.template_context['rhodecode_user']['email'] = c.rhodecode_user.email - ## current pr context, filled inside templates that expose that - pull_request_data: { - pull_request_id: null, - }, - - ## timeago settings, can be overwritten by custom user settings later - timeago: { - refresh_time: ${120 * 1000}, - cutoff_limit: ${1000*60*60*24*7} - }, - dispatch_info: ${h.json.dumps(getattr(c, 'pylons_dispatch_info', {}))|n} -} - -%def> +c.template_context['visual']['default_renderer'] = h.get_visual_attr(c, 'default_renderer') +%>
@@ -81,7 +45,7 @@