diff --git a/rhodecode/apps/repository/__init__.py b/rhodecode/apps/repository/__init__.py --- a/rhodecode/apps/repository/__init__.py +++ b/rhodecode/apps/repository/__init__.py @@ -485,13 +485,21 @@ def includeme(config): name='edit_repo_audit_logs', pattern='/{repo_name:.*?[^/]}/settings/audit_logs', repo_route=True) - # ATOM/RSS Feed + # ATOM/RSS Feed, shouldn't contain slashes for outlook compatibility config.add_route( name='rss_feed_home', + pattern='/{repo_name:.*?[^/]}/feed-rss', repo_route=True) + + config.add_route( + name='atom_feed_home', + pattern='/{repo_name:.*?[^/]}/feed-atom', repo_route=True) + + config.add_route( + name='rss_feed_home_old', pattern='/{repo_name:.*?[^/]}/feed/rss', repo_route=True) config.add_route( - name='atom_feed_home', + name='atom_feed_home_old', pattern='/{repo_name:.*?[^/]}/feed/atom', repo_route=True) # NOTE(marcink): needs to be at the end for catch-all diff --git a/rhodecode/apps/repository/tests/test_repo_feed.py b/rhodecode/apps/repository/tests/test_repo_feed.py --- a/rhodecode/apps/repository/tests/test_repo_feed.py +++ b/rhodecode/apps/repository/tests/test_repo_feed.py @@ -27,8 +27,10 @@ def route_path(name, params=None, **kwar import urllib base_url = { - 'rss_feed_home': '/{repo_name}/feed/rss', - 'atom_feed_home': '/{repo_name}/feed/atom', + 'rss_feed_home': '/{repo_name}/feed-rss', + 'atom_feed_home': '/{repo_name}/feed-atom', + 'rss_feed_home_old': '/{repo_name}/feed/rss', + 'atom_feed_home_old': '/{repo_name}/feed/atom', }[name].format(**kwargs) if params: @@ -73,6 +75,42 @@ class TestFeedView(TestController): assert response.content_type == content_type + @pytest.mark.parametrize("feed_type, content_type", [ + ('rss', "application/rss+xml"), + ('atom', "application/atom+xml") + ]) + def test_feed_with_auth_token_by_uid( + self, backend, user_admin, feed_type, content_type): + auth_token = user_admin.feed_token + assert auth_token != '' + + response = self.app.get( + route_path( + '{}_feed_home'.format(feed_type), + repo_name='_{}'.format(backend.repo.repo_id), + params=dict(auth_token=auth_token)), + status=200) + + assert response.content_type == content_type + + @pytest.mark.parametrize("feed_type, content_type", [ + ('rss', "application/rss+xml"), + ('atom', "application/atom+xml") + ]) + def test_feed_old_urls_with_auth_token( + self, backend, user_admin, feed_type, content_type): + auth_token = user_admin.feed_token + assert auth_token != '' + + response = self.app.get( + route_path( + '{}_feed_home_old'.format(feed_type), + repo_name=backend.repo_name, + params=dict(auth_token=auth_token)), + status=200) + + assert response.content_type == content_type + @pytest.mark.parametrize("feed_type", ['rss', 'atom']) def test_feed_with_auth_token_of_wrong_type( self, backend, user_util, feed_type): diff --git a/rhodecode/apps/repository/views/repo_feed.py b/rhodecode/apps/repository/views/repo_feed.py --- a/rhodecode/apps/repository/views/repo_feed.py +++ b/rhodecode/apps/repository/views/repo_feed.py @@ -40,8 +40,6 @@ log = logging.getLogger(__name__) class RepoFeedView(RepoAppView): def load_default_context(self): c = self._get_local_tmpl_context() - - self._load_defaults() return c @@ -117,6 +115,9 @@ class RepoFeedView(RepoAppView): @view_config( route_name='atom_feed_home', request_method='GET', renderer=None) + @view_config( + route_name='atom_feed_home_old', request_method='GET', + renderer=None) def atom(self): """ Produce an atom-1.0 feed via feedgenerator module @@ -181,6 +182,9 @@ class RepoFeedView(RepoAppView): @view_config( route_name='rss_feed_home', request_method='GET', renderer=None) + @view_config( + route_name='rss_feed_home_old', request_method='GET', + renderer=None) def rss(self): """ Produce an rss2 feed via feedgenerator module diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1841,6 +1841,10 @@ class Repository(Base, BaseModel): return q.all() @property + def repo_uid(self): + return '_{}'.format(self.repo_id) + + @property def forks(self): """ Return forks of this repo 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 @@ -263,8 +263,10 @@ function registerRCRoutes() { pyroutes.register('strip_check', '/%(repo_name)s/settings/strip_check', ['repo_name']); pyroutes.register('strip_execute', '/%(repo_name)s/settings/strip_execute', ['repo_name']); pyroutes.register('edit_repo_audit_logs', '/%(repo_name)s/settings/audit_logs', ['repo_name']); - pyroutes.register('rss_feed_home', '/%(repo_name)s/feed/rss', ['repo_name']); - pyroutes.register('atom_feed_home', '/%(repo_name)s/feed/atom', ['repo_name']); + pyroutes.register('rss_feed_home', '/%(repo_name)s/feed-rss', ['repo_name']); + pyroutes.register('atom_feed_home', '/%(repo_name)s/feed-atom', ['repo_name']); + pyroutes.register('rss_feed_home_old', '/%(repo_name)s/feed/rss', ['repo_name']); + pyroutes.register('atom_feed_home_old', '/%(repo_name)s/feed/atom', ['repo_name']); pyroutes.register('repo_summary', '/%(repo_name)s', ['repo_name']); pyroutes.register('repo_summary_slash', '/%(repo_name)s/', ['repo_name']); pyroutes.register('edit_repo_group', '/%(repo_group_name)s/_edit', ['repo_group_name']); 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 @@ -217,7 +217,7 @@ ## Context Actions