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/23 00:32:27 UTC
[allura] branch dw/8421 updated (3c0f4c1 -> 346a45a)
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.
from 3c0f4c1 [#8421] SEO - omit Discussions from sitemap if no posts
new 7ee933b fixup! [#8421] SEO - omit Discussions from sitemap if no posts
new 346a45a [#8421] SEO - omit /blogs/ from sitemap if no posts
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:
ForgeBlog/forgeblog/main.py | 23 +++++++++++++++++++++++
ForgeBlog/forgeblog/tests/test_app.py | 23 +++++++++++++++++++++++
ForgeDiscussion/forgediscussion/forum_main.py | 3 +++
3 files changed, 49 insertions(+)
[allura] 02/02: [#8421] SEO - omit /blogs/ 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 346a45ab604d3658c55bb9d2f4178ba3aee85a48
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Wed Mar 23 00:32:04 2022 +0000
[#8421] SEO - omit /blogs/ from sitemap if no posts
---
ForgeBlog/forgeblog/main.py | 23 +++++++++++++++++++++++
ForgeBlog/forgeblog/tests/test_app.py | 23 +++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 417c669..246e99e 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -155,6 +155,29 @@ class ForgeBlogApp(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):
+ if not has_access(self, 'read'):
+ return True
+
+ post = BM.BlogPost.query.get(
+ app_config_id=self.config._id,
+ state='published',
+ deleted=False)
+ if post:
+ return False
+ return True
+
@property
def show_discussion(self):
if 'show_discussion' in self.config.options:
diff --git a/ForgeBlog/forgeblog/tests/test_app.py b/ForgeBlog/forgeblog/tests/test_app.py
index a1b706a..98cc59f 100644
--- a/ForgeBlog/forgeblog/tests/test_app.py
+++ b/ForgeBlog/forgeblog/tests/test_app.py
@@ -49,6 +49,29 @@ class TestApp:
c.project.uninstall_app('blog')
assert not BM.BlogPost.query.get(title='Test title')
+ @td.with_tool('test', 'Blog', 'blog')
+ def test_sitemap_xml(self):
+ assert_equal([], c.app.sitemap_xml())
+ BM.BlogPost.new(
+ title='Blog Title',
+ state='draft',
+ text='This is my first blog Post',
+ )
+ assert_equal([], c.app.sitemap_xml())
+ BM.BlogPost.new(
+ title='Blog Title',
+ state='published',
+ text='This is my first blog Post',
+ deleted=True
+ )
+ assert_equal([], c.app.sitemap_xml())
+ BM.BlogPost.new(
+ title='Blog Title',
+ state='published',
+ text='This is my first blog Post',
+ )
+ assert_equal(1, len(c.app.sitemap_xml()))
+
class TestBulkExport:
[allura] 01/02: fixup! [#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 7ee933b2a71876ccca4cc185f03f979e91a9175e
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Wed Mar 23 00:31:30 2022 +0000
fixup! [#8421] SEO - omit Discussions from sitemap if no posts
---
ForgeDiscussion/forgediscussion/forum_main.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index fca6fc8..9087f95 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -138,6 +138,9 @@ class ForgeDiscussionApp(Application):
return self.main_menu()
def should_noindex(self):
+ if not has_access(self, 'read'):
+ return True
+
forums = self.forums
for forum in forums:
post = DM.ForumPost.query.get(