Skip to content

Commit

Permalink
Merge branch 'master' into fix_3216
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer authored Apr 16, 2024
2 parents c40d2a4 + 94bcd41 commit 69d92cd
Show file tree
Hide file tree
Showing 18 changed files with 617 additions and 158 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "pip"
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v3
- uses: pdm-project/setup-pdm@v4
with:
python-version: "3.11"
cache: true
Expand All @@ -64,14 +64,14 @@ jobs:
- name: Run linters
run: pdm lint --diff
- name: Run pre-commit checks on all files
uses: pre-commit/[email protected].0
uses: pre-commit/[email protected].1

build:
name: Test build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v3
- uses: pdm-project/setup-pdm@v4
with:
python-version: "3.11"
cache: true
Expand All @@ -90,7 +90,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
Expand All @@ -100,7 +100,7 @@ jobs:
- name: Check
run: tox -e docs
- name: cache the docs for inspection
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/_build/html/
Expand All @@ -122,7 +122,7 @@ jobs:
token: ${{ secrets.GH_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
args: ["--fix"]
Expand Down
6 changes: 3 additions & 3 deletions docs/content.rst
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ For **Markdown**, one must rely on an extension. For example, using the `mdx_inc
Importing an existing site
==========================

It is possible to import your site from WordPress, Tumblr, Dotclear, and RSS
feeds using a simple script. See :ref:`import`.
It is possible to import your site from several other blogging sites
(like WordPress, Tumblr, ..) using a simple script. See :ref:`import`.

Translations
============
Expand Down Expand Up @@ -631,7 +631,7 @@ 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/
.. _AsciiDoc: https://asciidoc.org
.. _Pelican Plugins: https://github.com/pelican-plugins
.. _pelican-plugins: https://github.com/getpelican/pelican-plugins
.. _Python-Markdown: https://github.com/Python-Markdown/markdown
Expand Down
28 changes: 26 additions & 2 deletions docs/importer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ software to reStructuredText or Markdown. The supported import formats are:

- Blogger XML export
- Dotclear export
- Medium export
- Tumblr API
- WordPress XML export
- RSS/Atom feed
Expand All @@ -26,6 +27,12 @@ not be converted (as Pelican also supports Markdown).
manually, or use a plugin such as `More Categories`_ that enables multiple
categories per article.

.. note::

Imported pages may contain links to images that still point to the original site.
So you might want to download those images into your local content and manually
re-link them from the relevant pages of your site.

Dependencies
============

Expand Down Expand Up @@ -65,6 +72,7 @@ Optional arguments
-h, --help Show this help message and exit
--blogger Blogger XML export (default: False)
--dotclear Dotclear export (default: False)
--medium Medium export (default: False)
--tumblr Tumblr API (default: False)
--wpfile WordPress XML export (default: False)
--feed Feed to parse (default: False)
Expand All @@ -80,8 +88,7 @@ Optional arguments
(default: False)
--filter-author Import only post from the specified author
--strip-raw Strip raw HTML code that can't be converted to markup
such as flash embeds or iframes (wordpress import
only) (default: False)
such as flash embeds or iframes (default: False)
--wp-custpost Put wordpress custom post types in directories. If
used with --dir-cat option directories will be created
as "/post_type/category/" (wordpress import only)
Expand Down Expand Up @@ -113,6 +120,14 @@ For Dotclear::

$ pelican-import --dotclear -o ~/output ~/backup.txt

For Medium::

$ pelican-import --medium -o ~/output ~/medium-export/posts/

The Medium export is a zip file. Unzip it, and point this tool to the
"posts" subdirectory. For more information on how to export, see
https://help.medium.com/hc/en-us/articles/115004745787-Export-your-account-data.

For Tumblr::

$ pelican-import --tumblr -o ~/output --blogname=<blogname> <api_key>
Expand All @@ -121,6 +136,15 @@ For WordPress::

$ pelican-import --wpfile -o ~/output ~/posts.xml

For Medium (an example of using an RSS feed):

$ python -m pip install feedparser
$ pelican-import --feed https://medium.com/feed/@username

.. note::

The RSS feed may only return the most recent posts — not all of them.

Tests
=====

Expand Down
16 changes: 13 additions & 3 deletions pelican/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ def init_plugins(self):
plugin.register()
self.plugins.append(plugin)
except Exception as e:
logger.error("Cannot register plugin `%s`\n%s", name, e)
logger.error(
"Cannot register plugin `%s`\n%s",
name,
e,
stacklevel=2,
)
if self.settings.get("DEBUG", False):
console.print_exception()

self.settings["PLUGINS"] = [get_plugin_name(p) for p in self.plugins]

Expand Down Expand Up @@ -120,12 +127,15 @@ def run(self):
if hasattr(p, "generate_context"):
p.generate_context()

# for plugins that create/edit the summary
logger.debug("Signal all_generators_finalized.send(<generators>)")
signals.all_generators_finalized.send(generators)

# update links in the summary, etc
for p in generators:
if hasattr(p, "refresh_metadata_intersite_links"):
p.refresh_metadata_intersite_links()

signals.all_generators_finalized.send(generators)

writer = self._get_writer()

for p in generators:
Expand Down
Loading

0 comments on commit 69d92cd

Please sign in to comment.