From 0b5934a1fa56bb7ca9b0b0011e35f9043afc6ce9 Mon Sep 17 00:00:00 2001 From: GiovanH Date: Fri, 19 Apr 2024 13:54:27 -0500 Subject: [PATCH 1/3] Feature: Add setting to append `ref` parameter to links in feeds (#3249) --- docs/settings.rst | 5 +++++ pelican/settings.py | 1 + pelican/writers.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/docs/settings.rst b/docs/settings.rst index e9edffde..4ae608c6 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -1008,6 +1008,11 @@ the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings: to ``False``, the full content will be included instead. This setting doesn't affect Atom feeds, only RSS ones. +.. data:: FEED_APPEND_REF = False + + If set to ``True``, ``?ref=feed`` will be appended to links in generated + feeds for the purpose of referrer tracking. + If you don't want to generate some or any of these feeds, set the above variables to ``None``. diff --git a/pelican/settings.py b/pelican/settings.py index 29051ddb..47457ec1 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -52,6 +52,7 @@ DEFAULT_CONFIG = { "TRANSLATION_FEED_ATOM": "feeds/all-{lang}.atom.xml", "FEED_MAX_ITEMS": 100, "RSS_FEED_SUMMARY_ONLY": True, + "FEED_APPEND_REF": False, "SITEURL": "", "SITENAME": "A Pelican Blog", "DISPLAY_PAGES_ON_MENU": True, diff --git a/pelican/writers.py b/pelican/writers.py index d405fc88..1c41b4ee 100644 --- a/pelican/writers.py +++ b/pelican/writers.py @@ -53,6 +53,9 @@ class Writer: title = Markup(item.title).striptags() link = self.urljoiner(self.site_url, item.url) + if self.settings["FEED_APPEND_REF"]: + link = link + "?ref=feed" + if isinstance(feed, Rss201rev2Feed): # RSS feeds use a single tag called 'description' for both the full # content and the summary From e4d7f0a9d95cf2816e4c0b2b59849f49766e05dc Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Wed, 29 May 2024 07:28:22 +0200 Subject: [PATCH 2/3] Docs: GitHub Pages workflow not officially supported --- .github/workflows/github_pages.yml | 1 + docs/tips.rst | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github_pages.yml b/.github/workflows/github_pages.yml index eb9e955f..f4a01b92 100644 --- a/.github/workflows/github_pages.yml +++ b/.github/workflows/github_pages.yml @@ -1,3 +1,4 @@ +# Workflow for publishing to GitHub Pages. **NO OFFICIAL SUPPORT PROVIDED.** name: Deploy to GitHub Pages on: workflow_call: diff --git a/docs/tips.rst b/docs/tips.rst index 904e5ee7..3344900d 100644 --- a/docs/tips.rst +++ b/docs/tips.rst @@ -126,8 +126,9 @@ branch of your GitHub repository:: Publishing to GitHub Pages Using a Custom GitHub Actions Workflow ----------------------------------------------------------------- -Pelican comes with a `custom workflow `_ -for publishing a Pelican site. To use it: +Pelican-powered sites can be published to GitHub Pages via a `custom workflow +`_. +**No official support is provided** for this community-submitted workflow. To use it: 1. Enable GitHub Pages in your repo: go to **Settings → Pages** and choose **GitHub Actions** for the **Source** setting. From 1001dcb6096d315bc460571c5f43ea88a33e1e18 Mon Sep 17 00:00:00 2001 From: boxydog Date: Wed, 29 May 2024 16:36:20 -0500 Subject: [PATCH 3/3] Fix test_deprecated_attribute failures in github tests --- pelican/tests/test_utils.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 22dd8e38..bd3f0d00 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -23,9 +23,17 @@ from pelican.tests.support import ( from pelican.writers import Writer -class TestUtils(LoggedTestCase): +class ClassDeprAttr: _new_attribute = "new_value" + @utils.deprecated_attribute( + old="_old_attribute", new="_new_attribute", since=(3, 1, 0), remove=(4, 1, 3) + ) + def _old_attribute(): + return None + + +class TestUtils(LoggedTestCase): def setUp(self): super().setUp() self.temp_output = mkdtemp(prefix="pelicantests.") @@ -34,15 +42,10 @@ class TestUtils(LoggedTestCase): super().tearDown() shutil.rmtree(self.temp_output) - @utils.deprecated_attribute( - old="_old_attribute", new="_new_attribute", since=(3, 1, 0), remove=(4, 1, 3) - ) - def _old_attribute(): - return None - def test_deprecated_attribute(self): - value = self._old_attribute - self.assertEqual(value, self._new_attribute) + test_class = ClassDeprAttr() + value = test_class._old_attribute + self.assertEqual(value, test_class._new_attribute) self.assertLogCountEqual( count=1, msg=(