From: Vladimír Vondruš Date: Thu, 13 Sep 2018 15:05:05 +0000 (+0200) Subject: theme: properly fallback to FEED_ATOM if FEED_ATOM_URL is not set. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=8e8151293c2a22d50ca2357a284e95670fe07f9c;p=blog.git theme: properly fallback to FEED_ATOM if FEED_ATOM_URL is not set. --- diff --git a/pelican-plugins/m/test/__init__.py b/pelican-plugins/m/test/__init__.py index 45c77de1..8050b498 100644 --- a/pelican-plugins/m/test/__init__.py +++ b/pelican-plugins/m/test/__init__.py @@ -55,7 +55,9 @@ class PluginTestCase(unittest.TestCase): 'PAGE_URL': '{slug}.html', 'PAGE_EXCLUDES': ['output'], 'ARTICLE_PATHS': ['articles'], # does not exist - 'FEED_ALL_ATOM': None, # Don't render feeds, we're not testing them *ever* + # Don't render feeds, we don't want to test them all the time + 'FEED_ALL_ATOM': None, + 'CATEGORY_FEED_ATOM': None, 'THEME': '../pelican-theme', 'PLUGIN_PATHS': ['.'], 'THEME_STATIC_DIR': 'static', diff --git a/pelican-theme/templates/base.html b/pelican-theme/templates/base.html index aed2a29c..9c9930d7 100644 --- a/pelican-theme/templates/base.html +++ b/pelican-theme/templates/base.html @@ -10,9 +10,15 @@ {% endblock head_links %} {% if FEED_ALL_ATOM_URL %} + {% elif FEED_ALL_ATOM %} + {% endif %} - {% if CATEGORY_FEED_ATOM_URL and category %} + {% if category %} + {% if CATEGORY_FEED_ATOM_URL %} + {% elif CATEGORY_FEED_ATOM %} + + {% endif %} {% endif %} {% if M_THEME_COLOR %} diff --git a/pelican-theme/test/__init__.py b/pelican-theme/test/__init__.py index 935e4285..ddd0ce9c 100644 --- a/pelican-theme/test/__init__.py +++ b/pelican-theme/test/__init__.py @@ -52,7 +52,9 @@ class MinimalTestCase(unittest.TestCase): 'OUTPUT_PATH': os.path.join(self.path, 'output'), 'PAGE_EXCLUDES': [os.path.join(self.path, 'output')], 'ARTICLE_EXCLUDES': [os.path.join(self.path, 'output')], - 'FEED_ALL_ATOM': None, # Don't render feeds, we're not testing them *ever* + # Don't render feeds, we don't want to test them all the time + 'FEED_ALL_ATOM': None, + 'CATEGORY_FEED_ATOM': None } implicit_settings.update(settings) settings = read_settings(path=None, override=implicit_settings) diff --git a/pelican-theme/test/blog_feeds/article.rst b/pelican-theme/test/blog_feeds/article.rst new file mode 100644 index 00000000..594c9b74 --- /dev/null +++ b/pelican-theme/test/blog_feeds/article.rst @@ -0,0 +1,5 @@ +An article +########## + +:date: 2018-09-13 +:category: A Category diff --git a/pelican-theme/test/blog_feeds/category-a-category.html b/pelican-theme/test/blog_feeds/category-a-category.html new file mode 100644 index 00000000..1f82b2c6 --- /dev/null +++ b/pelican-theme/test/blog_feeds/category-a-category.html @@ -0,0 +1,52 @@ + + + + + A Category | A Pelican Blog + + + + + + + +
+
+
+
+
+
+ Showing only posts in A Category. Show all posts. +
+ +
+ +
+
+
+ + diff --git a/pelican-theme/test/blog_feeds/index.html b/pelican-theme/test/blog_feeds/index.html new file mode 100644 index 00000000..63ef57fa --- /dev/null +++ b/pelican-theme/test/blog_feeds/index.html @@ -0,0 +1,48 @@ + + + + + A Pelican Blog + + + + + + +
+
+
+
+
+ +
+ +
+
+
+ + diff --git a/pelican-theme/test/blog_feeds_no_url/article.rst b/pelican-theme/test/blog_feeds_no_url/article.rst new file mode 100644 index 00000000..594c9b74 --- /dev/null +++ b/pelican-theme/test/blog_feeds_no_url/article.rst @@ -0,0 +1,5 @@ +An article +########## + +:date: 2018-09-13 +:category: A Category diff --git a/pelican-theme/test/test_blog.py b/pelican-theme/test/test_blog.py index a0f74f9e..907329d0 100644 --- a/pelican-theme/test/test_blog.py +++ b/pelican-theme/test/test_blog.py @@ -550,3 +550,35 @@ class Draft(BlogTestCase): self.assertEqual(*self.actual_expected_contents('article.html')) self.assertEqual(*self.actual_expected_contents('article-jumbo.html')) + +class Feeds(BlogTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'feeds', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'M_DISABLE_SOCIAL_META_TAGS': True, + 'FEED_ALL_ATOM': 'atom.xml', + 'FEED_ALL_ATOM_URL': 'feeds/atom.xml', + 'CATEGORY_FEED_ATOM': '%s.atom.xml', + 'CATEGORY_FEED_ATOM_URL': 'feeds/%s.atom.xml', + }) + + # There should be just the first column + self.assertEqual(*self.actual_expected_contents('index.html')) + self.assertEqual(*self.actual_expected_contents('category-a-category.html')) + +class FeedsNoUrl(BlogTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'feeds_no_url', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'M_DISABLE_SOCIAL_META_TAGS': True, + 'FEED_ALL_ATOM': 'feeds/atom.xml', + 'CATEGORY_FEED_ATOM': 'feeds/%s.atom.xml', + }) + + # The feed URLs should be the same as above + self.assertEqual(*self.actual_expected_contents('index.html', '../blog_feeds/index.html')) + self.assertEqual(*self.actual_expected_contents('category-a-category.html', '../blog_feeds/category-a-category.html'))