You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by di...@apache.org on 2022/03/18 18:47:58 UTC
[allura] branch dw/8421 updated (20cb16c -> 3c0f4c1)
This is an automated email from the ASF dual-hosted git repository.
dill0wn pushed a change to branch dw/8421
in repository https://gitbox.apache.org/repos/asf/allura.git.
discard 20cb16c [#8421] SEO - omit Discussions from sitemap if no posts
new 3c0f4c1 [#8421] SEO - omit Discussions from sitemap if no posts
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (20cb16c)
\
N -- N -- N refs/heads/dw/8421 (3c0f4c1)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 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:
ForgeDiscussion/forgediscussion/forum_main.py | 1 -
ForgeDiscussion/forgediscussion/tests/test_app.py | 1 -
2 files changed, 2 deletions(-)
[allura] 01/01: [#8421] SEO - omit Discussions from sitemap if no posts
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dill0wn pushed a commit to branch dw/8421
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 3c0f4c1a6eaa12bfa23a10a4dffddce399ece4db
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Fri Mar 18 18:27:07 2022 +0000
[#8421] SEO - omit Discussions from sitemap if no posts
---
ForgeDiscussion/forgediscussion/forum_main.py | 23 ++++++++++++++
ForgeDiscussion/forgediscussion/tests/test_app.py | 38 ++++++++++++++++++++++-
2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index caa19dd..fca6fc8 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -126,6 +126,29 @@ class ForgeDiscussionApp(Application):
return [
SitemapEntry(menu_id, '.')[self.sidebar_menu()]]
+ def sitemap_xml(self):
+ """
+ Used for generating sitemap.xml.
+ If the root page has default content, omit it from the sitemap.xml.
+ Assumes :attr:`main_menu` will return an entry pointing to the root page.
+ :return: a list of :class:`SitemapEntries <allura.app.SitemapEntry>`
+ """
+ if self.should_noindex():
+ return []
+ return self.main_menu()
+
+ def should_noindex(self):
+ forums = self.forums
+ for forum in forums:
+ post = DM.ForumPost.query.get(
+ discussion_id=forum._id,
+ status='ok',
+ deleted=False,
+ )
+ if post:
+ return False
+ return True
+
@property
def forums(self):
return DM.Forum.query.find(dict(app_config_id=self.config._id)).all()
diff --git a/ForgeDiscussion/forgediscussion/tests/test_app.py b/ForgeDiscussion/forgediscussion/tests/test_app.py
index 29d6ee5..32f4de2 100644
--- a/ForgeDiscussion/forgediscussion/tests/test_app.py
+++ b/ForgeDiscussion/forgediscussion/tests/test_app.py
@@ -18,20 +18,25 @@
import tempfile
import json
import os
+import random
from operator import attrgetter
from cgi import FieldStorage
from io import BytesIO
+from alluratest.controller import setup_basic_test
from alluratest.tools import assert_equal
from tg import tmpl_context as c
from forgediscussion.site_stats import posts_24hr
from ming.orm import ThreadLocalORMSession
+from ming.orm.base import session
from allura import model as M
+from allura.lib import helpers as h
from allura.tests import decorators as td
from forgediscussion.tests.functional.test_rest import TestDiscussionApiBase
-from forgediscussion.model.forum import Forum, ForumPost
+from forgediscussion.model.forum import Forum, ForumThread, ForumPost
+from forgediscussion import utils
class TestApp(TestDiscussionApiBase): # creates some sample data
@@ -49,6 +54,37 @@ class TestApp(TestDiscussionApiBase): # creates some sample data
assert_equal(2, posts_24hr())
+class TestAppSitemap:
+
+ def setUp(self):
+ setup_basic_test()
+ self.user = M.User.query.get(username='root')
+
+ @td.with_discussion
+ def test_sitemap_xml(self):
+ assert_equal([], c.app.sitemap_xml())
+ forum = utils.create_forum(c.app, dict(
+ shortname='test-forum',
+ name="Test Forum",
+ description="Test Forum Description",
+ ))
+ ThreadLocalORMSession.flush_all()
+ assert_equal([], c.app.sitemap_xml())
+ thread = ForumThread(
+ subject='test-thread',
+ )
+ thread.set_forum(forum)
+ ThreadLocalORMSession.flush_all()
+
+ assert_equal([], c.app.sitemap_xml())
+ thread.post(
+ subject='test-post',
+ text='this is a test post.',
+ )
+ ThreadLocalORMSession.flush_all()
+ assert_equal(1, len(c.app.sitemap_xml()))
+
+
class TestBulkExport(TestDiscussionApiBase):
def test_bulk_export(self):