From 58e3770b80a1e9649f29a0081041a81984e8f983 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Fri, 9 Jul 2021 08:28:15 -0600 Subject: [PATCH] Document how to add a new writer c.f. #2899 --- docs/plugins.rst | 27 +++++++++++++++++++++++++++ docs/tips.rst | 10 +++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/docs/plugins.rst b/docs/plugins.rst index f661afb8..8e24b0af 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -274,6 +274,33 @@ Adding a new generator is also really easy. You might want to have a look at signals.get_generators.connect(get_generators) +Adding a new writer +------------------- + +Adding a writer will allow you to output additional file formats to disk, or +change how the existing formats are written to disk. Note that only one writer +will be active at a time, so be sure to either subclass the built-in Writer, or +completely re-implement it. + +Here is a basic example of how to set up your own writer:: + + from pelican.writers import Writer + from pelican import signals + + class MyWriter(Writer): + # define new writer functionality + pass + + + def add_writer(pelican_object): + # use pelican_instance to setup stuff if needed + return MyWriter + + + def register(): + signals.get_writer.connect(add_writer) + + .. _Pip: https://pip.pypa.io/ .. _pelican-plugins bug #314: https://github.com/getpelican/pelican-plugins/issues/314 .. _Blinker: https://pythonhosted.org/blinker/ diff --git a/docs/tips.rst b/docs/tips.rst index 18a79ef0..78013227 100644 --- a/docs/tips.rst +++ b/docs/tips.rst @@ -93,21 +93,21 @@ by the ``ghp-import`` command) to the ``elemoine.github.io`` repository's To publish your Pelican site as User Pages, feel free to adjust the ``github`` target of the Makefile. - + Another option for publishing to User Pages is to generate the output files in the root directory of the project. For example, your main project folder is ``.github.io`` and you can create the Pelican project in a subdirectory called ``Pelican``. Then from inside the ``Pelican`` folder you can run:: - + $ pelican content -o .. -s pelicanconf.py Now you can push the whole project ``.github.io`` to the master branch of your GitHub repository:: - + $ git push origin master - + (assuming origin is set to your remote repository). Custom 404 Pages @@ -179,4 +179,4 @@ If you are using ``develop-server.sh``, add this to the top:: and modify the ``pelican.server`` line as follows:: - $PY -m pelican.server $port --ssl --cert="$CERT" --key="$KEY" & \ No newline at end of file + $PY -m pelican.server $port --ssl --cert="$CERT" --key="$KEY" &