From 219c01afb07e41020224e5bd92ecb48ba6405000 Mon Sep 17 00:00:00 2001 From: "Martin (mart-e)" Date: Wed, 29 Mar 2023 13:39:27 +0200 Subject: [PATCH 01/36] [IMP] pelican_import with gmf instead of markdown The markdown import of pandoc is their own flavour of markdown. It for instance uses fenced divs[1] which are not supported by python-markdown. When importing content from Wordpress, there is several issues as explained in discussion 3113[2] This change follows a discussion with pandoc developer[3] [1] https://pandoc.org/MANUAL.html#divs-and-spans [2] https://github.com/getpelican/pelican/discussions/3113 [3] https://fosstodon.org/@pandoc/110105559949588768 Take the following Wordpress blog post sample: ```html

Paragraph content


Some caption

``` Before this commit: was imported as ```md ``{=html} Paragraph content ``{=html} ``{=html} ::: wp-block-image

Some caption
::: ``{=html} ``` After this change: ```md Paragraph content

Some caption
``` Fixes #3113 --- pelican/tests/test_importer.py | 2 +- pelican/tools/pelican_import.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pelican/tests/test_importer.py b/pelican/tests/test_importer.py index 76feb9ce..198ee0fe 100644 --- a/pelican/tests/test_importer.py +++ b/pelican/tests/test_importer.py @@ -317,7 +317,7 @@ class TestWordpressXmlImporter(unittest.TestCase): self.posts) with temporary_folder() as temp: md = [r(f) for f in silent_f2p(test_post, 'markdown', temp)][0] - sample_line = re.search(r'- This is a code sample', md).group(0) + sample_line = re.search(r'- This is a code sample', md).group(0) code_line = re.search(r'\s+a = \[1, 2, 3\]', md).group(0) self.assertTrue(sample_line.rindex('This') < code_line.rindex('a')) diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py index 5b08b6b5..f8a6c631 100755 --- a/pelican/tools/pelican_import.py +++ b/pelican/tools/pelican_import.py @@ -839,12 +839,15 @@ def fields2pelican( if pandoc_version >= (1, 16) else '--no-wrap' cmd = ('pandoc --normalize {0} --from=html' ' --to={1} {2} -o "{3}" "{4}"') - cmd = cmd.format(parse_raw, out_markup, wrap_none, + cmd = cmd.format(parse_raw, + out_markup if out_markup != 'markdown' else "gfm", + wrap_none, out_filename, html_filename) else: from_arg = '-f html+raw_html' if not strip_raw else '-f html' cmd = ('pandoc {0} --to={1}-smart --wrap=none -o "{2}" "{3}"') - cmd = cmd.format(from_arg, out_markup, + cmd = cmd.format(from_arg, + out_markup if out_markup != 'markdown' else "gfm", out_filename, html_filename) try: From 7adcfc7938e0bd3a0ff406e87b200b760e3e455a Mon Sep 17 00:00:00 2001 From: FriedrichFroebel Date: Mon, 24 Apr 2023 18:44:50 +0200 Subject: [PATCH 02/36] Allow resetting `memoized` cache. Fixes #3110. --- pelican/tests/test_utils.py | 31 +++++++++++++++++++++++++++++++ pelican/utils.py | 4 +++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 449a6814..1890ffb9 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -860,3 +860,34 @@ class TestSanitisedJoin(unittest.TestCase): utils.posixize_path( os.path.abspath(os.path.join("/foo/bar", "test"))) ) + + +class TestMemoized(unittest.TestCase): + def test_memoized(self): + class Container: + def _get(self, key): + pass + + @utils.memoized + def get(self, key): + return self._get(key) + + container = Container() + + with unittest.mock.patch.object( + container, "_get", side_effect=lambda x: x + ) as get_mock: + self.assertEqual("foo", container.get("foo")) + get_mock.assert_called_once_with("foo") + + get_mock.reset_mock() + self.assertEqual("foo", container.get("foo")) + get_mock.assert_not_called() + + self.assertEqual("bar", container.get("bar")) + get_mock.assert_called_once_with("bar") + + get_mock.reset_mock() + container.get.cache.clear() + self.assertEqual("bar", container.get("bar")) + get_mock.assert_called_once_with("bar") diff --git a/pelican/utils.py b/pelican/utils.py index f3a01217..de6ef9bf 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -155,7 +155,9 @@ class memoized: def __get__(self, obj, objtype): '''Support instance methods.''' - return partial(self.__call__, obj) + fn = partial(self.__call__, obj) + fn.cache = self.cache + return fn def deprecated_attribute(old, new, since=None, remove=None, doc=None): From ef844dbe0a204ce964dbbdcbc76013c966345f47 Mon Sep 17 00:00:00 2001 From: "Martin (mart-e)" Date: Mon, 10 Apr 2023 12:50:06 +0200 Subject: [PATCH 03/36] Use the default configuration When importing a blog, a error is logged: 'No timezone information specified in the settings'. This is because the code calls read_settings() but no configuration file is provided. Instead of providing one (users may not already have one if they are at the import step), use the default settings. --- pelican/tools/pelican_import.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py index 5b08b6b5..37d1c21b 100755 --- a/pelican/tools/pelican_import.py +++ b/pelican/tools/pelican_import.py @@ -15,7 +15,7 @@ from urllib.request import urlretrieve # because logging.setLoggerClass has to be called before logging.getLogger from pelican.log import init -from pelican.settings import read_settings +from pelican.settings import DEFAULT_CONFIG from pelican.utils import SafeDatetime, slugify @@ -285,8 +285,7 @@ def dc2fields(file): print("%i posts read." % len(posts)) - settings = read_settings() - subs = settings['SLUG_REGEX_SUBSTITUTIONS'] + subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS'] for post in posts: fields = post.split('","') @@ -404,8 +403,7 @@ def posterous2fields(api_token, email, password): page = 1 posts = get_posterous_posts(api_token, email, password, page) - settings = read_settings() - subs = settings['SLUG_REGEX_SUBSTITUTIONS'] + subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS'] while len(posts) > 0: posts = get_posterous_posts(api_token, email, password, page) page += 1 @@ -446,8 +444,7 @@ def tumblr2fields(api_key, blogname): offset = 0 posts = get_tumblr_posts(api_key, blogname, offset) - settings = read_settings() - subs = settings['SLUG_REGEX_SUBSTITUTIONS'] + subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS'] while len(posts) > 0: for post in posts: title = \ @@ -531,8 +528,7 @@ def feed2fields(file): """Read a feed and yield pelican fields""" import feedparser d = feedparser.parse(file) - settings = read_settings() - subs = settings['SLUG_REGEX_SUBSTITUTIONS'] + subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS'] for entry in d.entries: date = (time.strftime('%Y-%m-%d %H:%M', entry.updated_parsed) if hasattr(entry, 'updated_parsed') else None) @@ -778,8 +774,7 @@ def fields2pelican( pandoc_version = get_pandoc_version() posts_require_pandoc = [] - settings = read_settings() - slug_subs = settings['SLUG_REGEX_SUBSTITUTIONS'] + slug_subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS'] for (title, content, filename, date, author, categories, tags, status, kind, in_markup) in fields: From 6f93202e60e1b2468af5ef58905e906baa291466 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Mon, 22 May 2023 15:12:09 +0200 Subject: [PATCH 04/36] Add new Pelican Plugins org link to content docs --- docs/content.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/content.rst b/docs/content.rst index 0ab80670..e7aeefdc 100644 --- a/docs/content.rst +++ b/docs/content.rst @@ -95,8 +95,9 @@ contains a list of reserved metadata keywords: ``url`` URL to use for this article/page =============== =============================================================== -Readers for additional formats (such as AsciiDoc_) are available via plugins. -Refer to `pelican-plugins`_ repository for those. +Readers for additional formats (such as AsciiDoc_) are available via plugins, +which you can find via the `Pelican Plugins`_ collection as well as the legacy +`pelican-plugins`_ repository. Pelican can also process HTML files ending in ``.html`` and ``.htm``. Pelican interprets the HTML in a very straightforward manner, reading metadata from @@ -626,11 +627,12 @@ Hidden Posts Like pages, posts can also be marked as ``hidden`` with the ``Status: hidden`` attribute. Hidden posts will be output to ``ARTICLE_SAVE_AS`` as expected, but -are not included by default in tag, category, and author indexes, nor in the +are not included by default in tag, category, and author indexes, nor in the main article feed. This has the effect of creating an "unlisted" post. .. _W3C ISO 8601: https://www.w3.org/TR/NOTE-datetime .. _AsciiDoc: https://www.methods.co.nz/asciidoc/ +.. _Pelican Plugins: https://github.com/pelican-plugins .. _pelican-plugins: https://github.com/getpelican/pelican-plugins .. _Python-Markdown: https://github.com/Python-Markdown/markdown .. _Markdown Extensions: https://python-markdown.github.io/extensions/ From 0a42b5f250b53bce3c48e789592ab62106dabc2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikolaus=20Sch=C3=BCler?= Date: Tue, 30 May 2023 15:58:09 +0200 Subject: [PATCH 05/36] Fix typo in pelican-themes.rst The least change would be to just say "suffixed", but I don't think that's a correct english word, so I choose "followed by" --- docs/pelican-themes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pelican-themes.rst b/docs/pelican-themes.rst index e63f6a19..29c905a5 100644 --- a/docs/pelican-themes.rst +++ b/docs/pelican-themes.rst @@ -62,7 +62,7 @@ or ``--list`` option: In this example, we can see there are three themes available: ``notmyidea``, ``simple``, and ``two-column``. -``two-column`` is prefixed with an ``@`` because this theme is not copied to +``two-column`` is followed by an ``@`` because this theme is not copied to the Pelican theme path, but is instead just linked to it (see `Creating symbolic links`_ for details about creating symbolic links). From bbbc96cf8321f1e6d8f2edda1d69e528d0304dce Mon Sep 17 00:00:00 2001 From: Matthew Pounsett Date: Sun, 4 Jun 2023 04:34:09 -0400 Subject: [PATCH 06/36] Add quoting to `devserver-global` target in Makefile, fixes #3072 (#3073) --- pelican/tools/templates/Makefile.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pelican/tools/templates/Makefile.jinja2 b/pelican/tools/templates/Makefile.jinja2 index 2bcb7473..02de5e5b 100644 --- a/pelican/tools/templates/Makefile.jinja2 +++ b/pelican/tools/templates/Makefile.jinja2 @@ -114,7 +114,7 @@ devserver: "$(PELICAN)" -lr "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(CONFFILE)" $(PELICANOPTS) devserver-global: - $(PELICAN) -lr $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -b 0.0.0.0 + "$(PELICAN)" -lr "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(CONFFILE)" $(PELICANOPTS) -b 0.0.0.0 publish: "$(PELICAN)" "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(PUBLISHCONF)" $(PELICANOPTS) From 418a9191b0424ba94ebd3d1ee1522c4a9440ef44 Mon Sep 17 00:00:00 2001 From: Matthew Pounsett Date: Tue, 20 Dec 2022 12:46:54 -0500 Subject: [PATCH 07/36] Add devserver-global Makefile target to .phony, fixes #3065 --- pelican/tools/templates/Makefile.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pelican/tools/templates/Makefile.jinja2 b/pelican/tools/templates/Makefile.jinja2 index 02de5e5b..a324d1b1 100644 --- a/pelican/tools/templates/Makefile.jinja2 +++ b/pelican/tools/templates/Makefile.jinja2 @@ -165,4 +165,4 @@ github: publish {% endif %} -.PHONY: html help clean regenerate serve serve-global devserver publish {{ upload|join(" ") }} +.PHONY: html help clean regenerate serve serve-global devserver devserver-global publish {{ upload|join(" ") }} From 1f6b344f7d7b7e8dd0271cc333a257faca566c15 Mon Sep 17 00:00:00 2001 From: Deniz Turgut Date: Sat, 29 Apr 2023 19:00:52 +0300 Subject: [PATCH 08/36] Add sftp_upload Makefile target to .phony Signed-off-by: Deniz Turgut --- pelican/tools/templates/Makefile.jinja2 | 1 + 1 file changed, 1 insertion(+) diff --git a/pelican/tools/templates/Makefile.jinja2 b/pelican/tools/templates/Makefile.jinja2 index a324d1b1..93ab1aa7 100644 --- a/pelican/tools/templates/Makefile.jinja2 +++ b/pelican/tools/templates/Makefile.jinja2 @@ -125,6 +125,7 @@ publish: ssh_upload: publish scp -P $(SSH_PORT) -r "$(OUTPUTDIR)"/* "$(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)" +{% set upload = upload + ["sftp_upload"] %} sftp_upload: publish printf 'put -r $(OUTPUTDIR)/*' | sftp $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) From 168093a75072c7d0f82df4541cf2c52ad6c71ea6 Mon Sep 17 00:00:00 2001 From: Jorge Maldonado Ventura Date: Fri, 23 Jun 2023 09:05:10 +0200 Subject: [PATCH 09/36] Fix typo in pelican-themes.rst --- docs/pelican-themes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pelican-themes.rst b/docs/pelican-themes.rst index 29c905a5..9e0bf572 100644 --- a/docs/pelican-themes.rst +++ b/docs/pelican-themes.rst @@ -21,7 +21,7 @@ Optional arguments: """"""""""""""""""" --h, --help Show the help an exit +-h, --help Show the help and exit -l, --list Show the themes already installed From 787737615397e967ea42872238e183de25c35573 Mon Sep 17 00:00:00 2001 From: Jorge Maldonado Ventura Date: Fri, 23 Jun 2023 09:20:32 +0200 Subject: [PATCH 10/36] More corrections to pelican-themes.rst --- docs/pelican-themes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pelican-themes.rst b/docs/pelican-themes.rst index 9e0bf572..b16b5389 100644 --- a/docs/pelican-themes.rst +++ b/docs/pelican-themes.rst @@ -82,7 +82,7 @@ Installing themes You can install one or more themes using the ``-i`` or ``--install`` option. This option takes as argument the path(s) of the theme(s) you want to install, -and can be combined with the verbose option: +and can be combined with the ``--verbose`` option: .. code-block:: console @@ -154,7 +154,7 @@ This is useful for theme development: Doing several things at once """""""""""""""""""""""""""" -The ``--install``, ``--remove`` and ``--symlink`` option are not mutually +The ``--install``, ``--remove`` and ``--symlink`` options are not mutually exclusive, so you can combine them in the same command line to do more than one operation at time, like this: From 7d6accac4dc3b5e8f43fa7788e3f60b55883010e Mon Sep 17 00:00:00 2001 From: Jorge Maldonado Ventura Date: Fri, 23 Jun 2023 09:27:51 +0200 Subject: [PATCH 11/36] Code should be between backquotes () --- docs/pelican-themes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pelican-themes.rst b/docs/pelican-themes.rst index b16b5389..6cb8896a 100644 --- a/docs/pelican-themes.rst +++ b/docs/pelican-themes.rst @@ -29,7 +29,7 @@ Optional arguments: -r theme_name, --remove theme_name One or more themes to remove --s theme_path, --symlink theme_path Same as "--install", but create a symbolic link instead of copying the theme. +-s theme_path, --symlink theme_path Same as ``--install``, but create a symbolic link instead of copying the theme. Useful for theme development -v, --verbose Verbose output From d3daa4d79469d13c13a5287c9f7e7625857c4231 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Fri, 23 Jun 2023 15:53:21 +0200 Subject: [PATCH 12/36] Update Furo theme & pytest-cov dependency versions --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index db18dd79..9acd5075 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,12 +49,12 @@ lxml = "^4.3" markdown = "~3.4.3" typogrify = "^2.0" sphinx = "^5.1" -furo = "2022.12.07" +furo = "2023.03.27" livereload = "^2.6" psutil = {version = "^5.7", optional = true} pygments = "~2.14" pytest = "^7.1" -pytest-cov = "^3.0" +pytest-cov = "^4.0" pytest-sugar = "^0.9.5" pytest-xdist = "^2.0" tox = {version = "^3.13", optional = true} From 410f60d6b322cb2b3c952914d9673958c01601c1 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Fri, 23 Jun 2023 15:54:39 +0200 Subject: [PATCH 13/36] Publish package via PyPI trusted publisher system --- .github/workflows/main.yml | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9574a0bc..b80d8926 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Python ${{ matrix.config.python }} + - name: Set up Python ${{ matrix.config.python }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.config.python }} @@ -63,7 +63,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.9" @@ -81,7 +81,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.9" @@ -95,34 +95,42 @@ jobs: deploy: name: Deploy + environment: Deployment needs: [test, lint, docs] runs-on: ubuntu-latest - if: ${{ github.ref=='refs/heads/master' && github.event_name!='pull_request' }} + if: github.ref=='refs/heads/master' && github.event_name!='pull_request' + + permissions: + contents: write + id-token: write steps: - uses: actions/checkout@v3 - - name: Setup Python + with: + token: ${{ secrets.GH_TOKEN }} + + - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.9" + - name: Check release id: check_release run: | - python -m pip install pip --upgrade - pip install poetry - pip install githubrelease - pip install --pre autopub + python -m pip install --upgrade pip + python -m pip install autopub[github] autopub check - continue-on-error: true + - name: Publish - if: steps.check_release.outcome=='success' + if: ${{ steps.check_release.outputs.autopub_release=='true' }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - git remote set-url origin https://$GITHUB_TOKEN@github.com/${{ github.repository }} autopub prepare - poetry build autopub commit + autopub build autopub githubrelease - poetry publish -u __token__ -p $PYPI_PASSWORD + + - name: Upload package to PyPI + if: ${{ steps.check_release.outputs.autopub_release=='true' }} + uses: pypa/gh-action-pypi-publish@release/v1 From b260b3838e62ec903857a1e6c2d1c8a97cb130d6 Mon Sep 17 00:00:00 2001 From: Jorge Maldonado Ventura Date: Sat, 24 Jun 2023 13:29:02 +0200 Subject: [PATCH 14/36] Fix grammar errors/typos from docs/faq.rst --- docs/faq.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index 8c91388d..c065b4ed 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -17,7 +17,7 @@ suggestions or problems you might have via `Pelican Discussions existing list of discussions and issues (both open and closed) in order to avoid submitting topics that have already been covered before. -If you want to contribute, please fork `the git repository +If you want to contribute, please fork `the Git repository `_, create a new feature branch, make your changes, and issue a pull request. Someone will review your changes as soon as possible. Please refer to the :doc:`How to Contribute ` @@ -68,7 +68,7 @@ I want to use Markdown, but I got an error. =========================================== If you try to generate Markdown content without first installing the Markdown -library, may see a message that says ``No valid files found in content``. +library, you may see a message that says ``No valid files found in content``. Markdown is not a hard dependency for Pelican, so if you have content in Markdown format, you will need to explicitly install the Markdown library. You can do so by typing the following command, prepending ``sudo`` if permissions @@ -128,7 +128,7 @@ to override the generated URL. Here is an example page in reST format:: :save_as: override/url/index.html With this metadata, the page will be written to ``override/url/index.html`` -and Pelican will use url ``override/url/`` to link to this page. +and Pelican will use the URL ``override/url/`` to link to this page. How can I use a static page as my home page? ============================================ @@ -229,7 +229,7 @@ This can be achieved by explicitly specifying only the filenames of those articles in ``ARTICLE_PATHS``. A list of such filenames could be found using a command similar to ``cd content; find -name '*.md' | head -n 10``. -My tag-cloud is missing/broken since I upgraded Pelican +My tag cloud is missing/broken since I upgraded Pelican ======================================================= In an ongoing effort to streamline Pelican, tag cloud generation has been From 0533e2da9f85f75be500dc2ef544cad82acf10a4 Mon Sep 17 00:00:00 2001 From: Jorge Maldonado Ventura Date: Tue, 27 Jun 2023 20:35:04 +0200 Subject: [PATCH 15/36] Small documentation fixes to docs/content.rst (#3156) --- docs/content.rst | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/content.rst b/docs/content.rst index e7aeefdc..cacacea9 100644 --- a/docs/content.rst +++ b/docs/content.rst @@ -184,7 +184,7 @@ files in it will be used to generate static pages, such as **About** or You can use the ``DISPLAY_PAGES_ON_MENU`` setting to control whether all those pages are displayed in the primary navigation menu. (Default is ``True``.) -If you want to exclude any pages from being linked to or listed in the menu +If you want to exclude any pages from being linked to or listed in the menu, then add a ``status: hidden`` attribute to its metadata. This is useful for things like making error pages that fit the generated theme of your site. @@ -235,7 +235,7 @@ that may be sitting alongside that post (instead of having to determine where the other content will be placed after site generation). To link to internal content (files in the ``content`` directory), use the -following syntax for the link target: ``{filename}path/to/file`` +following syntax for the link target: ``{filename}path/to/file``. Note: forward slashes, ``/``, are the required path separator in the ``{filename}`` directive on all operating systems, including Windows. @@ -307,7 +307,7 @@ Attaching static files ---------------------- Starting with Pelican 3.5, static files can be "attached" to a page or article -using this syntax for the link target: ``{attach}path/to/file`` This works +using this syntax for the link target: ``{attach}path/to/file``. This works like the ``{static}`` syntax, but also relocates the static file into the linking document's output directory. If the static file originates from a subdirectory beneath the linking document's source, that relationship will be @@ -539,12 +539,12 @@ The specified identifier (e.g. ``python``, ``ruby``) should be one that appears on the `list of available lexers `_. When using reStructuredText the following options are available in the -code-block directive: +`code-block` directive: ============= ============ ========================================= Option Valid values Description ============= ============ ========================================= -anchorlinenos N/A If present wrap line numbers in tags. +anchorlinenos N/A If present, wrap line numbers in ```` tags. classprefix string String to prepend to token class names hl_lines numbers List of lines to be highlighted, where line numbers to highlight are separated @@ -555,22 +555,22 @@ hl_lines numbers List of lines to be highlighted, where line numbers. lineanchors string Wrap each line in an anchor using this string and -linenumber. -linenos string If present or set to "table" output line - numbers in a table, if set to - "inline" output them inline. "none" means +linenos string If present or set to "table", output line + numbers in a table; if set to + "inline", output them inline. "none" means do not output the line numbers for this table. -linenospecial number If set every nth line will be given the - 'special' css class. +linenospecial number If set, every nth line will be given the + 'special' CSS class. linenostart number Line number for the first line. linenostep number Print every nth line number. lineseparator string String to print between lines of code, '\n' by default. linespans string Wrap each line in a span using this and -linenumber. -nobackground N/A If set do not output background color for +nobackground N/A If set, do not output background color for the wrapping element -nowrap N/A If set do not wrap the tokens at all. +nowrap N/A If set, do not wrap the tokens at all. tagsfile string ctags file to use for name definitions. tagurlformat string format for the ctag links. ============= ============ ========================================= @@ -596,7 +596,7 @@ Pelican settings file to include options that will be automatically applied to every code block. For example, if you want to have line numbers displayed for every code block -and a CSS prefix you would set this variable to:: +and a CSS prefix, you would set this variable to:: PYGMENTS_RST_OPTIONS = {'classprefix': 'pgcss', 'linenos': 'table'} @@ -612,7 +612,7 @@ its metadata. That article will then be output to the ``drafts`` folder and not listed on the index page nor on any category or tag page. If your articles should be automatically published as a draft (to not -accidentally publish an article before it is finished) include the status in +accidentally publish an article before it is finished), include the status in the ``DEFAULT_METADATA``:: DEFAULT_METADATA = { From ef7e26329cbabcafa4027442cb8e8c45136f8d17 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 29 Jun 2023 11:15:41 +0200 Subject: [PATCH 16/36] Change botpub email address for Git commits --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9acd5075..eb3a8f52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,7 +77,7 @@ pelican-themes = "pelican.tools.pelican_themes:main" [tool.autopub] project-name = "Pelican" git-username = "botpub" -git-email = "botpub@autopub.rocks" +git-email = "52496925+botpub@users.noreply.github.com" changelog-file = "docs/changelog.rst" changelog-header = "###############" version-header = "=" From b8bf5950b6a6c684196a6d047d41efbff0f95c85 Mon Sep 17 00:00:00 2001 From: "(GalaxyMaster)" Date: Wed, 12 Jul 2023 19:28:26 +1000 Subject: [PATCH 17/36] Adding missing tests for truncate_html_words() (#2918) --- pelican/tests/test_utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 1890ffb9..2dab2ab4 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -259,6 +259,26 @@ class TestUtils(LoggedTestCase): utils.truncate_html_words('' + 'word ' * 100, 20), '' + 'word ' * 20 + '…') + # Words enclosed or intervaled by HTML tags with a custom end + # marker containing HTML tags. + self.assertEqual( + utils.truncate_html_words('

' + 'word ' * 100 + '

', 20, + 'marker'), + '

' + 'word ' * 20 + 'marker

') + self.assertEqual( + utils.truncate_html_words( + '' + 'word ' * 100 + '', 20, + 'marker'), + '' + 'word ' * 20 + 'marker') + self.assertEqual( + utils.truncate_html_words('
' + 'word ' * 100, 20, + 'marker'), + '
' + 'word ' * 20 + 'marker') + self.assertEqual( + utils.truncate_html_words('' + 'word ' * 100, 20, + 'marker'), + '' + 'word ' * 20 + 'marker') + # Words with hypens and apostrophes. self.assertEqual( utils.truncate_html_words("a-b " * 100, 20), From 7f1ecdec8b88b9e0efa9bfa7b127862c4a2e85d5 Mon Sep 17 00:00:00 2001 From: Marcus Desai Date: Tue, 25 Jul 2023 20:27:40 +0100 Subject: [PATCH 18/36] Fixes #3163; cleanup child processes on kill --- pelican/__init__.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pelican/__init__.py b/pelican/__init__.py index 9858dbd3..bd867988 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -543,13 +543,15 @@ def main(argv=None): target=listen, args=(settings.get('BIND'), settings.get('PORT'), settings.get("OUTPUT_PATH"), excqueue)) - p1.start() - p2.start() - exc = excqueue.get() - p1.terminate() - p2.terminate() - if exc is not None: - logger.critical(exc) + try: + p1.start() + p2.start() + exc = excqueue.get() + if exc is not None: + logger.critical(exc) + finally: + p1.terminate() + p2.terminate() elif args.autoreload: autoreload(args) elif args.listen: From 715c056cd409b9f2a99092325c0ef6b5744613b5 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Wed, 26 Jul 2023 11:24:20 +0200 Subject: [PATCH 19/36] Update Pygments dev dependency version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index eb3a8f52..4ab2650a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,7 @@ sphinx = "^5.1" furo = "2023.03.27" livereload = "^2.6" psutil = {version = "^5.7", optional = true} -pygments = "~2.14" +pygments = "~2.15" pytest = "^7.1" pytest-cov = "^4.0" pytest-sugar = "^0.9.5" From 1d2bf8e96efa624743453f4bf8108f413e5c60f9 Mon Sep 17 00:00:00 2001 From: Will Thong Date: Wed, 26 Jul 2023 16:29:43 +0100 Subject: [PATCH 20/36] Replace `pytz` dependency with `zoneinfo`. Fix #2958 (#3161) --- pelican/contents.py | 15 ++++++++++----- pelican/tools/pelican_quickstart.py | 20 +++++++++++--------- pelican/utils.py | 15 +++++++++------ pyproject.toml | 2 +- setup.py | 4 ++-- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/pelican/contents.py b/pelican/contents.py index c979dd0a..b756f92d 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -4,10 +4,15 @@ import locale import logging import os import re +from datetime import timezone from html import unescape from urllib.parse import unquote, urljoin, urlparse, urlunparse -import pytz +try: + import zoneinfo +except ModuleNotFoundError: + from backports import zoneinfo + from pelican.plugins import signals from pelican.settings import DEFAULT_CONFIG @@ -120,9 +125,9 @@ class Content: self.date_format = self.date_format[1] # manage timezone - default_timezone = settings.get('TIMEZONE', 'UTC') - timezone = getattr(self, 'timezone', default_timezone) - self.timezone = pytz.timezone(timezone) + default_timezone = settings.get("TIMEZONE", "UTC") + timezone = getattr(self, "timezone", default_timezone) + self.timezone = zoneinfo.ZoneInfo(timezone) if hasattr(self, 'date'): self.date = set_date_tzinfo(self.date, timezone) @@ -525,7 +530,7 @@ class Article(Content): if self.date.tzinfo is None: now = datetime.datetime.now() else: - now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc) + now = datetime.datetime.utcnow().replace(tzinfo=timezone.utc) if self.date > now: self.status = 'draft' diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py index 2d5629ef..7bdf8538 100755 --- a/pelican/tools/pelican_quickstart.py +++ b/pelican/tools/pelican_quickstart.py @@ -7,7 +7,10 @@ from typing import Mapping from jinja2 import Environment, FileSystemLoader -import pytz +try: + import zoneinfo +except ModuleNotFoundError: + from backports import zoneinfo try: import readline # NOQA @@ -17,8 +20,8 @@ except ImportError: try: import tzlocal _DEFAULT_TIMEZONE = tzlocal.get_localzone().zone -except ImportError: - _DEFAULT_TIMEZONE = 'Europe/Rome' +except ModuleNotFoundError: + _DEFAULT_TIMEZONE = "Europe/Rome" from pelican import __version__ @@ -158,16 +161,15 @@ def ask(question, answer=str, default=None, length=None): def ask_timezone(question, default, tzurl): """Prompt for time zone and validate input""" - lower_tz = [tz.lower() for tz in pytz.all_timezones] + tz_dict = {tz.lower(): tz for tz in zoneinfo.available_timezones()} while True: r = ask(question, str, default) - r = r.strip().replace(' ', '_').lower() - if r in lower_tz: - r = pytz.all_timezones[lower_tz.index(r)] + r = r.strip().replace(" ", "_").lower() + if r in tz_dict.keys(): + r = tz_dict[r] break else: - print('Please enter a valid time zone:\n' - ' (check [{}])'.format(tzurl)) + print("Please enter a valid time zone:\n" " (check [{}])".format(tzurl)) return r diff --git a/pelican/utils.py b/pelican/utils.py index de6ef9bf..8d91c487 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -18,10 +18,12 @@ from operator import attrgetter import dateutil.parser +try: + import zoneinfo +except ModuleNotFoundError: + from backports import zoneinfo from markupsafe import Markup -import pytz - logger = logging.getLogger(__name__) @@ -919,10 +921,11 @@ class FileSystemWatcher: def set_date_tzinfo(d, tz_name=None): """Set the timezone for dates that don't have tzinfo""" if tz_name and not d.tzinfo: - tz = pytz.timezone(tz_name) - d = tz.localize(d) - return SafeDatetime(d.year, d.month, d.day, d.hour, d.minute, d.second, - d.microsecond, d.tzinfo) + timezone = zoneinfo.ZoneInfo(tz_name) + d = d.replace(tzinfo=timezone) + return SafeDatetime( + d.year, d.month, d.day, d.hour, d.minute, d.second, d.microsecond, d.tzinfo + ) return d diff --git a/pyproject.toml b/pyproject.toml index 4ab2650a..826c1179 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,10 +37,10 @@ feedgenerator = ">=1.9" jinja2 = ">=2.7" pygments = ">=2.6" python-dateutil = ">=2.8" -pytz = ">=2020.1" rich = ">=10.1" unidecode = ">=1.1" markdown = {version = ">=3.1", optional = true} +backports-zoneinfo = {version = "^0.2.1", python = "<3.9"} [tool.poetry.dev-dependencies] BeautifulSoup4 = "^4.9" diff --git a/setup.py b/setup.py index da038d24..5d2023c6 100755 --- a/setup.py +++ b/setup.py @@ -9,8 +9,8 @@ from setuptools import find_packages, setup version = "4.8.0" requires = ['feedgenerator >= 1.9', 'jinja2 >= 2.7', 'pygments', - 'docutils>=0.15', 'pytz >= 0a', 'blinker', 'unidecode', - 'python-dateutil', 'rich'] + 'docutils>=0.15', 'blinker', 'unidecode', 'python-dateutil', + 'rich', 'backports-zoneinfo[tzdata] >= 0.2; python_version<"3.9"'] entry_points = { 'console_scripts': [ From 44d97544665832b20b97fd6a2072feca0f24292f Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Wed, 2 Aug 2023 11:01:40 +0200 Subject: [PATCH 21/36] Add monthly downloads badge to README --- README.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index b8cf9371..3f708242 100644 --- a/README.rst +++ b/README.rst @@ -1,10 +1,10 @@ -Pelican |build-status| |pypi-version| |repology| -================================================ +Pelican |build-status| |pypi-version| |downloads| |repology| +============================================================ Pelican is a static site generator, written in Python_, that allows you to create web sites by composing text files in formats such as Markdown, reStructuredText, and HTML. -With Pelican, you can create web sites without worrying about databases or server-side programming. +With Pelican, you can create web sites without worrying about databases or server-side programming. Pelican generates static sites that can be served via any web server or hosting service. You can perform the following functions with Pelican: @@ -70,6 +70,9 @@ Why the name “Pelican”? .. |pypi-version| image:: https://img.shields.io/pypi/v/pelican.svg :target: https://pypi.org/project/pelican/ :alt: PyPI: the Python Package Index +.. |downloads| image:: https://img.shields.io/pypi/dm/pelican.svg + :target: https://pypi.org/project/pelican/ + :alt: Monthly Downloads from PyPI .. |repology| image:: https://repology.org/badge/tiny-repos/pelican.svg :target: https://repology.org/project/pelican/versions :alt: Repology: the packaging hub From 413c6a1c7171ea447bb1817b118d811516283b2e Mon Sep 17 00:00:00 2001 From: Paolo Melchiorre Date: Wed, 26 Jan 2022 20:30:03 +0100 Subject: [PATCH 22/36] Order codes in themes.rst --- docs/themes.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/themes.rst b/docs/themes.rst index fe6337d6..db307878 100644 --- a/docs/themes.rst +++ b/docs/themes.rst @@ -34,11 +34,10 @@ Structure To make your own theme, you must follow the following structure:: ├── static - │   ├── css - │   └── images + │ ├── css + │ └── images └── templates ├── archives.html // to display archives - ├── period_archives.html // to display time-period archives ├── article.html // processed for each article ├── author.html // processed for each author ├── authors.html // must list all the authors @@ -46,6 +45,7 @@ To make your own theme, you must follow the following structure:: ├── category.html // processed for each category ├── index.html // the index (list all the articles) ├── page.html // processed for each page + ├── period_archives.html // to display time-period archives ├── tag.html // processed for each tag └── tags.html // must list all the tags. Can be a tag cloud. @@ -465,14 +465,14 @@ The feed variables changed in 3.0. Each variable now explicitly lists ATOM or RSS in the name. ATOM is still the default. Old themes will need to be updated. Here is a complete list of the feed variables:: - FEED_ATOM - FEED_RSS - FEED_ALL_ATOM - FEED_ALL_RSS - CATEGORY_FEED_ATOM - CATEGORY_FEED_RSS AUTHOR_FEED_ATOM AUTHOR_FEED_RSS + CATEGORY_FEED_ATOM + CATEGORY_FEED_RSS + FEED_ALL_ATOM + FEED_ALL_RSS + FEED_ATOM + FEED_RSS TAG_FEED_ATOM TAG_FEED_RSS TRANSLATION_FEED_ATOM From 7acc9ac5546b8b3cc8d9960a34b2eff086740fc9 Mon Sep 17 00:00:00 2001 From: Paolo Melchiorre Date: Wed, 26 Jan 2022 20:42:12 +0100 Subject: [PATCH 23/36] Fix documentations errors --- CONTRIBUTING.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 7d7b2c3a..59147b31 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -20,7 +20,7 @@ Before you ask for help, please make sure you do the following: you read the docs for the Pelican version you are using. 2. Use a search engine (e.g., DuckDuckGo, Google) to search for a solution to your problem. Someone may have already found a solution, perhaps in the - form of a plugin_ or a specific combination of settings. + form of a ':pelican-doc:`plugins` or a specific combination of settings. 3. Try reproducing the issue in a clean environment, ensuring you are using: @@ -77,7 +77,7 @@ Contributing code Before you submit a contribution, please ask whether it is desired so that you don't spend a lot of time working on something that would be rejected for a known reason. Consider also whether your new feature might be better suited as -a plugin_ — you can `ask for help`_ to make that determination. +a ':pelican-doc:`plugins` — you can `ask for help`_ to make that determination. Using Git and GitHub -------------------- From bf0860ee86874777556d983b996a67b61fd5c5c4 Mon Sep 17 00:00:00 2001 From: Paolo Melchiorre Date: Wed, 26 Jan 2022 20:59:02 +0100 Subject: [PATCH 24/36] Try to fix documentation build --- CONTRIBUTING.rst | 4 ++-- docs/conf.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 59147b31..d994bb1d 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -132,8 +132,8 @@ Contribution quality standards * Ensure your code is compatible with the `officially-supported Python releases`_. * Add docs and tests for your changes. Undocumented and untested features will not be accepted. -* `Run all the tests`_ **on all versions of Python supported by Pelican** to - ensure nothing was accidentally broken. +* :pelican-doc:`Run all the tests ` **on all versions of Python + supported by Pelican** to ensure nothing was accidentally broken. Check out our `Git Tips`_ page or `ask for help`_ if you need assistance or have any questions about these guidelines. diff --git a/docs/conf.py b/docs/conf.py index 0211c71a..8f80ba63 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ rst_prolog = ''' '''.format(last_stable) extlinks = { - 'pelican-doc': ('https://docs.getpelican.com/%s/', '%s') + 'pelican-doc': ('https://docs.getpelican.com/en/latest/%s.html', '%s') } # -- Options for HTML output -------------------------------------------------- From 5d1dcd8ed3531dda0431db473d0152ea0d476048 Mon Sep 17 00:00:00 2001 From: Paolo Melchiorre Date: Wed, 26 Jan 2022 21:03:52 +0100 Subject: [PATCH 25/36] Remove useless url --- CONTRIBUTING.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index d994bb1d..c1175aa4 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -141,7 +141,6 @@ need assistance or have any questions about these guidelines. .. _`plugin`: https://docs.getpelican.com/en/latest/plugins.html .. _`Create a new branch`: https://github.com/getpelican/pelican/wiki/Git-Tips#making-your-changes .. _`Squash your commits`: https://github.com/getpelican/pelican/wiki/Git-Tips#squashing-commits -.. _`Run all the tests`: https://docs.getpelican.com/en/latest/contribute.html#running-the-test-suite .. _`Git Tips`: https://github.com/getpelican/pelican/wiki/Git-Tips .. _`PEP8 coding standards`: https://www.python.org/dev/peps/pep-0008/ .. _`ask for help`: `How to get help`_ From dcd3045f32420a7f4c5a535fba9b2578d9dbb613 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 3 Aug 2023 10:15:22 +0200 Subject: [PATCH 26/36] Docs: Escape extra setting environment variables. Fix #3016 --- docs/settings.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/settings.rst b/docs/settings.rst index e51c6a12..44108ea2 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -15,6 +15,9 @@ setting file. Note that values must follow JSON notation:: pelican content -e SITENAME='"A site"' READERS='{"html": null}' CACHE_CONTENT=true +Environment variables can also be used here but must be escaped appropriately:: + + pelican content -e API_KEY=''\"$API_KEY\"'' .. note:: From 5435dd0d811aaeac6419d76510ded53d241fe226 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 3 Aug 2023 11:34:05 +0200 Subject: [PATCH 27/36] Document _update_context(dict) --> list of tuples Fix #3024 --- pelican/generators.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pelican/generators.py b/pelican/generators.py index e18531be..4fd796ba 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -206,8 +206,9 @@ class Generator: self.context['static_links'] |= content.get_static_links() def _update_context(self, items): - """Update the context with the given items from the current - processor. + """Update the context with the given items from the current processor. + + Note that dictionary arguments will be converted to a list of tuples. """ for item in items: value = getattr(self, item) From 639173da6bf1917ca227ac20f91f19eea2ae4403 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 3 Aug 2023 14:05:17 +0200 Subject: [PATCH 28/36] Generalize analytics support in default theme As the number of privacy-preserving analytics options proliferates, it no longer makes sense to support specific solutions provided by ad-tracking corporations. --- docs/publish.rst | 2 +- docs/settings.rst | 19 ++++++------- .../themes/notmyidea/templates/analytics.html | 27 ++----------------- .../themes/simple/templates/gosquared.html | 14 ---------- 4 files changed, 13 insertions(+), 49 deletions(-) delete mode 100644 pelican/themes/simple/templates/gosquared.html diff --git a/docs/publish.rst b/docs/publish.rst index 46913dea..f5ebfff5 100644 --- a/docs/publish.rst +++ b/docs/publish.rst @@ -67,7 +67,7 @@ Deployment After you have generated your site, previewed it in your local development environment, and are ready to deploy it to production, you might first -re-generate your site with any production-specific settings (e.g., analytics +re-generate your site with any production-specific settings (e.g., analytics, feeds, etc.) that you may have defined:: pelican content -s publishconf.py diff --git a/docs/settings.rst b/docs/settings.rst index 44108ea2..8417e209 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -1245,18 +1245,19 @@ Feel free to use them in your themes as well. Your GitHub URL (if you have one). It will then use this information to create a GitHub ribbon. -.. data:: GOOGLE_ANALYTICS +.. data:: ANALYTICS - Set to ``UA-XXXXX-Y`` Property's tracking ID to activate Google Analytics. + Put any desired analytics scripts in this setting in ``publishconf.py``. + Example: -.. data:: GA_COOKIE_DOMAIN + .. parsed-literal:: - Set cookie domain field of Google Analytics tracking code. Defaults to - ``auto``. - -.. data:: GOSQUARED_SITENAME - - Set to 'XXX-YYYYYY-X' to activate GoSquared. + ANALYTICS = """ + + + """ .. data:: MENUITEMS diff --git a/pelican/themes/notmyidea/templates/analytics.html b/pelican/themes/notmyidea/templates/analytics.html index 071c77f7..22642579 100644 --- a/pelican/themes/notmyidea/templates/analytics.html +++ b/pelican/themes/notmyidea/templates/analytics.html @@ -1,26 +1,3 @@ -{% if GOOGLE_ANALYTICS %} - -{% endif %} -{% if GAUGES %} - +{% if ANALYTICS %} +{{ ANALYTICS }} {% endif %} diff --git a/pelican/themes/simple/templates/gosquared.html b/pelican/themes/simple/templates/gosquared.html deleted file mode 100644 index 49ccbbef..00000000 --- a/pelican/themes/simple/templates/gosquared.html +++ /dev/null @@ -1,14 +0,0 @@ -{% if GOSQUARED_SITENAME %} - -{% endif %} From 9384e7cb0b91f6c0ccb9aaf31337410b7a57c111 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 3 Aug 2023 14:29:18 +0200 Subject: [PATCH 29/36] Add ReadTheDocs configuration file --- .readthedocs.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 00000000..dec90401 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,21 @@ +--- +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the OS, Python version, and any other needed tools +build: + os: ubuntu-22.04 + tools: + python: "3.10" + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/conf.py + +# Version of Python and requirements required to build the docs +python: + install: + - requirements: requirements/developer.pip From 48a0484d15636a6fab3d4e1be9de78ff500ae56a Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 3 Aug 2023 14:37:39 +0200 Subject: [PATCH 30/36] Improve ReadTheDocs configuration --- .readthedocs.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index dec90401..17084beb 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -11,6 +11,9 @@ build: tools: python: "3.10" +# Build all formats +formats: all + # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py @@ -19,3 +22,5 @@ sphinx: python: install: - requirements: requirements/developer.pip + - method: pip + path: . From 63b60da919937c04d55b7cddaad29fd171033dc6 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 3 Aug 2023 14:44:13 +0200 Subject: [PATCH 31/36] Build docs in zipped HTML and PDF formats --- .readthedocs.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 17084beb..b18ff005 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -11,8 +11,10 @@ build: tools: python: "3.10" -# Build all formats -formats: all +# Build HTML & PDF formats +formats: + - htmlzip + - pdf # Build documentation in the docs/ directory with Sphinx sphinx: From 0d1bcd4b1114f84fc775b422119185cab61cdd37 Mon Sep 17 00:00:00 2001 From: Moritz Meier Date: Tue, 8 Aug 2023 09:21:10 +0200 Subject: [PATCH 32/36] Pelican QuickStart: Address tzlocal API change (#3155) --- pelican/tools/pelican_quickstart.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py index 7bdf8538..4b6d93cc 100755 --- a/pelican/tools/pelican_quickstart.py +++ b/pelican/tools/pelican_quickstart.py @@ -19,7 +19,10 @@ except ImportError: try: import tzlocal - _DEFAULT_TIMEZONE = tzlocal.get_localzone().zone + if hasattr(tzlocal.get_localzone(), "zone"): + _DEFAULT_TIMEZONE = tzlocal.get_localzone().zone + else: + _DEFAULT_TIMEZONE = tzlocal.get_localzone_name() except ModuleNotFoundError: _DEFAULT_TIMEZONE = "Europe/Rome" From 2eeff62fd70d6b150d85910bf7ebc1db3ca57651 Mon Sep 17 00:00:00 2001 From: Will Thong Date: Tue, 15 Aug 2023 19:07:39 +0100 Subject: [PATCH 33/36] Replace `pytz` dependency in tests (#3165) --- docs/install.rst | 1 - pelican/contents.py | 6 +++--- pelican/tests/test_utils.py | 22 +++++++++++++--------- pelican/utils.py | 6 +++--- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/docs/install.rst b/docs/install.rst index cdc17bb9..ea47311f 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -64,7 +64,6 @@ automatically installed without any action on your part: * `pygments `_, for syntax highlighting * `docutils `_, for supporting reStructuredText as an input format -* `pytz `_, for timezone definitions * `blinker `_, an object-to-object and broadcast signaling system * `unidecode `_, for ASCII diff --git a/pelican/contents.py b/pelican/contents.py index b756f92d..4541e2ae 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -9,9 +9,9 @@ from html import unescape from urllib.parse import unquote, urljoin, urlparse, urlunparse try: - import zoneinfo + from zoneinfo import ZoneInfo except ModuleNotFoundError: - from backports import zoneinfo + from backports.zoneinfo import ZoneInfo from pelican.plugins import signals @@ -127,7 +127,7 @@ class Content: # manage timezone default_timezone = settings.get("TIMEZONE", "UTC") timezone = getattr(self, "timezone", default_timezone) - self.timezone = zoneinfo.ZoneInfo(timezone) + self.timezone = ZoneInfo(timezone) if hasattr(self, 'date'): self.date = set_date_tzinfo(self.date, timezone) diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 2dab2ab4..e1758726 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -3,10 +3,14 @@ import logging import os import shutil import time +from datetime import timezone from sys import platform from tempfile import mkdtemp -import pytz +try: + from zoneinfo import ZoneInfo +except ModuleNotFoundError: + from backports.zoneinfo import ZoneInfo from pelican import utils from pelican.generators import TemplatePagesGenerator @@ -50,21 +54,21 @@ class TestUtils(LoggedTestCase): 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=pytz.timezone('UTC')) + tzinfo=timezone.utc) date_hour_est = utils.SafeDatetime( year=2012, month=11, day=22, hour=22, minute=11, - tzinfo=pytz.timezone('EST')) + tzinfo=ZoneInfo("EST")) date_hour_sec = utils.SafeDatetime( year=2012, month=11, day=22, hour=22, minute=11, second=10) date_hour_sec_z = utils.SafeDatetime( year=2012, month=11, day=22, hour=22, minute=11, second=10, - tzinfo=pytz.timezone('UTC')) + tzinfo=timezone.utc) date_hour_sec_est = utils.SafeDatetime( year=2012, month=11, day=22, hour=22, minute=11, second=10, - tzinfo=pytz.timezone('EST')) + tzinfo=ZoneInfo("EST")) date_hour_sec_frac_z = utils.SafeDatetime( year=2012, month=11, day=22, hour=22, minute=11, second=10, - microsecond=123000, tzinfo=pytz.timezone('UTC')) + microsecond=123000, tzinfo=timezone.utc) dates = { '2012-11-22': date, '2012/11/22': date, @@ -86,13 +90,13 @@ class TestUtils(LoggedTestCase): iso_8601_date = utils.SafeDatetime(year=1997, month=7, day=16) iso_8601_date_hour_tz = utils.SafeDatetime( year=1997, month=7, day=16, hour=19, minute=20, - tzinfo=pytz.timezone('CET')) + tzinfo=ZoneInfo("Europe/London")) iso_8601_date_hour_sec_tz = utils.SafeDatetime( year=1997, month=7, day=16, hour=19, minute=20, second=30, - tzinfo=pytz.timezone('CET')) + tzinfo=ZoneInfo("Europe/London")) iso_8601_date_hour_sec_ms_tz = utils.SafeDatetime( year=1997, month=7, day=16, hour=19, minute=20, second=30, - microsecond=450000, tzinfo=pytz.timezone('CET')) + microsecond=450000, tzinfo=ZoneInfo("Europe/London")) iso_8601 = { '1997-07-16': iso_8601_date, '1997-07-16T19:20+01:00': iso_8601_date_hour_tz, diff --git a/pelican/utils.py b/pelican/utils.py index 8d91c487..d8cf15b4 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -19,9 +19,9 @@ from operator import attrgetter import dateutil.parser try: - import zoneinfo + from zoneinfo import ZoneInfo except ModuleNotFoundError: - from backports import zoneinfo + from backports.zoneinfo import ZoneInfo from markupsafe import Markup @@ -921,7 +921,7 @@ class FileSystemWatcher: def set_date_tzinfo(d, tz_name=None): """Set the timezone for dates that don't have tzinfo""" if tz_name and not d.tzinfo: - timezone = zoneinfo.ZoneInfo(tz_name) + timezone = ZoneInfo(tz_name) d = d.replace(tzinfo=timezone) return SafeDatetime( d.year, d.month, d.day, d.hour, d.minute, d.second, d.microsecond, d.tzinfo From e724de9ffe6752416a44b86705590f076acf9951 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Sun, 27 Aug 2023 16:39:27 +0200 Subject: [PATCH 34/36] Improve GitHub-Linguist language breakdown Refs #3188 --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index 9053428d..b6e6ec8f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,4 +4,7 @@ # Improve accuracy of GitHub's Linguist-powered language statistics pelican/tests/content/* linguist-vendored pelican/tests/output/* linguist-vendored +pelican/tests/theme_overrides/* linguist-vendored +pelican/themes/notmyidea/templates/*.html linguist-language=Jinja +pelican/themes/simple/templates/*.html linguist-language=Jinja samples/* linguist-vendored From 3be0703b14e65aabd547122c311f3d820b18e416 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Sun, 27 Aug 2023 16:47:45 +0200 Subject: [PATCH 35/36] Tell GitHub-Linguist to ignore HTML files Refs #3188 --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index b6e6ec8f..652980b9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,3 +8,4 @@ pelican/tests/theme_overrides/* linguist-vendored pelican/themes/notmyidea/templates/*.html linguist-language=Jinja pelican/themes/simple/templates/*.html linguist-language=Jinja samples/* linguist-vendored +*.html linguist-vendored From de0fae81821a78ed6b508d3570b56edb35293309 Mon Sep 17 00:00:00 2001 From: Lioman Date: Tue, 3 Oct 2023 16:59:57 +0200 Subject: [PATCH 36/36] Add python 3.12 to test matrix --- .github/workflows/main.yml | 17 ++++++++--------- setup.py | 2 ++ tox.ini | 3 ++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b80d8926..58333075 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,6 +25,8 @@ jobs: python: "3.10" - os: ubuntu python: "3.11" + - os: ubuntu + python: "3.12" - os: macos python: "3.7" - os: windows @@ -36,8 +38,8 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.config.python }} - cache: 'pip' - cache-dependency-path: '**/requirements/*' + cache: "pip" + cache-dependency-path: "**/requirements/*" - name: Install locale (Linux) if: startsWith(runner.os, 'Linux') run: sudo locale-gen fr_FR.UTF-8 tr_TR.UTF-8 @@ -56,7 +58,6 @@ jobs: - name: Run tests run: tox -e py${{ matrix.config.python }} - lint: name: Lint runs-on: ubuntu-latest @@ -67,14 +68,13 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.9" - cache: 'pip' - cache-dependency-path: '**/requirements/*' + cache: "pip" + cache-dependency-path: "**/requirements/*" - name: Install tox run: python -m pip install -U pip tox - name: Check run: tox -e flake8 - docs: name: Build docs runs-on: ubuntu-latest @@ -85,14 +85,13 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.9" - cache: 'pip' - cache-dependency-path: '**/requirements/*' + cache: "pip" + cache-dependency-path: "**/requirements/*" - name: Install tox run: python -m pip install -U pip tox - name: Check run: tox -e docs - deploy: name: Deploy environment: Deployment diff --git a/setup.py b/setup.py index 5d2023c6..18eedb00 100755 --- a/setup.py +++ b/setup.py @@ -77,6 +77,8 @@ setup( 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: Implementation :: CPython', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Software Development :: Libraries :: Python Modules', diff --git a/tox.ini b/tox.ini index 93819218..8f43fbc5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{3.7,3.8,3.9,3.10,3.11},docs,flake8 +envlist = py{3.7,3.8,3.9,3.10,3.11.3.12},docs,flake8 [testenv] basepython = @@ -8,6 +8,7 @@ basepython = py3.9: python3.9 py3.10: python3.10 py3.11: python3.11 + py3.12: python3.12 passenv = * usedevelop=True deps =