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 2020/11/11 01:49:16 UTC

[allura] branch master updated (637ee23 -> 8763368)

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git.


    from 637ee23  [#8378] ldap fixes for py3
     new 7f33f2a  improve repo navbar SEO by 302->301
     new 8763368  canonical on wiki pages

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.


Summary of changes:
 Allura/allura/controllers/repository.py                | 4 +++-
 Allura/allura/tests/functional/test_home.py            | 2 +-
 Allura/allura/tests/functional/test_neighborhood.py    | 8 ++++----
 ForgeGit/forgegit/controllers.py                       | 4 +++-
 ForgeGit/forgegit/tests/functional/test_controllers.py | 6 +++---
 ForgeSVN/forgesvn/controllers.py                       | 4 +++-
 ForgeWiki/forgewiki/templates/wiki/page_view.html      | 1 +
 ForgeWiki/forgewiki/tests/functional/test_root.py      | 6 +++---
 ForgeWiki/forgewiki/wiki_main.py                       | 4 ++--
 9 files changed, 23 insertions(+), 16 deletions(-)


[allura] 01/02: improve repo navbar SEO by 302->301

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 7f33f2a445f0d9a46fc27195ea9dbc16a28d91a4
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Fri Oct 23 17:09:04 2020 +0000

    improve repo navbar SEO by 302->301
---
 Allura/allura/controllers/repository.py                | 4 +++-
 Allura/allura/tests/functional/test_home.py            | 2 +-
 Allura/allura/tests/functional/test_neighborhood.py    | 8 ++++----
 ForgeGit/forgegit/controllers.py                       | 4 +++-
 ForgeGit/forgegit/tests/functional/test_controllers.py | 6 +++---
 ForgeSVN/forgesvn/controllers.py                       | 4 +++-
 ForgeWiki/forgewiki/tests/functional/test_root.py      | 6 +++---
 ForgeWiki/forgewiki/wiki_main.py                       | 4 ++--
 8 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 7ee5e95..a4396e9 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -20,6 +20,8 @@ from __future__ import absolute_import
 import os
 import logging
 import difflib
+
+from allura.lib.utils import permanent_redirect
 from datetime import datetime
 from six.moves.urllib.parse import quote, unquote
 from collections import defaultdict, OrderedDict
@@ -94,7 +96,7 @@ class RepoRootController(BaseController, FeedController):
     def index(self, offset=0, branch=None, **kw):
         if branch is None:
             branch = c.app.default_branch_name
-        redirect(c.app.repo.url_for_commit(branch, url_type='ref'))
+        permanent_redirect(c.app.repo.url_for_commit(branch, url_type='ref'))
 
     @with_trailing_slash
     @expose('jinja:allura:templates/repo/forks.html')
diff --git a/Allura/allura/tests/functional/test_home.py b/Allura/allura/tests/functional/test_home.py
index ab5834f..6ab70d1 100644
--- a/Allura/allura/tests/functional/test_home.py
+++ b/Allura/allura/tests/functional/test_home.py
@@ -137,7 +137,7 @@ class TestProjectHome(TestController):
 
     @td.with_wiki
     def test_neighborhood_home(self):
-        self.app.get('/p/test/wiki/', status=302)
+        self.app.get('/p/test/wiki/', status=301)
         self.app.get('/adobe/test/wiki/', status=404)
         self.app.get('/adobe/no_such_project/wiki/', status=404)
 
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index 33b0ba6..ce75e9c 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -29,7 +29,7 @@ from mock import patch
 from tg import config
 from nose.tools import assert_equal, assert_in, assert_not_equal
 from ming.orm.ormsession import ThreadLocalORMSession, session
-from paste.httpexceptions import HTTPFound
+from paste.httpexceptions import HTTPFound, HTTPMovedPermanently
 from tg import app_globals as g, tmpl_context as c
 
 import allura
@@ -44,7 +44,7 @@ from six.moves import map
 
 class TestNeighborhood(TestController):
     def test_home_project(self):
-        r = self.app.get('/adobe/wiki/', status=302)
+        r = self.app.get('/adobe/wiki/', status=301)
         assert r.location.endswith('/adobe/wiki/Home/')
         r = r.follow()
         assert 'This is the "Adobe" neighborhood' in str(r), str(r)
@@ -332,7 +332,7 @@ class TestNeighborhood(TestController):
         neighborhood = M.Neighborhood.query.get(name='Adobe')
         neighborhood.features['css'] = 'picker'
         r = self.app.get('/adobe/')
-        while isinstance(r.response, HTTPFound):
+        while isinstance(r.response, HTTPFound) or isinstance(r.response, HTTPMovedPermanently):
             r = r.follow()
         assert test_css in r
         r = self.app.get('/adobe/_admin/overview',
@@ -342,7 +342,7 @@ class TestNeighborhood(TestController):
         neighborhood = M.Neighborhood.query.get(name='Adobe')
         neighborhood.features['css'] = 'custom'
         r = self.app.get('/adobe/')
-        while isinstance(r.response, HTTPFound):
+        while isinstance(r.response, HTTPFound) or isinstance(r.response, HTTPMovedPermanently):
             r = r.follow()
         assert test_css in r
         r = self.app.get('/adobe/_admin/overview',
diff --git a/ForgeGit/forgegit/controllers.py b/ForgeGit/forgegit/controllers.py
index 188f8c4..e25238c 100644
--- a/ForgeGit/forgegit/controllers.py
+++ b/ForgeGit/forgegit/controllers.py
@@ -17,6 +17,8 @@
 
 from __future__ import unicode_literals
 from __future__ import absolute_import
+
+from allura.lib.utils import permanent_redirect
 from tg import expose, redirect
 from tg.decorators import with_trailing_slash
 from tg import tmpl_context as c
@@ -33,4 +35,4 @@ class BranchBrowser(repository.BranchBrowser):
         latest = c.app.repo.latest(branch=self._branch)
         if is_empty or not latest:
             return dict(allow_fork=False, log=[], is_empty=is_empty)
-        redirect(c.app.repo.url_for_commit(self._branch) + 'tree/')
+        permanent_redirect(c.app.repo.url_for_commit(self._branch) + 'tree/')
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 6b6a212..c08993d 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -648,10 +648,10 @@ class TestFork(_TestCase):
             shutil.rmtree(clone_path, ignore_errors=True)
 
     def _follow(self, r, **kw):
-        if r.status_int == 302:
+        if r.status_int == 301 or r.status_int == 302:
             print(r.request.url)
-        while r.status_int == 302:
-            print(' ==> 302 ==> %s' % r.location)
+        while r.status_int == 301 or r.status_int == 302:
+            print(' ==> 302/301 ==> %s' % r.location)
             r = r.follow(**kw)
         return r
 
diff --git a/ForgeSVN/forgesvn/controllers.py b/ForgeSVN/forgesvn/controllers.py
index 1d967e4..7eab0c2 100644
--- a/ForgeSVN/forgesvn/controllers.py
+++ b/ForgeSVN/forgesvn/controllers.py
@@ -17,6 +17,8 @@
 
 from __future__ import unicode_literals
 from __future__ import absolute_import
+
+from allura.lib.utils import permanent_redirect
 from tg import expose, redirect
 from tg.decorators import with_trailing_slash
 from tg import tmpl_context as c
@@ -40,7 +42,7 @@ class BranchBrowser(repository.BranchBrowser, FeedController):
         latest = c.app.repo.latest(branch=self._branch)
         if is_empty or not latest:
             return dict(allow_fork=False, log=[], is_empty=is_empty)
-        redirect(c.app.repo.url_for_commit(c.app.default_branch_name)
+        permanent_redirect(c.app.repo.url_for_commit(c.app.default_branch_name)
                  + 'tree/')
 
     @expose()
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 7ea79bc..35f2b3c 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -673,7 +673,7 @@ class TestRootController(TestController):
         assert_equal(homepage_admin.form['new_home'].value, 'Home')
         homepage_admin.form['new_home'].value = 'our_néw_home'
         homepage_admin.form.submit()
-        root_path = self.app.get('/wiki/', status=302)
+        root_path = self.app.get('/wiki/', status=301)
         assert root_path.location.endswith('/wiki/our_n%C3%A9w_home/'), root_path.location
 
     def test_edit_mount_label(self):
@@ -753,13 +753,13 @@ class TestRootController(TestController):
         assert found_links == 10, 'Wrong number of links found'
 
     def test_home_rename(self):
-        assert 'The resource was found at http://localhost/p/test/wiki/Home/;' in self.app.get(
+        assert 'The resource has been moved to http://localhost/p/test/wiki/Home/;' in self.app.get(
             '/p/test/wiki/')
         req = self.app.get('/p/test/wiki/Home/edit')
         form = self._find_edit_form(req)
         form['title'].value = 'new_title'
         form.submit()
-        assert 'The resource was found at http://localhost/p/test/wiki/new_title/;' in self.app.get(
+        assert 'The resource has been moved to http://localhost/p/test/wiki/new_title/;' in self.app.get(
             '/p/test/wiki/')
 
     @patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='0')
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index c30eb8e..3e5c702 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -43,7 +43,7 @@ from allura.app import Application, SitemapEntry, DefaultAdminController, Config
 from allura.lib.search import search_app
 from allura.lib.decorators import require_post, memorable_forget
 from allura.lib.security import require_access, has_access
-from allura.lib.utils import is_ajax, JSONForExport
+from allura.lib.utils import is_ajax, JSONForExport, permanent_redirect
 from allura.tasks import notification_tasks
 from allura.lib import exceptions as forge_exc
 from allura.controllers import AppDiscussionController, BaseController, AppDiscussionRestController
@@ -392,7 +392,7 @@ class RootController(BaseController, DispatchIndex, FeedController):
     @with_trailing_slash
     @expose()
     def index(self, **kw):
-        redirect(h.urlquote(h.really_unicode(c.app.root_page_name)+ '/'))
+        permanent_redirect(h.urlquote(h.really_unicode(c.app.root_page_name)+ '/'))
 
     @expose()
     def _lookup(self, pname, *remainder):


[allura] 02/02: canonical on wiki pages

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 87633685b76d4c558ab293a6696c13e4347d1984
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Fri Oct 23 19:21:21 2020 +0000

    canonical on wiki pages
---
 ForgeWiki/forgewiki/templates/wiki/page_view.html | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ForgeWiki/forgewiki/templates/wiki/page_view.html b/ForgeWiki/forgewiki/templates/wiki/page_view.html
index 7380232..03b836f 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_view.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_view.html
@@ -36,6 +36,7 @@
 <link rel="alternate" type="application/atom+xml" title="Page Atom" href="feed.atom"/>
 <link rel="alternate" type="application/rss+xml" title="Wiki RSS" href="../feed.rss"/>
 <link rel="alternate" type="application/atom+xml" title="Wiki Atom" href="../feed.atom"/>
+<link rel="canonical" href="{{ h.absurl(page.url()) }}">
 {% endblock %}
 {% block body_css_class %} {{super()}} wiki-{{(page.title).replace(' ','_')}}{% endblock %}