You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2019/03/04 16:00:29 UTC
[allura] branch db/8269 created (now 317e9b6)
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a change to branch db/8269
in repository https://gitbox.apache.org/repos/asf/allura.git.
at 317e9b6 [#8269] link directly to the external url from the menu
This branch includes the following new commits:
new b49989d [#8269] make external link redirects use 302 since the URL could change
new 317e9b6 [#8269] link directly to the external url from the menu
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[allura] 01/02: [#8269] make external link redirects use 302 since
the URL could change
Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8269
in repository https://gitbox.apache.org/repos/asf/allura.git
commit b49989d3f1bd230f1e2b174370a2567cf3e5df14
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri Mar 1 17:55:04 2019 -0500
[#8269] make external link redirects use 302 since the URL could change
---
ForgeLink/forgelink/link_main.py | 7 +++----
ForgeLink/forgelink/tests/functional/test_root.py | 8 ++++----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index 07238f1..43a4624 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -20,7 +20,7 @@ import logging
import json
# Non-stdlib imports
-from tg import expose, jsonify
+from tg import expose, jsonify, redirect
from pylons import tmpl_context as c
from pylons import request
from formencode import validators as fev
@@ -29,7 +29,6 @@ from formencode import validators as fev
from allura.app import Application, ConfigOption, SitemapEntry
from allura.lib import helpers as h
from allura.lib.security import require_access
-from allura.lib.utils import permanent_redirect
from allura import model as M
from allura.controllers import BaseController
from allura.controllers.rest import AppRestControllerMixin
@@ -121,7 +120,7 @@ class RootController(BaseController):
def index(self, **kw):
url = c.app.config.options.get('url')
if url:
- permanent_redirect(url)
+ redirect(url)
return dict()
@expose()
@@ -129,7 +128,7 @@ class RootController(BaseController):
path = "/".join(remainder)
url = c.app.config.options.get('url')
if url:
- permanent_redirect(url + h.really_unicode(path).encode('utf-8'))
+ redirect(url + h.really_unicode(path).encode('utf-8'))
return dict()
diff --git a/ForgeLink/forgelink/tests/functional/test_root.py b/ForgeLink/forgelink/tests/functional/test_root.py
index 6235707..f0fe1fd 100644
--- a/ForgeLink/forgelink/tests/functional/test_root.py
+++ b/ForgeLink/forgelink/tests/functional/test_root.py
@@ -34,7 +34,7 @@ class TestRootController(TestController):
response = self.app.get('/admin/link/options', validate_chunk=True)
response.form['url'] = 'http://www.google.com/'
response.form.submit()
- redir = self.app.get('/link/index', status=301)
+ redir = self.app.get('/link/index', status=302)
assert_equal(redir.location, 'http://www.google.com/')
@td.with_link
@@ -42,7 +42,7 @@ class TestRootController(TestController):
response = self.app.get('/admin/link/options', validate_chunk=True)
response.form['url'] = 'http://www.google.com/'
response.form.submit()
- redir = self.app.get('/link', status=301)
+ redir = self.app.get('/link', status=302)
assert_equal(redir.location, 'http://www.google.com/')
@td.with_link
@@ -50,7 +50,7 @@ class TestRootController(TestController):
response = self.app.get('/admin/link/options', validate_chunk=True)
response.form['url'] = 'http://www.google.com/'
response.form.submit()
- redir = self.app.get('/link/service', status=301)
+ redir = self.app.get('/link/service', status=302)
assert_equal(redir.location, 'http://www.google.com/service')
@td.with_link
@@ -58,7 +58,7 @@ class TestRootController(TestController):
response = self.app.get('/admin/link/options', validate_chunk=True)
response.form['url'] = 'http://www.google.de/search?q='
response.form.submit()
- redir = self.app.get('/link/help', status=301)
+ redir = self.app.get('/link/help', status=302)
assert_equal(redir.location, 'http://www.google.de/search?q=help')
[allura] 02/02: [#8269] link directly to the external url from the
menu
Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8269
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 317e9b66282facd0816d2e1ac1fbe877fddbd2ad
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri Mar 1 18:29:04 2019 -0500
[#8269] link directly to the external url from the menu
---
ForgeLink/forgelink/link_main.py | 2 +-
ForgeLink/forgelink/tests/functional/test_root.py | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index 43a4624..cece76e 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -82,7 +82,7 @@ class ForgeLinkApp(Application):
@h.exceptionless([], log)
def sitemap(self):
menu_id = self.config.options.mount_label
- return [SitemapEntry(menu_id, '.')[self.sidebar_menu()]]
+ return [SitemapEntry(menu_id, self.config.options.get('url') or '.')]
def sidebar_menu(self):
return []
diff --git a/ForgeLink/forgelink/tests/functional/test_root.py b/ForgeLink/forgelink/tests/functional/test_root.py
index f0fe1fd..c861748 100644
--- a/ForgeLink/forgelink/tests/functional/test_root.py
+++ b/ForgeLink/forgelink/tests/functional/test_root.py
@@ -16,7 +16,8 @@
# under the License.
import json
-from nose.tools import assert_equal
+
+from nose.tools import assert_equal, assert_in
from allura import model as M
from allura.tests import decorators as td
@@ -113,3 +114,15 @@ class TestConfigOptions(TestController):
assert_equal(flash['status'], 'error')
assert_equal(flash['message'], 'url: That is not a valid URL')
self.assert_url('link', None)
+
+ @td.with_link
+ def test_menu_url(self):
+ resp = self.app.get('/p/test/admin/')
+ assert_in('/p/test/link/', str(resp.html.find(id='top_nav')))
+
+ response = self.app.get('/admin/link/options')
+ response.form['url'] = 'http://foo.bar/baz'
+ response.form.submit()
+
+ resp = self.app.get('/p/test/admin/')
+ assert_in('http://foo.bar/baz', str(resp.html.find(id='top_nav')))