##// END OF EJS Templates
debug-style: moved from pylons controller to pyramid view.
dan -
r1900:7da9bb63 default
parent child Browse files
Show More
@@ -0,0 +1,42 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2016-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 from rhodecode.apps._base import ADMIN_PREFIX
21 from rhodecode.lib.utils2 import str2bool
22
23
24 def debug_style_enabled(info, request):
25 return str2bool(request.registry.settings.get('debug_style'))
26
27
28 def includeme(config):
29 config.add_route(
30 name='debug_style_home',
31 pattern=ADMIN_PREFIX + '/debug_style',
32 custom_predicates=(debug_style_enabled,))
33 config.add_route(
34 name='debug_style_template',
35 pattern=ADMIN_PREFIX + '/debug_style/t/{t_path}',
36 custom_predicates=(debug_style_enabled,))
37
38 # Scan module for configuration decorators.
39 config.scan()
40
41
42
@@ -0,0 +1,58 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2016-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
21 import os
22 import logging
23
24 from pyramid.view import view_config
25 from pyramid.renderers import render_to_response
26 from rhodecode.apps._base import BaseAppView
27
28 log = logging.getLogger(__name__)
29
30
31 class DebugStyleView(BaseAppView):
32 def load_default_context(self):
33 c = self._get_local_tmpl_context()
34 self._register_global_c(c)
35 return c
36
37 @view_config(
38 route_name='debug_style_home', request_method='GET',
39 renderer=None)
40 def index(self):
41 c = self.load_default_context()
42 c.active = 'index'
43
44 return render_to_response(
45 'debug_style/index.html', self._get_template_context(c),
46 request=self.request)
47
48 @view_config(
49 route_name='debug_style_template', request_method='GET',
50 renderer=None)
51 def template(self):
52 t_path = self.request.matchdict['t_path']
53 c = self.load_default_context()
54 c.active = os.path.splitext(t_path)[0]
55
56 return render_to_response(
57 'debug_style/' + t_path, self._get_template_context(c),
58 request=self.request) No newline at end of file
@@ -305,6 +305,7 b' def includeme(config):'
305 305 config.include('rhodecode.apps.svn_support')
306 306 config.include('rhodecode.apps.gist')
307 307
308 config.include('rhodecode.apps.debug_style')
308 309 config.include('rhodecode.tweens')
309 310 config.include('rhodecode.api')
310 311
@@ -369,15 +369,6 b' def make_map(config):'
369 369 m.connect('admin_defaults_repositories', '/defaults/repositories',
370 370 action='index', conditions={'method': ['GET']})
371 371
372 # ADMIN DEBUG STYLE ROUTES
373 if str2bool(config.get('debug_style')):
374 with rmap.submapper(path_prefix=ADMIN_PREFIX + '/debug_style',
375 controller='debug_style') as m:
376 m.connect('debug_style_home', '',
377 action='index', conditions={'method': ['GET']})
378 m.connect('debug_style_template', '/t/{t_path}',
379 action='template', conditions={'method': ['GET']})
380
381 372 # ADMIN SETTINGS ROUTES
382 373 with rmap.submapper(path_prefix=ADMIN_PREFIX,
383 374 controller='admin/settings') as m:
@@ -170,5 +170,7 b' function registerRCRoutes() {'
170 170 pyroutes.register('gist_show_rev', '/_admin/gists/%(gist_id)s/%(revision)s', ['gist_id', 'revision']);
171 171 pyroutes.register('gist_show_formatted', '/_admin/gists/%(gist_id)s/%(revision)s/%(format)s', ['gist_id', 'revision', 'format']);
172 172 pyroutes.register('gist_show_formatted_path', '/_admin/gists/%(gist_id)s/%(revision)s/%(format)s/%(f_path)s', ['gist_id', 'revision', 'format', 'f_path']);
173 pyroutes.register('debug_style_home', '/_admin/debug_style', []);
174 pyroutes.register('debug_style_template', '/_admin/debug_style/t/%(t_path)s', ['t_path']);
173 175 pyroutes.register('apiv2', '/_admin/api', []);
174 176 }
@@ -425,7 +425,7 b''
425 425 % endif
426 426 % if c.debug_style:
427 427 <li class="${is_active('debug_style')}">
428 <a class="menulink" title="${_('Style')}" href="${h.url('debug_style_home')}">
428 <a class="menulink" title="${_('Style')}" href="${h.route_path('debug_style_home')}">
429 429 <div class="menulabel">${_('Style')}</div>
430 430 </a>
431 431 </li>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -3,7 +3,7 b''
3 3 <%inherit file="/debug_style/index.html"/>
4 4
5 5 <%def name="breadcrumbs_links()">
6 ${h.link_to(_('Style'), h.url('debug_style_home'))}
6 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
7 7 &raquo;
8 8 ${c.active}
9 9 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -51,29 +51,29 b''
51 51 <%def name="sidebar()">
52 52 <div class="sidebar">
53 53 <ul class="nav nav-pills nav-stacked">
54 <li class="${'active' if c.active=='index' else ''}"><a href="${h.url('debug_style_home')}">${_('Index')}</a></li>
55 <li class="${'active' if c.active=='typography' else ''}"><a href="${h.url('debug_style_template', t_path='typography.html')}">${_('Typography')}</a></li>
56 <li class="${'active' if c.active=='forms' else ''}"><a href="${h.url('debug_style_template', t_path='forms.html')}">${_('Forms')}</a></li>
57 <li class="${'active' if c.active=='buttons' else ''}"><a href="${h.url('debug_style_template', t_path='buttons.html')}">${_('Buttons')}</a></li>
58 <li class="${'active' if c.active=='labels' else ''}"><a href="${h.url('debug_style_template', t_path='labels.html')}">${_('Labels')}</a></li>
59 <li class="${'active' if c.active=='alerts' else ''}"><a href="${h.url('debug_style_template', t_path='alerts.html')}">${_('Alerts')}</a></li>
60 <li class="${'active' if c.active=='tables' else ''}"><a href="${h.url('debug_style_template', t_path='tables.html')}">${_('Tables')}</a></li>
61 <li class="${'active' if c.active=='tables-wide' else ''}"><a href="${h.url('debug_style_template', t_path='tables-wide.html')}">${_('Tables wide')}</a></li>
62 <li class="${'active' if c.active=='collapsable-content' else ''}"><a href="${h.url('debug_style_template', t_path='collapsable-content.html')}">${_('Collapsable Content')}</a></li>
63 <li class="${'active' if c.active=='icons' else ''}"><a href="${h.url('debug_style_template', t_path='icons.html')}">${_('Icons')}</a></li>
64 <li class="${'active' if c.active=='layout-form-sidebar' else ''}"><a href="${h.url('debug_style_template', t_path='layout-form-sidebar.html')}">${_('Layout form with sidebar')}</a></li>
65 <li class="${'active' if c.active=='login' else ''}"><a href="${h.url('debug_style_template', t_path='login.html')}">${_('Login')}</a></li>
66 <li class="${'active' if c.active=='login2' else ''}"><a href="${h.url('debug_style_template', t_path='login2.html')}">${_('Login 2')}</a></li>
67 <li class="${'active' if c.active=='code-block' else ''}"><a href="${h.url('debug_style_template', t_path='code-block.html')}">${_('Code blocks')}</a></li>
54 <li class="${'active' if c.active=='index' else ''}"><a href="${h.route_path('debug_style_home')}">${_('Index')}</a></li>
55 <li class="${'active' if c.active=='typography' else ''}"><a href="${h.route_path('debug_style_template', t_path='typography.html')}">${_('Typography')}</a></li>
56 <li class="${'active' if c.active=='forms' else ''}"><a href="${h.route_path('debug_style_template', t_path='forms.html')}">${_('Forms')}</a></li>
57 <li class="${'active' if c.active=='buttons' else ''}"><a href="${h.route_path('debug_style_template', t_path='buttons.html')}">${_('Buttons')}</a></li>
58 <li class="${'active' if c.active=='labels' else ''}"><a href="${h.route_path('debug_style_template', t_path='labels.html')}">${_('Labels')}</a></li>
59 <li class="${'active' if c.active=='alerts' else ''}"><a href="${h.route_path('debug_style_template', t_path='alerts.html')}">${_('Alerts')}</a></li>
60 <li class="${'active' if c.active=='tables' else ''}"><a href="${h.route_path('debug_style_template', t_path='tables.html')}">${_('Tables')}</a></li>
61 <li class="${'active' if c.active=='tables-wide' else ''}"><a href="${h.route_path('debug_style_template', t_path='tables-wide.html')}">${_('Tables wide')}</a></li>
62 <li class="${'active' if c.active=='collapsable-content' else ''}"><a href="${h.route_path('debug_style_template', t_path='collapsable-content.html')}">${_('Collapsable Content')}</a></li>
63 <li class="${'active' if c.active=='icons' else ''}"><a href="${h.route_path('debug_style_template', t_path='icons.html')}">${_('Icons')}</a></li>
64 <li class="${'active' if c.active=='layout-form-sidebar' else ''}"><a href="${h.route_path('debug_style_template', t_path='layout-form-sidebar.html')}">${_('Layout form with sidebar')}</a></li>
65 <li class="${'active' if c.active=='login' else ''}"><a href="${h.route_path('debug_style_template', t_path='login.html')}">${_('Login')}</a></li>
66 <li class="${'active' if c.active=='login2' else ''}"><a href="${h.route_path('debug_style_template', t_path='login2.html')}">${_('Login 2')}</a></li>
67 <li class="${'active' if c.active=='code-block' else ''}"><a href="${h.route_path('debug_style_template', t_path='code-block.html')}">${_('Code blocks')}</a></li>
68 68
69 69 <li class="divider"><strong>Experimental</strong></li>
70 <li class="${'active' if c.active=='panels' else ''}"><a href="${h.url('debug_style_template', t_path='panels.html')}">${_('Panels')}</a></li>
70 <li class="${'active' if c.active=='panels' else ''}"><a href="${h.route_path('debug_style_template', t_path='panels.html')}">${_('Panels')}</a></li>
71 71
72 72 <li class="divider"><strong>Depreciated</strong></li>
73 <li class="${'active' if c.active=='form-elements' else ''}"><a href="${h.url('debug_style_template', t_path='form-elements.html')}">${_('Form elements')}</a></li>
74 <li class="${'active' if c.active=='form-elements-small' else ''}"><a href="${h.url('debug_style_template', t_path='form-elements-small.html')}">${_('Form elements small')}</a></li>
75 <li class="${'active' if c.active=='form-inline' else ''}"><a href="${h.url('debug_style_template', t_path='form-inline.html')}">${_('Form inline elements')}</a></li>
76 <li class="${'active' if c.active=='form-vertical' else ''}"><a href="${h.url('debug_style_template', t_path='form-vertical.html')}">${_('Form vertical')}</a></li>
73 <li class="${'active' if c.active=='form-elements' else ''}"><a href="${h.route_path('debug_style_template', t_path='form-elements.html')}">${_('Form elements')}</a></li>
74 <li class="${'active' if c.active=='form-elements-small' else ''}"><a href="${h.route_path('debug_style_template', t_path='form-elements-small.html')}">${_('Form elements small')}</a></li>
75 <li class="${'active' if c.active=='form-inline' else ''}"><a href="${h.route_path('debug_style_template', t_path='form-inline.html')}">${_('Form inline elements')}</a></li>
76 <li class="${'active' if c.active=='form-vertical' else ''}"><a href="${h.route_path('debug_style_template', t_path='form-vertical.html')}">${_('Form vertical')}</a></li>
77 77 </ul>
78 78 </div>
79 79 </%def> No newline at end of file
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -3,7 +3,7 b''
3 3
4 4
5 5 <%def name="breadcrumbs_links()">
6 ${h.link_to(_('Style'), h.url('debug_style_home'))}
6 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
7 7 &raquo;
8 8 ${c.active}
9 9 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
@@ -2,7 +2,7 b''
2 2 <%inherit file="/debug_style/index.html"/>
3 3
4 4 <%def name="breadcrumbs_links()">
5 ${h.link_to(_('Style'), h.url('debug_style_home'))}
5 ${h.link_to(_('Style'), h.route_path('debug_style_home'))}
6 6 &raquo;
7 7 ${c.active}
8 8 </%def>
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now