diff --git a/rhodecode/apps/home/__init__.py b/rhodecode/apps/home/__init__.py --- a/rhodecode/apps/home/__init__.py +++ b/rhodecode/apps/home/__init__.py @@ -17,6 +17,7 @@ # 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): @@ -37,5 +38,8 @@ def includeme(config): name='goto_switcher_data', pattern='/_goto_data') + # register our static links via redirection mechanismy + routing_links.connect_redirection_links(config) + # Scan module for configuration decorators. config.scan() diff --git a/rhodecode/config/routing.py b/rhodecode/config/routing.py --- a/rhodecode/config/routing.py +++ b/rhodecode/config/routing.py @@ -32,8 +32,6 @@ import os import re from routes import Mapper -from rhodecode.config import routing_links - # prefix for non repository related links needs to be prefixed with `/` ADMIN_PREFIX = '/_admin' STATIC_FILE_PREFIX = '/_static' @@ -189,24 +187,7 @@ def make_map(config): # MAIN PAGE rmap.connect('home', '/', controller='home', action='index', jsroute=True) - # TODO: johbo: Static links, to be replaced by our redirection mechanism - rmap.connect('rst_help', - 'http://docutils.sourceforge.net/docs/user/rst/quickref.html', - _static=True) - rmap.connect('markdown_help', - 'http://daringfireball.net/projects/markdown/syntax', - _static=True) - rmap.connect('rhodecode_official', 'https://rhodecode.com', _static=True) - rmap.connect('rhodecode_support', 'https://rhodecode.com/help/', _static=True) - rmap.connect('rhodecode_translations', 'https://rhodecode.com/translate/enterprise', _static=True) - # TODO: anderson - making this a static link since redirect won't play - # nice with POST requests - rmap.connect('enterprise_license_convert_from_old', - 'https://rhodecode.com/u/license-upgrade', - _static=True) - - routing_links.connect_redirection_links(rmap) - + # ping and pylons error test rmap.connect('ping', '%s/ping' % (ADMIN_PREFIX,), controller='home', action='ping') rmap.connect('error_test', '%s/error_test' % (ADMIN_PREFIX,), controller='home', action='error_test') diff --git a/rhodecode/config/routing_links.py b/rhodecode/config/routing_links.py --- a/rhodecode/config/routing_links.py +++ b/rhodecode/config/routing_links.py @@ -46,27 +46,56 @@ you can see it working. # flake8: noqa from __future__ import unicode_literals +link_config = [ + { + "name": "enterprise_docs", + "target": "https://rhodecode.com/r1/enterprise/docs/", + "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/", + }, + { + "name": "enterprise_log_file_locations", + "target": "https://rhodecode.com/r1/enterprise/docs/admin-system-overview/", + "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/admin/system-overview.html#log-files", + }, + { + "name": "enterprise_issue_tracker_settings", + "target": "https://rhodecode.com/r1/enterprise/docs/issue-trackers-overview/", + "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/issue-trackers/issue-trackers.html", + }, + { + "name": "enterprise_svn_setup", + "target": "https://rhodecode.com/r1/enterprise/docs/svn-setup/", + "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/admin/svn-http.html", + }, + { + "name": "rst_help", + "target": "http://docutils.sourceforge.net/docs/user/rst/quickref.html", + "external_target": "http://docutils.sourceforge.net/docs/user/rst/quickref.html", + }, + { + "name": "markdown_help", + "target": "http://daringfireball.net/projects/markdown/syntax", + "external_target": "http://daringfireball.net/projects/markdown/syntax", + }, + { + "name": "rhodecode_official", + "target": "https://rhodecode.com", + "external_target": "https://rhodecode.com/", + }, + { + "name": "rhodecode_support", + "target": "https://rhodecode.com/help/", + "external_target": "https://rhodecode.com/support", + }, + { + "name": "rhodecode_translations", + "target": "https://rhodecode.com/translate/enterprise", + "external_target": "https://www.transifex.com/rhodecode/RhodeCode/", + }, -link_config = [ - {"name": "enterprise_docs", - "target": "https://rhodecode.com/r1/enterprise/docs/", - "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/", - }, - {"name": "enterprise_log_file_locations", - "target": "https://rhodecode.com/r1/enterprise/docs/admin-system-overview/", - "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/admin/system-overview.html#log-files", - }, - {"name": "enterprise_issue_tracker_settings", - "target": "https://rhodecode.com/r1/enterprise/docs/issue-trackers-overview/", - "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/issue-trackers/issue-trackers.html", - }, - {"name": "enterprise_svn_setup", - "target": "https://rhodecode.com/r1/enterprise/docs/svn-setup/", - "external_target": "https://docs.rhodecode.com/RhodeCode-Enterprise/admin/svn-http.html", - }, ] -def connect_redirection_links(rmap): +def connect_redirection_links(config): for link in link_config: - rmap.connect(link['name'], link['target'], _static=True) + config.add_route(link['name'], link['target'], static=True) diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -302,7 +302,7 @@ def attach_context_attributes(context, r 'rhodecode_markup_renderer', 'rst') context.visual.comment_types = ChangesetComment.COMMENT_TYPES context.visual.rhodecode_support_url = \ - rc_config.get('rhodecode_support_url') or url('rhodecode_support') + rc_config.get('rhodecode_support_url') or h.route_url('rhodecode_support') context.pre_code = rc_config.get('rhodecode_pre_code') context.post_code = rc_config.get('rhodecode_post_code') diff --git a/rhodecode/templates/admin/users/user_edit_profile.mako b/rhodecode/templates/admin/users/user_edit_profile.mako --- a/rhodecode/templates/admin/users/user_edit_profile.mako +++ b/rhodecode/templates/admin/users/user_edit_profile.mako @@ -127,7 +127,7 @@ ## allowed_languages is defined in the users.py ## c.language comes from base.py as a default language ${h.select('language', c.language, c.allowed_languages)} -

