Merge branch 'getpelican:master' into Chinese-translation

This commit is contained in:
GeorgeHu 2024-05-08 10:04:55 +08:00 committed by GitHub
commit 19f8706793
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20 additions and 2 deletions

View file

@ -14,7 +14,7 @@ repos:
- id: forbid-new-submodules
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.5
rev: v0.1.15
hooks:
- id: ruff
- id: ruff-format

View file

@ -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``.

View file

@ -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,

View file

@ -132,6 +132,10 @@ class DateFormatter:
def __init__(self) -> None:
self.locale = locale.setlocale(locale.LC_TIME)
# python has issue with Turkish_Türkiye.1254 locale, replace it to
# something accepted: Turkish
if self.locale == "Turkish_Türkiye.1254":
self.locale = "Turkish"
def __call__(self, date: datetime.datetime, date_format: str) -> str:
# on OSX, encoding from LC_CTYPE determines the unicode output in PY3
@ -922,6 +926,10 @@ def temporary_locale(
class to use the C locale.
"""
orig_locale = locale.setlocale(lc_category)
# python has issue with Turkish_Türkiye.1254 locale, replace it to
# something accepted: Turkish
if orig_locale == "Turkish_Türkiye.1254":
orig_locale = "Turkish"
if temp_locale:
locale.setlocale(lc_category, temp_locale)
yield

View file

@ -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

View file

@ -69,6 +69,7 @@ changelog-header = "###############"
version-header = "="
[tool.pdm]
ignore_package_warnings = ["sphinx"]
[tool.pdm.scripts]
docbuild = "invoke docbuild"
@ -95,7 +96,7 @@ dev = [
"pytest-xdist>=3.4.0",
"tox>=4.11.3",
"invoke>=2.2.0",
"ruff>=0.1.5,<0.2.0",
"ruff>=0.1.15,<0.2.0",
"tomli>=2.0.1; python_version < \"3.11\"",
]