diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14b8ee90..06d90677 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu, macos, windows] - python: ["3.10", "3.11", "3.12", "3.13", "3.14"] + python: ["3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/checkout@v6 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index b18ff005..cd5f2060 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.10" + python: "3.11" # Build HTML & PDF formats formats: diff --git a/docs/conf.py b/docs/conf.py index e335e73c..77c49bcb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,12 +2,7 @@ import datetime import os import sys import time - -if sys.version_info >= (3, 11): - import tomllib -else: - import tomli as tomllib - +import tomllib sys.path.append(os.path.abspath(os.pardir)) @@ -32,7 +27,7 @@ source_suffix = ".rst" master_doc = "index" project = project_data.get("name").upper() year = datetime.datetime.fromtimestamp( - int(os.environ.get("SOURCE_DATE_EPOCH", time.time())), datetime.timezone.utc + int(os.environ.get("SOURCE_DATE_EPOCH", time.time())), datetime.UTC ).year project_copyright = f"2010–{year}" # noqa: RUF001 exclude_patterns = ["_build"] diff --git a/pelican/contents.py b/pelican/contents.py index 8494145a..3d9e086c 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -590,7 +590,7 @@ class Article(Content): if self.date.tzinfo is None: now = datetime.datetime.now() else: - now = datetime.datetime.now(datetime.timezone.utc) + now = datetime.datetime.now(datetime.UTC) if self.date > now: self.status = "draft" diff --git a/pelican/settings.py b/pelican/settings.py index 98b1357e..dbe903f1 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -673,9 +673,10 @@ def configure_settings(settings: Settings) -> Settings: ] if any(settings.get(k) for k in feed_keys): - if not settings.get("SITEURL"): + if not (settings.get("SITEURL") or settings.get("FEED_DOMAIN")): logger.warning( - "Feeds generated without SITEURL set properly may not be valid" + "Feeds generated without SITEURL or FEED_DOMAIN set properly" + " may not be valid" ) if "TIMEZONE" not in settings: diff --git a/pelican/tests/test_settings.py b/pelican/tests/test_settings.py index 84f7a5c9..59eebd53 100644 --- a/pelican/tests/test_settings.py +++ b/pelican/tests/test_settings.py @@ -1,8 +1,10 @@ import copy import locale +import logging import os from os.path import abspath, dirname, join +from pelican import log from pelican.settings import ( DEFAULT_CONFIG, DEFAULT_THEME, @@ -11,7 +13,7 @@ from pelican.settings import ( handle_deprecated_settings, read_settings, ) -from pelican.tests.support import unittest +from pelican.tests.support import LogCountHandler, unittest class TestSettingsConfiguration(unittest.TestCase): @@ -108,6 +110,39 @@ class TestSettingsConfiguration(unittest.TestCase): configure_settings(settings) self.assertEqual(settings["FEED_DOMAIN"], "http://feeds.example.com") + def _feeds_warning_settings(self, **overrides): + base = { + "LOCALE": "", + "PATH": os.curdir, + "THEME": DEFAULT_THEME, + "FEED_RSS": "feeds/all.rss.xml", + } + base.update(overrides) + handler = LogCountHandler() + logger = logging.getLogger() + logger.addHandler(handler) + saved = log.LimitFilter._raised_messages.copy() + log.LimitFilter._raised_messages = set() + try: + configure_settings(base) + return handler.count_logs( + "Feeds generated without SITEURL", logging.WARNING + ) + finally: + log.LimitFilter._raised_messages = saved + logger.removeHandler(handler) + + def test_feeds_warning_with_siteurl(self): + self.assertEqual(self._feeds_warning_settings(SITEURL="http://example.com"), 0) + + def test_feeds_warning_with_feed_domain(self): + self.assertEqual( + self._feeds_warning_settings(FEED_DOMAIN="http://feeds.example.com"), 0 + ) + + def test_feeds_warning_without_siteurl_or_feed_domain(self): + self.assertEqual(self._feeds_warning_settings(), 1) + def test_theme_settings_exceptions(self): settings = self.settings diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 95bf197a..b5a53eac 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -2,7 +2,7 @@ import locale import logging import os import shutil -from datetime import timezone +from datetime import UTC from sys import platform from tempfile import mkdtemp @@ -62,10 +62,15 @@ class TestUtils(LoggedTestCase): date = utils.SafeDatetime(year=2012, month=11, day=22) date_hour = utils.SafeDatetime(year=2012, month=11, day=22, hour=22, minute=11) date_hour_z = utils.SafeDatetime( - year=2012, month=11, day=22, hour=22, minute=11, tzinfo=timezone.utc + year=2012, month=11, day=22, hour=22, minute=11, tzinfo=UTC ) - date_hour_est = utils.SafeDatetime( - year=2012, month=11, day=22, hour=22, minute=11, tzinfo=ZoneInfo("EST") + date_hour_wib = utils.SafeDatetime( + year=2012, + month=11, + day=22, + hour=22, + minute=11, + tzinfo=ZoneInfo("Asia/Jakarta"), ) date_hour_sec = utils.SafeDatetime( year=2012, month=11, day=22, hour=22, minute=11, second=10 @@ -77,16 +82,16 @@ class TestUtils(LoggedTestCase): hour=22, minute=11, second=10, - tzinfo=timezone.utc, + tzinfo=UTC, ) - date_hour_sec_est = utils.SafeDatetime( + date_hour_sec_wib = utils.SafeDatetime( year=2012, month=11, day=22, hour=22, minute=11, second=10, - tzinfo=ZoneInfo("EST"), + tzinfo=ZoneInfo("Asia/Jakarta"), ) date_hour_sec_frac_z = utils.SafeDatetime( year=2012, @@ -96,7 +101,7 @@ class TestUtils(LoggedTestCase): minute=11, second=10, microsecond=123000, - tzinfo=timezone.utc, + tzinfo=UTC, ) dates = { "2012-11-22": date, @@ -108,10 +113,10 @@ class TestUtils(LoggedTestCase): "22.11.2012": date, "22.11.2012 22:11": date_hour, "2012-11-22T22:11Z": date_hour_z, - "2012-11-22T22:11-0500": date_hour_est, + "2012-11-22T22:11+0700": date_hour_wib, "2012-11-22 22:11:10": date_hour_sec, "2012-11-22T22:11:10Z": date_hour_sec_z, - "2012-11-22T22:11:10-0500": date_hour_sec_est, + "2012-11-22T22:11:10+0700": date_hour_sec_wib, "2012-11-22T22:11:10.123Z": date_hour_sec_frac_z, } diff --git a/pelican/themes/simple/templates/index.html b/pelican/themes/simple/templates/index.html index 97caac6a..100a7200 100644 --- a/pelican/themes/simple/templates/index.html +++ b/pelican/themes/simple/templates/index.html @@ -11,11 +11,13 @@
{{ article.summary }}
{% endfor %} diff --git a/pelican/themes/simple/templates/page.html b/pelican/themes/simple/templates/page.html index 0eefc7e3..4096e7a4 100644 --- a/pelican/themes/simple/templates/page.html +++ b/pelican/themes/simple/templates/page.html @@ -20,7 +20,7 @@ {% import 'translations.html' as translations with context %} {{ translations.translations_for(page) }} - {{ page.content }} + {% block page_content %}{{ page.content }}{% endblock page_content %} {% if page.modified %}