${h.literal(_('Help translate %(rc_link)s into your language.') % {'rc_link': h.link_to('RhodeCode Enterprise', h.url('rhodecode_translations'))})}

+

${h.literal(_('Help translate %(rc_link)s into your language.') % {'rc_link': h.link_to('RhodeCode Enterprise', h.route_url('rhodecode_translations'))})}

diff --git a/rhodecode/templates/base/base.mako b/rhodecode/templates/base/base.mako --- a/rhodecode/templates/base/base.mako +++ b/rhodecode/templates/base/base.mako @@ -41,7 +41,7 @@ % if c.visual.show_version: RhodeCode Enterprise ${c.rhodecode_version} ${c.rhodecode_edition} % endif - © 2010-${h.datetime.today().year}, RhodeCode GmbH. All rights reserved. + © 2010-${h.datetime.today().year}, RhodeCode GmbH. All rights reserved. % if c.visual.rhodecode_support_url: ${_('Support')} % endif diff --git a/rhodecode/templates/base/issue_tracker_settings.mako b/rhodecode/templates/base/issue_tracker_settings.mako --- a/rhodecode/templates/base/issue_tracker_settings.mako +++ b/rhodecode/templates/base/issue_tracker_settings.mako @@ -18,7 +18,7 @@ ${'(?:#)(?P\d+)'} ${'https://myissueserver.com/${repo}/issue/${issue_id}'} # - ${_('Read more')} + ${_('Read more')} %for uid, entry in patterns: diff --git a/rhodecode/templates/base/vcs_settings.mako b/rhodecode/templates/base/vcs_settings.mako --- a/rhodecode/templates/base/vcs_settings.mako +++ b/rhodecode/templates/base/vcs_settings.mako @@ -201,7 +201,7 @@
${_('Subversion HTTP Support. Enables communication with SVN over HTTP protocol.')} - ${_('SVN Protocol setup Documentation')}. + ${_('SVN Protocol setup Documentation')}.
diff --git a/rhodecode/templates/changeset/changeset_file_comment.mako b/rhodecode/templates/changeset/changeset_file_comment.mako --- a/rhodecode/templates/changeset/changeset_file_comment.mako +++ b/rhodecode/templates/changeset/changeset_file_comment.mako @@ -346,7 +346,7 @@
${(_('Comments parsed using %s syntax with %s, and %s actions support.') % ( - ('%s' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())), + ('%s' % (h.route_url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())), ('@mention' % _('Use @username inside this text to send notification to this RhodeCode user')), ('`/`' % _('Start typing with / for certain actions to be triggered via text box.')) ) diff --git a/rhodecode/templates/errors/error_document.mako b/rhodecode/templates/errors/error_document.mako --- a/rhodecode/templates/errors/error_document.mako +++ b/rhodecode/templates/errors/error_document.mako @@ -62,12 +62,12 @@

Support

For support, go to ${_('Support')}. - It may be useful to include your log file; see the log file locations here. + It may be useful to include your log file; see the log file locations here.

Documentation

-

For more information, see docs.rhodecode.com.

+

For more information, see docs.rhodecode.com.

diff --git a/rhodecode/templates/summary/components.mako b/rhodecode/templates/summary/components.mako --- a/rhodecode/templates/summary/components.mako +++ b/rhodecode/templates/summary/components.mako @@ -53,7 +53,7 @@ ${_('Show by ID')} -

${_('SVN Protocol is disabled. To enable it, see the')} ${_('documentation here')}.

+

${_('SVN Protocol is disabled. To enable it, see the')} ${_('documentation here')}.

%else:
diff --git a/rhodecode/tests/config/test_routing_links.py b/rhodecode/tests/config/test_routing_links.py --- a/rhodecode/tests/config/test_routing_links.py +++ b/rhodecode/tests/config/test_routing_links.py @@ -18,23 +18,28 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ -import mock - +import pytest +import requests from rhodecode.config import routing_links -def test_connect_redirection_links(): - link_config = [ - {"name": "example_link", - "external_target": "http://example.com", - "target": "https://rhodecode.com/r/v1/enterprise/example", - }, - ] +def check_connection(): + try: + response = requests.get('https://rhodecode.com') + return response.status_code == 200 + except Exception as e: + print(e) + + return False + - rmap = mock.Mock() - with mock.patch.object(routing_links, 'link_config', link_config): - routing_links.connect_redirection_links(rmap) +connection_available = pytest.mark.skipif( + not check_connection(), reason="No outside internet connection available") + - rmap.connect.assert_called_with( - link_config[0]['name'], link_config[0]['target'], - _static=True) +@connection_available +def test_connect_redirection_links(): + + for link_data in routing_links.link_config: + response = requests.get(link_data['target']) + assert response.url == link_data['external_target']