##// END OF EJS Templates
routing: switched static redirection links to pyramid....
marcink -
r1679:c94a1c49 default
parent child Browse files
Show More
@@ -17,6 +17,7 b''
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 from rhodecode.config import routing_links
20 21
21 22
22 23 def includeme(config):
@@ -37,5 +38,8 b' def includeme(config):'
37 38 name='goto_switcher_data',
38 39 pattern='/_goto_data')
39 40
41 # register our static links via redirection mechanismy
42 routing_links.connect_redirection_links(config)
43
40 44 # Scan module for configuration decorators.
41 45 config.scan()
@@ -32,8 +32,6 b' import os'
32 32 import re
33 33 from routes import Mapper
34 34
35 from rhodecode.config import routing_links
36
37 35 # prefix for non repository related links needs to be prefixed with `/`
38 36 ADMIN_PREFIX = '/_admin'
39 37 STATIC_FILE_PREFIX = '/_static'
@@ -189,24 +187,7 b' def make_map(config):'
189 187 # MAIN PAGE
190 188 rmap.connect('home', '/', controller='home', action='index', jsroute=True)
191 189
192 # TODO: johbo: Static links, to be replaced by our redirection mechanism
193 rmap.connect('rst_help',
194 'http://docutils.sourceforge.net/docs/user/rst/quickref.html',
195 _static=True)
196 rmap.connect('markdown_help',
197 'http://daringfireball.net/projects/markdown/syntax',
198 _static=True)
199 rmap.connect('rhodecode_official', 'https://rhodecode.com', _static=True)
200 rmap.connect('rhodecode_support', 'https://rhodecode.com/help/', _static=True)
201 rmap.connect('rhodecode_translations', 'https://rhodecode.com/translate/enterprise', _static=True)
202 # TODO: anderson - making this a static link since redirect won't play
203 # nice with POST requests
204 rmap.connect('enterprise_license_convert_from_old',
205 'https://rhodecode.com/u/license-upgrade',
206 _static=True)
207
208 routing_links.connect_redirection_links(rmap)
209
190 # ping and pylons error test
210 191 rmap.connect('ping', '%s/ping' % (ADMIN_PREFIX,), controller='home', action='ping')
211 192 rmap.connect('error_test', '%s/error_test' % (ADMIN_PREFIX,), controller='home', action='error_test')
212 193
@@ -46,27 +46,56 b' you can see it working.'
46 46 # flake8: noqa
47 47 from __future__ import unicode_literals
48 48
49
50 49 link_config = [
51 {"name": "enterprise_docs",
50 {
51 "name": "enterprise_docs",
52 52 "target": "https://rhodecode.com/r1/enterprise/docs/",
53 53 "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/",
54 54 },
55 {"name": "enterprise_log_file_locations",
55 {
56 "name": "enterprise_log_file_locations",
56 57 "target": "https://rhodecode.com/r1/enterprise/docs/admin-system-overview/",
57 58 "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/admin/system-overview.html#log-files",
58 59 },
59 {"name": "enterprise_issue_tracker_settings",
60 {
61 "name": "enterprise_issue_tracker_settings",
60 62 "target": "https://rhodecode.com/r1/enterprise/docs/issue-trackers-overview/",
61 63 "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/issue-trackers/issue-trackers.html",
62 64 },
63 {"name": "enterprise_svn_setup",
65 {
66 "name": "enterprise_svn_setup",
64 67 "target": "https://rhodecode.com/r1/enterprise/docs/svn-setup/",
65 68 "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/admin/svn-http.html",
66 69 },
70 {
71 "name": "rst_help",
72 "target": "http://docutils.sourceforge.net/docs/user/rst/quickref.html",
73 "external_target": "http://docutils.sourceforge.net/docs/user/rst/quickref.html",
74 },
75 {
76 "name": "markdown_help",
77 "target": "http://daringfireball.net/projects/markdown/syntax",
78 "external_target": "http://daringfireball.net/projects/markdown/syntax",
79 },
80 {
81 "name": "rhodecode_official",
82 "target": "https://rhodecode.com",
83 "external_target": "https://rhodecode.com/",
84 },
85 {
86 "name": "rhodecode_support",
87 "target": "https://rhodecode.com/help/",
88 "external_target": "https://rhodecode.com/support",
89 },
90 {
91 "name": "rhodecode_translations",
92 "target": "https://rhodecode.com/translate/enterprise",
93 "external_target": "https://www.transifex.com/rhodecode/RhodeCode/",
94 },
95
67 96 ]
68 97
69 98
70 def connect_redirection_links(rmap):
99 def connect_redirection_links(config):
71 100 for link in link_config:
72 rmap.connect(link['name'], link['target'], _static=True)
101 config.add_route(link['name'], link['target'], static=True)
@@ -302,7 +302,7 b' def attach_context_attributes(context, r'
302 302 'rhodecode_markup_renderer', 'rst')
303 303 context.visual.comment_types = ChangesetComment.COMMENT_TYPES
304 304 context.visual.rhodecode_support_url = \
305 rc_config.get('rhodecode_support_url') or url('rhodecode_support')
305 rc_config.get('rhodecode_support_url') or h.route_url('rhodecode_support')
306 306
307 307 context.pre_code = rc_config.get('rhodecode_pre_code')
308 308 context.post_code = rc_config.get('rhodecode_post_code')
@@ -127,7 +127,7 b''
127 127 ## allowed_languages is defined in the users.py
128 128 ## c.language comes from base.py as a default language
129 129 ${h.select('language', c.language, c.allowed_languages)}
130 <p class="help-block">${h.literal(_('Help translate %(rc_link)s into your language.') % {'rc_link': h.link_to('RhodeCode Enterprise', h.url('rhodecode_translations'))})}</p>
130 <p class="help-block">${h.literal(_('Help translate %(rc_link)s into your language.') % {'rc_link': h.link_to('RhodeCode Enterprise', h.route_url('rhodecode_translations'))})}</p>
131 131 </div>
132 132 </div>
133 133 <div class="buttons">
@@ -41,7 +41,7 b''
41 41 % if c.visual.show_version:
42 42 RhodeCode Enterprise ${c.rhodecode_version} ${c.rhodecode_edition}
43 43 % endif
44 &copy; 2010-${h.datetime.today().year}, <a href="${h.url('rhodecode_official')}" target="_blank">RhodeCode GmbH</a>. All rights reserved.
44 &copy; 2010-${h.datetime.today().year}, <a href="${h.route_url('rhodecode_official')}" target="_blank">RhodeCode GmbH</a>. All rights reserved.
45 45 % if c.visual.rhodecode_support_url:
46 46 <a href="${c.visual.rhodecode_support_url}" target="_blank">${_('Support')}</a>
47 47 % endif
@@ -18,7 +18,7 b''
18 18 <td class="td-regex issue-tracker-example">${'(?:#)(?P<issue_id>\d+)'}</td>
19 19 <td class="td-url issue-tracker-example">${'https://myissueserver.com/${repo}/issue/${issue_id}'}</td>
20 20 <td class="td-prefix issue-tracker-example">#</td>
21 <td class="issue-tracker-example"><a href="https://docs.rhodecode.com/RhodeCode-Enterprise/issue-trackers/issue-trackers.html" target="_blank">${_('Read more')}</a></td>
21 <td class="issue-tracker-example"><a href="${h.route_url('enterprise_issue_tracker_settings')}" target="_blank">${_('Read more')}</a></td>
22 22 </tr>
23 23 %for uid, entry in patterns:
24 24 <tr id="entry_${uid}">
@@ -201,7 +201,7 b''
201 201 <div class="label">
202 202 <span class="help-block">
203 203 ${_('Subversion HTTP Support. Enables communication with SVN over HTTP protocol.')}
204 <a href="${h.url('enterprise_svn_setup')}" target="_blank">${_('SVN Protocol setup Documentation')}</a>.
204 <a href="${h.route_url('enterprise_svn_setup')}" target="_blank">${_('SVN Protocol setup Documentation')}</a>.
205 205 </span>
206 206 </div>
207 207 </div>
@@ -346,7 +346,7 b''
346 346 <div class="toolbar">
347 347 <div class="toolbar-text">
348 348 ${(_('Comments parsed using %s syntax with %s, and %s actions support.') % (
349 ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
349 ('<a href="%s">%s</a>' % (h.route_url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
350 350 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user')),
351 351 ('<span class="tooltip" title="%s">`/`</span>' % _('Start typing with / for certain actions to be triggered via text box.'))
352 352 )
@@ -62,12 +62,12 b''
62 62 <div class="inner-column">
63 63 <h4>Support</h4>
64 64 <p>For support, go to <a href="${c.visual.rhodecode_support_url}" target="_blank">${_('Support')}</a>.
65 It may be useful to include your log file; see the log file locations <a href="${h.url('enterprise_log_file_locations')}">here</a>.
65 It may be useful to include your log file; see the log file locations <a href="${h.route_url('enterprise_log_file_locations')}">here</a>.
66 66 </p>
67 67 </div>
68 68 <div class="inner-column">
69 69 <h4>Documentation</h4>
70 <p>For more information, see <a href="${h.url('enterprise_docs')}">docs.rhodecode.com</a>.</p>
70 <p>For more information, see <a href="${h.route_url('enterprise_docs')}">docs.rhodecode.com</a>.</p>
71 71 </div>
72 72 </div>
73 73 </div>
@@ -53,7 +53,7 b''
53 53 <input type="text" class="input-monospace" id="clone_url_id" disabled value="${c.clone_repo_url_id}" style="display: none;"/>
54 54 <a id="clone_by_name" class="clone" style="display: none;">${_('Show by Name')}</a>
55 55 <a id="clone_by_id" class="clone">${_('Show by ID')}</a>
56 <p class="help-block">${_('SVN Protocol is disabled. To enable it, see the')} <a href="${h.url('enterprise_svn_setup')}" target="_blank">${_('documentation here')}</a>.</p>
56 <p class="help-block">${_('SVN Protocol is disabled. To enable it, see the')} <a href="${h.route_url('enterprise_svn_setup')}" target="_blank">${_('documentation here')}</a>.</p>
57 57 </div>
58 58 %else:
59 59 <div class="left-label">
@@ -18,23 +18,28 b''
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 import mock
22
21 import pytest
22 import requests
23 23 from rhodecode.config import routing_links
24 24
25 25
26 def test_connect_redirection_links():
27 link_config = [
28 {"name": "example_link",
29 "external_target": "http://example.com",
30 "target": "https://rhodecode.com/r/v1/enterprise/example",
31 },
32 ]
26 def check_connection():
27 try:
28 response = requests.get('https://rhodecode.com')
29 return response.status_code == 200
30 except Exception as e:
31 print(e)
32
33 return False
34
33 35
34 rmap = mock.Mock()
35 with mock.patch.object(routing_links, 'link_config', link_config):
36 routing_links.connect_redirection_links(rmap)
36 connection_available = pytest.mark.skipif(
37 not check_connection(), reason="No outside internet connection available")
38
37 39
38 rmap.connect.assert_called_with(
39 link_config[0]['name'], link_config[0]['target'],
40 _static=True)
40 @connection_available
41 def test_connect_redirection_links():
42
43 for link_data in routing_links.link_config:
44 response = requests.get(link_data['target'])
45 assert response.url == link_data['external_target']
General Comments 0
You need to be logged in to leave comments. Login now