mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge branch 'master' into html_list_tags
This commit is contained in:
commit
d974ba898c
59 changed files with 1098 additions and 786 deletions
|
|
@ -12,6 +12,11 @@ matrix:
|
||||||
- python: 3.6
|
- python: 3.6
|
||||||
env:
|
env:
|
||||||
- TOX_ENV=py36
|
- TOX_ENV=py36
|
||||||
|
- python: 3.7
|
||||||
|
sudo: true
|
||||||
|
dist: xenial
|
||||||
|
env:
|
||||||
|
- TOX_ENV=py37
|
||||||
addons:
|
addons:
|
||||||
apt_packages:
|
apt_packages:
|
||||||
- pandoc
|
- pandoc
|
||||||
|
|
|
||||||
1
THANKS
1
THANKS
|
|
@ -155,6 +155,7 @@ Tshepang Lekhonkhobe
|
||||||
Valentin-Costel Hăloiu
|
Valentin-Costel Hăloiu
|
||||||
Vlad Niculae
|
Vlad Niculae
|
||||||
William Light
|
William Light
|
||||||
|
William Minchin
|
||||||
Wladislaw Merezhko
|
Wladislaw Merezhko
|
||||||
W. Trevor King
|
W. Trevor King
|
||||||
Zoresvit
|
Zoresvit
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ Release history
|
||||||
Next release
|
Next release
|
||||||
============
|
============
|
||||||
|
|
||||||
|
* All settings for slugs now use ``{slug}`` and/or ``{lang}`` rather than
|
||||||
|
``%s``. If ``%s``-style settings are encountered, Pelican will emit a warning
|
||||||
|
and fallback to the default setting.
|
||||||
* New signal: ``feed_generated``
|
* New signal: ``feed_generated``
|
||||||
* Replace Fabric by Invoke and ``fabfile.py`` template by ``tasks.py``.
|
* Replace Fabric by Invoke and ``fabfile.py`` template by ``tasks.py``.
|
||||||
* Replace ``SLUG_SUBSTITUTIONS`` (and friends) by ``SLUG_REGEX_SUBSTITUTIONS``
|
* Replace ``SLUG_SUBSTITUTIONS`` (and friends) by ``SLUG_REGEX_SUBSTITUTIONS``
|
||||||
|
|
@ -12,8 +15,11 @@ Next release
|
||||||
``'bar'`` from ``'foo/bar.html'`` (unless ``'bar' == 'index'``).
|
``'bar'`` from ``'foo/bar.html'`` (unless ``'bar' == 'index'``).
|
||||||
* ``ARTICLE_ORDER_BY`` and ``PAGE_ORDER_BY`` now also affect 1) category, tag
|
* ``ARTICLE_ORDER_BY`` and ``PAGE_ORDER_BY`` now also affect 1) category, tag
|
||||||
and author pages 2) feeds 3) draft and hidden articles and pages
|
and author pages 2) feeds 3) draft and hidden articles and pages
|
||||||
* New ``ARTICLE_TRANSLATION_ID`` and ``PAGE_TRANSLATION_ID`` settings to specify
|
* New ``ARTICLE_TRANSLATION_ID`` and ``PAGE_TRANSLATION_ID`` settings to
|
||||||
metadata attributes used to identify translations; or to disable translations
|
specify metadata attributes used to identify/disable translations
|
||||||
|
* New ``{static}`` syntax to link to static content; content linked to by
|
||||||
|
``{static}`` and ``{attach}`` is automatically copied over even if not in
|
||||||
|
``STATIC_PATHS``
|
||||||
* Make the HTML reader parse multiple occurrences of metadata tags as a list
|
* Make the HTML reader parse multiple occurrences of metadata tags as a list
|
||||||
|
|
||||||
3.7.1 (2017-01-10)
|
3.7.1 (2017-01-10)
|
||||||
|
|
@ -101,8 +107,8 @@ Next release
|
||||||
directory as articles and pages using ``{attach}`` in the path.
|
directory as articles and pages using ``{attach}`` in the path.
|
||||||
* Prevent Pelican from raising an exception when there are duplicate pieces of
|
* Prevent Pelican from raising an exception when there are duplicate pieces of
|
||||||
metadata in a Markdown file.
|
metadata in a Markdown file.
|
||||||
* Introduce the ``TYPOGRIFY_IGNORE_TAGS`` setting to add HTML tags to be ignored
|
* Introduce the ``TYPOGRIFY_IGNORE_TAGS`` setting to add HTML tags to be
|
||||||
by Typogrify.
|
ignored by Typogrify.
|
||||||
* Add the ability to use ``-`` in date formats to strip leading zeros. For
|
* Add the ability to use ``-`` in date formats to strip leading zeros. For
|
||||||
example, ``%-d/%-m/%y`` will now result in the date ``9/8/12``.
|
example, ``%-d/%-m/%y`` will now result in the date ``9/8/12``.
|
||||||
* Ensure feed generation is correctly disabled during quickstart configuration.
|
* Ensure feed generation is correctly disabled during quickstart configuration.
|
||||||
|
|
@ -205,8 +211,10 @@ Next release
|
||||||
* Improve appearance of LinkedIn icon in default theme
|
* Improve appearance of LinkedIn icon in default theme
|
||||||
* Add GitHub and Google+ social icons support in default theme
|
* Add GitHub and Google+ social icons support in default theme
|
||||||
* Optimize social icons
|
* Optimize social icons
|
||||||
* Add ``FEED_ALL_ATOM`` and ``FEED_ALL_RSS`` to generate feeds containing all posts regardless of their language
|
* Add ``FEED_ALL_ATOM`` and ``FEED_ALL_RSS`` to generate feeds containing all
|
||||||
* Split ``TRANSLATION_FEED`` into ``TRANSLATION_FEED_ATOM`` and ``TRANSLATION_FEED_RSS``
|
posts regardless of their language
|
||||||
|
* Split ``TRANSLATION_FEED`` into ``TRANSLATION_FEED_ATOM`` and
|
||||||
|
``TRANSLATION_FEED_RSS``
|
||||||
* Different feeds can now be enabled/disabled individually
|
* Different feeds can now be enabled/disabled individually
|
||||||
* Allow for blank author: if ``AUTHOR`` setting is not set, author won't
|
* Allow for blank author: if ``AUTHOR`` setting is not set, author won't
|
||||||
default to ``${USER}`` anymore, and a post won't contain any author
|
default to ``${USER}`` anymore, and a post won't contain any author
|
||||||
|
|
@ -214,7 +222,8 @@ Next release
|
||||||
* Move LESS and Webassets support from Pelican core to plugin
|
* Move LESS and Webassets support from Pelican core to plugin
|
||||||
* The ``DEFAULT_DATE`` setting now defaults to ``None``, which means that
|
* The ``DEFAULT_DATE`` setting now defaults to ``None``, which means that
|
||||||
articles won't be generated unless date metadata is specified
|
articles won't be generated unless date metadata is specified
|
||||||
* Add ``FILENAME_METADATA`` setting to support metadata extraction from filename
|
* Add ``FILENAME_METADATA`` setting to support metadata extraction from
|
||||||
|
filename
|
||||||
* Add ``gzip_cache`` plugin to compress common text files into a ``.gz``
|
* Add ``gzip_cache`` plugin to compress common text files into a ``.gz``
|
||||||
file within the same directory as the original file, preventing the server
|
file within the same directory as the original file, preventing the server
|
||||||
(e.g. Nginx) from having to compress files during an HTTP call
|
(e.g. Nginx) from having to compress files during an HTTP call
|
||||||
|
|
@ -285,7 +294,8 @@ Next release
|
||||||
* Added translations
|
* Added translations
|
||||||
* Added a way to use cleaner URLs with a rewrite url module (or equivalent)
|
* Added a way to use cleaner URLs with a rewrite url module (or equivalent)
|
||||||
* Added a tag cloud
|
* Added a tag cloud
|
||||||
* Added an autoreloading feature: the blog is automatically regenerated each time a modification is detected
|
* Added an autoreloading feature: the blog is automatically regenerated each
|
||||||
|
time a modification is detected
|
||||||
* Translate the documentation into French
|
* Translate the documentation into French
|
||||||
* Import a blog from an RSS feed
|
* Import a blog from an RSS feed
|
||||||
* Pagination support
|
* Pagination support
|
||||||
|
|
|
||||||
109
docs/content.rst
109
docs/content.rst
|
|
@ -70,7 +70,9 @@ Metadata syntax for Markdown posts should follow this pattern::
|
||||||
|
|
||||||
This is the content of my super blog post.
|
This is the content of my super blog post.
|
||||||
|
|
||||||
You can also have your own metadata keys (so long as they don't conflict with reserved metadata keywords) for use in your python templates. The following is the list of reserved metadata keywords:
|
You can also have your own metadata keys (so long as they don't conflict with
|
||||||
|
reserved metadata keywords) for use in your python templates. The following is
|
||||||
|
the list of reserved metadata keywords:
|
||||||
|
|
||||||
* `Title`
|
* `Title`
|
||||||
* `Tags`
|
* `Tags`
|
||||||
|
|
@ -133,12 +135,13 @@ the W3C's `suggested subset ISO 8601`__.
|
||||||
|
|
||||||
__ `W3C ISO 8601`_
|
__ `W3C ISO 8601`_
|
||||||
|
|
||||||
``modified`` should be last time you updated the article, and defaults to ``date`` if not specified.
|
``modified`` should be last time you updated the article, and defaults to
|
||||||
Besides you can show ``modified`` in the templates, feed entries in feed readers will be updated automatically
|
``date`` if not specified. Besides you can show ``modified`` in the templates,
|
||||||
when you set ``modified`` to the current date after you modified your article.
|
feed entries in feed readers will be updated automatically when you set
|
||||||
|
``modified`` to the current date after you modified your article.
|
||||||
|
|
||||||
``authors`` is a comma-separated list of article authors. If there's only one author you
|
``authors`` is a comma-separated list of article authors. If there's only one
|
||||||
can use ``author`` field.
|
author you can use ``author`` field.
|
||||||
|
|
||||||
If you do not explicitly specify summary metadata for a given post, the
|
If you do not explicitly specify summary metadata for a given post, the
|
||||||
``SUMMARY_MAX_LENGTH`` setting can be used to specify how many words from the
|
``SUMMARY_MAX_LENGTH`` setting can be used to specify how many words from the
|
||||||
|
|
@ -168,6 +171,34 @@ 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
|
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.
|
things like making error pages that fit the generated theme of your site.
|
||||||
|
|
||||||
|
Static content
|
||||||
|
==============
|
||||||
|
|
||||||
|
Static files are files other than articles and pages that are copied to the
|
||||||
|
output folder as-is, without processing. You can control which static files
|
||||||
|
are copied over with the ``STATIC_PATHS`` setting of the project's
|
||||||
|
``pelicanconf.py`` file. Pelican's default configuration includes the
|
||||||
|
``images`` directory for this, but others must be added manually. In addition,
|
||||||
|
static files that are explicitly linked to are included (see below).
|
||||||
|
|
||||||
|
Mixed content in the same directory
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
Starting with Pelican 3.5, static files can safely share a source directory
|
||||||
|
with page source files, without exposing the page sources in the generated
|
||||||
|
site. Any such directory must be added to both ``STATIC_PATHS`` and
|
||||||
|
``PAGE_PATHS`` (or ``STATIC_PATHS`` and ``ARTICLE_PATHS``). Pelican will
|
||||||
|
identify and process the page source files normally, and copy the remaining
|
||||||
|
files as if they lived in a separate directory reserved for static files.
|
||||||
|
|
||||||
|
Note: Placing static and content source files together in the same source
|
||||||
|
directory does not guarantee that they will end up in the same place in the
|
||||||
|
generated site. The easiest way to do this is by using the ``{attach}`` link
|
||||||
|
syntax (described below). Alternatively, the ``STATIC_SAVE_AS``,
|
||||||
|
``PAGE_SAVE_AS``, and ``ARTICLE_SAVE_AS`` settings (and the corresponding
|
||||||
|
``*_URL`` settings) can be configured to place files of different types
|
||||||
|
together, just as they could in earlier versions of Pelican.
|
||||||
|
|
||||||
.. _ref-linking-to-internal-content:
|
.. _ref-linking-to-internal-content:
|
||||||
|
|
||||||
Linking to internal content
|
Linking to internal content
|
||||||
|
|
@ -221,13 +252,10 @@ and ``article2.md``::
|
||||||
Linking to static files
|
Linking to static files
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
Linking to non-article or non-page content uses the same ``{filename}`` syntax
|
You can link to static content using ``{static}path/to/file``. Files linked to
|
||||||
as described above. It is important to remember that those files will not be
|
with this syntax will automatically be copied to the output directory, even if
|
||||||
copied to the output directory unless the source directories containing them
|
the source directories containing them are not included in the ``STATIC_PATHS``
|
||||||
are included in the ``STATIC_PATHS`` setting of the project's ``pelicanconf.py``
|
setting of the project's ``pelicanconf.py`` file.
|
||||||
file. Pelican's default configuration includes the ``images`` directory for
|
|
||||||
this, but others must be added manually. Forgetting to do so will result in
|
|
||||||
broken links.
|
|
||||||
|
|
||||||
For example, a project's content directory might be structured like this::
|
For example, a project's content directory might be structured like this::
|
||||||
|
|
||||||
|
|
@ -241,48 +269,28 @@ For example, a project's content directory might be structured like this::
|
||||||
|
|
||||||
``test.md`` would include::
|
``test.md`` would include::
|
||||||
|
|
||||||

|

|
||||||
[Our Menu]({filename}/pdfs/menu.pdf)
|
[Our Menu]({static}/pdfs/menu.pdf)
|
||||||
|
|
||||||
``pelicanconf.py`` would include::
|
|
||||||
|
|
||||||
STATIC_PATHS = ['images', 'pdfs']
|
|
||||||
|
|
||||||
Site generation would then copy ``han.jpg`` to ``output/images/han.jpg``,
|
Site generation would then copy ``han.jpg`` to ``output/images/han.jpg``,
|
||||||
``menu.pdf`` to ``output/pdfs/menu.pdf``, and write the appropriate links
|
``menu.pdf`` to ``output/pdfs/menu.pdf``, and write the appropriate links
|
||||||
in ``test.md``.
|
in ``test.md``.
|
||||||
|
|
||||||
Mixed content in the same directory
|
If you use ``{static}`` to link to an article or a page, this will be turned
|
||||||
-----------------------------------
|
into a link to its source code.
|
||||||
|
|
||||||
Starting with Pelican 3.5, static files can safely share a source directory with
|
|
||||||
page source files, without exposing the page sources in the generated site.
|
|
||||||
Any such directory must be added to both ``STATIC_PATHS`` and ``PAGE_PATHS``
|
|
||||||
(or ``STATIC_PATHS`` and ``ARTICLE_PATHS``). Pelican will identify and process
|
|
||||||
the page source files normally, and copy the remaining files as if they lived
|
|
||||||
in a separate directory reserved for static files.
|
|
||||||
|
|
||||||
Note: Placing static and content source files together in the same source
|
|
||||||
directory does not guarantee that they will end up in the same place in the
|
|
||||||
generated site. The easiest way to do this is by using the ``{attach}`` link
|
|
||||||
syntax (described below). Alternatively, the ``STATIC_SAVE_AS``,
|
|
||||||
``PAGE_SAVE_AS``, and ``ARTICLE_SAVE_AS`` settings (and the corresponding
|
|
||||||
``*_URL`` settings) can be configured to place files of different types
|
|
||||||
together, just as they could in earlier versions of Pelican.
|
|
||||||
|
|
||||||
Attaching static files
|
Attaching static files
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
Starting with Pelican 3.5, static files can be "attached" to a page or article
|
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 ``{filename}`` syntax, but also relocates the static file into the
|
like the ``{static}`` syntax, but also relocates the static file into the
|
||||||
linking document's output directory. If the static file originates from a
|
linking document's output directory. If the static file originates from a
|
||||||
subdirectory beneath the linking document's source, that relationship will be
|
subdirectory beneath the linking document's source, that relationship will be
|
||||||
preserved on output. Otherwise, it will become a sibling of the linking
|
preserved on output. Otherwise, it will become a sibling of the linking
|
||||||
document.
|
document.
|
||||||
|
|
||||||
This only works for linking to static files, and only when they originate from
|
This only works for linking to static files.
|
||||||
a directory included in the ``STATIC_PATHS`` setting.
|
|
||||||
|
|
||||||
For example, a project's content directory might be structured like this::
|
For example, a project's content directory might be structured like this::
|
||||||
|
|
||||||
|
|
@ -298,7 +306,6 @@ For example, a project's content directory might be structured like this::
|
||||||
``pelicanconf.py`` would include::
|
``pelicanconf.py`` would include::
|
||||||
|
|
||||||
PATH = 'content'
|
PATH = 'content'
|
||||||
STATIC_PATHS = ['blog', 'downloads']
|
|
||||||
ARTICLE_PATHS = ['blog']
|
ARTICLE_PATHS = ['blog']
|
||||||
ARTICLE_SAVE_AS = '{date:%Y}/{slug}.html'
|
ARTICLE_SAVE_AS = '{date:%Y}/{slug}.html'
|
||||||
ARTICLE_URL = '{date:%Y}/{slug}.html'
|
ARTICLE_URL = '{date:%Y}/{slug}.html'
|
||||||
|
|
@ -328,7 +335,7 @@ the article's output directory.
|
||||||
|
|
||||||
If a static file is linked multiple times, the relocating feature of
|
If a static file is linked multiple times, the relocating feature of
|
||||||
``{attach}`` will only work in the first of those links to be processed.
|
``{attach}`` will only work in the first of those links to be processed.
|
||||||
After the first link, Pelican will treat ``{attach}`` like ``{filename}``.
|
After the first link, Pelican will treat ``{attach}`` like ``{static}``.
|
||||||
This avoids breaking the already-processed links.
|
This avoids breaking the already-processed links.
|
||||||
|
|
||||||
**Be careful when linking to a file from multiple documents:**
|
**Be careful when linking to a file from multiple documents:**
|
||||||
|
|
@ -342,7 +349,7 @@ file's old location might then find their links broken. **It is therefore
|
||||||
advisable to use {attach} only if you use it in all links to a file, and only
|
advisable to use {attach} only if you use it in all links to a file, and only
|
||||||
if the linking documents share a single directory.** Under these conditions,
|
if the linking documents share a single directory.** Under these conditions,
|
||||||
the file's output location will not change in future builds. In cases where
|
the file's output location will not change in future builds. In cases where
|
||||||
these precautions are not possible, consider using ``{filename}`` links instead
|
these precautions are not possible, consider using ``{static}`` links instead
|
||||||
of ``{attach}``, and letting the file's location be determined by the project's
|
of ``{attach}``, and letting the file's location be determined by the project's
|
||||||
``STATIC_SAVE_AS`` and ``STATIC_URL`` settings. (Per-file ``save_as`` and
|
``STATIC_SAVE_AS`` and ``STATIC_URL`` settings. (Per-file ``save_as`` and
|
||||||
``url`` overrides can still be set in ``EXTRA_PATH_METADATA``.)
|
``url`` overrides can still be set in ``EXTRA_PATH_METADATA``.)
|
||||||
|
|
@ -356,12 +363,15 @@ You can link to authors, categories, index and tags using the ``{author}name``,
|
||||||
Deprecated internal link syntax
|
Deprecated internal link syntax
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
To remain compatible with earlier versions, Pelican still supports vertical bars
|
To remain compatible with earlier versions, Pelican still supports vertical
|
||||||
(``||``) in addition to curly braces (``{}``) for internal links. For example:
|
bars (``||``) in addition to curly braces (``{}``) for internal links. For
|
||||||
``|filename|an_article.rst``, ``|tag|tagname``, ``|category|foobar``.
|
example: ``|filename|an_article.rst``, ``|tag|tagname``, ``|category|foobar``.
|
||||||
The syntax was changed from ``||`` to ``{}`` to avoid collision with Markdown
|
The syntax was changed from ``||`` to ``{}`` to avoid collision with Markdown
|
||||||
extensions or reST directives. Support for the old syntax may eventually be
|
extensions or reST directives. Similarly, Pelican also still supports linking
|
||||||
removed.
|
to static content with ``{filename}``. The syntax was changed to ``{static}``
|
||||||
|
to allow linking to both generated articles and pages and their static sources.
|
||||||
|
|
||||||
|
Support for the old syntax may eventually be removed.
|
||||||
|
|
||||||
|
|
||||||
Importing an existing site
|
Importing an existing site
|
||||||
|
|
@ -539,8 +549,9 @@ before publishing, for example), you can add a ``Status: draft`` attribute to
|
||||||
its metadata. That article will then be output to the ``drafts`` folder and not
|
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.
|
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
|
If your articles should be automatically published as a draft (to not
|
||||||
publish an article before it is finished) include the status in the ``DEFAULT_METADATA``::
|
accidentally publish an article before it is finished) include the status in
|
||||||
|
the ``DEFAULT_METADATA``::
|
||||||
|
|
||||||
DEFAULT_METADATA = {
|
DEFAULT_METADATA = {
|
||||||
'status': 'draft',
|
'status': 'draft',
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,8 @@ Open ``_build/html/index.html`` in your browser to preview the documentation.
|
||||||
Running the test suite
|
Running the test suite
|
||||||
======================
|
======================
|
||||||
|
|
||||||
Each time you add a feature, there are two things to do regarding tests:
|
Each time you add a feature, there are two things to do regarding tests: check
|
||||||
check that the existing tests pass, and add tests for the new feature
|
that the existing tests pass, and add tests for the new feature or bugfix.
|
||||||
or bugfix.
|
|
||||||
|
|
||||||
The tests live in ``pelican/tests`` and you can run them using the
|
The tests live in ``pelican/tests`` and you can run them using the
|
||||||
"discover" feature of ``unittest``::
|
"discover" feature of ``unittest``::
|
||||||
|
|
@ -92,8 +91,8 @@ functional tests. To do so, **make sure you have both** ``en_EN.utf8`` **and**
|
||||||
|
|
||||||
You may also find that some tests are skipped because some dependency (e.g.,
|
You may also find that some tests are skipped because some dependency (e.g.,
|
||||||
Pandoc) is not installed. This does not automatically mean that these tests
|
Pandoc) is not installed. This does not automatically mean that these tests
|
||||||
have passed; you should at least verify that any skipped tests are not
|
have passed; you should at least verify that any skipped tests are not affected
|
||||||
affected by your changes.
|
by your changes.
|
||||||
|
|
||||||
You should run the test suite under each of the supported versions of Python.
|
You should run the test suite under each of the supported versions of Python.
|
||||||
This is best done by creating a separate Python environment for each version.
|
This is best done by creating a separate Python environment for each version.
|
||||||
|
|
@ -178,9 +177,9 @@ Optionally, you can also set ``'limit_args'`` as a tuple of arguments in
|
||||||
``extra`` dict if your generic message needs formatting.
|
``extra`` dict if your generic message needs formatting.
|
||||||
|
|
||||||
Limit is set to ``5``, i.e, first four logs with the same ``'limit_msg'`` are
|
Limit is set to ``5``, i.e, first four logs with the same ``'limit_msg'`` are
|
||||||
outputted normally but the fifth one will be logged using
|
outputted normally but the fifth one will be logged using ``'limit_msg'`` (and
|
||||||
``'limit_msg'`` (and ``'limit_args'`` if present). After the fifth,
|
``'limit_args'`` if present). After the fifth, corresponding log messages will
|
||||||
corresponding log messages will be ignored.
|
be ignored.
|
||||||
|
|
||||||
For example, if you want to log missing resources, use the following code::
|
For example, if you want to log missing resources, use the following code::
|
||||||
|
|
||||||
|
|
|
||||||
117
docs/faq.rst
117
docs/faq.rst
|
|
@ -12,10 +12,10 @@ How can I help?
|
||||||
===============
|
===============
|
||||||
|
|
||||||
There are several ways to help out. First, you can report any Pelican
|
There are several ways to help out. First, you can report any Pelican
|
||||||
suggestions or problems you might have via IRC (preferred) or the
|
suggestions or problems you might have via IRC (preferred) or the `issue
|
||||||
`issue tracker <https://github.com/getpelican/pelican/issues>`_. If submitting
|
tracker <https://github.com/getpelican/pelican/issues>`_. If submitting an
|
||||||
an issue report, please first check the existing issue list (both open and
|
issue report, please first check the existing issue list (both open and closed)
|
||||||
closed) in order to avoid submitting a duplicate issue.
|
in order to avoid submitting a duplicate issue.
|
||||||
|
|
||||||
If you want to contribute, please fork `the git repository
|
If you want to contribute, please fork `the git repository
|
||||||
<https://github.com/getpelican/pelican/>`_, create a new feature branch, make
|
<https://github.com/getpelican/pelican/>`_, create a new feature branch, make
|
||||||
|
|
@ -35,10 +35,10 @@ via the command line. See ``pelican --help`` for more information.
|
||||||
Changes to the settings file take no effect
|
Changes to the settings file take no effect
|
||||||
===========================================
|
===========================================
|
||||||
|
|
||||||
When experimenting with different settings (especially the metadata
|
When experimenting with different settings (especially the metadata ones)
|
||||||
ones) caching may interfere and the changes may not be visible. In
|
caching may interfere and the changes may not be visible. In such cases, ensure
|
||||||
such cases, ensure that caching is disabled via ``LOAD_CONTENT_CACHE = False``
|
that caching is disabled via ``LOAD_CONTENT_CACHE = False`` or use the
|
||||||
or use the ``--ignore-cache`` command-line switch.
|
``--ignore-cache`` command-line switch.
|
||||||
|
|
||||||
I'm creating my own theme. How do I use Pygments for syntax highlighting?
|
I'm creating my own theme. How do I use Pygments for syntax highlighting?
|
||||||
=========================================================================
|
=========================================================================
|
||||||
|
|
@ -70,9 +70,9 @@ I want to use Markdown, but I got an error.
|
||||||
If you try to generate Markdown content without first installing the Markdown
|
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, 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 is not a hard dependency for Pelican, so if you have content in
|
||||||
Markdown format, you will need to explicitly install the Markdown library.
|
Markdown format, you will need to explicitly install the Markdown library. You
|
||||||
You can do so by typing the following command, prepending ``sudo`` if
|
can do so by typing the following command, prepending ``sudo`` if permissions
|
||||||
permissions require it::
|
require it::
|
||||||
|
|
||||||
pip install markdown
|
pip install markdown
|
||||||
|
|
||||||
|
|
@ -150,9 +150,9 @@ the ``'index'`` direct template.
|
||||||
What if I want to disable feed generation?
|
What if I want to disable feed generation?
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
To disable feed generation, all feed settings should be set to ``None``.
|
To disable feed generation, all feed settings should be set to ``None``. All
|
||||||
All but three feed settings already default to ``None``, so if you want to
|
but three feed settings already default to ``None``, so if you want to disable
|
||||||
disable all feed generation, you only need to specify the following settings::
|
all feed generation, you only need to specify the following settings::
|
||||||
|
|
||||||
FEED_ALL_ATOM = None
|
FEED_ALL_ATOM = None
|
||||||
CATEGORY_FEED_ATOM = None
|
CATEGORY_FEED_ATOM = None
|
||||||
|
|
@ -167,9 +167,9 @@ I'm getting a warning about feeds generated without SITEURL being set properly
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
`RSS and Atom feeds require all URL links to be absolute
|
`RSS and Atom feeds require all URL links to be absolute
|
||||||
<http://validator.w3.org/feed/docs/rss2.html#comments>`_.
|
<http://validator.w3.org/feed/docs/rss2.html#comments>`_. In order to properly
|
||||||
In order to properly generate links in Pelican you will need to set ``SITEURL``
|
generate links in Pelican you will need to set ``SITEURL`` to the full path of
|
||||||
to the full path of your site.
|
your site.
|
||||||
|
|
||||||
Feeds are still generated when this warning is displayed, but links within may
|
Feeds are still generated when this warning is displayed, but links within may
|
||||||
be malformed and thus the feed may not validate.
|
be malformed and thus the feed may not validate.
|
||||||
|
|
@ -185,26 +185,26 @@ setting names). Here is an exact list of the renamed settings::
|
||||||
TAG_FEED -> TAG_FEED_ATOM
|
TAG_FEED -> TAG_FEED_ATOM
|
||||||
CATEGORY_FEED -> CATEGORY_FEED_ATOM
|
CATEGORY_FEED -> CATEGORY_FEED_ATOM
|
||||||
|
|
||||||
Starting in 3.1, the new feed ``FEED_ALL_ATOM`` has been introduced: this
|
Starting in 3.1, the new feed ``FEED_ALL_ATOM`` has been introduced: this feed
|
||||||
feed will aggregate all posts regardless of their language. This setting
|
will aggregate all posts regardless of their language. This setting generates
|
||||||
generates ``'feeds/all.atom.xml'`` by default and ``FEED_ATOM`` now defaults to
|
``'feeds/all.atom.xml'`` by default and ``FEED_ATOM`` now defaults to ``None``.
|
||||||
``None``. The following feed setting has also been renamed::
|
The following feed setting has also been renamed::
|
||||||
|
|
||||||
TRANSLATION_FEED -> TRANSLATION_FEED_ATOM
|
TRANSLATION_FEED -> TRANSLATION_FEED_ATOM
|
||||||
|
|
||||||
Older themes that referenced the old setting names may not link properly.
|
Older themes that referenced the old setting names may not link properly. In
|
||||||
In order to rectify this, please update your theme for compatibility by changing
|
order to rectify this, please update your theme for compatibility by changing
|
||||||
the relevant values in your template files. For an example of complete feed
|
the relevant values in your template files. For an example of complete feed
|
||||||
headers and usage please check out the ``simple`` theme.
|
headers and usage please check out the ``simple`` theme.
|
||||||
|
|
||||||
Is Pelican only suitable for blogs?
|
Is Pelican only suitable for blogs?
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
No. Pelican can be easily configured to create and maintain any type of static site.
|
No. Pelican can be easily configured to create and maintain any type of static
|
||||||
This may require a little customization of your theme and Pelican configuration.
|
site. This may require a little customization of your theme and Pelican
|
||||||
For example, if you are building a launch site for your product and do not need
|
configuration. For example, if you are building a launch site for your product
|
||||||
tags on your site, you could remove the relevant HTML code from your theme.
|
and do not need tags on your site, you could remove the relevant HTML code from
|
||||||
You can also disable generation of tag-related pages via::
|
your theme. You can also disable generation of tag-related pages via::
|
||||||
|
|
||||||
TAGS_SAVE_AS = ''
|
TAGS_SAVE_AS = ''
|
||||||
TAG_SAVE_AS = ''
|
TAG_SAVE_AS = ''
|
||||||
|
|
@ -212,52 +212,49 @@ You can also disable generation of tag-related pages via::
|
||||||
Why does Pelican always write all HTML files even with content caching enabled?
|
Why does Pelican always write all HTML files even with content caching enabled?
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|
||||||
In order to reliably determine whether the HTML output is different
|
In order to reliably determine whether the HTML output is different before
|
||||||
before writing it, a large part of the generation environment
|
writing it, a large part of the generation environment including the template
|
||||||
including the template contexts, imported plugins, etc. would have to
|
contexts, imported plugins, etc. would have to be saved and compared, at least
|
||||||
be saved and compared, at least in the form of a hash (which would
|
in the form of a hash (which would require special handling of unhashable
|
||||||
require special handling of unhashable types), because of all the
|
types), because of all the possible combinations of plugins, pagination, etc.
|
||||||
possible combinations of plugins, pagination, etc. which may change in
|
which may change in many different ways. This would require a lot more
|
||||||
many different ways. This would require a lot more processing time
|
processing time and memory and storage space. Simply writing the files each
|
||||||
and memory and storage space. Simply writing the files each time is a
|
time is a lot faster and a lot more reliable.
|
||||||
lot faster and a lot more reliable.
|
|
||||||
|
|
||||||
However, this means that the modification time of the files changes
|
However, this means that the modification time of the files changes every time,
|
||||||
every time, so a ``rsync`` based upload will transfer them even if
|
so a ``rsync`` based upload will transfer them even if their content hasn't
|
||||||
their content hasn't changed. A simple solution is to make ``rsync``
|
changed. A simple solution is to make ``rsync`` use the ``--checksum`` option,
|
||||||
use the ``--checksum`` option, which will make it compare the file
|
which will make it compare the file checksums in a much faster way than Pelican
|
||||||
checksums in a much faster way than Pelican would.
|
would.
|
||||||
|
|
||||||
When only several specific output files are of interest (e.g. when
|
When only several specific output files are of interest (e.g. when working on
|
||||||
working on some specific page or the theme templates), the
|
some specific page or the theme templates), the `WRITE_SELECTED` option may
|
||||||
`WRITE_SELECTED` option may help, see
|
help, see :ref:`writing_only_selected_content`.
|
||||||
:ref:`writing_only_selected_content`.
|
|
||||||
|
|
||||||
How to process only a subset of all articles?
|
How to process only a subset of all articles?
|
||||||
=============================================
|
=============================================
|
||||||
|
|
||||||
It is often useful to process only e.g. 10 articles for debugging
|
It is often useful to process only e.g. 10 articles for debugging purposes.
|
||||||
purposes. This can be achieved by explicitly specifying only the
|
This can be achieved by explicitly specifying only the filenames of those
|
||||||
filenames of those articles in ``ARTICLE_PATHS``. A list of such
|
articles in ``ARTICLE_PATHS``. A list of such filenames could be found using a
|
||||||
filenames could be found using a command similar to ``cd content;
|
command similar to ``cd content; find -name '*.md' | head -n 10``.
|
||||||
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 steamline Pelican, `tag_cloud` generation has been
|
In an ongoing effort to steamline Pelican, `tag_cloud` generation has been
|
||||||
moved out of the pelican core and into a separate `plugin
|
moved out of the pelican core and into a separate `plugin
|
||||||
<https://github.com/getpelican/pelican-plugins/tree/master/tag_cloud>`_.
|
<https://github.com/getpelican/pelican-plugins/tree/master/tag_cloud>`_. See
|
||||||
See the :ref:`plugins` documentation further information about the
|
the :ref:`plugins` documentation further information about the Pelican plugin
|
||||||
Pelican plugin system.
|
system.
|
||||||
|
|
||||||
Since I upgraded Pelican my pages are no longer rendered
|
Since I upgraded Pelican my pages are no longer rendered
|
||||||
========================================================
|
========================================================
|
||||||
|
|
||||||
Pages were available to themes as lowercase ``pages`` and uppercase
|
Pages were available to themes as lowercase ``pages`` and uppercase ``PAGES``.
|
||||||
``PAGES``. To bring this inline with the :ref:`templates-variables` section,
|
To bring this inline with the :ref:`templates-variables` section, ``PAGES`` has
|
||||||
``PAGES`` has been removed. This is quickly resolved by updating your theme
|
been removed. This is quickly resolved by updating your theme to iterate over
|
||||||
to iterate over ``pages`` instead of ``PAGES``. Just replace::
|
``pages`` instead of ``PAGES``. Just replace::
|
||||||
|
|
||||||
{% for pg in PAGES %}
|
{% for pg in PAGES %}
|
||||||
|
|
||||||
|
|
@ -271,8 +268,8 @@ How can I stop Pelican from trying to parse my static files as content?
|
||||||
Pelican's article and page generators run before it's static generator. That
|
Pelican's article and page generators run before it's static generator. That
|
||||||
means if you use a setup similar to the default configuration, where a static
|
means if you use a setup similar to the default configuration, where a static
|
||||||
source directory is defined inside a ``*_PATHS`` setting, all files that have a
|
source directory is defined inside a ``*_PATHS`` setting, all files that have a
|
||||||
valid content file ending (``.html``, ``.rst``, ``.md``, ...) will be treated as
|
valid content file ending (``.html``, ``.rst``, ``.md``, ...) will be treated
|
||||||
articles or pages before they get treated as static files.
|
as articles or pages before they get treated as static files.
|
||||||
|
|
||||||
To circumvent this issue either use the appropriate ``*_EXCLUDES`` setting or
|
To circumvent this issue either use the appropriate ``*_EXCLUDES`` setting or
|
||||||
disable the offending reader via ``READERS`` if you don't need it.
|
disable the offending reader via ``READERS`` if you don't need it.
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,9 @@ Dependencies
|
||||||
|
|
||||||
``pelican-import`` has some dependencies not required by the rest of Pelican:
|
``pelican-import`` has some dependencies not required by the rest of Pelican:
|
||||||
|
|
||||||
- *BeautifulSoup4* and *lxml*, for WordPress and Dotclear import. Can be installed like
|
- *BeautifulSoup4* and *lxml*, for WordPress and Dotclear import. Can be
|
||||||
any other Python package (``pip install BeautifulSoup4 lxml``).
|
installed like any other Python package (``pip install BeautifulSoup4
|
||||||
|
lxml``).
|
||||||
- *Feedparser*, for feed import (``pip install feedparser``).
|
- *Feedparser*, for feed import (``pip install feedparser``).
|
||||||
- *Pandoc*, see the `Pandoc site`_ for installation instructions on your
|
- *Pandoc*, see the `Pandoc site`_ for installation instructions on your
|
||||||
operating system.
|
operating system.
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ Pelican |release|
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
This documentation is for the version of Pelican currently under development.
|
This documentation is for the version of Pelican currently under
|
||||||
Were you looking for version |last_stable| documentation?
|
development. Were you looking for version |last_stable| documentation?
|
||||||
|
|
||||||
|
|
||||||
Pelican is a static site generator, written in Python_. Highlights include:
|
Pelican is a static site generator, written in Python_. Highlights include:
|
||||||
|
|
||||||
* Write your content directly with your editor of choice
|
* Write your content directly with your editor of choice in reStructuredText_
|
||||||
in reStructuredText_ or Markdown_ formats
|
or Markdown_ formats
|
||||||
* Includes a simple CLI tool to (re)generate your site
|
* Includes a simple CLI tool to (re)generate your site
|
||||||
* Easy to interface with distributed version control systems and web hooks
|
* Easy to interface with distributed version control systems and web hooks
|
||||||
* Completely static output is easy to host anywhere
|
* Completely static output is easy to host anywhere
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ You can install Pelican via several different methods. The simplest is via
|
||||||
(Keep in mind that operating systems will often require you to prefix the above
|
(Keep in mind that operating systems will often require you to prefix the above
|
||||||
command with ``sudo`` in order to install Pelican system-wide.)
|
command with ``sudo`` in order to install Pelican system-wide.)
|
||||||
|
|
||||||
While the above is the simplest method, the recommended approach is to create
|
While the above is the simplest method, the recommended approach is to create a
|
||||||
a virtual environment for Pelican via virtualenv_ before installing Pelican.
|
virtual environment for Pelican via virtualenv_ before installing Pelican.
|
||||||
Assuming you have virtualenv_ installed, you can then open a new terminal
|
Assuming you have virtualenv_ installed, you can then open a new terminal
|
||||||
session and create a new virtual environment for Pelican::
|
session and create a new virtual environment for Pelican::
|
||||||
|
|
||||||
|
|
@ -22,9 +22,8 @@ session and create a new virtual environment for Pelican::
|
||||||
source bin/activate
|
source bin/activate
|
||||||
|
|
||||||
Once the virtual environment has been created and activated, Pelican can be
|
Once the virtual environment has been created and activated, Pelican can be
|
||||||
installed via ``pip install pelican`` as noted above. Alternatively, if
|
installed via ``pip install pelican`` as noted above. Alternatively, if you
|
||||||
you have the project source, you can install Pelican using the distutils
|
have the project source, you can install Pelican using the distutils method::
|
||||||
method::
|
|
||||||
|
|
||||||
cd path-to-Pelican-source
|
cd path-to-Pelican-source
|
||||||
python setup.py install
|
python setup.py install
|
||||||
|
|
@ -96,8 +95,9 @@ your site::
|
||||||
pelican-quickstart
|
pelican-quickstart
|
||||||
|
|
||||||
Once you finish answering all the questions, your project will consist of the
|
Once you finish answering all the questions, your project will consist of the
|
||||||
following hierarchy (except for *pages* — shown in parentheses below — which you
|
following hierarchy (except for *pages* — shown in parentheses below — which
|
||||||
can optionally add yourself if you plan to create non-chronological content)::
|
you can optionally add yourself if you plan to create non-chronological
|
||||||
|
content)::
|
||||||
|
|
||||||
yourproject/
|
yourproject/
|
||||||
├── content
|
├── content
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
Pelican internals
|
Pelican internals
|
||||||
#################
|
#################
|
||||||
|
|
||||||
This section describe how Pelican works internally. As you'll see, it's
|
This section describe how Pelican works internally. As you'll see, it's quite
|
||||||
quite simple, but a bit of documentation doesn't hurt. :)
|
simple, but a bit of documentation doesn't hurt. :)
|
||||||
|
|
||||||
You can also find in the :doc:`report` section an excerpt of a report the
|
You can also find in the :doc:`report` section an excerpt of a report the
|
||||||
original author wrote with some software design information.
|
original author wrote with some software design information.
|
||||||
|
|
@ -13,9 +13,8 @@ Overall structure
|
||||||
=================
|
=================
|
||||||
|
|
||||||
What Pelican does is take a list of files and process them into some sort of
|
What Pelican does is take a list of files and process them into some sort of
|
||||||
output. Usually, the input files are reStructuredText and Markdown
|
output. Usually, the input files are reStructuredText and Markdown files, and
|
||||||
files, and the output is a blog, but both input and output can be anything you
|
the output is a blog, but both input and output can be anything you want.
|
||||||
want.
|
|
||||||
|
|
||||||
The logic is separated into different classes and concepts:
|
The logic is separated into different classes and concepts:
|
||||||
|
|
||||||
|
|
@ -27,9 +26,10 @@ The logic is separated into different classes and concepts:
|
||||||
reStructuredText for now, but the system is extensible). Given a file, they
|
reStructuredText for now, but the system is extensible). Given a file, they
|
||||||
return metadata (author, tags, category, etc.) and content (HTML-formatted).
|
return metadata (author, tags, category, etc.) and content (HTML-formatted).
|
||||||
|
|
||||||
* **Generators** generate the different outputs. For instance, Pelican comes with
|
* **Generators** generate the different outputs. For instance, Pelican comes
|
||||||
``ArticlesGenerator`` and ``PageGenerator``. Given a configuration, they can do
|
with ``ArticlesGenerator`` and ``PageGenerator``. Given a configuration, they
|
||||||
whatever they want. Most of the time, it's generating files from inputs.
|
can do whatever they want. Most of the time, it's generating files from
|
||||||
|
inputs.
|
||||||
|
|
||||||
* Pelican also uses templates, so it's easy to write your own theme. The
|
* Pelican also uses templates, so it's easy to write your own theme. The
|
||||||
syntax is `Jinja2 <http://jinja.pocoo.org/>`_ and is very easy to learn, so
|
syntax is `Jinja2 <http://jinja.pocoo.org/>`_ and is very easy to learn, so
|
||||||
|
|
@ -38,9 +38,9 @@ The logic is separated into different classes and concepts:
|
||||||
How to implement a new reader?
|
How to implement a new reader?
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
Is there an awesome markup language you want to add to Pelican?
|
Is there an awesome markup language you want to add to Pelican? Well, the only
|
||||||
Well, the only thing you have to do is to create a class with a ``read``
|
thing you have to do is to create a class with a ``read`` method that returns
|
||||||
method that returns HTML content and some metadata.
|
HTML content and some metadata.
|
||||||
|
|
||||||
Take a look at the Markdown reader::
|
Take a look at the Markdown reader::
|
||||||
|
|
||||||
|
|
@ -65,17 +65,17 @@ Take a look at the Markdown reader::
|
||||||
|
|
||||||
Simple, isn't it?
|
Simple, isn't it?
|
||||||
|
|
||||||
If your new reader requires additional Python dependencies, then you should wrap
|
If your new reader requires additional Python dependencies, then you should
|
||||||
their ``import`` statements in a ``try...except`` block. Then inside the reader's
|
wrap their ``import`` statements in a ``try...except`` block. Then inside the
|
||||||
class, set the ``enabled`` class attribute to mark import success or failure.
|
reader's class, set the ``enabled`` class attribute to mark import success or
|
||||||
This makes it possible for users to continue using their favourite markup method
|
failure. This makes it possible for users to continue using their favourite
|
||||||
without needing to install modules for formats they don't use.
|
markup method without needing to install modules for formats they don't use.
|
||||||
|
|
||||||
How to implement a new generator?
|
How to implement a new generator?
|
||||||
=================================
|
=================================
|
||||||
|
|
||||||
Generators have two important methods. You're not forced to create
|
Generators have two important methods. You're not forced to create both; only
|
||||||
both; only the existing ones will be called.
|
the existing ones will be called.
|
||||||
|
|
||||||
* ``generate_context``, that is called first, for all the generators.
|
* ``generate_context``, that is called first, for all the generators.
|
||||||
Do whatever you have to do, and update the global context if needed. This
|
Do whatever you have to do, and update the global context if needed. This
|
||||||
|
|
@ -89,5 +89,5 @@ both; only the existing ones will be called.
|
||||||
generating the output. :) It's here that you may want to look at the context
|
generating the output. :) It's here that you may want to look at the context
|
||||||
and call the methods of the ``writer`` object that is passed as the first
|
and call the methods of the ``writer`` object that is passed as the first
|
||||||
argument of this function. In the ``PageGenerator`` example, this method will
|
argument of this function. In the ``PageGenerator`` example, this method will
|
||||||
look at all the pages recorded in the global context and output a file on
|
look at all the pages recorded in the global context and output a file on the
|
||||||
the disk (using the writer method ``write_file``) for each page encountered.
|
disk (using the writer method ``write_file``) for each page encountered.
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ Examples
|
||||||
Listing the installed themes
|
Listing the installed themes
|
||||||
""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""
|
||||||
|
|
||||||
With ``pelican-themes``, you can see the available themes by using the ``-l`` or ``--list`` option:
|
With ``pelican-themes``, you can see the available themes by using the ``-l``
|
||||||
|
or ``--list`` option:
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
|
|
@ -57,11 +58,15 @@ With ``pelican-themes``, you can see the available themes by using the ``-l`` or
|
||||||
two-column@
|
two-column@
|
||||||
simple
|
simple
|
||||||
|
|
||||||
In this example, we can see there are three themes available: ``notmyidea``, ``simple``, and ``two-column``.
|
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 the Pelican theme path, but is instead just linked to it (see `Creating symbolic links`_ for details about creating symbolic links).
|
``two-column`` is prefixed with 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).
|
||||||
|
|
||||||
Note that you can combine the ``--list`` option with the ``-v`` or ``--verbose`` option to get more verbose output, like this:
|
Note that you can combine the ``--list`` option with the ``-v`` or
|
||||||
|
``--verbose`` option to get more verbose output, like this:
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
|
|
@ -75,7 +80,8 @@ Installing themes
|
||||||
"""""""""""""""""
|
"""""""""""""""""
|
||||||
|
|
||||||
You can install one or more themes using the ``-i`` or ``--install`` option.
|
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:
|
This option takes as argument the path(s) of the theme(s) you want to install,
|
||||||
|
and can be combined with the verbose option:
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
|
|
@ -95,8 +101,9 @@ This option takes as argument the path(s) of the theme(s) you want to install, a
|
||||||
Removing themes
|
Removing themes
|
||||||
"""""""""""""""
|
"""""""""""""""
|
||||||
|
|
||||||
The ``pelican-themes`` command can also remove themes from the Pelican themes path.
|
The ``pelican-themes`` command can also remove themes from the Pelican themes
|
||||||
The ``-r`` or ``--remove`` option takes as argument the name(s) of the theme(s) you want to remove, and can be combined with the ``--verbose`` option.
|
path. The ``-r`` or ``--remove`` option takes as argument the name(s) of the
|
||||||
|
theme(s) you want to remove, and can be combined with the ``--verbose`` option.
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
|
|
@ -113,15 +120,19 @@ The ``-r`` or ``--remove`` option takes as argument the name(s) of the theme(s)
|
||||||
Creating symbolic links
|
Creating symbolic links
|
||||||
"""""""""""""""""""""""
|
"""""""""""""""""""""""
|
||||||
|
|
||||||
``pelican-themes`` can also install themes by creating symbolic links instead of copying entire themes into the Pelican themes path.
|
``pelican-themes`` can also install themes by creating symbolic links instead
|
||||||
|
of copying entire themes into the Pelican themes path.
|
||||||
|
|
||||||
To symbolically link a theme, you can use the ``-s`` or ``--symlink``, which works exactly as the ``--install`` option:
|
To symbolically link a theme, you can use the ``-s`` or ``--symlink``, which
|
||||||
|
works exactly as the ``--install`` option:
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
# pelican-themes --symlink ~/Dev/Python/pelican-themes/two-column
|
# pelican-themes --symlink ~/Dev/Python/pelican-themes/two-column
|
||||||
|
|
||||||
In this example, the ``two-column`` theme is now symbolically linked to the Pelican themes path, so we can use it, but we can also modify it without having to reinstall it after each modification.
|
In this example, the ``two-column`` theme is now symbolically linked to the
|
||||||
|
Pelican themes path, so we can use it, but we can also modify it without having
|
||||||
|
to reinstall it after each modification.
|
||||||
|
|
||||||
This is useful for theme development:
|
This is useful for theme development:
|
||||||
|
|
||||||
|
|
@ -142,7 +153,9 @@ This is useful for theme development:
|
||||||
Doing several things at once
|
Doing several things at once
|
||||||
""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""
|
||||||
|
|
||||||
The ``--install``, ``--remove`` and ``--symlink`` option are not mutually exclusive, so you can combine them in the same command line to do more than one operation at time, like this:
|
The ``--install``, ``--remove`` and ``--symlink`` option are not mutually
|
||||||
|
exclusive, so you can combine them in the same command line to do more than one
|
||||||
|
operation at time, like this:
|
||||||
|
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
@ -152,4 +165,5 @@ The ``--install``, ``--remove`` and ``--symlink`` option are not mutually exclus
|
||||||
--symlink ~/Dev/Python/pelican-themes/two-column \
|
--symlink ~/Dev/Python/pelican-themes/two-column \
|
||||||
--verbose
|
--verbose
|
||||||
|
|
||||||
In this example, the theme ``notmyidea-cms`` is replaced by the theme ``notmyidea-cms-fr``
|
In this example, the theme ``notmyidea-cms`` is replaced by the theme
|
||||||
|
``notmyidea-cms-fr``
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,10 @@ Alternatively, another method is to import them and add them to the list::
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
When experimenting with different plugins (especially the ones that
|
When experimenting with different plugins (especially the ones that deal
|
||||||
deal with metadata and content) caching may interfere and the
|
with metadata and content) caching may interfere and the changes may not be
|
||||||
changes may not be visible. In such cases disable caching with
|
visible. In such cases disable caching with ``LOAD_CONTENT_CACHE = False``
|
||||||
``LOAD_CONTENT_CACHE = False`` or use the ``--ignore-cache``
|
or use the ``--ignore-cache`` command-line switch.
|
||||||
command-line switch.
|
|
||||||
|
|
||||||
If your plugins are not in an importable path, you can specify a list of paths
|
If your plugins are not in an importable path, you can specify a list of paths
|
||||||
via the ``PLUGIN_PATHS`` setting. As shown in the following example, paths in
|
via the ``PLUGIN_PATHS`` setting. As shown in the following example, paths in
|
||||||
|
|
@ -60,7 +59,7 @@ which you map the signals to your plugin logic. Let's take a simple example::
|
||||||
from pelican import signals
|
from pelican import signals
|
||||||
|
|
||||||
def test(sender):
|
def test(sender):
|
||||||
print "%s initialized !!" % sender
|
print("{} initialized !!".format(sender))
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
signals.initialized.connect(test)
|
signals.initialized.connect(test)
|
||||||
|
|
@ -126,17 +125,17 @@ feed_written path, context, feed invoked each
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
Avoid ``content_object_init`` signal if you intend to read ``summary``
|
Avoid ``content_object_init`` signal if you intend to read ``summary`` or
|
||||||
or ``content`` properties of the content object. That combination can
|
``content`` properties of the content object. That combination can result in
|
||||||
result in unresolved links when :ref:`ref-linking-to-internal-content`
|
unresolved links when :ref:`ref-linking-to-internal-content` (see
|
||||||
(see `pelican-plugins bug #314`_). Use ``_summary`` and ``_content``
|
`pelican-plugins bug #314`_). Use ``_summary`` and ``_content`` properties
|
||||||
properties instead, or, alternatively, run your plugin at a later
|
instead, or, alternatively, run your plugin at a later stage (e.g.
|
||||||
stage (e.g. ``all_generators_finalized``).
|
``all_generators_finalized``).
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
After Pelican 3.2, signal names were standardized. Older plugins
|
After Pelican 3.2, signal names were standardized. Older plugins may need
|
||||||
may need to be updated to use the new names:
|
to be updated to use the new names:
|
||||||
|
|
||||||
========================== ===========================
|
========================== ===========================
|
||||||
Old name New name
|
Old name New name
|
||||||
|
|
@ -162,9 +161,9 @@ How to create a new reader
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
One thing you might want is to add support for your very own input format.
|
One thing you might want is to add support for your very own input format.
|
||||||
While it might make sense to add this feature in Pelican core, we
|
While it might make sense to add this feature in Pelican core, we wisely chose
|
||||||
wisely chose to avoid this situation and instead have the different readers
|
to avoid this situation and instead have the different readers defined via
|
||||||
defined via plugins.
|
plugins.
|
||||||
|
|
||||||
The rationale behind this choice is mainly that plugins are really easy to
|
The rationale behind this choice is mainly that plugins are really easy to
|
||||||
write and don't slow down Pelican itself when they're not active.
|
write and don't slow down Pelican itself when they're not active.
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ argument, like so::
|
||||||
|
|
||||||
Note that you must specify the path to the generated *output* file — not the
|
Note that you must specify the path to the generated *output* file — not the
|
||||||
source content. To determine the output file name and location, use the
|
source content. To determine the output file name and location, use the
|
||||||
``--debug`` flag. If desired, ``--write-selected``
|
``--debug`` flag. If desired, ``--write-selected`` can take a comma-separated
|
||||||
can take a comma-separated list of paths or can be configured as a setting.
|
list of paths or can be configured as a setting. (See:
|
||||||
(See: :ref:`writing_only_selected_content`)
|
:ref:`writing_only_selected_content`)
|
||||||
|
|
||||||
You can also tell Pelican to watch for your modifications, instead of
|
You can also tell Pelican to watch for your modifications, instead of manually
|
||||||
manually re-running it every time you want to see your changes. To enable this,
|
re-running it every time you want to see your changes. To enable this, run the
|
||||||
run the ``pelican`` command with the ``-r`` or ``--autoreload`` option.
|
``pelican`` command with the ``-r`` or ``--autoreload`` option.
|
||||||
|
|
||||||
Pelican has other command-line switches available. Have a look at the help to
|
Pelican has other command-line switches available. Have a look at the help to
|
||||||
see all the options you can use::
|
see all the options you can use::
|
||||||
|
|
@ -75,17 +75,17 @@ feeds, etc.) that you may have defined::
|
||||||
|
|
||||||
pelican content -s publishconf.py
|
pelican content -s publishconf.py
|
||||||
|
|
||||||
To base your publish configuration on top of your ``pelicanconf.py``, you
|
To base your publish configuration on top of your ``pelicanconf.py``, you can
|
||||||
can import your ``pelicanconf`` settings by including the following line in
|
import your ``pelicanconf`` settings by including the following line in your
|
||||||
your ``publishconf.py``::
|
``publishconf.py``::
|
||||||
|
|
||||||
from pelicanconf import *
|
from pelicanconf import *
|
||||||
|
|
||||||
If you have generated a ``publishconf.py`` using ``pelican-quickstart``,
|
If you have generated a ``publishconf.py`` using ``pelican-quickstart``, this
|
||||||
this line is included by default.
|
line is included by default.
|
||||||
|
|
||||||
The steps for deploying your site will depend on where it will be hosted.
|
The steps for deploying your site will depend on where it will be hosted. If
|
||||||
If you have SSH access to a server running Nginx or Apache, you might use the
|
you have SSH access to a server running Nginx or Apache, you might use the
|
||||||
``rsync`` tool to transmit your site files::
|
``rsync`` tool to transmit your site files::
|
||||||
|
|
||||||
rsync -avc --delete output/ host.example.com:/var/www/your-site/
|
rsync -avc --delete output/ host.example.com:/var/www/your-site/
|
||||||
|
|
@ -98,17 +98,17 @@ Automation
|
||||||
==========
|
==========
|
||||||
|
|
||||||
While the ``pelican`` command is the canonical way to generate your site,
|
While the ``pelican`` command is the canonical way to generate your site,
|
||||||
automation tools can be used to streamline the generation and publication
|
automation tools can be used to streamline the generation and publication flow.
|
||||||
flow. One of the questions asked during the ``pelican-quickstart`` process
|
One of the questions asked during the ``pelican-quickstart`` process pertains
|
||||||
pertains to whether you want to automate site generation and publication.
|
to whether you want to automate site generation and publication. If you
|
||||||
If you answered "yes" to that question, a ``tasks.py`` and
|
answered "yes" to that question, a ``tasks.py`` and ``Makefile`` will be
|
||||||
``Makefile`` will be generated in the root of your project. These files,
|
generated in the root of your project. These files, pre-populated with certain
|
||||||
pre-populated with certain information gleaned from other answers provided
|
information gleaned from other answers provided during the
|
||||||
during the ``pelican-quickstart`` process, are meant as a starting point and
|
``pelican-quickstart`` process, are meant as a starting point and should be
|
||||||
should be customized to fit your particular needs and usage patterns. If you
|
customized to fit your particular needs and usage patterns. If you find one or
|
||||||
find one or both of these automation tools to be of limited utility, these
|
both of these automation tools to be of limited utility, these files can
|
||||||
files can deleted at any time and will not affect usage of the canonical
|
deleted at any time and will not affect usage of the canonical ``pelican``
|
||||||
``pelican`` command.
|
command.
|
||||||
|
|
||||||
Following are automation tools that "wrap" the ``pelican`` command and can
|
Following are automation tools that "wrap" the ``pelican`` command and can
|
||||||
simplify the process of generating, previewing, and uploading your site.
|
simplify the process of generating, previewing, and uploading your site.
|
||||||
|
|
@ -123,9 +123,9 @@ separately. Use the following command to install Invoke, prefixing with
|
||||||
|
|
||||||
pip install invoke
|
pip install invoke
|
||||||
|
|
||||||
Take a moment to open the ``tasks.py`` file that was generated in your
|
Take a moment to open the ``tasks.py`` file that was generated in your project
|
||||||
project root. You will see a number of commands, any one of which can be
|
root. You will see a number of commands, any one of which can be renamed,
|
||||||
renamed, removed, and/or customized to your liking. Using the out-of-the-box
|
removed, and/or customized to your liking. Using the out-of-the-box
|
||||||
configuration, you can generate your site via::
|
configuration, you can generate your site via::
|
||||||
|
|
||||||
invoke build
|
invoke build
|
||||||
|
|
@ -155,12 +155,12 @@ needs and preferences.
|
||||||
Make
|
Make
|
||||||
----
|
----
|
||||||
|
|
||||||
A ``Makefile`` is also automatically created for you when you say "yes" to
|
A ``Makefile`` is also automatically created for you when you say "yes" to the
|
||||||
the relevant question during the ``pelican-quickstart`` process. The advantage
|
relevant question during the ``pelican-quickstart`` process. The advantage of
|
||||||
of this method is that the ``make`` command is built into most POSIX systems
|
this method is that the ``make`` command is built into most POSIX systems and
|
||||||
and thus doesn't require installing anything else in order to use it. The
|
thus doesn't require installing anything else in order to use it. The downside
|
||||||
downside is that non-POSIX systems (e.g., Windows) do not include ``make``,
|
is that non-POSIX systems (e.g., Windows) do not include ``make``, and
|
||||||
and installing it on those systems can be a non-trivial task.
|
installing it on those systems can be a non-trivial task.
|
||||||
|
|
||||||
If you want to use ``make`` to generate your site using the settings in
|
If you want to use ``make`` to generate your site using the settings in
|
||||||
``pelicanconf.py``, run::
|
``pelicanconf.py``, run::
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,9 @@ From your site directory, run the ``pelican`` command to generate your site::
|
||||||
|
|
||||||
pelican content
|
pelican content
|
||||||
|
|
||||||
Your site has now been generated inside the ``output`` directory. (You may see a
|
Your site has now been generated inside the ``output`` directory. (You may see
|
||||||
warning related to feeds, but that is normal when developing locally and can be
|
a warning related to feeds, but that is normal when developing locally and can
|
||||||
ignored for now.)
|
be ignored for now.)
|
||||||
|
|
||||||
Preview your site
|
Preview your site
|
||||||
-----------------
|
-----------------
|
||||||
|
|
@ -68,8 +68,9 @@ following command to launch Pelican's web server::
|
||||||
|
|
||||||
Preview your site by navigating to http://localhost:8000/ in your browser.
|
Preview your site by navigating to http://localhost:8000/ in your browser.
|
||||||
|
|
||||||
Continue reading the other documentation sections for more detail, and check out
|
Continue reading the other documentation sections for more detail, and check
|
||||||
the Pelican wiki's Tutorials_ page for links to community-published tutorials.
|
out the Pelican wiki's Tutorials_ page for links to community-published
|
||||||
|
tutorials.
|
||||||
|
|
||||||
.. _Tutorials: https://github.com/getpelican/pelican/wiki/Tutorials
|
.. _Tutorials: https://github.com/getpelican/pelican/wiki/Tutorials
|
||||||
|
|
||||||
|
|
|
||||||
117
docs/report.rst
117
docs/report.rst
|
|
@ -7,29 +7,27 @@ Some history about Pelican
|
||||||
right after writing Pelican, in December 2010. The information may not be
|
right after writing Pelican, in December 2010. The information may not be
|
||||||
up-to-date.
|
up-to-date.
|
||||||
|
|
||||||
Pelican is a simple static blog generator. It parses markup files
|
Pelican is a simple static blog generator. It parses markup files (Markdown or
|
||||||
(Markdown or reStructuredText for now) and generates an HTML folder
|
reStructuredText for now) and generates an HTML folder with all the files in
|
||||||
with all the files in it.
|
it. I've chosen to use Python to implement Pelican because it seemed to be
|
||||||
I've chosen to use Python to implement Pelican because it seemed to
|
simple and to fit to my needs. I did not wanted to define a class for each
|
||||||
be simple and to fit to my needs. I did not wanted to define a class for
|
thing, but still wanted to keep my things loosely coupled. It turns out that it
|
||||||
each thing, but still wanted to keep my things loosely coupled.
|
was exactly what I wanted. From time to time, thanks to the feedback of some
|
||||||
It turns out that it was exactly what I wanted. From time to time,
|
users, it took me a very few time to provide fixes on it. So far, I've
|
||||||
thanks to the feedback of some users, it took me a very few time to
|
re-factored the Pelican code by two
|
||||||
provide fixes on it. So far, I've re-factored the Pelican code by two
|
|
||||||
times; each time took less than 30 minutes.
|
times; each time took less than 30 minutes.
|
||||||
|
|
||||||
Use case
|
Use case
|
||||||
========
|
========
|
||||||
|
|
||||||
I was previously using WordPress, a solution you can host on a web
|
I was previously using WordPress, a solution you can host on a web server to
|
||||||
server to manage your blog. Most of the time, I prefer using markup
|
manage your blog. Most of the time, I prefer using markup languages such as
|
||||||
languages such as Markdown or reStructuredText to type my articles.
|
Markdown or reStructuredText to type my articles. To do so, I use vim. I think
|
||||||
To do so, I use vim. I think it is important to let the people choose the
|
it is important to let the people choose the tool they want to write the
|
||||||
tool they want to write the articles. In my opinion, a blog manager
|
articles. In my opinion, a blog manager should just allow you to take any kind
|
||||||
should just allow you to take any kind of input and transform it to a
|
of input and transform it to a weblog. That's what Pelican does. You can write
|
||||||
weblog. That's what Pelican does.
|
your articles using the tool you want, and the markup language you want, and
|
||||||
You can write your articles using the tool you want, and the markup
|
then generate a static HTML weblog.
|
||||||
language you want, and then generate a static HTML weblog.
|
|
||||||
|
|
||||||
.. image:: _static/overall.png
|
.. image:: _static/overall.png
|
||||||
|
|
||||||
|
|
@ -40,39 +38,36 @@ Design process
|
||||||
==============
|
==============
|
||||||
|
|
||||||
Pelican came from a need I have. I started by creating a single file
|
Pelican came from a need I have. I started by creating a single file
|
||||||
application, and I have make it grow to support what it does by now.
|
application, and I have make it grow to support what it does by now. To start,
|
||||||
To start, I wrote a piece of documentation about what I wanted to do.
|
I wrote a piece of documentation about what I wanted to do. Then, I created the
|
||||||
Then, I created the content I wanted to parse (the reStructuredText files)
|
content I wanted to parse (the reStructuredText files) and started
|
||||||
and started experimenting with the code. Pelican was 200 lines long and
|
experimenting with the code. Pelican was 200 lines long and contained almost
|
||||||
contained almost ten functions and one class when it was first usable.
|
ten functions and one class when it was first usable.
|
||||||
|
|
||||||
I have been facing different problems all over the time and wanted to
|
I have been facing different problems all over the time and wanted to add
|
||||||
add features to Pelican while using it. The first change I have done was
|
features to Pelican while using it. The first change I have done was to add the
|
||||||
to add the support of a settings file. It is possible to pass the options to
|
support of a settings file. It is possible to pass the options to the command
|
||||||
the command line, but can be tedious if there is a lot of them.
|
line, but can be tedious if there is a lot of them. In the same way, I have
|
||||||
In the same way, I have added the support of different things over
|
added the support of different things over time: Atom feeds, multiple themes,
|
||||||
time: Atom feeds, multiple themes, multiple markup support, etc.
|
multiple markup support, etc. At some point, it appears that the "only one
|
||||||
At some point, it appears that the "only one file" mantra was not good
|
file" mantra was not good enough for Pelican, so I decided to rework a bit all
|
||||||
enough for Pelican, so I decided to rework a bit all that, and split this in
|
that, and split this in multiple different files.
|
||||||
multiple different files.
|
|
||||||
|
|
||||||
I’ve separated the logic in different classes and concepts:
|
I’ve separated the logic in different classes and concepts:
|
||||||
|
|
||||||
* *writers* are responsible of all the writing process of the files.
|
* *writers* are responsible of all the writing process of the files.
|
||||||
They are responsible of writing .html files, RSS feeds and so on.
|
They are responsible of writing .html files, RSS feeds and so on. Since those
|
||||||
Since those operations are commonly used, the object is created
|
operations are commonly used, the object is created once, and then passed to
|
||||||
once, and then passed to the generators.
|
the generators.
|
||||||
|
|
||||||
* *readers* are used to read from various formats (Markdown and
|
* *readers* are used to read from various formats (Markdown and
|
||||||
reStructuredText for now, but the system is extensible). Given a
|
reStructuredText for now, but the system is extensible). Given a file, they
|
||||||
file, they return metadata (author, tags, category, etc) and
|
return metadata (author, tags, category, etc) and content (HTML formatted).
|
||||||
content (HTML formatted).
|
|
||||||
|
|
||||||
* *generators* generate the different outputs. For instance, Pelican
|
* *generators* generate the different outputs. For instance, Pelican
|
||||||
comes with an ArticlesGenerator and PagesGenerator, into
|
comes with an ArticlesGenerator and PagesGenerator, into others. Given a
|
||||||
others. Given a configuration, they can do whatever you want
|
configuration, they can do whatever you want them to do. Most of the time
|
||||||
them to do. Most of the time it's generating files from inputs
|
it's generating files from inputs (user inputs and files).
|
||||||
(user inputs and files).
|
|
||||||
|
|
||||||
I also deal with contents objects. They can be ``Articles``, ``Pages``,
|
I also deal with contents objects. They can be ``Articles``, ``Pages``,
|
||||||
``Quotes``, or whatever you want. They are defined in the ``contents.py``
|
``Quotes``, or whatever you want. They are defined in the ``contents.py``
|
||||||
|
|
@ -90,32 +85,30 @@ whole picture. I do use duck typing and not interfaces.
|
||||||
|
|
||||||
Internally, the following process is followed:
|
Internally, the following process is followed:
|
||||||
|
|
||||||
* First of all, the command line is parsed, and some content from
|
* First of all, the command line is parsed, and some content from the user is
|
||||||
the user is used to initialize the different generator objects.
|
used to initialize the different generator objects.
|
||||||
|
|
||||||
* A ``context`` is created. It contains the settings from the command
|
* A ``context`` is created. It contains the settings from the command line and
|
||||||
line and a settings file if provided.
|
a settings file if provided.
|
||||||
* The ``generate_context`` method of each generator is called, updating
|
* The ``generate_context`` method of each generator is called, updating
|
||||||
the context.
|
the context.
|
||||||
|
* The writer is created and given to the ``generate_output`` method of each
|
||||||
|
generator.
|
||||||
|
|
||||||
* The writer is created and given to the ``generate_output`` method of
|
I make two calls because it is important that when the output is generated by
|
||||||
each generator.
|
the generators, the context will not change. In other words, the first method
|
||||||
|
``generate_context`` should modify the context, whereas the second
|
||||||
I make two calls because it is important that when the output is
|
``generate_output`` method should not.
|
||||||
generated by the generators, the context will not change. In other
|
|
||||||
words, the first method ``generate_context`` should modify the context,
|
|
||||||
whereas the second ``generate_output`` method should not.
|
|
||||||
|
|
||||||
Then, it is up to the generators to do what the want, in the
|
Then, it is up to the generators to do what the want, in the
|
||||||
``generate_context`` and ``generate_content`` method.
|
``generate_context`` and ``generate_content`` method. Taking the
|
||||||
Taking the ``ArticlesGenerator`` class will help to understand some others
|
``ArticlesGenerator`` class will help to understand some others concepts. Here
|
||||||
concepts. Here is what happens when calling the ``generate_context``
|
is what happens when calling the ``generate_context`` method:
|
||||||
method:
|
|
||||||
|
|
||||||
* Read the folder “path”, looking for restructured text files, load
|
* Read the folder “path”, looking for restructured text files, load each of
|
||||||
each of them, and construct a content object (``Article``) with it. To do so,
|
them, and construct a content object (``Article``) with it. To do so, use
|
||||||
use ``Reader`` objects.
|
``Reader`` objects.
|
||||||
* Update the ``context`` with all those articles.
|
* Update the ``context`` with all those articles.
|
||||||
|
|
||||||
Then, the ``generate_content`` method uses the ``context`` and the ``writer`` to
|
Then, the ``generate_content`` method uses the ``context`` and the ``writer``
|
||||||
generate the wanted output.
|
to generate the wanted output.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
Settings
|
Settings
|
||||||
########
|
########
|
||||||
|
|
||||||
Pelican is configurable thanks to a settings file you can pass to
|
Pelican is configurable thanks to a settings file you can pass to the command
|
||||||
the command line::
|
line::
|
||||||
|
|
||||||
pelican content -s path/to/your/pelicanconf.py
|
pelican content -s path/to/your/pelicanconf.py
|
||||||
|
|
||||||
|
|
@ -11,10 +11,10 @@ be named ``pelicanconf.py`` by default.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
When experimenting with different settings (especially the metadata
|
When experimenting with different settings (especially the metadata ones)
|
||||||
ones) caching may interfere and the changes may not be visible. In
|
caching may interfere and the changes may not be visible. In such cases
|
||||||
such cases disable caching with ``LOAD_CONTENT_CACHE = False`` or
|
disable caching with ``LOAD_CONTENT_CACHE = False`` or use the
|
||||||
use the ``--ignore-cache`` command-line switch.
|
``--ignore-cache`` command-line switch.
|
||||||
|
|
||||||
Settings are configured in the form of a Python module (a file). There is an
|
Settings are configured in the form of a Python module (a file). There is an
|
||||||
`example settings file
|
`example settings file
|
||||||
|
|
@ -35,8 +35,8 @@ quotation marks.
|
||||||
|
|
||||||
Unless otherwise specified, settings that refer to paths can be either absolute
|
Unless otherwise specified, settings that refer to paths can be either absolute
|
||||||
or relative to the configuration file. The settings you define in the
|
or relative to the configuration file. The settings you define in the
|
||||||
configuration file will be passed to the templates, which allows you to use your
|
configuration file will be passed to the templates, which allows you to use
|
||||||
settings to add site-wide content.
|
your settings to add site-wide content.
|
||||||
|
|
||||||
Here is a list of settings for Pelican:
|
Here is a list of settings for Pelican:
|
||||||
|
|
||||||
|
|
@ -89,8 +89,8 @@ Basic settings
|
||||||
.. data:: JINJA_ENVIRONMENT = {'trim_blocks': True, 'lstrip_blocks': True}
|
.. data:: JINJA_ENVIRONMENT = {'trim_blocks': True, 'lstrip_blocks': True}
|
||||||
|
|
||||||
A dictionary of custom Jinja2 environment variables you want to use. This
|
A dictionary of custom Jinja2 environment variables you want to use. This
|
||||||
also includes a list of extensions you may want to include.
|
also includes a list of extensions you may want to include. See `Jinja
|
||||||
See `Jinja Environment documentation`_.
|
Environment documentation`_.
|
||||||
|
|
||||||
.. data:: JINJA_FILTERS = {}
|
.. data:: JINJA_FILTERS = {}
|
||||||
|
|
||||||
|
|
@ -212,8 +212,8 @@ Basic settings
|
||||||
your SITEURL; if you do not, feeds will not be generated with
|
your SITEURL; if you do not, feeds will not be generated with
|
||||||
properly-formed URLs. If your site is available via HTTPS, this setting
|
properly-formed URLs. If your site is available via HTTPS, this setting
|
||||||
should begin with ``https://`` — otherwise use ``http://``. Then append your
|
should begin with ``https://`` — otherwise use ``http://``. Then append your
|
||||||
domain, with no trailing slash at the end.
|
domain, with no trailing slash at the end. Example: ``SITEURL =
|
||||||
Example: ``SITEURL = 'https://example.com'``
|
'https://example.com'``
|
||||||
|
|
||||||
.. data:: STATIC_PATHS = ['images']
|
.. data:: STATIC_PATHS = ['images']
|
||||||
|
|
||||||
|
|
@ -239,17 +239,17 @@ Basic settings
|
||||||
|
|
||||||
.. data:: STATIC_CREATE_LINKS = False
|
.. data:: STATIC_CREATE_LINKS = False
|
||||||
|
|
||||||
Create links instead of copying files. If the content and output
|
Create links instead of copying files. If the content and output directories
|
||||||
directories are on the same device, then create hard links. Falls
|
are on the same device, then create hard links. Falls back to symbolic
|
||||||
back to symbolic links if the output directory is on a different
|
links if the output directory is on a different filesystem. If symlinks are
|
||||||
filesystem. If symlinks are created, don't forget to add the ``-L``
|
created, don't forget to add the ``-L`` or ``--copy-links`` option to rsync
|
||||||
or ``--copy-links`` option to rsync when uploading your site.
|
when uploading your site.
|
||||||
|
|
||||||
.. data:: STATIC_CHECK_IF_MODIFIED = False
|
.. data:: STATIC_CHECK_IF_MODIFIED = False
|
||||||
|
|
||||||
If set to ``True``, and ``STATIC_CREATE_LINKS`` is ``False``, compare
|
If set to ``True``, and ``STATIC_CREATE_LINKS`` is ``False``, compare mtimes
|
||||||
mtimes of content and output files, and only copy content files that
|
of content and output files, and only copy content files that are newer than
|
||||||
are newer than existing output files.
|
existing output files.
|
||||||
|
|
||||||
.. data:: TYPOGRIFY = False
|
.. data:: TYPOGRIFY = False
|
||||||
|
|
||||||
|
|
@ -347,11 +347,11 @@ URL settings
|
||||||
============
|
============
|
||||||
|
|
||||||
The first thing to understand is that there are currently two supported methods
|
The first thing to understand is that there are currently two supported methods
|
||||||
for URL formation: *relative* and *absolute*. Relative URLs are useful
|
for URL formation: *relative* and *absolute*. Relative URLs are useful when
|
||||||
when testing locally, and absolute URLs are reliable and most useful when
|
testing locally, and absolute URLs are reliable and most useful when
|
||||||
publishing. One method of supporting both is to have one Pelican configuration
|
publishing. One method of supporting both is to have one Pelican configuration
|
||||||
file for local development and another for publishing. To see an example of this
|
file for local development and another for publishing. To see an example of
|
||||||
type of setup, use the ``pelican-quickstart`` script as described in the
|
this type of setup, use the ``pelican-quickstart`` script as described in the
|
||||||
:doc:`Installation <install>` section, which will produce two separate
|
:doc:`Installation <install>` section, which will produce two separate
|
||||||
configuration files for local development and publishing, respectively.
|
configuration files for local development and publishing, respectively.
|
||||||
|
|
||||||
|
|
@ -365,8 +365,8 @@ and pages anywhere you want.
|
||||||
.. note::
|
.. note::
|
||||||
If you specify a ``datetime`` directive, it will be substituted using the
|
If you specify a ``datetime`` directive, it will be substituted using the
|
||||||
input files' date metadata attribute. If the date is not specified for a
|
input files' date metadata attribute. If the date is not specified for a
|
||||||
particular file, Pelican will rely on the file's ``mtime`` timestamp.
|
particular file, Pelican will rely on the file's ``mtime`` timestamp. Check
|
||||||
Check the `Python datetime documentation`_ for more information.
|
the `Python datetime documentation`_ for more information.
|
||||||
|
|
||||||
.. _Python datetime documentation:
|
.. _Python datetime documentation:
|
||||||
http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
|
http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
|
||||||
|
|
@ -387,10 +387,9 @@ Example usage::
|
||||||
PAGE_SAVE_AS = 'pages/{slug}/index.html'
|
PAGE_SAVE_AS = 'pages/{slug}/index.html'
|
||||||
|
|
||||||
This would save your articles into something like
|
This would save your articles into something like
|
||||||
``/posts/2011/Aug/07/sample-post/index.html``,
|
``/posts/2011/Aug/07/sample-post/index.html``, save your pages into
|
||||||
save your pages into ``/pages/about/index.html``, and render them available at
|
``/pages/about/index.html``, and render them available at URLs of
|
||||||
URLs of ``/posts/2011/Aug/07/sample-post/`` and ``/pages/about/``,
|
``/posts/2011/Aug/07/sample-post/`` and ``/pages/about/``, respectively.
|
||||||
respectively.
|
|
||||||
|
|
||||||
.. data:: RELATIVE_URLS = False
|
.. data:: RELATIVE_URLS = False
|
||||||
|
|
||||||
|
|
@ -528,9 +527,10 @@ respectively.
|
||||||
|
|
||||||
Pelican can optionally create per-year, per-month, and per-day archives of your
|
Pelican can optionally create per-year, per-month, and per-day archives of your
|
||||||
posts. These secondary archives are disabled by default but are automatically
|
posts. These secondary archives are disabled by default but are automatically
|
||||||
enabled if you supply format strings for their respective ``_SAVE_AS`` settings.
|
enabled if you supply format strings for their respective ``_SAVE_AS``
|
||||||
Period archives fit intuitively with the hierarchical model of web URLs and can
|
settings. Period archives fit intuitively with the hierarchical model of web
|
||||||
make it easier for readers to navigate through the posts you've written over time.
|
URLs and can make it easier for readers to navigate through the posts you've
|
||||||
|
written over time.
|
||||||
|
|
||||||
Example usage::
|
Example usage::
|
||||||
|
|
||||||
|
|
@ -543,9 +543,8 @@ posts for the month at ``posts/2011/Aug/index.html``.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
Period archives work best when the final path segment is ``index.html``.
|
Period archives work best when the final path segment is ``index.html``.
|
||||||
This way a reader can remove a portion of your URL and automatically
|
This way a reader can remove a portion of your URL and automatically arrive
|
||||||
arrive at an appropriate archive of posts, without having to specify
|
at an appropriate archive of posts, without having to specify a page name.
|
||||||
a page name.
|
|
||||||
|
|
||||||
``DIRECT_TEMPLATES`` work a bit differently than noted above. Only the
|
``DIRECT_TEMPLATES`` work a bit differently than noted above. Only the
|
||||||
``_SAVE_AS`` settings are available, but it is available for any direct
|
``_SAVE_AS`` settings are available, but it is available for any direct
|
||||||
|
|
@ -585,7 +584,8 @@ template.
|
||||||
|
|
||||||
URLs for direct template pages are theme-dependent. Some themes use
|
URLs for direct template pages are theme-dependent. Some themes use
|
||||||
corresponding ``*_URL`` setting as string, while others hard-code them:
|
corresponding ``*_URL`` setting as string, while others hard-code them:
|
||||||
``'archives.html'``, ``'authors.html'``, ``'categories.html'``, ``'tags.html'``.
|
``'archives.html'``, ``'authors.html'``, ``'categories.html'``,
|
||||||
|
``'tags.html'``.
|
||||||
|
|
||||||
.. data:: SLUG_REGEX_SUBSTITUTIONS = [
|
.. data:: SLUG_REGEX_SUBSTITUTIONS = [
|
||||||
(r'[^\w\s-]', ''), # remove non-alphabetical/whitespace/'-' chars
|
(r'[^\w\s-]', ''), # remove non-alphabetical/whitespace/'-' chars
|
||||||
|
|
@ -604,11 +604,13 @@ corresponding ``*_URL`` setting as string, while others hard-code them:
|
||||||
|
|
||||||
.. data:: AUTHOR_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS
|
.. data:: AUTHOR_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS
|
||||||
|
|
||||||
Regex substitutions for author slugs. Defaults to ``SLUG_REGEX_SUBSTITUTIONS``.
|
Regex substitutions for author slugs. Defaults to
|
||||||
|
``SLUG_REGEX_SUBSTITUTIONS``.
|
||||||
|
|
||||||
.. data:: CATEGORY_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS
|
.. data:: CATEGORY_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS
|
||||||
|
|
||||||
Regex substitutions for category slugs. Defaults to ``SLUG_REGEX_SUBSTITUTIONS``.
|
Regex substitutions for category slugs. Defaults to
|
||||||
|
``SLUG_REGEX_SUBSTITUTIONS``.
|
||||||
|
|
||||||
.. data:: TAG_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS
|
.. data:: TAG_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS
|
||||||
|
|
||||||
|
|
@ -784,13 +786,13 @@ Metadata
|
||||||
unlike some other Pelican file settings.
|
unlike some other Pelican file settings.
|
||||||
|
|
||||||
Not all metadata needs to be :ref:`embedded in source file itself
|
Not all metadata needs to be :ref:`embedded in source file itself
|
||||||
<internal_metadata>`. For example, blog posts are often named
|
<internal_metadata>`. For example, blog posts are often named following a
|
||||||
following a ``YYYY-MM-DD-SLUG.rst`` pattern, or nested into
|
``YYYY-MM-DD-SLUG.rst`` pattern, or nested into ``YYYY/MM/DD-SLUG``
|
||||||
``YYYY/MM/DD-SLUG`` directories. To extract metadata from the
|
directories. To extract metadata from the filename or path, set
|
||||||
filename or path, set ``FILENAME_METADATA`` or ``PATH_METADATA`` to
|
``FILENAME_METADATA`` or ``PATH_METADATA`` to regular expressions that use
|
||||||
regular expressions that use Python's `group name notation`_ ``(?P<name>…)``.
|
Python's `group name notation`_ ``(?P<name>…)``. If you want to attach
|
||||||
If you want to attach additional metadata but don't want to encode
|
additional metadata but don't want to encode it in the path, you can set
|
||||||
it in the path, you can set ``EXTRA_PATH_METADATA``:
|
``EXTRA_PATH_METADATA``:
|
||||||
|
|
||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
|
|
@ -804,8 +806,8 @@ it in the path, you can set ``EXTRA_PATH_METADATA``:
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
This can be a convenient way to shift the installed location of a
|
This can be a convenient way to shift the installed location of a particular
|
||||||
particular file:
|
file:
|
||||||
|
|
||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
|
|
@ -829,8 +831,8 @@ Feed settings
|
||||||
By default, Pelican uses Atom feeds. However, it is also possible to use RSS
|
By default, Pelican uses Atom feeds. However, it is also possible to use RSS
|
||||||
feeds if you prefer.
|
feeds if you prefer.
|
||||||
|
|
||||||
Pelican generates category feeds as well as feeds for all your articles. It does
|
Pelican generates category feeds as well as feeds for all your articles. It
|
||||||
not generate feeds for tags by default, but it is possible to do so using
|
does not generate feeds for tags by default, but it is possible to do so using
|
||||||
the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings:
|
the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings:
|
||||||
|
|
||||||
.. data:: FEED_DOMAIN = None, i.e. base URL is "/"
|
.. data:: FEED_DOMAIN = None, i.e. base URL is "/"
|
||||||
|
|
@ -879,59 +881,61 @@ the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings:
|
||||||
Relative URL of the all-posts RSS feed. If not set, ``FEED_ALL_RSS`` is used
|
Relative URL of the all-posts RSS feed. If not set, ``FEED_ALL_RSS`` is used
|
||||||
both for save location and URL.
|
both for save location and URL.
|
||||||
|
|
||||||
.. data:: CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
|
.. data:: CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'
|
||||||
|
|
||||||
The location to save the category Atom feeds. [2]_
|
The location to save the category Atom feeds. [2]_
|
||||||
|
|
||||||
.. data:: CATEGORY_FEED_ATOM_URL = None
|
.. data:: CATEGORY_FEED_ATOM_URL = None
|
||||||
|
|
||||||
Relative URL of the category Atom feeds, including the ``%s`` placeholder.
|
Relative URL of the category Atom feeds, including the ``{slug}``
|
||||||
[2]_ If not set, ``CATEGORY_FEED_ATOM`` is used both for save location and
|
placeholder. [2]_ If not set, ``CATEGORY_FEED_ATOM`` is used both for save
|
||||||
URL.
|
location and URL.
|
||||||
|
|
||||||
.. data:: CATEGORY_FEED_RSS = None, i.e. no RSS
|
.. data:: CATEGORY_FEED_RSS = None, i.e. no RSS
|
||||||
|
|
||||||
The location to save the category RSS feeds, including the ``%s``
|
The location to save the category RSS feeds, including the ``{slug}``
|
||||||
placeholder. [2]_
|
placeholder. [2]_
|
||||||
|
|
||||||
.. data:: CATEGORY_FEED_RSS_URL = None
|
.. data:: CATEGORY_FEED_RSS_URL = None
|
||||||
|
|
||||||
Relative URL of the category RSS feeds, including the ``%s`` placeholder.
|
Relative URL of the category RSS feeds, including the ``{slug}``
|
||||||
[2]_ If not set, ``CATEGORY_FEED_RSS`` is used both for save location and
|
placeholder. [2]_ If not set, ``CATEGORY_FEED_RSS`` is used both for save
|
||||||
URL.
|
location and URL.
|
||||||
|
|
||||||
.. data:: AUTHOR_FEED_ATOM = 'feeds/%s.atom.xml'
|
.. data:: AUTHOR_FEED_ATOM = 'feeds/{slug}.atom.xml'
|
||||||
|
|
||||||
The location to save the author Atom feeds. [2]_
|
The location to save the author Atom feeds. [2]_
|
||||||
|
|
||||||
.. data:: AUTHOR_FEED_ATOM_URL = None
|
.. data:: AUTHOR_FEED_ATOM_URL = None
|
||||||
|
|
||||||
Relative URL of the author Atom feeds, including the ``%s`` placeholder.
|
Relative URL of the author Atom feeds, including the ``{slug}`` placeholder.
|
||||||
[2]_ If not set, ``AUTHOR_FEED_ATOM`` is used both for save location and
|
[2]_ If not set, ``AUTHOR_FEED_ATOM`` is used both for save location and
|
||||||
URL.
|
URL.
|
||||||
|
|
||||||
.. data:: AUTHOR_FEED_RSS = 'feeds/%s.rss.xml'
|
.. data:: AUTHOR_FEED_RSS = 'feeds/{slug}.rss.xml'
|
||||||
|
|
||||||
The location to save the author RSS feeds. [2]_
|
The location to save the author RSS feeds. [2]_
|
||||||
|
|
||||||
.. data:: AUTHOR_FEED_RSS_URL = None
|
.. data:: AUTHOR_FEED_RSS_URL = None
|
||||||
|
|
||||||
Relative URL of the author RSS feeds, including the ``%s`` placeholder. [2]_
|
Relative URL of the author RSS feeds, including the ``{slug}`` placeholder.
|
||||||
If not set, ``AUTHOR_FEED_RSS`` is used both for save location and URL.
|
[2]_ If not set, ``AUTHOR_FEED_RSS`` is used both for save location and URL.
|
||||||
|
|
||||||
.. data:: TAG_FEED_ATOM = None, i.e. no tag feed
|
.. data:: TAG_FEED_ATOM = None, i.e. no tag feed
|
||||||
|
|
||||||
The location to save the tag Atom feed, including the ``%s`` placeholder.
|
The location to save the tag Atom feed, including the ``{slug}``
|
||||||
[2]_
|
placeholder. [2]_
|
||||||
|
|
||||||
.. data:: TAG_FEED_ATOM_URL = None
|
.. data:: TAG_FEED_ATOM_URL = None
|
||||||
|
|
||||||
Relative URL of the tag Atom feed, including the ``%s`` placeholder. [2]_
|
Relative URL of the tag Atom feed, including the ``{slug}`` placeholder.
|
||||||
|
[2]_
|
||||||
|
|
||||||
.. data:: TAG_FEED_RSS = None, i.e. no RSS tag feed
|
.. data:: TAG_FEED_RSS = None, i.e. no RSS tag feed
|
||||||
|
|
||||||
Relative URL to output the tag RSS feed, including the ``%s`` placeholder.
|
Relative URL to output the tag RSS feed, including the ``{slug}``
|
||||||
If not set, ``TAG_FEED_RSS`` is used both for save location and URL.
|
placeholder. If not set, ``TAG_FEED_RSS`` is used both for save location and
|
||||||
|
URL.
|
||||||
|
|
||||||
.. data:: FEED_MAX_ITEMS
|
.. data:: FEED_MAX_ITEMS
|
||||||
|
|
||||||
|
|
@ -944,9 +948,10 @@ the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings:
|
||||||
to ``False``, the full content will be included instead. This setting
|
to ``False``, the full content will be included instead. This setting
|
||||||
doesn't affect Atom feeds, only RSS ones.
|
doesn't affect Atom feeds, only RSS ones.
|
||||||
|
|
||||||
If you don't want to generate some or any of these feeds, set the above variables to ``None``.
|
If you don't want to generate some or any of these feeds, set the above
|
||||||
|
variables to ``None``.
|
||||||
|
|
||||||
.. [2] ``%s`` is replaced by name of the category / author / tag.
|
.. [2] ``{slug}`` is replaced by name of the category / author / tag.
|
||||||
|
|
||||||
|
|
||||||
FeedBurner
|
FeedBurner
|
||||||
|
|
@ -954,17 +959,18 @@ FeedBurner
|
||||||
|
|
||||||
If you want to use FeedBurner for your feed, you will likely need to decide
|
If you want to use FeedBurner for your feed, you will likely need to decide
|
||||||
upon a unique identifier. For example, if your site were called "Thyme" and
|
upon a unique identifier. For example, if your site were called "Thyme" and
|
||||||
hosted on the www.example.com domain, you might use "thymefeeds" as your
|
hosted on the www.example.com domain, you might use "thymefeeds" as your unique
|
||||||
unique identifier, which we'll use throughout this section for illustrative
|
identifier, which we'll use throughout this section for illustrative purposes.
|
||||||
purposes. In your Pelican settings, set the ``FEED_ATOM`` attribute to
|
In your Pelican settings, set the ``FEED_ATOM`` attribute to
|
||||||
``thymefeeds/main.xml`` to create an Atom feed with an original address of
|
``thymefeeds/main.xml`` to create an Atom feed with an original address of
|
||||||
``http://www.example.com/thymefeeds/main.xml``. Set the ``FEED_DOMAIN``
|
``http://www.example.com/thymefeeds/main.xml``. Set the ``FEED_DOMAIN``
|
||||||
attribute to ``http://feeds.feedburner.com``, or ``http://feeds.example.com`` if
|
attribute to ``http://feeds.feedburner.com``, or ``http://feeds.example.com``
|
||||||
you are using a CNAME on your own domain (i.e., FeedBurner's "MyBrand" feature).
|
if you are using a CNAME on your own domain (i.e., FeedBurner's "MyBrand"
|
||||||
|
feature).
|
||||||
|
|
||||||
There are two fields to configure in the `FeedBurner
|
There are two fields to configure in the `FeedBurner
|
||||||
<http://feedburner.google.com>`_ interface: "Original Feed" and "Feed
|
<http://feedburner.google.com>`_ interface: "Original Feed" and "Feed Address".
|
||||||
Address". In this example, the "Original Feed" would be
|
In this example, the "Original Feed" would be
|
||||||
``http://www.example.com/thymefeeds/main.xml`` and the "Feed Address" suffix
|
``http://www.example.com/thymefeeds/main.xml`` and the "Feed Address" suffix
|
||||||
would be ``thymefeeds/main.xml``.
|
would be ``thymefeeds/main.xml``.
|
||||||
|
|
||||||
|
|
@ -972,10 +978,10 @@ would be ``thymefeeds/main.xml``.
|
||||||
Pagination
|
Pagination
|
||||||
==========
|
==========
|
||||||
|
|
||||||
The default behaviour of Pelican is to list all the article titles along
|
The default behaviour of Pelican is to list all the article titles along with a
|
||||||
with a short description on the index page. While this works well for
|
short description on the index page. While this works well for small-to-medium
|
||||||
small-to-medium sites, sites with a large quantity of articles will probably
|
sites, sites with a large quantity of articles will probably benefit from
|
||||||
benefit from paginating this list.
|
paginating this list.
|
||||||
|
|
||||||
You can use the following settings to configure the pagination.
|
You can use the following settings to configure the pagination.
|
||||||
|
|
||||||
|
|
@ -1014,9 +1020,9 @@ change this. It takes a sequence of triples, where each triple consists of::
|
||||||
For ``page_url`` and ``page_save_as``, you may use a number of variables.
|
For ``page_url`` and ``page_save_as``, you may use a number of variables.
|
||||||
``{url}`` and ``{save_as}`` correspond respectively to the ``*_URL`` and
|
``{url}`` and ``{save_as}`` correspond respectively to the ``*_URL`` and
|
||||||
``*_SAVE_AS`` values of the corresponding page type (e.g. ``ARTICLE_SAVE_AS``).
|
``*_SAVE_AS`` values of the corresponding page type (e.g. ``ARTICLE_SAVE_AS``).
|
||||||
If ``{save_as} == foo/bar.html``, then ``{name} == foo/bar`` and
|
If ``{save_as} == foo/bar.html``, then ``{name} == foo/bar`` and ``{extension}
|
||||||
``{extension} == .html``. ``{base_name}`` equals ``{name}`` except that it
|
== .html``. ``{base_name}`` equals ``{name}`` except that it strips trailing
|
||||||
strips trailing ``/index`` if present. ``{number}`` equals the page number.
|
``/index`` if present. ``{number}`` equals the page number.
|
||||||
|
|
||||||
For example, if you want to leave the first page unchanged, but place
|
For example, if you want to leave the first page unchanged, but place
|
||||||
subsequent pages at ``.../page/2/`` etc, you could set ``PAGINATION_PATTERNS``
|
subsequent pages at ``.../page/2/`` etc, you could set ``PAGINATION_PATTERNS``
|
||||||
|
|
@ -1031,8 +1037,8 @@ as follows::
|
||||||
Translations
|
Translations
|
||||||
============
|
============
|
||||||
|
|
||||||
Pelican offers a way to translate articles. See the :doc:`Content <content>` section for
|
Pelican offers a way to translate articles. See the :doc:`Content <content>`
|
||||||
more information.
|
section for more information.
|
||||||
|
|
||||||
.. data:: DEFAULT_LANG = 'en'
|
.. data:: DEFAULT_LANG = 'en'
|
||||||
|
|
||||||
|
|
@ -1046,17 +1052,17 @@ more information.
|
||||||
|
|
||||||
.. data:: PAGE_TRANSLATION_ID = 'slug'
|
.. data:: PAGE_TRANSLATION_ID = 'slug'
|
||||||
|
|
||||||
The metadata attribute(s) used to identify which pages are translations
|
The metadata attribute(s) used to identify which pages are translations of
|
||||||
of one another. May be a string or a collection of strings. Set to ``None``
|
one another. May be a string or a collection of strings. Set to ``None`` or
|
||||||
or ``False`` to disable the identification of translations.
|
``False`` to disable the identification of translations.
|
||||||
|
|
||||||
.. data:: TRANSLATION_FEED_ATOM = 'feeds/all-%s.atom.xml'
|
.. data:: TRANSLATION_FEED_ATOM = 'feeds/all-{lang}.atom.xml'
|
||||||
|
|
||||||
The location to save the Atom feed for translations. [3]_
|
The location to save the Atom feed for translations. [3]_
|
||||||
|
|
||||||
.. data:: TRANSLATION_FEED_ATOM_URL = None
|
.. data:: TRANSLATION_FEED_ATOM_URL = None
|
||||||
|
|
||||||
Relative URL of the Atom feed for translations, including the ``%s``
|
Relative URL of the Atom feed for translations, including the ``{lang}``
|
||||||
placeholder. [3]_ If not set, ``TRANSLATION_FEED_ATOM`` is used both for
|
placeholder. [3]_ If not set, ``TRANSLATION_FEED_ATOM`` is used both for
|
||||||
save location and URL.
|
save location and URL.
|
||||||
|
|
||||||
|
|
@ -1066,11 +1072,11 @@ more information.
|
||||||
|
|
||||||
.. data:: TRANSLATION_FEED_RSS_URL = None
|
.. data:: TRANSLATION_FEED_RSS_URL = None
|
||||||
|
|
||||||
Relative URL of the RSS feed for translations, including the ``%s``
|
Relative URL of the RSS feed for translations, including the ``{lang}``
|
||||||
placeholder. [3]_ If not set, ``TRANSLATION_FEED_RSS`` is used both for save
|
placeholder. [3]_ If not set, ``TRANSLATION_FEED_RSS`` is used both for save
|
||||||
location and URL.
|
location and URL.
|
||||||
|
|
||||||
.. [3] %s is the language
|
.. [3] {lang} is the language code
|
||||||
|
|
||||||
|
|
||||||
Ordering content
|
Ordering content
|
||||||
|
|
@ -1106,8 +1112,9 @@ Ordering content
|
||||||
Themes
|
Themes
|
||||||
======
|
======
|
||||||
|
|
||||||
Creating Pelican themes is addressed in a dedicated section (see :ref:`theming-pelican`).
|
Creating Pelican themes is addressed in a dedicated section (see
|
||||||
However, here are the settings that are related to themes.
|
:ref:`theming-pelican`). However, here are the settings that are related to
|
||||||
|
themes.
|
||||||
|
|
||||||
.. data:: THEME
|
.. data:: THEME
|
||||||
|
|
||||||
|
|
@ -1152,11 +1159,13 @@ setting or by passing the ``-t`` option to the ``pelican`` command:
|
||||||
* notmyidea
|
* notmyidea
|
||||||
* simple (a synonym for "plain text" :)
|
* simple (a synonym for "plain text" :)
|
||||||
|
|
||||||
There are a number of other themes available at https://github.com/getpelican/pelican-themes.
|
There are a number of other themes available at
|
||||||
Pelican comes with :doc:`pelican-themes`, a small script for managing themes.
|
https://github.com/getpelican/pelican-themes. Pelican comes with
|
||||||
|
:doc:`pelican-themes`, a small script for managing themes.
|
||||||
|
|
||||||
You can define your own theme, either by starting from scratch or by duplicating
|
You can define your own theme, either by starting from scratch or by
|
||||||
and modifying a pre-existing theme. Here is :doc:`a guide on how to create your theme <themes>`.
|
duplicating and modifying a pre-existing theme. Here is :doc:`a guide on how to
|
||||||
|
create your theme <themes>`.
|
||||||
|
|
||||||
Following are example ways to specify your preferred theme::
|
Following are example ways to specify your preferred theme::
|
||||||
|
|
||||||
|
|
@ -1169,8 +1178,8 @@ Following are example ways to specify your preferred theme::
|
||||||
# Specify a customized theme, via absolute path
|
# Specify a customized theme, via absolute path
|
||||||
THEME = "/home/myuser/projects/mysite/themes/mycustomtheme"
|
THEME = "/home/myuser/projects/mysite/themes/mycustomtheme"
|
||||||
|
|
||||||
The built-in ``notmyidea`` theme can make good use of the following settings. Feel
|
The built-in ``notmyidea`` theme can make good use of the following settings.
|
||||||
free to use them in your themes as well.
|
Feel free to use them in your themes as well.
|
||||||
|
|
||||||
.. data:: SITESUBTITLE
|
.. data:: SITESUBTITLE
|
||||||
|
|
||||||
|
|
@ -1256,9 +1265,9 @@ can be quite tricky. In order to filter out redundant log messages, Pelican
|
||||||
comes with the ``LOG_FILTER`` setting.
|
comes with the ``LOG_FILTER`` setting.
|
||||||
|
|
||||||
``LOG_FILTER`` should be a list of tuples ``(level, msg)``, each of them being
|
``LOG_FILTER`` should be a list of tuples ``(level, msg)``, each of them being
|
||||||
composed of the logging level (up to ``warning``) and the message to be ignored.
|
composed of the logging level (up to ``warning``) and the message to be
|
||||||
Simply populate the list with the log messages you want to hide, and they will
|
ignored. Simply populate the list with the log messages you want to hide, and
|
||||||
be filtered out.
|
they will be filtered out.
|
||||||
|
|
||||||
For example::
|
For example::
|
||||||
|
|
||||||
|
|
@ -1274,6 +1283,7 @@ For example::
|
||||||
LOG_FILTER = [(logging.WARN, 'Empty alt attribute for image %s in %s')]
|
LOG_FILTER = [(logging.WARN, 'Empty alt attribute for image %s in %s')]
|
||||||
|
|
||||||
.. Warning::
|
.. Warning::
|
||||||
|
|
||||||
Silencing messages by templates is a dangerous feature. It is possible to
|
Silencing messages by templates is a dangerous feature. It is possible to
|
||||||
unintentionally filter out multiple message types with the same template
|
unintentionally filter out multiple message types with the same template
|
||||||
(including messages from future Pelican versions). Proceed with caution.
|
(including messages from future Pelican versions). Proceed with caution.
|
||||||
|
|
@ -1288,16 +1298,15 @@ For example::
|
||||||
Reading only modified content
|
Reading only modified content
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
To speed up the build process, Pelican can optionally read only articles
|
To speed up the build process, Pelican can optionally read only articles and
|
||||||
and pages with modified content.
|
pages with modified content.
|
||||||
|
|
||||||
When Pelican is about to read some content source file:
|
When Pelican is about to read some content source file:
|
||||||
|
|
||||||
1. The hash or modification time information for the file from a
|
1. The hash or modification time information for the file from a
|
||||||
previous build are loaded from a cache file if ``LOAD_CONTENT_CACHE``
|
previous build are loaded from a cache file if ``LOAD_CONTENT_CACHE`` is
|
||||||
is ``True``. These files are stored in the ``CACHE_PATH``
|
``True``. These files are stored in the ``CACHE_PATH`` directory. If the
|
||||||
directory. If the file has no record in the cache file, it is read
|
file has no record in the cache file, it is read as usual.
|
||||||
as usual.
|
|
||||||
2. The file is checked according to ``CHECK_MODIFIED_METHOD``:
|
2. The file is checked according to ``CHECK_MODIFIED_METHOD``:
|
||||||
|
|
||||||
- If set to ``'mtime'``, the modification time of the file is
|
- If set to ``'mtime'``, the modification time of the file is
|
||||||
|
|
@ -1305,47 +1314,45 @@ When Pelican is about to read some content source file:
|
||||||
- If set to a name of a function provided by the ``hashlib``
|
- If set to a name of a function provided by the ``hashlib``
|
||||||
module, e.g. ``'md5'``, the file hash is checked.
|
module, e.g. ``'md5'``, the file hash is checked.
|
||||||
- If set to anything else or the necessary information about the
|
- If set to anything else or the necessary information about the
|
||||||
file cannot be found in the cache file, the content is read as
|
file cannot be found in the cache file, the content is read as usual.
|
||||||
usual.
|
|
||||||
|
|
||||||
3. If the file is considered unchanged, the content data saved in a
|
3. If the file is considered unchanged, the content data saved in a
|
||||||
previous build corresponding to the file is loaded from the cache,
|
previous build corresponding to the file is loaded from the cache, and the
|
||||||
and the file is not read.
|
file is not read.
|
||||||
4. If the file is considered changed, the file is read and the new
|
4. If the file is considered changed, the file is read and the new
|
||||||
modification information and the content data are saved to the
|
modification information and the content data are saved to the cache if
|
||||||
cache if ``CACHE_CONTENT`` is ``True``.
|
``CACHE_CONTENT`` is ``True``.
|
||||||
|
|
||||||
If ``CONTENT_CACHING_LAYER`` is set to ``'reader'`` (the default),
|
If ``CONTENT_CACHING_LAYER`` is set to ``'reader'`` (the default), the raw
|
||||||
the raw content and metadata returned by a reader are cached. If this
|
content and metadata returned by a reader are cached. If this setting is
|
||||||
setting is instead set to ``'generator'``, the processed content
|
instead set to ``'generator'``, the processed content object is cached. Caching
|
||||||
object is cached. Caching the processed content object may conflict
|
the processed content object may conflict with plugins (as some reading related
|
||||||
with plugins (as some reading related signals may be skipped) and the
|
signals may be skipped) and the ``WITH_FUTURE_DATES`` functionality (as the
|
||||||
``WITH_FUTURE_DATES`` functionality (as the ``draft`` status of the
|
``draft`` status of the cached content objects would not change automatically
|
||||||
cached content objects would not change automatically over time).
|
over time).
|
||||||
|
|
||||||
Checking modification times is faster than comparing file hashes,
|
Checking modification times is faster than comparing file hashes, but it is not
|
||||||
but it is not as reliable because ``mtime`` information can be lost,
|
as reliable because ``mtime`` information can be lost, e.g., when copying
|
||||||
e.g., when copying content source files using the ``cp`` or ``rsync``
|
content source files using the ``cp`` or ``rsync`` commands without the
|
||||||
commands without the ``mtime`` preservation mode (which for ``rsync``
|
``mtime`` preservation mode (which for ``rsync`` can be invoked by passing the
|
||||||
can be invoked by passing the ``--archive`` flag).
|
``--archive`` flag).
|
||||||
|
|
||||||
The cache files are Python pickles, so they may not be readable by
|
The cache files are Python pickles, so they may not be readable by different
|
||||||
different versions of Python as the pickle format often changes. If
|
versions of Python as the pickle format often changes. If such an error is
|
||||||
such an error is encountered, it is caught and the cache file is
|
encountered, it is caught and the cache file is rebuilt automatically in the
|
||||||
rebuilt automatically in the new format. The cache files will also be
|
new format. The cache files will also be rebuilt after the ``GZIP_CACHE``
|
||||||
rebuilt after the ``GZIP_CACHE`` setting has been changed.
|
setting has been changed.
|
||||||
|
|
||||||
The ``--ignore-cache`` command-line option is useful when the
|
The ``--ignore-cache`` command-line option is useful when the whole cache needs
|
||||||
whole cache needs to be regenerated, such as when making modifications
|
to be regenerated, such as when making modifications to the settings file that
|
||||||
to the settings file that will affect the cached content, or just for
|
will affect the cached content, or just for debugging purposes. When Pelican
|
||||||
debugging purposes. When Pelican runs in autoreload mode, modification
|
runs in autoreload mode, modification of the settings file will make it ignore
|
||||||
of the settings file will make it ignore the cache automatically if
|
the cache automatically if ``AUTORELOAD_IGNORE_CACHE`` is ``True``.
|
||||||
``AUTORELOAD_IGNORE_CACHE`` is ``True``.
|
|
||||||
|
|
||||||
Note that even when using cached content, all output is always
|
Note that even when using cached content, all output is always written, so the
|
||||||
written, so the modification times of the generated ``*.html`` files
|
modification times of the generated ``*.html`` files will always change.
|
||||||
will always change. Therefore, ``rsync``-based uploading may benefit
|
Therefore, ``rsync``-based uploading may benefit from the ``--checksum``
|
||||||
from the ``--checksum`` option.
|
option.
|
||||||
|
|
||||||
.. _writing_only_selected_content:
|
.. _writing_only_selected_content:
|
||||||
|
|
||||||
|
|
@ -1353,16 +1360,14 @@ from the ``--checksum`` option.
|
||||||
Writing only selected content
|
Writing only selected content
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
When only working on a single article or page, or making tweaks to
|
When only working on a single article or page, or making tweaks to your theme,
|
||||||
your theme, it is often desirable to generate and review your work
|
it is often desirable to generate and review your work as quickly as possible.
|
||||||
as quickly as possible. In such cases, generating and writing the
|
In such cases, generating and writing the entire site output is often
|
||||||
entire site output is often unnecessary. By specifying only the
|
unnecessary. By specifying only the desired files as output paths in the
|
||||||
desired files as output paths in the ``WRITE_SELECTED`` list,
|
``WRITE_SELECTED`` list, **only** those files will be written. This list can be
|
||||||
**only** those files will be written. This list can be also specified
|
also specified on the command line using the ``--write-selected`` option, which
|
||||||
on the command line using the ``--write-selected`` option, which
|
accepts a comma-separated list of output file paths. By default this list is
|
||||||
accepts a comma-separated list of output file paths. By default this
|
empty, so all output is written. See :ref:`site_generation` for more details.
|
||||||
list is empty, so all output is written. See :ref:`site_generation` for
|
|
||||||
more details.
|
|
||||||
|
|
||||||
|
|
||||||
Example settings
|
Example settings
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@
|
||||||
Creating themes
|
Creating themes
|
||||||
###############
|
###############
|
||||||
|
|
||||||
To generate its HTML output, Pelican uses the `Jinja <http://jinja.pocoo.org/>`_
|
To generate its HTML output, Pelican uses the `Jinja
|
||||||
templating engine due to its flexibility and straightforward syntax. If you want
|
<http://jinja.pocoo.org/>`_ templating engine due to its flexibility and
|
||||||
to create your own theme, feel free to take inspiration from the `"simple" theme
|
straightforward syntax. If you want to create your own theme, feel free to take
|
||||||
|
inspiration from the `"simple" theme
|
||||||
<https://github.com/getpelican/pelican/tree/master/pelican/themes/simple/templates>`_.
|
<https://github.com/getpelican/pelican/tree/master/pelican/themes/simple/templates>`_.
|
||||||
|
|
||||||
To generate your site using a theme you have created (or downloaded manually and
|
To generate your site using a theme you have created (or downloaded manually
|
||||||
then modified), you can specify that theme via the ``-t`` flag::
|
and then modified), you can specify that theme via the ``-t`` flag::
|
||||||
|
|
||||||
pelican content -s pelicanconf.py -t /projects/your-site/themes/your-theme
|
pelican content -s pelicanconf.py -t /projects/your-site/themes/your-theme
|
||||||
|
|
||||||
|
|
@ -42,9 +43,9 @@ To make your own theme, you must follow the following structure::
|
||||||
`theme` folder. The above filesystem layout includes CSS and image folders,
|
`theme` folder. The above filesystem layout includes CSS and image folders,
|
||||||
but those are just examples. Put what you need here.
|
but those are just examples. Put what you need here.
|
||||||
|
|
||||||
* `templates` contains all the templates that will be used to generate the content.
|
* `templates` contains all the templates that will be used to generate the
|
||||||
The template files listed above are mandatory; you can add your own templates
|
content. The template files listed above are mandatory; you can add your own
|
||||||
if it helps you keep things organized while creating your theme.
|
templates if it helps you keep things organized while creating your theme.
|
||||||
|
|
||||||
|
|
||||||
.. _templates-variables:
|
.. _templates-variables:
|
||||||
|
|
@ -93,13 +94,13 @@ draft_pages The list of draft pages
|
||||||
Sorting
|
Sorting
|
||||||
-------
|
-------
|
||||||
|
|
||||||
URL wrappers (currently categories, tags, and authors), have
|
URL wrappers (currently categories, tags, and authors), have comparison methods
|
||||||
comparison methods that allow them to be easily sorted by name::
|
that allow them to be easily sorted by name::
|
||||||
|
|
||||||
{% for tag, articles in tags|sort %}
|
{% for tag, articles in tags|sort %}
|
||||||
|
|
||||||
If you want to sort based on different criteria, `Jinja's sort
|
If you want to sort based on different criteria, `Jinja's sort command`__ has a
|
||||||
command`__ has a number of options.
|
number of options.
|
||||||
|
|
||||||
__ http://jinja.pocoo.org/docs/templates/#sort
|
__ http://jinja.pocoo.org/docs/templates/#sort
|
||||||
|
|
||||||
|
|
@ -108,13 +109,12 @@ Date Formatting
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Pelican formats the date according to your settings and locale
|
Pelican formats the date according to your settings and locale
|
||||||
(``DATE_FORMATS``/``DEFAULT_DATE_FORMAT``) and provides a
|
(``DATE_FORMATS``/``DEFAULT_DATE_FORMAT``) and provides a ``locale_date``
|
||||||
``locale_date`` attribute. On the other hand, the ``date`` attribute will
|
attribute. On the other hand, the ``date`` attribute will be a `datetime`_
|
||||||
be a `datetime`_ object. If you need custom formatting for a date
|
object. If you need custom formatting for a date different than your settings,
|
||||||
different than your settings, use the Jinja filter ``strftime``
|
use the Jinja filter ``strftime`` that comes with Pelican. Usage is same as
|
||||||
that comes with Pelican. Usage is same as Python `strftime`_ format,
|
Python `strftime`_ format, but the filter will do the right thing and format
|
||||||
but the filter will do the right thing and format your date according
|
your date according to the locale given in your settings::
|
||||||
to the locale given in your settings::
|
|
||||||
|
|
||||||
{{ article.date|strftime('%d %B %Y') }}
|
{{ article.date|strftime('%d %B %Y') }}
|
||||||
|
|
||||||
|
|
@ -127,7 +127,8 @@ index.html
|
||||||
|
|
||||||
This is the home page or index of your blog, generated at ``index.html``.
|
This is the home page or index of your blog, generated at ``index.html``.
|
||||||
|
|
||||||
If pagination is active, subsequent pages will reside in ``index{number}.html``.
|
If pagination is active, subsequent pages will reside in
|
||||||
|
``index{number}.html``.
|
||||||
|
|
||||||
====================== ===================================================
|
====================== ===================================================
|
||||||
Variable Description
|
Variable Description
|
||||||
|
|
@ -153,8 +154,8 @@ page_name 'index' -- useful for pagination links
|
||||||
author.html
|
author.html
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
This template will be processed for each of the existing authors, with
|
This template will be processed for each of the existing authors, with output
|
||||||
output generated according to the ``AUTHOR_SAVE_AS`` setting (`Default:`
|
generated according to the ``AUTHOR_SAVE_AS`` setting (`Default:`
|
||||||
``author/{slug}.html``). If pagination is active, subsequent pages will by
|
``author/{slug}.html``). If pagination is active, subsequent pages will by
|
||||||
default reside at ``author/{slug}{number}.html``.
|
default reside at ``author/{slug}{number}.html``.
|
||||||
|
|
||||||
|
|
@ -221,10 +222,9 @@ page_name CATEGORY_URL where everything after `{slug}` is
|
||||||
article.html
|
article.html
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
This template will be processed for each article, with
|
This template will be processed for each article, with output generated
|
||||||
output generated according to the ``ARTICLE_SAVE_AS`` setting (`Default:`
|
according to the ``ARTICLE_SAVE_AS`` setting (`Default:` ``{slug}.html``). The
|
||||||
``{slug}.html``). The following variables are available when
|
following variables are available when rendering.
|
||||||
rendering.
|
|
||||||
|
|
||||||
============= ===================================================
|
============= ===================================================
|
||||||
Variable Description
|
Variable Description
|
||||||
|
|
@ -233,9 +233,9 @@ article The article object to be displayed
|
||||||
category The name of the category for the current article
|
category The name of the category for the current article
|
||||||
============= ===================================================
|
============= ===================================================
|
||||||
|
|
||||||
Any metadata that you put in the header of the article source file
|
Any metadata that you put in the header of the article source file will be
|
||||||
will be available as fields on the ``article`` object. The field name will be
|
available as fields on the ``article`` object. The field name will be the same
|
||||||
the same as the name of the metadata field, except in all-lowercase characters.
|
as the name of the metadata field, except in all-lowercase characters.
|
||||||
|
|
||||||
For example, you could add a field called `FacebookImage` to your article
|
For example, you could add a field called `FacebookImage` to your article
|
||||||
metadata, as shown below:
|
metadata, as shown below:
|
||||||
|
|
@ -251,8 +251,8 @@ metadata, as shown below:
|
||||||
FacebookImage: http://franciscabrel.com/images/pythonlove.png
|
FacebookImage: http://franciscabrel.com/images/pythonlove.png
|
||||||
|
|
||||||
This new metadata will be made available as `article.facebookimage` in your
|
This new metadata will be made available as `article.facebookimage` in your
|
||||||
`article.html` template. This would allow you, for example, to specify an
|
`article.html` template. This would allow you, for example, to specify an image
|
||||||
image for the Facebook open graph tags that will change for each article:
|
for the Facebook open graph tags that will change for each article:
|
||||||
|
|
||||||
.. code-block:: html+jinja
|
.. code-block:: html+jinja
|
||||||
|
|
||||||
|
|
@ -262,10 +262,9 @@ image for the Facebook open graph tags that will change for each article:
|
||||||
page.html
|
page.html
|
||||||
---------
|
---------
|
||||||
|
|
||||||
This template will be processed for each page, with
|
This template will be processed for each page, with output generated according
|
||||||
output generated according to the ``PAGE_SAVE_AS`` setting (`Default:`
|
to the ``PAGE_SAVE_AS`` setting (`Default:` ``pages/{slug}.html``). The
|
||||||
``pages/{slug}.html``). The following variables are available when
|
following variables are available when rendering.
|
||||||
rendering.
|
|
||||||
|
|
||||||
============= ===================================================
|
============= ===================================================
|
||||||
Variable Description
|
Variable Description
|
||||||
|
|
@ -278,10 +277,10 @@ page The page object to be displayed. You can access its
|
||||||
tag.html
|
tag.html
|
||||||
--------
|
--------
|
||||||
|
|
||||||
This template will be processed for each tag, with
|
This template will be processed for each tag, with output generated according
|
||||||
output generated according to the ``TAG_SAVE_AS`` setting (`Default:`
|
to the ``TAG_SAVE_AS`` setting (`Default:` ``tag/{slug}.html``). If pagination
|
||||||
``tag/{slug}.html``). If pagination is active, subsequent pages will by
|
is active, subsequent pages will by default reside at
|
||||||
default reside at ``tag/{slug}{number}.html``.
|
``tag/{slug}{number}.html``.
|
||||||
|
|
||||||
====================== ===================================================
|
====================== ===================================================
|
||||||
Variable Description
|
Variable Description
|
||||||
|
|
@ -312,9 +311,9 @@ page_name TAG_URL where everything after `{slug}` is removed
|
||||||
period_archives.html
|
period_archives.html
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
This template will be processed for each year of your posts if a path
|
This template will be processed for each year of your posts if a path for
|
||||||
for ``YEAR_ARCHIVE_SAVE_AS`` is defined, each month if ``MONTH_ARCHIVE_SAVE_AS``
|
``YEAR_ARCHIVE_SAVE_AS`` is defined, each month if ``MONTH_ARCHIVE_SAVE_AS`` is
|
||||||
is defined, and each day if ``DAY_ARCHIVE_SAVE_AS`` is defined.
|
defined, and each day if ``DAY_ARCHIVE_SAVE_AS`` is defined.
|
||||||
|
|
||||||
=================== ===================================================
|
=================== ===================================================
|
||||||
Variable Description
|
Variable Description
|
||||||
|
|
@ -464,9 +463,9 @@ Since version 3.0, Pelican supports inheritance from the ``simple`` theme, so
|
||||||
you can re-use the ``simple`` theme templates in your own themes.
|
you can re-use the ``simple`` theme templates in your own themes.
|
||||||
|
|
||||||
If one of the mandatory files in the ``templates/`` directory of your theme is
|
If one of the mandatory files in the ``templates/`` directory of your theme is
|
||||||
missing, it will be replaced by the matching template from the ``simple`` theme.
|
missing, it will be replaced by the matching template from the ``simple``
|
||||||
So if the HTML structure of a template in the ``simple`` theme is right for you,
|
theme. So if the HTML structure of a template in the ``simple`` theme is right
|
||||||
you don't have to write a new template from scratch.
|
for you, you don't have to write a new template from scratch.
|
||||||
|
|
||||||
You can also extend templates from the ``simple`` theme in your own themes by
|
You can also extend templates from the ``simple`` theme in your own themes by
|
||||||
using the ``{% extends %}`` directive as in the following example:
|
using the ``{% extends %}`` directive as in the following example:
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ Custom 404 Pages
|
||||||
|
|
||||||
When a browser requests a resource that the web server cannot find, the web
|
When a browser requests a resource that the web server cannot find, the web
|
||||||
server usually displays a generic "File not found" (404) error page that can be
|
server usually displays a generic "File not found" (404) error page that can be
|
||||||
stark and unsightly. One way to provide an error page that matches the theme
|
stark and unsightly. One way to provide an error page that matches the theme of
|
||||||
of your site is to create a custom 404 page (*not* an article), such as this
|
your site is to create a custom 404 page (*not* an article), such as this
|
||||||
Markdown-formatted example stored in ``content/pages/404.md``::
|
Markdown-formatted example stored in ``content/pages/404.md``::
|
||||||
|
|
||||||
Title: Not Found
|
Title: Not Found
|
||||||
|
|
@ -29,8 +29,8 @@ For Apache::
|
||||||
|
|
||||||
ErrorDocument 404 /404.html
|
ErrorDocument 404 /404.html
|
||||||
|
|
||||||
For Amazon S3, first navigate to the ``Static Site Hosting`` menu in the
|
For Amazon S3, first navigate to the ``Static Site Hosting`` menu in the bucket
|
||||||
bucket settings on your AWS cosole. From there::
|
settings on your AWS cosole. From there::
|
||||||
|
|
||||||
Error Document: 404.html
|
Error Document: 404.html
|
||||||
|
|
||||||
|
|
@ -67,15 +67,10 @@ already exist). The ``git push origin gh-pages`` command updates the remote
|
||||||
``gh-pages`` branch, effectively publishing the Pelican site.
|
``gh-pages`` branch, effectively publishing the Pelican site.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
The ``github`` target of the Makefile (and the ``gh_pages`` task of ``tasks.py``)
|
|
||||||
created by the ``pelican-quickstart`` command
|
|
||||||
publishes the Pelican site as Project Pages, as described above.
|
|
||||||
|
|
||||||
.. note:: ghp-import on Windows
|
The ``github`` target of the Makefile (and the ``gh_pages`` task of
|
||||||
|
``tasks.py``) created by the ``pelican-quickstart`` command publishes the
|
||||||
Until `ghp-import Pull Request #25 <https://github.com/davisp/ghp-import/pull/25>`_
|
Pelican site as Project Pages, as described above.
|
||||||
is accepted, you will need to install a custom build of ghp-import:
|
|
||||||
``pip install https://github.com/chevah/ghp-import/archive/win-support.zip``
|
|
||||||
|
|
||||||
User Pages
|
User Pages
|
||||||
----------
|
----------
|
||||||
|
|
@ -99,13 +94,17 @@ 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
|
To publish your Pelican site as User Pages, feel free to adjust the
|
||||||
``github`` target of the Makefile.
|
``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.
|
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 ``<username>.github.io`` and you can create the Pelican project in a subdirectory called ``Pelican``. Then from inside the ``Pelican`` folder you can run::
|
For example, your main project folder is ``<username>.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
|
$ pelican content -o .. -s pelicanconf.py
|
||||||
|
|
||||||
Now you can push the whole project ``<username>.github.io`` to the master branch of your GitHub repository::
|
Now you can push the whole project ``<username>.github.io`` to the master
|
||||||
|
branch of your GitHub repository::
|
||||||
|
|
||||||
$ git push origin master
|
$ git push origin master
|
||||||
|
|
||||||
|
|
@ -120,8 +119,8 @@ relevant `GitHub docs <https://help.github.com/articles/custom-404-pages/>`_.
|
||||||
Update your site on each commit
|
Update your site on each commit
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
To automatically update your Pelican site on each commit, you can create
|
To automatically update your Pelican site on each commit, you can create a
|
||||||
a post-commit hook. For example, you can add the following to
|
post-commit hook. For example, you can add the following to
|
||||||
``.git/hooks/post-commit``::
|
``.git/hooks/post-commit``::
|
||||||
|
|
||||||
pelican content -o output -s pelicanconf.py && ghp-import output && git push origin gh-pages
|
pelican content -o output -s pelicanconf.py && ghp-import output && git push origin gh-pages
|
||||||
|
|
@ -142,8 +141,8 @@ output directory. For example::
|
||||||
|
|
||||||
Note: use forward slashes, ``/``, even on Windows.
|
Note: use forward slashes, ``/``, even on Windows.
|
||||||
|
|
||||||
You can also use the ``EXTRA_PATH_METADATA`` mechanism
|
You can also use the ``EXTRA_PATH_METADATA`` mechanism to place a
|
||||||
to place a ``favicon.ico`` or ``robots.txt`` at the root of any site.
|
``favicon.ico`` or ``robots.txt`` at the root of any site.
|
||||||
|
|
||||||
How to add YouTube or Vimeo Videos
|
How to add YouTube or Vimeo Videos
|
||||||
==================================
|
==================================
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,11 @@ class Pelican(object):
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
context = self.settings.copy()
|
context = self.settings.copy()
|
||||||
# Share these among all the generators and content objects:
|
# Share these among all the generators and content objects
|
||||||
context['filenames'] = {} # maps source path to Content object or None
|
# They map source paths to Content objects or None
|
||||||
|
context['generated_content'] = {}
|
||||||
|
context['static_links'] = set()
|
||||||
|
context['static_content'] = {}
|
||||||
context['localsiteurl'] = self.settings['SITEURL']
|
context['localsiteurl'] = self.settings['SITEURL']
|
||||||
|
|
||||||
generators = [
|
generators = [
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,8 @@ class Content(object):
|
||||||
if not hasattr(self, 'status'):
|
if not hasattr(self, 'status'):
|
||||||
self.status = getattr(self, 'default_status', None)
|
self.status = getattr(self, 'default_status', None)
|
||||||
|
|
||||||
if len(self._context.get('filenames', [])) > 0:
|
if (len(self._context.get('generated_content', [])) > 0 or
|
||||||
|
len(self._context.get('static_content', [])) > 0):
|
||||||
self.refresh_metadata_intersite_links()
|
self.refresh_metadata_intersite_links()
|
||||||
|
|
||||||
signals.content_object_init.send(self)
|
signals.content_object_init.send(self)
|
||||||
|
|
@ -255,7 +256,7 @@ class Content(object):
|
||||||
siteurl += '/'
|
siteurl += '/'
|
||||||
|
|
||||||
# XXX Put this in a different location.
|
# XXX Put this in a different location.
|
||||||
if what in {'filename', 'attach'}:
|
if what in {'filename', 'static', 'attach'}:
|
||||||
if path.startswith('/'):
|
if path.startswith('/'):
|
||||||
path = path[1:]
|
path = path[1:]
|
||||||
else:
|
else:
|
||||||
|
|
@ -264,22 +265,33 @@ class Content(object):
|
||||||
os.path.join(self.relative_dir, path)
|
os.path.join(self.relative_dir, path)
|
||||||
)
|
)
|
||||||
|
|
||||||
if path not in self._context['filenames']:
|
key = 'static_content' if what in ('static', 'attach')\
|
||||||
unquoted_path = path.replace('%20', ' ')
|
else 'generated_content'
|
||||||
|
|
||||||
if unquoted_path in self._context['filenames']:
|
def _get_linked_content(key, path):
|
||||||
path = unquoted_path
|
try:
|
||||||
|
return self._context[key][path]
|
||||||
|
except KeyError:
|
||||||
|
try:
|
||||||
|
# Markdown escapes spaces, try unescaping
|
||||||
|
return self._context[key][path.replace('%20', ' ')]
|
||||||
|
except KeyError:
|
||||||
|
if what == 'filename' and key == 'generated_content':
|
||||||
|
key = 'static_content'
|
||||||
|
linked_content = _get_linked_content(key, path)
|
||||||
|
if linked_content:
|
||||||
|
logger.warning(
|
||||||
|
'{filename} used for linking to static'
|
||||||
|
'content %s in %s. Use {static} instead',
|
||||||
|
path,
|
||||||
|
self.get_relative_source_path())
|
||||||
|
return linked_content
|
||||||
|
return None
|
||||||
|
|
||||||
linked_content = self._context['filenames'].get(path)
|
linked_content = _get_linked_content(key, path)
|
||||||
if linked_content:
|
if linked_content:
|
||||||
if what == 'attach':
|
if what == 'attach':
|
||||||
if isinstance(linked_content, Static):
|
linked_content.attach_to(self)
|
||||||
linked_content.attach_to(self)
|
|
||||||
else:
|
|
||||||
logger.warning(
|
|
||||||
"%s used {attach} link syntax on a "
|
|
||||||
"non-static file. Use {filename} instead.",
|
|
||||||
self.get_relative_source_path())
|
|
||||||
origin = joiner(siteurl, linked_content.url)
|
origin = joiner(siteurl, linked_content.url)
|
||||||
origin = origin.replace('\\', '/') # for Windows paths.
|
origin = origin.replace('\\', '/') # for Windows paths.
|
||||||
else:
|
else:
|
||||||
|
|
@ -310,6 +322,17 @@ class Content(object):
|
||||||
return ''.join((m.group('markup'), m.group('quote'), origin,
|
return ''.join((m.group('markup'), m.group('quote'), origin,
|
||||||
m.group('quote')))
|
m.group('quote')))
|
||||||
|
|
||||||
|
def _get_intrasite_link_regex(self):
|
||||||
|
intrasite_link_regex = self.settings['INTRASITE_LINK_REGEX']
|
||||||
|
regex = r"""
|
||||||
|
(?P<markup><[^\>]+ # match tag with all url-value attributes
|
||||||
|
(?:href|src|poster|data|cite|formaction|action)\s*=\s*)
|
||||||
|
|
||||||
|
(?P<quote>["\']) # require value to be quoted
|
||||||
|
(?P<path>{0}(?P<value>.*?)) # the url value
|
||||||
|
\2""".format(intrasite_link_regex)
|
||||||
|
return re.compile(regex, re.X)
|
||||||
|
|
||||||
def _update_content(self, content, siteurl):
|
def _update_content(self, content, siteurl):
|
||||||
"""Update the content attribute.
|
"""Update the content attribute.
|
||||||
|
|
||||||
|
|
@ -323,18 +346,29 @@ class Content(object):
|
||||||
if not content:
|
if not content:
|
||||||
return content
|
return content
|
||||||
|
|
||||||
instrasite_link_regex = self.settings['INTRASITE_LINK_REGEX']
|
hrefs = self._get_intrasite_link_regex()
|
||||||
regex = r"""
|
|
||||||
(?P<markup><[^\>]+ # match tag with all url-value attributes
|
|
||||||
(?:href|src|poster|data|cite|formaction|action)\s*=\s*)
|
|
||||||
|
|
||||||
(?P<quote>["\']) # require value to be quoted
|
|
||||||
(?P<path>{0}(?P<value>.*?)) # the url value
|
|
||||||
\2""".format(instrasite_link_regex)
|
|
||||||
hrefs = re.compile(regex, re.X)
|
|
||||||
|
|
||||||
return hrefs.sub(lambda m: self._link_replacer(siteurl, m), content)
|
return hrefs.sub(lambda m: self._link_replacer(siteurl, m), content)
|
||||||
|
|
||||||
|
def get_static_links(self):
|
||||||
|
static_links = set()
|
||||||
|
hrefs = self._get_intrasite_link_regex()
|
||||||
|
for m in hrefs.finditer(self._content):
|
||||||
|
what = m.group('what')
|
||||||
|
value = urlparse(m.group('value'))
|
||||||
|
path = value.path
|
||||||
|
if what not in {'static', 'attach'}:
|
||||||
|
continue
|
||||||
|
if path.startswith('/'):
|
||||||
|
path = path[1:]
|
||||||
|
else:
|
||||||
|
# relative to the source path of this content
|
||||||
|
path = self.get_relative_source_path(
|
||||||
|
os.path.join(self.relative_dir, path)
|
||||||
|
)
|
||||||
|
path = path.replace('%20', ' ')
|
||||||
|
static_links.add(path)
|
||||||
|
return static_links
|
||||||
|
|
||||||
def get_siteurl(self):
|
def get_siteurl(self):
|
||||||
return self._context.get('localsiteurl', '')
|
return self._context.get('localsiteurl', '')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ class Generator(object):
|
||||||
parent_path, subdir = os.path.split(os.path.join(self.path, e))
|
parent_path, subdir = os.path.split(os.path.join(self.path, e))
|
||||||
exclusions_by_dirpath.setdefault(parent_path, set()).add(subdir)
|
exclusions_by_dirpath.setdefault(parent_path, set()).add(subdir)
|
||||||
|
|
||||||
files = []
|
files = set()
|
||||||
ignores = self.settings['IGNORE_FILES']
|
ignores = self.settings['IGNORE_FILES']
|
||||||
for path in paths:
|
for path in paths:
|
||||||
# careful: os.path.join() will add a slash when path == ''.
|
# careful: os.path.join() will add a slash when path == ''.
|
||||||
|
|
@ -170,33 +170,41 @@ class Generator(object):
|
||||||
for f in temp_files:
|
for f in temp_files:
|
||||||
fp = os.path.join(reldir, f)
|
fp = os.path.join(reldir, f)
|
||||||
if self._include_path(fp, extensions):
|
if self._include_path(fp, extensions):
|
||||||
files.append(fp)
|
files.add(fp)
|
||||||
elif os.path.exists(root) and self._include_path(path, extensions):
|
elif os.path.exists(root) and self._include_path(path, extensions):
|
||||||
files.append(path) # can't walk non-directories
|
files.add(path) # can't walk non-directories
|
||||||
return files
|
return files
|
||||||
|
|
||||||
def add_source_path(self, content):
|
def add_source_path(self, content, static=False):
|
||||||
"""Record a source file path that a Generator found and processed.
|
"""Record a source file path that a Generator found and processed.
|
||||||
Store a reference to its Content object, for url lookups later.
|
Store a reference to its Content object, for url lookups later.
|
||||||
"""
|
"""
|
||||||
location = content.get_relative_source_path()
|
location = content.get_relative_source_path()
|
||||||
self.context['filenames'][location] = content
|
key = 'static_content' if static else 'generated_content'
|
||||||
|
self.context[key][location] = content
|
||||||
|
|
||||||
def _add_failed_source_path(self, path):
|
def _add_failed_source_path(self, path, static=False):
|
||||||
"""Record a source file path that a Generator failed to process.
|
"""Record a source file path that a Generator failed to process.
|
||||||
(For example, one that was missing mandatory metadata.)
|
(For example, one that was missing mandatory metadata.)
|
||||||
The path argument is expected to be relative to self.path.
|
The path argument is expected to be relative to self.path.
|
||||||
"""
|
"""
|
||||||
self.context['filenames'][posixize_path(os.path.normpath(path))] = None
|
key = 'static_content' if static else 'generated_content'
|
||||||
|
self.context[key][posixize_path(os.path.normpath(path))] = None
|
||||||
|
|
||||||
def _is_potential_source_path(self, path):
|
def _is_potential_source_path(self, path, static=False):
|
||||||
"""Return True if path was supposed to be used as a source file.
|
"""Return True if path was supposed to be used as a source file.
|
||||||
(This includes all source files that have been found by generators
|
(This includes all source files that have been found by generators
|
||||||
before this method is called, even if they failed to process.)
|
before this method is called, even if they failed to process.)
|
||||||
The path argument is expected to be relative to self.path.
|
The path argument is expected to be relative to self.path.
|
||||||
"""
|
"""
|
||||||
return (posixize_path(os.path.normpath(path))
|
key = 'static_content' if static else 'generated_content'
|
||||||
in self.context['filenames'])
|
return (posixize_path(os.path.normpath(path)) in self.context[key])
|
||||||
|
|
||||||
|
def add_static_links(self, content):
|
||||||
|
"""Add file links in content to context to be processed as Static
|
||||||
|
content.
|
||||||
|
"""
|
||||||
|
self.context['static_links'] |= content.get_static_links()
|
||||||
|
|
||||||
def _update_context(self, items):
|
def _update_context(self, items):
|
||||||
"""Update the context with the given items from the currrent
|
"""Update the context with the given items from the currrent
|
||||||
|
|
@ -294,17 +302,21 @@ class ArticlesGenerator(CachingGenerator):
|
||||||
"""Generate the feeds from the current context, and output files."""
|
"""Generate the feeds from the current context, and output files."""
|
||||||
|
|
||||||
if self.settings.get('FEED_ATOM'):
|
if self.settings.get('FEED_ATOM'):
|
||||||
writer.write_feed(self.articles, self.context,
|
writer.write_feed(
|
||||||
self.settings['FEED_ATOM'],
|
self.articles,
|
||||||
self.settings.get('FEED_ATOM_URL',
|
self.context,
|
||||||
self.settings['FEED_ATOM']))
|
self.settings['FEED_ATOM'],
|
||||||
|
self.settings.get('FEED_ATOM_URL', self.settings['FEED_ATOM'])
|
||||||
|
)
|
||||||
|
|
||||||
if self.settings.get('FEED_RSS'):
|
if self.settings.get('FEED_RSS'):
|
||||||
writer.write_feed(self.articles, self.context,
|
writer.write_feed(
|
||||||
self.settings['FEED_RSS'],
|
self.articles,
|
||||||
self.settings.get('FEED_RSS_URL',
|
self.context,
|
||||||
self.settings['FEED_RSS']),
|
self.settings['FEED_RSS'],
|
||||||
feed_type='rss')
|
self.settings.get('FEED_RSS_URL', self.settings['FEED_RSS']),
|
||||||
|
feed_type='rss'
|
||||||
|
)
|
||||||
|
|
||||||
if (self.settings.get('FEED_ALL_ATOM') or
|
if (self.settings.get('FEED_ALL_ATOM') or
|
||||||
self.settings.get('FEED_ALL_RSS')):
|
self.settings.get('FEED_ALL_RSS')):
|
||||||
|
|
@ -315,80 +327,105 @@ class ArticlesGenerator(CachingGenerator):
|
||||||
order_by=self.settings['ARTICLE_ORDER_BY'])
|
order_by=self.settings['ARTICLE_ORDER_BY'])
|
||||||
|
|
||||||
if self.settings.get('FEED_ALL_ATOM'):
|
if self.settings.get('FEED_ALL_ATOM'):
|
||||||
writer.write_feed(all_articles, self.context,
|
writer.write_feed(
|
||||||
self.settings['FEED_ALL_ATOM'],
|
all_articles,
|
||||||
self.settings.get(
|
self.context,
|
||||||
'FEED_ALL_ATOM_URL',
|
self.settings['FEED_ALL_ATOM'],
|
||||||
self.settings['FEED_ALL_ATOM']))
|
self.settings.get('FEED_ALL_ATOM_URL',
|
||||||
|
self.settings['FEED_ALL_ATOM'])
|
||||||
|
)
|
||||||
|
|
||||||
if self.settings.get('FEED_ALL_RSS'):
|
if self.settings.get('FEED_ALL_RSS'):
|
||||||
writer.write_feed(all_articles, self.context,
|
writer.write_feed(
|
||||||
self.settings['FEED_ALL_RSS'],
|
all_articles,
|
||||||
self.settings.get(
|
self.context,
|
||||||
'FEED_ALL_RSS_URL',
|
self.settings['FEED_ALL_RSS'],
|
||||||
|
self.settings.get('FEED_ALL_RSS_URL',
|
||||||
self.settings['FEED_ALL_RSS']),
|
self.settings['FEED_ALL_RSS']),
|
||||||
feed_type='rss')
|
feed_type='rss'
|
||||||
|
)
|
||||||
|
|
||||||
for cat, arts in self.categories:
|
for cat, arts in self.categories:
|
||||||
if self.settings.get('CATEGORY_FEED_ATOM'):
|
if self.settings.get('CATEGORY_FEED_ATOM'):
|
||||||
writer.write_feed(arts, self.context,
|
writer.write_feed(
|
||||||
self.settings['CATEGORY_FEED_ATOM']
|
arts,
|
||||||
% cat.slug,
|
self.context,
|
||||||
self.settings.get(
|
self.settings['CATEGORY_FEED_ATOM'].format(slug=cat.slug),
|
||||||
'CATEGORY_FEED_ATOM_URL',
|
self.settings.get(
|
||||||
self.settings['CATEGORY_FEED_ATOM'])
|
'CATEGORY_FEED_ATOM_URL',
|
||||||
% cat.slug, feed_title=cat.name)
|
self.settings['CATEGORY_FEED_ATOM']).format(
|
||||||
|
slug=cat.slug
|
||||||
|
),
|
||||||
|
feed_title=cat.name
|
||||||
|
)
|
||||||
|
|
||||||
if self.settings.get('CATEGORY_FEED_RSS'):
|
if self.settings.get('CATEGORY_FEED_RSS'):
|
||||||
writer.write_feed(arts, self.context,
|
writer.write_feed(
|
||||||
self.settings['CATEGORY_FEED_RSS']
|
arts,
|
||||||
% cat.slug,
|
self.context,
|
||||||
self.settings.get(
|
self.settings['CATEGORY_FEED_RSS'].format(slug=cat.slug),
|
||||||
'CATEGORY_FEED_RSS_URL',
|
self.settings.get(
|
||||||
self.settings['CATEGORY_FEED_RSS'])
|
'CATEGORY_FEED_RSS_URL',
|
||||||
% cat.slug, feed_title=cat.name,
|
self.settings['CATEGORY_FEED_RSS']).format(
|
||||||
feed_type='rss')
|
slug=cat.slug
|
||||||
|
),
|
||||||
|
feed_title=cat.name,
|
||||||
|
feed_type='rss'
|
||||||
|
)
|
||||||
|
|
||||||
for auth, arts in self.authors:
|
for auth, arts in self.authors:
|
||||||
if self.settings.get('AUTHOR_FEED_ATOM'):
|
if self.settings.get('AUTHOR_FEED_ATOM'):
|
||||||
writer.write_feed(arts, self.context,
|
writer.write_feed(
|
||||||
self.settings['AUTHOR_FEED_ATOM']
|
arts,
|
||||||
% auth.slug,
|
self.context,
|
||||||
self.settings.get(
|
self.settings['AUTHOR_FEED_ATOM'].format(slug=auth.slug),
|
||||||
'AUTHOR_FEED_ATOM_URL',
|
self.settings.get(
|
||||||
self.settings['AUTHOR_FEED_ATOM'])
|
'AUTHOR_FEED_ATOM_URL',
|
||||||
% auth.slug, feed_title=auth.name)
|
self.settings['AUTHOR_FEED_ATOM']
|
||||||
|
).format(slug=auth.slug),
|
||||||
|
feed_title=auth.name
|
||||||
|
)
|
||||||
|
|
||||||
if self.settings.get('AUTHOR_FEED_RSS'):
|
if self.settings.get('AUTHOR_FEED_RSS'):
|
||||||
writer.write_feed(arts, self.context,
|
writer.write_feed(
|
||||||
self.settings['AUTHOR_FEED_RSS']
|
arts,
|
||||||
% auth.slug,
|
self.context,
|
||||||
self.settings.get(
|
self.settings['AUTHOR_FEED_RSS'].format(slug=auth.slug),
|
||||||
'AUTHOR_FEED_RSS_URL',
|
self.settings.get(
|
||||||
self.settings['AUTHOR_FEED_RSS'])
|
'AUTHOR_FEED_RSS_URL',
|
||||||
% auth.slug, feed_title=auth.name,
|
self.settings['AUTHOR_FEED_RSS']
|
||||||
feed_type='rss')
|
).format(slug=auth.slug),
|
||||||
|
feed_title=auth.name,
|
||||||
|
feed_type='rss'
|
||||||
|
)
|
||||||
|
|
||||||
if (self.settings.get('TAG_FEED_ATOM') or
|
if (self.settings.get('TAG_FEED_ATOM') or
|
||||||
self.settings.get('TAG_FEED_RSS')):
|
self.settings.get('TAG_FEED_RSS')):
|
||||||
for tag, arts in self.tags.items():
|
for tag, arts in self.tags.items():
|
||||||
if self.settings.get('TAG_FEED_ATOM'):
|
if self.settings.get('TAG_FEED_ATOM'):
|
||||||
writer.write_feed(arts, self.context,
|
writer.write_feed(
|
||||||
self.settings['TAG_FEED_ATOM']
|
arts,
|
||||||
% tag.slug,
|
self.context,
|
||||||
self.settings.get(
|
self.settings['TAG_FEED_ATOM'].format(slug=tag.slug),
|
||||||
'TAG_FEED_ATOM_URL',
|
self.settings.get(
|
||||||
self.settings['TAG_FEED_ATOM'])
|
'TAG_FEED_ATOM_URL',
|
||||||
% tag.slug, feed_title=tag.name)
|
self.settings['TAG_FEED_ATOM']
|
||||||
|
).format(slug=tag.slug),
|
||||||
|
feed_title=tag.name
|
||||||
|
)
|
||||||
|
|
||||||
if self.settings.get('TAG_FEED_RSS'):
|
if self.settings.get('TAG_FEED_RSS'):
|
||||||
writer.write_feed(arts, self.context,
|
writer.write_feed(
|
||||||
self.settings['TAG_FEED_RSS'] % tag.slug,
|
arts,
|
||||||
self.settings.get(
|
self.context,
|
||||||
'TAG_FEED_RSS_URL',
|
self.settings['TAG_FEED_RSS'].format(slug=tag.slug),
|
||||||
self.settings['TAG_FEED_RSS'])
|
self.settings.get(
|
||||||
% tag.slug, feed_title=tag.name,
|
'TAG_FEED_RSS_URL',
|
||||||
feed_type='rss')
|
self.settings['TAG_FEED_RSS']
|
||||||
|
).format(slug=tag.slug),
|
||||||
|
feed_title=tag.name,
|
||||||
|
feed_type='rss'
|
||||||
|
)
|
||||||
|
|
||||||
if (self.settings.get('TRANSLATION_FEED_ATOM') or
|
if (self.settings.get('TRANSLATION_FEED_ATOM') or
|
||||||
self.settings.get('TRANSLATION_FEED_RSS')):
|
self.settings.get('TRANSLATION_FEED_RSS')):
|
||||||
|
|
@ -401,19 +438,27 @@ class ArticlesGenerator(CachingGenerator):
|
||||||
items, order_by=self.settings['ARTICLE_ORDER_BY'])
|
items, order_by=self.settings['ARTICLE_ORDER_BY'])
|
||||||
if self.settings.get('TRANSLATION_FEED_ATOM'):
|
if self.settings.get('TRANSLATION_FEED_ATOM'):
|
||||||
writer.write_feed(
|
writer.write_feed(
|
||||||
items, self.context,
|
items,
|
||||||
self.settings['TRANSLATION_FEED_ATOM'] % lang,
|
self.context,
|
||||||
|
self.settings['TRANSLATION_FEED_ATOM']
|
||||||
|
.format(lang=lang),
|
||||||
self.settings.get(
|
self.settings.get(
|
||||||
'TRANSLATION_FEED_ATOM_URL',
|
'TRANSLATION_FEED_ATOM_URL',
|
||||||
self.settings['TRANSLATION_FEED_ATOM']) % lang)
|
self.settings['TRANSLATION_FEED_ATOM']
|
||||||
|
).format(lang=lang),
|
||||||
|
)
|
||||||
if self.settings.get('TRANSLATION_FEED_RSS'):
|
if self.settings.get('TRANSLATION_FEED_RSS'):
|
||||||
writer.write_feed(
|
writer.write_feed(
|
||||||
items, self.context,
|
items,
|
||||||
self.settings['TRANSLATION_FEED_RSS'] % lang,
|
self.context,
|
||||||
|
self.settings['TRANSLATION_FEED_RSS']
|
||||||
|
.format(lang=lang),
|
||||||
self.settings.get(
|
self.settings.get(
|
||||||
'TRANSLATION_FEED_RSS_URL',
|
'TRANSLATION_FEED_RSS_URL',
|
||||||
self.settings['TRANSLATION_FEED_RSS']) % lang,
|
self.settings['TRANSLATION_FEED_RSS']
|
||||||
feed_type='rss')
|
).format(lang=lang),
|
||||||
|
feed_type='rss'
|
||||||
|
)
|
||||||
|
|
||||||
def generate_articles(self, write):
|
def generate_articles(self, write):
|
||||||
"""Generate the articles."""
|
"""Generate the articles."""
|
||||||
|
|
@ -596,6 +641,7 @@ class ArticlesGenerator(CachingGenerator):
|
||||||
elif article.status == "draft":
|
elif article.status == "draft":
|
||||||
all_drafts.append(article)
|
all_drafts.append(article)
|
||||||
self.add_source_path(article)
|
self.add_source_path(article)
|
||||||
|
self.add_static_links(article)
|
||||||
|
|
||||||
def _process(arts):
|
def _process(arts):
|
||||||
origs, translations = process_translations(
|
origs, translations = process_translations(
|
||||||
|
|
@ -702,6 +748,7 @@ class PagesGenerator(CachingGenerator):
|
||||||
elif page.status == "draft":
|
elif page.status == "draft":
|
||||||
draft_pages.append(page)
|
draft_pages.append(page)
|
||||||
self.add_source_path(page)
|
self.add_source_path(page)
|
||||||
|
self.add_static_links(page)
|
||||||
|
|
||||||
def _process(pages):
|
def _process(pages):
|
||||||
origs, translations = process_translations(
|
origs, translations = process_translations(
|
||||||
|
|
@ -753,9 +800,12 @@ class StaticGenerator(Generator):
|
||||||
|
|
||||||
def generate_context(self):
|
def generate_context(self):
|
||||||
self.staticfiles = []
|
self.staticfiles = []
|
||||||
for f in self.get_files(self.settings['STATIC_PATHS'],
|
linked_files = {os.path.join(self.path, path)
|
||||||
exclude=self.settings['STATIC_EXCLUDES'],
|
for path in self.context['static_links']}
|
||||||
extensions=False):
|
found_files = self.get_files(self.settings['STATIC_PATHS'],
|
||||||
|
exclude=self.settings['STATIC_EXCLUDES'],
|
||||||
|
extensions=False)
|
||||||
|
for f in linked_files | found_files:
|
||||||
|
|
||||||
# skip content source files unless the user explicitly wants them
|
# skip content source files unless the user explicitly wants them
|
||||||
if self.settings['STATIC_EXCLUDE_SOURCES']:
|
if self.settings['STATIC_EXCLUDE_SOURCES']:
|
||||||
|
|
@ -770,7 +820,7 @@ class StaticGenerator(Generator):
|
||||||
context_signal=signals.static_generator_context,
|
context_signal=signals.static_generator_context,
|
||||||
context_sender=self)
|
context_sender=self)
|
||||||
self.staticfiles.append(static)
|
self.staticfiles.append(static)
|
||||||
self.add_source_path(static)
|
self.add_source_path(static, static=True)
|
||||||
self._update_context(('staticfiles',))
|
self._update_context(('staticfiles',))
|
||||||
signals.static_generator_finalized.send(self)
|
signals.static_generator_finalized.send(self)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ class BaseFormatter(logging.Formatter):
|
||||||
record.__dict__['customlevelname'] = customlevel
|
record.__dict__['customlevelname'] = customlevel
|
||||||
# format multiline messages 'nicely' to make it clear they are together
|
# format multiline messages 'nicely' to make it clear they are together
|
||||||
record.msg = record.msg.replace('\n', '\n | ')
|
record.msg = record.msg.replace('\n', '\n | ')
|
||||||
|
record.args = tuple(arg.replace('\n', '\n | ') if
|
||||||
|
isinstance(arg, six.string_types) else
|
||||||
|
arg for arg in record.args)
|
||||||
return super(BaseFormatter, self).format(record)
|
return super(BaseFormatter, self).format(record)
|
||||||
|
|
||||||
def formatException(self, ei):
|
def formatException(self, ei):
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import docutils.io
|
||||||
from docutils.writers.html4css1 import HTMLTranslator, Writer
|
from docutils.writers.html4css1 import HTMLTranslator, Writer
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
from six import StringIO
|
||||||
from six.moves.html_parser import HTMLParser
|
from six.moves.html_parser import HTMLParser
|
||||||
|
|
||||||
from pelican import rstdirectives # NOQA
|
from pelican import rstdirectives # NOQA
|
||||||
|
|
@ -256,7 +257,9 @@ class RstReader(BaseReader):
|
||||||
'syntax_highlight': 'short',
|
'syntax_highlight': 'short',
|
||||||
'input_encoding': 'utf-8',
|
'input_encoding': 'utf-8',
|
||||||
'language_code': self.settings.get('DEFAULT_LANG'),
|
'language_code': self.settings.get('DEFAULT_LANG'),
|
||||||
'exit_status_level': 2,
|
'halt_level': 2,
|
||||||
|
'traceback': True,
|
||||||
|
'warning_stream': StringIO(),
|
||||||
'embed_stylesheet': False}
|
'embed_stylesheet': False}
|
||||||
user_params = self.settings.get('DOCUTILS_SETTINGS')
|
user_params = self.settings.get('DOCUTILS_SETTINGS')
|
||||||
if user_params:
|
if user_params:
|
||||||
|
|
@ -269,7 +272,7 @@ class RstReader(BaseReader):
|
||||||
pub.set_components('standalone', 'restructuredtext', 'html')
|
pub.set_components('standalone', 'restructuredtext', 'html')
|
||||||
pub.process_programmatic_settings(None, extra_params, None)
|
pub.process_programmatic_settings(None, extra_params, None)
|
||||||
pub.set_source(source_path=source_path)
|
pub.set_source(source_path=source_path)
|
||||||
pub.publish(enable_exit_status=True)
|
pub.publish()
|
||||||
return pub
|
return pub
|
||||||
|
|
||||||
def read(self, source_path):
|
def read(self, source_path):
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,10 @@ DEFAULT_CONFIG = {
|
||||||
'THEME_STATIC_DIR': 'theme',
|
'THEME_STATIC_DIR': 'theme',
|
||||||
'THEME_STATIC_PATHS': ['static', ],
|
'THEME_STATIC_PATHS': ['static', ],
|
||||||
'FEED_ALL_ATOM': posix_join('feeds', 'all.atom.xml'),
|
'FEED_ALL_ATOM': posix_join('feeds', 'all.atom.xml'),
|
||||||
'CATEGORY_FEED_ATOM': posix_join('feeds', '%s.atom.xml'),
|
'CATEGORY_FEED_ATOM': posix_join('feeds', '{slug}.atom.xml'),
|
||||||
'AUTHOR_FEED_ATOM': posix_join('feeds', '%s.atom.xml'),
|
'AUTHOR_FEED_ATOM': posix_join('feeds', '{slug}.atom.xml'),
|
||||||
'AUTHOR_FEED_RSS': posix_join('feeds', '%s.rss.xml'),
|
'AUTHOR_FEED_RSS': posix_join('feeds', '{slug}.rss.xml'),
|
||||||
'TRANSLATION_FEED_ATOM': posix_join('feeds', 'all-%s.atom.xml'),
|
'TRANSLATION_FEED_ATOM': posix_join('feeds', 'all-{lang}.atom.xml'),
|
||||||
'FEED_MAX_ITEMS': '',
|
'FEED_MAX_ITEMS': '',
|
||||||
'RSS_FEED_SUMMARY_ONLY': True,
|
'RSS_FEED_SUMMARY_ONLY': True,
|
||||||
'SITEURL': '',
|
'SITEURL': '',
|
||||||
|
|
@ -385,6 +385,26 @@ def handle_deprecated_settings(settings):
|
||||||
settings[f + '_REGEX_SUBSTITUTIONS'] = regex_subs
|
settings[f + '_REGEX_SUBSTITUTIONS'] = regex_subs
|
||||||
settings.pop(f + '_SUBSTITUTIONS', None)
|
settings.pop(f + '_SUBSTITUTIONS', None)
|
||||||
|
|
||||||
|
# `%s` -> '{slug}` or `{lang}` in FEED settings
|
||||||
|
for key in ['TRANSLATION_FEED_ATOM',
|
||||||
|
'TRANSLATION_FEED_RSS'
|
||||||
|
]:
|
||||||
|
if key in settings and '%s' in settings[key]:
|
||||||
|
logger.warning('%%s usage in %s is deprecated, use {lang} '
|
||||||
|
'instead. Falling back to default.', key)
|
||||||
|
settings[key] = DEFAULT_CONFIG[key]
|
||||||
|
for key in ['AUTHOR_FEED_ATOM',
|
||||||
|
'AUTHOR_FEED_RSS',
|
||||||
|
'CATEGORY_FEED_ATOM',
|
||||||
|
'CATEGORY_FEED_RSS',
|
||||||
|
'TAG_FEED_ATOM',
|
||||||
|
'TAG_FEED_RSS',
|
||||||
|
]:
|
||||||
|
if key in settings and '%s' in settings[key]:
|
||||||
|
logger.warning('%%s usage in %s is deprecated, use {slug} '
|
||||||
|
'instead. Falling back to default.', key)
|
||||||
|
settings[key] = DEFAULT_CONFIG[key]
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
7
pelican/tests/TestPages/page_with_static_links.md
Normal file
7
pelican/tests/TestPages/page_with_static_links.md
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
Title: Page with static links
|
||||||
|
|
||||||
|
My links:
|
||||||
|
|
||||||
|
[Link 0]({static}image0.jpg)
|
||||||
|
|
||||||
|
[Link 1]({attach}image1.jpg)
|
||||||
|
|
@ -12,7 +12,7 @@ REVERSE_CATEGORY_ORDER = True
|
||||||
DEFAULT_PAGINATION = 2
|
DEFAULT_PAGINATION = 2
|
||||||
|
|
||||||
FEED_RSS = 'feeds/all.rss.xml'
|
FEED_RSS = 'feeds/all.rss.xml'
|
||||||
CATEGORY_FEED_RSS = 'feeds/%s.rss.xml'
|
CATEGORY_FEED_RSS = 'feeds/{slug}.rss.xml'
|
||||||
|
|
||||||
LINKS = (('Biologeek', 'http://biologeek.org'),
|
LINKS = (('Biologeek', 'http://biologeek.org'),
|
||||||
('Filyb', "http://filyb.info/"),
|
('Filyb', "http://filyb.info/"),
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@
|
||||||
<div class="section" id="this-is-a-simple-title">
|
<div class="section" id="this-is-a-simple-title">
|
||||||
<h2>This is a simple title</h2>
|
<h2>This is a simple title</h2>
|
||||||
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
>>> from ipdb import set_trace
|
>>> from ipdb import set_trace
|
||||||
>>> set_trace()
|
>>> set_trace()
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="readmore" href="/oh-yeah.html">read more</a>
|
<a class="readmore" href="/oh-yeah.html">read more</a>
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</aside><!-- /#featured -->
|
</aside><!-- /#featured -->
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@
|
||||||
<div class="section" id="this-is-a-simple-title">
|
<div class="section" id="this-is-a-simple-title">
|
||||||
<h2>This is a simple title</h2>
|
<h2>This is a simple title</h2>
|
||||||
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
>>> from ipdb import set_trace
|
>>> from ipdb import set_trace
|
||||||
>>> set_trace()
|
>>> set_trace()
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<div class="section" id="this-is-a-simple-title">
|
<div class="section" id="this-is-a-simple-title">
|
||||||
<h2>This is a simple title</h2>
|
<h2>This is a simple title</h2>
|
||||||
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
&gt;&gt;&gt; from ipdb import set_trace
|
&gt;&gt;&gt; from ipdb import set_trace
|
||||||
&gt;&gt;&gt; set_trace()
|
&gt;&gt;&gt; set_trace()
|
||||||
|
|
@ -17,12 +17,12 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</summary><content type="html"><div class="section" id="why-not">
|
</summary><content type="html"><div class="section" id="why-not">
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</content><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry></feed>
|
</content><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry></feed>
|
||||||
|
|
@ -5,6 +5,6 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Wed, 20 Oct 2010 10:14:00 +0000</pubDate><guid isPermaLink="false">tag:None,2010-10-20:/oh-yeah.html</guid><category>oh</category><category>bar</category><category>yeah</category></item></channel></rss>
|
</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexis Métaireau</dc:creator><pubDate>Wed, 20 Oct 2010 10:14:00 +0000</pubDate><guid isPermaLink="false">tag:None,2010-10-20:/oh-yeah.html</guid><category>oh</category><category>bar</category><category>yeah</category></item></channel></rss>
|
||||||
|
|
@ -19,8 +19,8 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<div class="section" id="this-is-a-simple-title">
|
<div class="section" id="this-is-a-simple-title">
|
||||||
<h2>This is a simple title</h2>
|
<h2>This is a simple title</h2>
|
||||||
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
&gt;&gt;&gt; from ipdb import set_trace
|
&gt;&gt;&gt; from ipdb import set_trace
|
||||||
&gt;&gt;&gt; set_trace()
|
&gt;&gt;&gt; set_trace()
|
||||||
|
|
@ -31,13 +31,13 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</summary><content type="html"><div class="section" id="why-not">
|
</summary><content type="html"><div class="section" id="why-not">
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</content><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry><entry><title>Unbelievable !</title><link href="/unbelievable.html" rel="alternate"></link><published>2010-10-15T20:30:00+00:00</published><updated>2010-10-15T20:30:00+00:00</updated><author><name></name></author><id>tag:None,2010-10-15:/unbelievable.html</id><summary type="html"><p>Or completely awesome. Depends the needs.</p>
|
</content><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry><entry><title>Unbelievable !</title><link href="/unbelievable.html" rel="alternate"></link><published>2010-10-15T20:30:00+00:00</published><updated>2010-10-15T20:30:00+00:00</updated><author><name></name></author><id>tag:None,2010-10-15:/unbelievable.html</id><summary type="html"><p>Or completely awesome. Depends the needs.</p>
|
||||||
<p><a class="reference external" href="/a-markdown-powered-article.html">a root-relative link to markdown-article</a>
|
<p><a class="reference external" href="/a-markdown-powered-article.html">a root-relative link to markdown-article</a>
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<div class="section" id="this-is-a-simple-title">
|
<div class="section" id="this-is-a-simple-title">
|
||||||
<h2>This is a simple title</h2>
|
<h2>This is a simple title</h2>
|
||||||
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
&gt;&gt;&gt; from ipdb import set_trace
|
&gt;&gt;&gt; from ipdb import set_trace
|
||||||
&gt;&gt;&gt; set_trace()
|
&gt;&gt;&gt; set_trace()
|
||||||
|
|
@ -33,13 +33,13 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</summary><content type="html"><div class="section" id="why-not">
|
</summary><content type="html"><div class="section" id="why-not">
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</content><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry><entry><title>Unbelievable !</title><link href="/unbelievable.html" rel="alternate"></link><published>2010-10-15T20:30:00+00:00</published><updated>2010-10-15T20:30:00+00:00</updated><author><name></name></author><id>tag:None,2010-10-15:/unbelievable.html</id><summary type="html"><p>Or completely awesome. Depends the needs.</p>
|
</content><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry><entry><title>Unbelievable !</title><link href="/unbelievable.html" rel="alternate"></link><published>2010-10-15T20:30:00+00:00</published><updated>2010-10-15T20:30:00+00:00</updated><author><name></name></author><id>tag:None,2010-10-15:/unbelievable.html</id><summary type="html"><p>Or completely awesome. Depends the needs.</p>
|
||||||
<p><a class="reference external" href="/a-markdown-powered-article.html">a root-relative link to markdown-article</a>
|
<p><a class="reference external" href="/a-markdown-powered-article.html">a root-relative link to markdown-article</a>
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</summary><content type="html"><div class="section" id="why-not">
|
</summary><content type="html"><div class="section" id="why-not">
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</content><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry></feed>
|
</content><category term="oh"></category><category term="bar"></category><category term="yeah"></category></entry></feed>
|
||||||
|
|
@ -5,8 +5,8 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<div class="section" id="this-is-a-simple-title">
|
<div class="section" id="this-is-a-simple-title">
|
||||||
<h2>This is a simple title</h2>
|
<h2>This is a simple title</h2>
|
||||||
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
&gt;&gt;&gt; from ipdb import set_trace
|
&gt;&gt;&gt; from ipdb import set_trace
|
||||||
&gt;&gt;&gt; set_trace()
|
&gt;&gt;&gt; set_trace()
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="readmore" href="/oh-yeah.html">read more</a>
|
<a class="readmore" href="/oh-yeah.html">read more</a>
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div><!-- /.entry-content -->
|
</div><!-- /.entry-content -->
|
||||||
|
|
|
||||||
BIN
pelican/tests/output/basic/pictures/Sushi.jpg
Normal file
BIN
pelican/tests/output/basic/pictures/Sushi.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
pelican/tests/output/basic/pictures/Sushi_Macro.jpg
Normal file
BIN
pelican/tests/output/basic/pictures/Sushi_Macro.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
|
|
@ -90,7 +90,7 @@ as well as <strong>inline markup</strong>.</p>
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="readmore" href="/oh-yeah.html">read more</a>
|
<a class="readmore" href="/oh-yeah.html">read more</a>
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@
|
||||||
<div class="section" id="this-is-a-simple-title">
|
<div class="section" id="this-is-a-simple-title">
|
||||||
<h2>This is a simple title</h2>
|
<h2>This is a simple title</h2>
|
||||||
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
>>> from ipdb import set_trace
|
>>> from ipdb import set_trace
|
||||||
>>> set_trace()
|
>>> set_trace()
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
<h2>Why not ?</h2>
|
<h2>Why not ?</h2>
|
||||||
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
<p>After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !</p>
|
YEAH !</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</aside><!-- /#featured -->
|
</aside><!-- /#featured -->
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@
|
||||||
<div class="section" id="this-is-a-simple-title">
|
<div class="section" id="this-is-a-simple-title">
|
||||||
<h2>This is a simple title</h2>
|
<h2>This is a simple title</h2>
|
||||||
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
<p>And here comes the cool <a class="reference external" href="http://books.couchdb.org/relax/design-documents/views">stuff</a>.</p>
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" />
|
||||||
<img alt="alternate text" src="|filename|/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
<img alt="alternate text" src="/pictures/Sushi_Macro.jpg" style="width: 600px; height: 450px;" />
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
>>> from ipdb import set_trace
|
>>> from ipdb import set_trace
|
||||||
>>> set_trace()
|
>>> set_trace()
|
||||||
|
|
|
||||||
4
pelican/tests/parse_error/parse_error.rst
Normal file
4
pelican/tests/parse_error/parse_error.rst
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
Page with a parse error
|
||||||
|
#############
|
||||||
|
|
||||||
|
The underline is too short.
|
||||||
|
|
@ -175,6 +175,15 @@ def get_settings(**kwargs):
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
def get_context(settings=None, **kwargs):
|
||||||
|
context = settings.copy() if settings else {}
|
||||||
|
context['generated_content'] = {}
|
||||||
|
context['static_links'] = set()
|
||||||
|
context['static_content'] = {}
|
||||||
|
context.update(kwargs)
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
class LogCountHandler(BufferingHandler):
|
class LogCountHandler(BufferingHandler):
|
||||||
"""Capturing and counting logged messages."""
|
"""Capturing and counting logged messages."""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ from shutil import rmtree
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
|
|
||||||
from pelican.generators import ArticlesGenerator, PagesGenerator
|
from pelican.generators import ArticlesGenerator, PagesGenerator
|
||||||
from pelican.tests.support import get_settings, unittest
|
from pelican.tests.support import get_context, get_settings, unittest
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
@ -29,7 +29,7 @@ class TestCache(unittest.TestCase):
|
||||||
rmtree(self.temp_cache)
|
rmtree(self.temp_cache)
|
||||||
|
|
||||||
def _get_cache_enabled_settings(self):
|
def _get_cache_enabled_settings(self):
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['CACHE_CONTENT'] = True
|
settings['CACHE_CONTENT'] = True
|
||||||
settings['LOAD_CONTENT_CACHE'] = True
|
settings['LOAD_CONTENT_CACHE'] = True
|
||||||
settings['CACHE_PATH'] = self.temp_cache
|
settings['CACHE_PATH'] = self.temp_cache
|
||||||
|
|
@ -42,20 +42,21 @@ class TestCache(unittest.TestCase):
|
||||||
settings['PAGE_PATHS'] = ['TestPages']
|
settings['PAGE_PATHS'] = ['TestPages']
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
def sorted_titles(items):
|
def sorted_titles(items):
|
||||||
return sorted(item.title for item in items)
|
return sorted(item.title for item in items)
|
||||||
|
|
||||||
# Articles
|
# Articles
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
uncached_articles = sorted_titles(generator.articles)
|
uncached_articles = sorted_titles(generator.articles)
|
||||||
uncached_drafts = sorted_titles(generator.drafts)
|
uncached_drafts = sorted_titles(generator.drafts)
|
||||||
|
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
cached_articles = sorted_titles(generator.articles)
|
cached_articles = sorted_titles(generator.articles)
|
||||||
|
|
@ -66,7 +67,7 @@ class TestCache(unittest.TestCase):
|
||||||
|
|
||||||
# Pages
|
# Pages
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
uncached_pages = sorted_titles(generator.pages)
|
uncached_pages = sorted_titles(generator.pages)
|
||||||
|
|
@ -74,7 +75,7 @@ class TestCache(unittest.TestCase):
|
||||||
uncached_draft_pages = sorted_titles(generator.draft_pages)
|
uncached_draft_pages = sorted_titles(generator.draft_pages)
|
||||||
|
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
cached_pages = sorted_titles(generator.pages)
|
cached_pages = sorted_titles(generator.pages)
|
||||||
|
|
@ -92,20 +93,21 @@ class TestCache(unittest.TestCase):
|
||||||
settings['PAGE_PATHS'] = ['TestPages']
|
settings['PAGE_PATHS'] = ['TestPages']
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
def sorted_titles(items):
|
def sorted_titles(items):
|
||||||
return sorted(item.title for item in items)
|
return sorted(item.title for item in items)
|
||||||
|
|
||||||
# Articles
|
# Articles
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
uncached_articles = sorted_titles(generator.articles)
|
uncached_articles = sorted_titles(generator.articles)
|
||||||
uncached_drafts = sorted_titles(generator.drafts)
|
uncached_drafts = sorted_titles(generator.drafts)
|
||||||
|
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
cached_articles = sorted_titles(generator.articles)
|
cached_articles = sorted_titles(generator.articles)
|
||||||
|
|
@ -116,14 +118,14 @@ class TestCache(unittest.TestCase):
|
||||||
|
|
||||||
# Pages
|
# Pages
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
uncached_pages = sorted_titles(generator.pages)
|
uncached_pages = sorted_titles(generator.pages)
|
||||||
uncached_hidden_pages = sorted_titles(generator.hidden_pages)
|
uncached_hidden_pages = sorted_titles(generator.hidden_pages)
|
||||||
|
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
cached_pages = sorted_titles(generator.pages)
|
cached_pages = sorted_titles(generator.pages)
|
||||||
|
|
@ -139,15 +141,16 @@ class TestCache(unittest.TestCase):
|
||||||
settings['CONTENT_CACHING_LAYER'] = 'generator'
|
settings['CONTENT_CACHING_LAYER'] = 'generator'
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
self.assertTrue(hasattr(generator, '_cache'))
|
self.assertTrue(hasattr(generator, '_cache'))
|
||||||
|
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.readers.read_file = MagicMock()
|
generator.readers.read_file = MagicMock()
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
@ -167,15 +170,16 @@ class TestCache(unittest.TestCase):
|
||||||
"""Test raw article content caching at the reader level"""
|
"""Test raw article content caching at the reader level"""
|
||||||
settings = self._get_cache_enabled_settings()
|
settings = self._get_cache_enabled_settings()
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
self.assertTrue(hasattr(generator.readers, '_cache'))
|
self.assertTrue(hasattr(generator.readers, '_cache'))
|
||||||
|
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
readers = generator.readers.readers
|
readers = generator.readers.readers
|
||||||
for reader in readers.values():
|
for reader in readers.values():
|
||||||
|
|
@ -191,9 +195,10 @@ class TestCache(unittest.TestCase):
|
||||||
used in --ignore-cache or autoreload mode"""
|
used in --ignore-cache or autoreload mode"""
|
||||||
settings = self._get_cache_enabled_settings()
|
settings = self._get_cache_enabled_settings()
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.readers.read_file = MagicMock()
|
generator.readers.read_file = MagicMock()
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
@ -202,7 +207,7 @@ class TestCache(unittest.TestCase):
|
||||||
|
|
||||||
settings['LOAD_CONTENT_CACHE'] = False
|
settings['LOAD_CONTENT_CACHE'] = False
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.readers.read_file = MagicMock()
|
generator.readers.read_file = MagicMock()
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
@ -217,15 +222,16 @@ class TestCache(unittest.TestCase):
|
||||||
settings['CONTENT_CACHING_LAYER'] = 'generator'
|
settings['CONTENT_CACHING_LAYER'] = 'generator'
|
||||||
settings['PAGE_PATHS'] = ['TestPages']
|
settings['PAGE_PATHS'] = ['TestPages']
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
self.assertTrue(hasattr(generator, '_cache'))
|
self.assertTrue(hasattr(generator, '_cache'))
|
||||||
|
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.readers.read_file = MagicMock()
|
generator.readers.read_file = MagicMock()
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
@ -241,15 +247,16 @@ class TestCache(unittest.TestCase):
|
||||||
settings = self._get_cache_enabled_settings()
|
settings = self._get_cache_enabled_settings()
|
||||||
settings['PAGE_PATHS'] = ['TestPages']
|
settings['PAGE_PATHS'] = ['TestPages']
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
self.assertTrue(hasattr(generator.readers, '_cache'))
|
self.assertTrue(hasattr(generator.readers, '_cache'))
|
||||||
|
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
readers = generator.readers.readers
|
readers = generator.readers.readers
|
||||||
for reader in readers.values():
|
for reader in readers.values():
|
||||||
|
|
@ -266,9 +273,10 @@ class TestCache(unittest.TestCase):
|
||||||
settings = self._get_cache_enabled_settings()
|
settings = self._get_cache_enabled_settings()
|
||||||
settings['PAGE_PATHS'] = ['TestPages']
|
settings['PAGE_PATHS'] = ['TestPages']
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.readers.read_file = MagicMock()
|
generator.readers.read_file = MagicMock()
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
@ -277,7 +285,7 @@ class TestCache(unittest.TestCase):
|
||||||
|
|
||||||
settings['LOAD_CONTENT_CACHE'] = False
|
settings['LOAD_CONTENT_CACHE'] = False
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.readers.read_file = MagicMock()
|
generator.readers.read_file = MagicMock()
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ import six
|
||||||
from pelican.contents import Article, Author, Category, Page, Static, Tag
|
from pelican.contents import Article, Author, Category, Page, Static, Tag
|
||||||
from pelican.settings import DEFAULT_CONFIG
|
from pelican.settings import DEFAULT_CONFIG
|
||||||
from pelican.signals import content_object_init
|
from pelican.signals import content_object_init
|
||||||
from pelican.tests.support import LoggedTestCase, get_settings, unittest
|
from pelican.tests.support import LoggedTestCase, get_context, get_settings,\
|
||||||
|
unittest
|
||||||
from pelican.utils import SafeDatetime, path_to_url, truncate_html_words
|
from pelican.utils import SafeDatetime, path_to_url, truncate_html_words
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -264,7 +265,7 @@ class TestPage(LoggedTestCase):
|
||||||
args = self.page_kwargs.copy()
|
args = self.page_kwargs.copy()
|
||||||
args['settings'] = get_settings()
|
args['settings'] = get_settings()
|
||||||
args['source_path'] = 'content'
|
args['source_path'] = 'content'
|
||||||
args['context']['filenames'] = {'article.rst': article}
|
args['context']['generated_content'] = {'article.rst': article}
|
||||||
|
|
||||||
# Classic intrasite link via filename
|
# Classic intrasite link via filename
|
||||||
args['content'] = (
|
args['content'] = (
|
||||||
|
|
@ -343,22 +344,24 @@ class TestPage(LoggedTestCase):
|
||||||
args = self.page_kwargs.copy()
|
args = self.page_kwargs.copy()
|
||||||
args['settings'] = get_settings()
|
args['settings'] = get_settings()
|
||||||
args['source_path'] = 'content'
|
args['source_path'] = 'content'
|
||||||
args['context']['filenames'] = {
|
args['context']['static_content'] = {
|
||||||
'images/poster.jpg': type(
|
'images/poster.jpg':
|
||||||
cls_name, (object,), {'url': 'images/poster.jpg'}),
|
type(cls_name, (object,), {'url': 'images/poster.jpg'}),
|
||||||
'assets/video.mp4': type(
|
'assets/video.mp4':
|
||||||
cls_name, (object,), {'url': 'assets/video.mp4'}),
|
type(cls_name, (object,), {'url': 'assets/video.mp4'}),
|
||||||
'images/graph.svg': type(
|
'images/graph.svg':
|
||||||
cls_name, (object,), {'url': 'images/graph.svg'}),
|
type(cls_name, (object,), {'url': 'images/graph.svg'}),
|
||||||
'reference.rst': type(
|
}
|
||||||
cls_name, (object,), {'url': 'reference.html'}),
|
args['context']['generated_content'] = {
|
||||||
|
'reference.rst':
|
||||||
|
type(cls_name, (object,), {'url': 'reference.html'}),
|
||||||
}
|
}
|
||||||
|
|
||||||
# video.poster
|
# video.poster
|
||||||
args['content'] = (
|
args['content'] = (
|
||||||
'There is a video with poster '
|
'There is a video with poster '
|
||||||
'<video controls poster="{filename}/images/poster.jpg">'
|
'<video controls poster="{static}/images/poster.jpg">'
|
||||||
'<source src="|filename|/assets/video.mp4" type="video/mp4">'
|
'<source src="|static|/assets/video.mp4" type="video/mp4">'
|
||||||
'</video>'
|
'</video>'
|
||||||
)
|
)
|
||||||
content = Page(**args).get_content('http://notmyidea.org')
|
content = Page(**args).get_content('http://notmyidea.org')
|
||||||
|
|
@ -374,7 +377,7 @@ class TestPage(LoggedTestCase):
|
||||||
# object.data
|
# object.data
|
||||||
args['content'] = (
|
args['content'] = (
|
||||||
'There is a svg object '
|
'There is a svg object '
|
||||||
'<object data="{filename}/images/graph.svg"'
|
'<object data="{static}/images/graph.svg"'
|
||||||
' type="image/svg+xml">'
|
' type="image/svg+xml">'
|
||||||
'</object>'
|
'</object>'
|
||||||
)
|
)
|
||||||
|
|
@ -409,14 +412,15 @@ class TestPage(LoggedTestCase):
|
||||||
STATIC_URL='http://static.cool.site/{path}',
|
STATIC_URL='http://static.cool.site/{path}',
|
||||||
ARTICLE_URL='http://blog.cool.site/{slug}.html')
|
ARTICLE_URL='http://blog.cool.site/{slug}.html')
|
||||||
args['source_path'] = 'content'
|
args['source_path'] = 'content'
|
||||||
args['context']['filenames'] = {
|
args['context']['static_content'] = {
|
||||||
'images/poster.jpg': Static('',
|
'images/poster.jpg':
|
||||||
settings=args['settings'],
|
Static('', settings=args['settings'],
|
||||||
source_path='images/poster.jpg'),
|
source_path='images/poster.jpg'),
|
||||||
'article.rst': Article('',
|
}
|
||||||
settings=args['settings'],
|
args['context']['generated_content'] = {
|
||||||
metadata={'slug': 'article',
|
'article.rst':
|
||||||
'title': 'Article'})
|
Article('', settings=args['settings'], metadata={
|
||||||
|
'slug': 'article', 'title': 'Article'})
|
||||||
}
|
}
|
||||||
|
|
||||||
# Article link will go to blog
|
# Article link will go to blog
|
||||||
|
|
@ -441,7 +445,7 @@ class TestPage(LoggedTestCase):
|
||||||
|
|
||||||
# Image link will go to static
|
# Image link will go to static
|
||||||
args['content'] = (
|
args['content'] = (
|
||||||
'<img src="{filename}/images/poster.jpg"/>'
|
'<img src="{static}/images/poster.jpg"/>'
|
||||||
)
|
)
|
||||||
content = Page(**args).get_content('http://cool.site')
|
content = Page(**args).get_content('http://cool.site')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|
@ -458,7 +462,7 @@ class TestPage(LoggedTestCase):
|
||||||
args = self.page_kwargs.copy()
|
args = self.page_kwargs.copy()
|
||||||
args['settings'] = get_settings()
|
args['settings'] = get_settings()
|
||||||
args['source_path'] = 'content'
|
args['source_path'] = 'content'
|
||||||
args['context']['filenames'] = {'article spaces.rst': article}
|
args['context']['generated_content'] = {'article spaces.rst': article}
|
||||||
|
|
||||||
# An intrasite link via filename with %20 as a space
|
# An intrasite link via filename with %20 as a space
|
||||||
args['content'] = (
|
args['content'] = (
|
||||||
|
|
@ -472,6 +476,55 @@ class TestPage(LoggedTestCase):
|
||||||
'<a href="http://notmyidea.org/article-spaces.html">link</a>'
|
'<a href="http://notmyidea.org/article-spaces.html">link</a>'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_intrasite_link_source_and_generated(self):
|
||||||
|
"""Test linking both to the source and the generated article
|
||||||
|
"""
|
||||||
|
cls_name = '_DummyAsset' if six.PY3 else b'_DummyAsset'
|
||||||
|
|
||||||
|
args = self.page_kwargs.copy()
|
||||||
|
args['settings'] = get_settings()
|
||||||
|
args['source_path'] = 'content'
|
||||||
|
args['context']['generated_content'] = {
|
||||||
|
'article.rst': type(cls_name, (object,), {'url': 'article.html'})}
|
||||||
|
args['context']['static_content'] = {
|
||||||
|
'article.rst': type(cls_name, (object,), {'url': 'article.rst'})}
|
||||||
|
|
||||||
|
args['content'] = (
|
||||||
|
'A simple test, with a link to an'
|
||||||
|
'<a href="{filename}article.rst">article</a> and its'
|
||||||
|
'<a href="{static}article.rst">source</a>'
|
||||||
|
)
|
||||||
|
content = Page(**args).get_content('http://notmyidea.org')
|
||||||
|
self.assertEqual(
|
||||||
|
content,
|
||||||
|
'A simple test, with a link to an'
|
||||||
|
'<a href="http://notmyidea.org/article.html">article</a> and its'
|
||||||
|
'<a href="http://notmyidea.org/article.rst">source</a>'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_intrasite_link_to_static_content_with_filename(self):
|
||||||
|
"""Test linking to a static resource with deprecated {filename}
|
||||||
|
"""
|
||||||
|
cls_name = '_DummyAsset' if six.PY3 else b'_DummyAsset'
|
||||||
|
|
||||||
|
args = self.page_kwargs.copy()
|
||||||
|
args['settings'] = get_settings()
|
||||||
|
args['source_path'] = 'content'
|
||||||
|
args['context']['static_content'] = {
|
||||||
|
'poster.jpg':
|
||||||
|
type(cls_name, (object,), {'url': 'images/poster.jpg'})}
|
||||||
|
|
||||||
|
args['content'] = (
|
||||||
|
'A simple test, with a link to a'
|
||||||
|
'<a href="{filename}poster.jpg">poster</a>'
|
||||||
|
)
|
||||||
|
content = Page(**args).get_content('http://notmyidea.org')
|
||||||
|
self.assertEqual(
|
||||||
|
content,
|
||||||
|
'A simple test, with a link to a'
|
||||||
|
'<a href="http://notmyidea.org/images/poster.jpg">poster</a>'
|
||||||
|
)
|
||||||
|
|
||||||
def test_multiple_authors(self):
|
def test_multiple_authors(self):
|
||||||
"""Test article with multiple authors."""
|
"""Test article with multiple authors."""
|
||||||
args = self.page_kwargs.copy()
|
args = self.page_kwargs.copy()
|
||||||
|
|
@ -599,13 +652,13 @@ class TestStatic(LoggedTestCase):
|
||||||
STATIC_URL='{path}',
|
STATIC_URL='{path}',
|
||||||
PAGE_SAVE_AS=os.path.join('outpages', '{slug}.html'),
|
PAGE_SAVE_AS=os.path.join('outpages', '{slug}.html'),
|
||||||
PAGE_URL='outpages/{slug}.html')
|
PAGE_URL='outpages/{slug}.html')
|
||||||
self.context = self.settings.copy()
|
self.context = get_context(self.settings)
|
||||||
|
|
||||||
self.static = Static(content=None, metadata={}, settings=self.settings,
|
self.static = Static(content=None, metadata={}, settings=self.settings,
|
||||||
source_path=posix_join('dir', 'foo.jpg'),
|
source_path=posix_join('dir', 'foo.jpg'),
|
||||||
context=self.context)
|
context=self.context)
|
||||||
|
|
||||||
self.context['filenames'] = {self.static.source_path: self.static}
|
self.context['static_content'][self.static.source_path] = self.static
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
|
@ -674,7 +727,7 @@ class TestStatic(LoggedTestCase):
|
||||||
|
|
||||||
def test_attach_to_does_nothing_after_save_as_referenced(self):
|
def test_attach_to_does_nothing_after_save_as_referenced(self):
|
||||||
"""attach_to() does nothing if the save_as was already referenced.
|
"""attach_to() does nothing if the save_as was already referenced.
|
||||||
(For example, by a {filename} link an a document processed earlier.)
|
(For example, by a {static} link an a document processed earlier.)
|
||||||
"""
|
"""
|
||||||
original_save_as = self.static.save_as
|
original_save_as = self.static.save_as
|
||||||
|
|
||||||
|
|
@ -690,7 +743,7 @@ class TestStatic(LoggedTestCase):
|
||||||
|
|
||||||
def test_attach_to_does_nothing_after_url_referenced(self):
|
def test_attach_to_does_nothing_after_url_referenced(self):
|
||||||
"""attach_to() does nothing if the url was already referenced.
|
"""attach_to() does nothing if the url was already referenced.
|
||||||
(For example, by a {filename} link an a document processed earlier.)
|
(For example, by a {static} link an a document processed earlier.)
|
||||||
"""
|
"""
|
||||||
original_url = self.static.url
|
original_url = self.static.url
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ from tempfile import mkdtemp
|
||||||
from pelican.generators import (ArticlesGenerator, Generator, PagesGenerator,
|
from pelican.generators import (ArticlesGenerator, Generator, PagesGenerator,
|
||||||
PelicanTemplateNotFound, StaticGenerator,
|
PelicanTemplateNotFound, StaticGenerator,
|
||||||
TemplatePagesGenerator)
|
TemplatePagesGenerator)
|
||||||
from pelican.tests.support import get_settings, unittest
|
from pelican.tests.support import get_context, get_settings, unittest
|
||||||
from pelican.writers import Writer
|
from pelican.writers import Writer
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -178,14 +178,15 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['DEFAULT_CATEGORY'] = 'Default'
|
settings['DEFAULT_CATEGORY'] = 'Default'
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
settings['CACHE_CONTENT'] = False
|
settings['CACHE_CONTENT'] = False
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
cls.generator = ArticlesGenerator(
|
cls.generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context, settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
cls.generator.generate_context()
|
cls.generator.generate_context()
|
||||||
cls.articles = cls.distill_articles(cls.generator.articles)
|
cls.articles = cls.distill_articles(cls.generator.articles)
|
||||||
|
|
@ -300,15 +301,15 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
self.assertEqual(sorted(categories), sorted(categories_expected))
|
self.assertEqual(sorted(categories), sorted(categories_expected))
|
||||||
|
|
||||||
def test_do_not_use_folder_as_category(self):
|
def test_do_not_use_folder_as_category(self):
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['DEFAULT_CATEGORY'] = 'Default'
|
settings['DEFAULT_CATEGORY'] = 'Default'
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
settings['USE_FOLDER_AS_CATEGORY'] = False
|
settings['USE_FOLDER_AS_CATEGORY'] = False
|
||||||
settings['CACHE_PATH'] = self.temp_cache
|
settings['CACHE_PATH'] = self.temp_cache
|
||||||
settings['READERS'] = {'asc': None}
|
settings['READERS'] = {'asc': None}
|
||||||
settings['filenames'] = {}
|
context = get_context(settings)
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context, settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
# test for name
|
# test for name
|
||||||
|
|
@ -329,15 +330,16 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
@unittest.skipUnless(MagicMock, 'Needs Mock module')
|
@unittest.skipUnless(MagicMock, 'Needs Mock module')
|
||||||
def test_direct_templates_save_as_url_default(self):
|
def test_direct_templates_save_as_url_default(self):
|
||||||
|
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['CACHE_PATH'] = self.temp_cache
|
settings['CACHE_PATH'] = self.temp_cache
|
||||||
|
context = get_context(settings)
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings, settings=settings,
|
context=context, settings=settings,
|
||||||
path=None, theme=settings['THEME'], output_path=None)
|
path=None, theme=settings['THEME'], output_path=None)
|
||||||
write = MagicMock()
|
write = MagicMock()
|
||||||
generator.generate_direct_templates(write)
|
generator.generate_direct_templates(write)
|
||||||
write.assert_called_with("archives.html",
|
write.assert_called_with("archives.html",
|
||||||
generator.get_template("archives"), settings,
|
generator.get_template("archives"), context,
|
||||||
articles=generator.articles,
|
articles=generator.articles,
|
||||||
dates=generator.dates, blog=True,
|
dates=generator.dates, blog=True,
|
||||||
template_name='archives',
|
template_name='archives',
|
||||||
|
|
@ -397,13 +399,14 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
old_locale = locale.setlocale(locale.LC_ALL)
|
old_locale = locale.setlocale(locale.LC_ALL)
|
||||||
locale.setlocale(locale.LC_ALL, str('C'))
|
locale.setlocale(locale.LC_ALL, str('C'))
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
|
|
||||||
settings['YEAR_ARCHIVE_SAVE_AS'] = 'posts/{date:%Y}/index.html'
|
settings['YEAR_ARCHIVE_SAVE_AS'] = 'posts/{date:%Y}/index.html'
|
||||||
settings['YEAR_ARCHIVE_URL'] = 'posts/{date:%Y}/'
|
settings['YEAR_ARCHIVE_URL'] = 'posts/{date:%Y}/'
|
||||||
settings['CACHE_PATH'] = self.temp_cache
|
settings['CACHE_PATH'] = self.temp_cache
|
||||||
|
context = get_context(settings)
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings, settings=settings,
|
context=context, settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
write = MagicMock()
|
write = MagicMock()
|
||||||
|
|
@ -412,20 +415,20 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
articles = [d for d in generator.articles if d.date.year == 1970]
|
articles = [d for d in generator.articles if d.date.year == 1970]
|
||||||
self.assertEqual(len(dates), 1)
|
self.assertEqual(len(dates), 1)
|
||||||
# among other things it must have at least been called with this
|
# among other things it must have at least been called with this
|
||||||
settings["period"] = (1970,)
|
context["period"] = (1970,)
|
||||||
write.assert_called_with("posts/1970/index.html",
|
write.assert_called_with("posts/1970/index.html",
|
||||||
generator.get_template("period_archives"),
|
generator.get_template("period_archives"),
|
||||||
settings, blog=True, articles=articles,
|
context, blog=True, articles=articles,
|
||||||
dates=dates, template_name='period_archives',
|
dates=dates, template_name='period_archives',
|
||||||
url="posts/1970/")
|
url="posts/1970/")
|
||||||
|
|
||||||
del settings["period"]
|
|
||||||
settings['MONTH_ARCHIVE_SAVE_AS'] = \
|
settings['MONTH_ARCHIVE_SAVE_AS'] = \
|
||||||
'posts/{date:%Y}/{date:%b}/index.html'
|
'posts/{date:%Y}/{date:%b}/index.html'
|
||||||
settings['MONTH_ARCHIVE_URL'] = \
|
settings['MONTH_ARCHIVE_URL'] = \
|
||||||
'posts/{date:%Y}/{date:%b}/'
|
'posts/{date:%Y}/{date:%b}/'
|
||||||
|
context = get_context(settings)
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings, settings=settings,
|
context=context, settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
write = MagicMock()
|
write = MagicMock()
|
||||||
|
|
@ -435,21 +438,21 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
articles = [d for d in generator.articles
|
articles = [d for d in generator.articles
|
||||||
if d.date.year == 1970 and d.date.month == 1]
|
if d.date.year == 1970 and d.date.month == 1]
|
||||||
self.assertEqual(len(dates), 1)
|
self.assertEqual(len(dates), 1)
|
||||||
settings["period"] = (1970, "January")
|
context["period"] = (1970, "January")
|
||||||
# among other things it must have at least been called with this
|
# among other things it must have at least been called with this
|
||||||
write.assert_called_with("posts/1970/Jan/index.html",
|
write.assert_called_with("posts/1970/Jan/index.html",
|
||||||
generator.get_template("period_archives"),
|
generator.get_template("period_archives"),
|
||||||
settings, blog=True, articles=articles,
|
context, blog=True, articles=articles,
|
||||||
dates=dates, template_name='period_archives',
|
dates=dates, template_name='period_archives',
|
||||||
url="posts/1970/Jan/")
|
url="posts/1970/Jan/")
|
||||||
|
|
||||||
del settings["period"]
|
|
||||||
settings['DAY_ARCHIVE_SAVE_AS'] = \
|
settings['DAY_ARCHIVE_SAVE_AS'] = \
|
||||||
'posts/{date:%Y}/{date:%b}/{date:%d}/index.html'
|
'posts/{date:%Y}/{date:%b}/{date:%d}/index.html'
|
||||||
settings['DAY_ARCHIVE_URL'] = \
|
settings['DAY_ARCHIVE_URL'] = \
|
||||||
'posts/{date:%Y}/{date:%b}/{date:%d}/'
|
'posts/{date:%Y}/{date:%b}/{date:%d}/'
|
||||||
|
context = get_context(settings)
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings, settings=settings,
|
context=context, settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
write = MagicMock()
|
write = MagicMock()
|
||||||
|
|
@ -467,20 +470,21 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
d.date.day == 1
|
d.date.day == 1
|
||||||
]
|
]
|
||||||
self.assertEqual(len(dates), 1)
|
self.assertEqual(len(dates), 1)
|
||||||
settings["period"] = (1970, "January", 1)
|
context["period"] = (1970, "January", 1)
|
||||||
# among other things it must have at least been called with this
|
# among other things it must have at least been called with this
|
||||||
write.assert_called_with("posts/1970/Jan/01/index.html",
|
write.assert_called_with("posts/1970/Jan/01/index.html",
|
||||||
generator.get_template("period_archives"),
|
generator.get_template("period_archives"),
|
||||||
settings, blog=True, articles=articles,
|
context, blog=True, articles=articles,
|
||||||
dates=dates, template_name='period_archives',
|
dates=dates, template_name='period_archives',
|
||||||
url="posts/1970/Jan/01/")
|
url="posts/1970/Jan/01/")
|
||||||
locale.setlocale(locale.LC_ALL, old_locale)
|
locale.setlocale(locale.LC_ALL, old_locale)
|
||||||
|
|
||||||
def test_nonexistent_template(self):
|
def test_nonexistent_template(self):
|
||||||
"""Attempt to load a non-existent template"""
|
"""Attempt to load a non-existent template"""
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
|
context = get_context(settings)
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings, settings=settings,
|
context=context, settings=settings,
|
||||||
path=None, theme=settings['THEME'], output_path=None)
|
path=None, theme=settings['THEME'], output_path=None)
|
||||||
self.assertRaises(Exception, generator.get_template, "not_a_template")
|
self.assertRaises(Exception, generator.get_template, "not_a_template")
|
||||||
|
|
||||||
|
|
@ -498,7 +502,7 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
self.assertEqual(sorted(authors), sorted(authors_expected))
|
self.assertEqual(sorted(authors), sorted(authors_expected))
|
||||||
|
|
||||||
def test_standard_metadata_in_default_metadata(self):
|
def test_standard_metadata_in_default_metadata(self):
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['CACHE_CONTENT'] = False
|
settings['CACHE_CONTENT'] = False
|
||||||
settings['DEFAULT_CATEGORY'] = 'Default'
|
settings['DEFAULT_CATEGORY'] = 'Default'
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
|
|
@ -507,8 +511,9 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
# DEFAULT_CATEGORY
|
# DEFAULT_CATEGORY
|
||||||
('category', 'Random'),
|
('category', 'Random'),
|
||||||
('tags', 'general, untagged'))
|
('tags', 'general, untagged'))
|
||||||
|
context = get_context(settings)
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context, settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
||||||
|
|
@ -531,13 +536,14 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
self.assertEqual(tags, tags_expected)
|
self.assertEqual(tags, tags_expected)
|
||||||
|
|
||||||
def test_article_order_by(self):
|
def test_article_order_by(self):
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['DEFAULT_CATEGORY'] = 'Default'
|
settings['DEFAULT_CATEGORY'] = 'Default'
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
settings['ARTICLE_ORDER_BY'] = 'title'
|
settings['ARTICLE_ORDER_BY'] = 'title'
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context, settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
||||||
|
|
@ -577,13 +583,14 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
self.assertEqual(articles, expected)
|
self.assertEqual(articles, expected)
|
||||||
|
|
||||||
# reversed title
|
# reversed title
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['DEFAULT_CATEGORY'] = 'Default'
|
settings['DEFAULT_CATEGORY'] = 'Default'
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
settings['ARTICLE_ORDER_BY'] = 'reversed-title'
|
settings['ARTICLE_ORDER_BY'] = 'reversed-title'
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context, settings=settings,
|
||||||
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
path=CONTENT_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
||||||
|
|
@ -607,13 +614,14 @@ class TestPageGenerator(unittest.TestCase):
|
||||||
return [[page.title, page.status, page.template] for page in pages]
|
return [[page.title, page.status, page.template] for page in pages]
|
||||||
|
|
||||||
def test_generate_context(self):
|
def test_generate_context(self):
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['CACHE_PATH'] = self.temp_cache
|
settings['CACHE_PATH'] = self.temp_cache
|
||||||
settings['PAGE_PATHS'] = ['TestPages'] # relative to CUR_DIR
|
settings['PAGE_PATHS'] = ['TestPages'] # relative to CUR_DIR
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context, settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
pages = self.distill_pages(generator.pages)
|
pages = self.distill_pages(generator.pages)
|
||||||
|
|
@ -626,6 +634,7 @@ class TestPageGenerator(unittest.TestCase):
|
||||||
['This is a test page with a preset template', 'published',
|
['This is a test page with a preset template', 'published',
|
||||||
'custom'],
|
'custom'],
|
||||||
['Page with a bunch of links', 'published', 'page'],
|
['Page with a bunch of links', 'published', 'page'],
|
||||||
|
['Page with static links', 'published', 'page'],
|
||||||
['A Page (Test) for sorting', 'published', 'page'],
|
['A Page (Test) for sorting', 'published', 'page'],
|
||||||
]
|
]
|
||||||
hidden_pages_expected = [
|
hidden_pages_expected = [
|
||||||
|
|
@ -655,10 +664,11 @@ class TestPageGenerator(unittest.TestCase):
|
||||||
sorted(self.distill_pages(generator.context['draft_pages'])))
|
sorted(self.distill_pages(generator.context['draft_pages'])))
|
||||||
|
|
||||||
def test_generate_sorted(self):
|
def test_generate_sorted(self):
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['PAGE_PATHS'] = ['TestPages'] # relative to CUR_DIR
|
settings['PAGE_PATHS'] = ['TestPages'] # relative to CUR_DIR
|
||||||
settings['CACHE_PATH'] = self.temp_cache
|
settings['CACHE_PATH'] = self.temp_cache
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
# default sort (filename)
|
# default sort (filename)
|
||||||
pages_expected_sorted_by_filename = [
|
pages_expected_sorted_by_filename = [
|
||||||
|
|
@ -666,11 +676,12 @@ class TestPageGenerator(unittest.TestCase):
|
||||||
['This is a markdown test page', 'published', 'page'],
|
['This is a markdown test page', 'published', 'page'],
|
||||||
['A Page (Test) for sorting', 'published', 'page'],
|
['A Page (Test) for sorting', 'published', 'page'],
|
||||||
['Page with a bunch of links', 'published', 'page'],
|
['Page with a bunch of links', 'published', 'page'],
|
||||||
|
['Page with static links', 'published', 'page'],
|
||||||
['This is a test page with a preset template', 'published',
|
['This is a test page with a preset template', 'published',
|
||||||
'custom'],
|
'custom'],
|
||||||
]
|
]
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context, settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
pages = self.distill_pages(generator.pages)
|
pages = self.distill_pages(generator.pages)
|
||||||
|
|
@ -680,14 +691,16 @@ class TestPageGenerator(unittest.TestCase):
|
||||||
pages_expected_sorted_by_title = [
|
pages_expected_sorted_by_title = [
|
||||||
['A Page (Test) for sorting', 'published', 'page'],
|
['A Page (Test) for sorting', 'published', 'page'],
|
||||||
['Page with a bunch of links', 'published', 'page'],
|
['Page with a bunch of links', 'published', 'page'],
|
||||||
|
['Page with static links', 'published', 'page'],
|
||||||
['This is a markdown test page', 'published', 'page'],
|
['This is a markdown test page', 'published', 'page'],
|
||||||
['This is a test page', 'published', 'page'],
|
['This is a test page', 'published', 'page'],
|
||||||
['This is a test page with a preset template', 'published',
|
['This is a test page with a preset template', 'published',
|
||||||
'custom'],
|
'custom'],
|
||||||
]
|
]
|
||||||
settings['PAGE_ORDER_BY'] = 'title'
|
settings['PAGE_ORDER_BY'] = 'title'
|
||||||
|
context = get_context(settings)
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context.copy(), settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
pages = self.distill_pages(generator.pages)
|
pages = self.distill_pages(generator.pages)
|
||||||
|
|
@ -699,12 +712,14 @@ class TestPageGenerator(unittest.TestCase):
|
||||||
'custom'],
|
'custom'],
|
||||||
['This is a test page', 'published', 'page'],
|
['This is a test page', 'published', 'page'],
|
||||||
['This is a markdown test page', 'published', 'page'],
|
['This is a markdown test page', 'published', 'page'],
|
||||||
|
['Page with static links', 'published', 'page'],
|
||||||
['Page with a bunch of links', 'published', 'page'],
|
['Page with a bunch of links', 'published', 'page'],
|
||||||
['A Page (Test) for sorting', 'published', 'page'],
|
['A Page (Test) for sorting', 'published', 'page'],
|
||||||
]
|
]
|
||||||
settings['PAGE_ORDER_BY'] = 'reversed-title'
|
settings['PAGE_ORDER_BY'] = 'reversed-title'
|
||||||
|
context = get_context(settings)
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context, settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
pages = self.distill_pages(generator.pages)
|
pages = self.distill_pages(generator.pages)
|
||||||
|
|
@ -715,21 +730,43 @@ class TestPageGenerator(unittest.TestCase):
|
||||||
Test to ensure links of the form {tag}tagname and {category}catname
|
Test to ensure links of the form {tag}tagname and {category}catname
|
||||||
are generated correctly on pages
|
are generated correctly on pages
|
||||||
"""
|
"""
|
||||||
settings = get_settings(filenames={})
|
settings = get_settings()
|
||||||
settings['PAGE_PATHS'] = ['TestPages'] # relative to CUR_DIR
|
settings['PAGE_PATHS'] = ['TestPages'] # relative to CUR_DIR
|
||||||
settings['CACHE_PATH'] = self.temp_cache
|
settings['CACHE_PATH'] = self.temp_cache
|
||||||
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
generator = PagesGenerator(
|
generator = PagesGenerator(
|
||||||
context=settings.copy(), settings=settings,
|
context=context, settings=settings,
|
||||||
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
pages_by_title = {p.title: p.content for p in generator.pages}
|
pages_by_title = {p.title: p for p in generator.pages}
|
||||||
|
|
||||||
test_content = pages_by_title['Page with a bunch of links']
|
test_content = pages_by_title['Page with a bunch of links'].content
|
||||||
self.assertIn('<a href="/category/yeah.html">', test_content)
|
self.assertIn('<a href="/category/yeah.html">', test_content)
|
||||||
self.assertIn('<a href="/tag/matsuku.html">', test_content)
|
self.assertIn('<a href="/tag/matsuku.html">', test_content)
|
||||||
|
|
||||||
|
def test_static_and_attach_links_on_generated_pages(self):
|
||||||
|
"""
|
||||||
|
Test to ensure links of the form {static}filename and {attach}filename
|
||||||
|
are included in context['static_links']
|
||||||
|
"""
|
||||||
|
settings = get_settings()
|
||||||
|
settings['PAGE_PATHS'] = ['TestPages/page_with_static_links.md']
|
||||||
|
settings['CACHE_PATH'] = self.temp_cache
|
||||||
|
settings['DEFAULT_DATE'] = (1970, 1, 1)
|
||||||
|
context = get_context(settings)
|
||||||
|
|
||||||
|
generator = PagesGenerator(
|
||||||
|
context=context, settings=settings,
|
||||||
|
path=CUR_DIR, theme=settings['THEME'], output_path=None)
|
||||||
|
generator.generate_context()
|
||||||
|
|
||||||
|
self.assertIn('pelican/tests/TestPages/image0.jpg',
|
||||||
|
context['static_links'])
|
||||||
|
self.assertIn('pelican/tests/TestPages/image1.jpg',
|
||||||
|
context['static_links'])
|
||||||
|
|
||||||
|
|
||||||
class TestTemplatePagesGenerator(unittest.TestCase):
|
class TestTemplatePagesGenerator(unittest.TestCase):
|
||||||
|
|
||||||
|
|
@ -793,7 +830,7 @@ class TestStaticGenerator(unittest.TestCase):
|
||||||
"static", "staticfile")
|
"static", "staticfile")
|
||||||
self.endfile = os.path.join(self.temp_output, "static", "staticfile")
|
self.endfile = os.path.join(self.temp_output, "static", "staticfile")
|
||||||
self.generator = StaticGenerator(
|
self.generator = StaticGenerator(
|
||||||
context={'filenames': {}},
|
context=get_context(),
|
||||||
settings=self.settings,
|
settings=self.settings,
|
||||||
path=self.temp_content,
|
path=self.temp_content,
|
||||||
theme="",
|
theme="",
|
||||||
|
|
@ -810,11 +847,8 @@ class TestStaticGenerator(unittest.TestCase):
|
||||||
def test_theme_static_paths_dirs(self):
|
def test_theme_static_paths_dirs(self):
|
||||||
"""Test that StaticGenerator properly copies also files mentioned in
|
"""Test that StaticGenerator properly copies also files mentioned in
|
||||||
TEMPLATE_STATIC_PATHS, not just directories."""
|
TEMPLATE_STATIC_PATHS, not just directories."""
|
||||||
settings = get_settings(
|
settings = get_settings(PATH=self.content_path)
|
||||||
PATH=self.content_path,
|
context = get_context(settings, staticfiles=[])
|
||||||
filenames={})
|
|
||||||
context = settings.copy()
|
|
||||||
context['staticfiles'] = []
|
|
||||||
|
|
||||||
StaticGenerator(
|
StaticGenerator(
|
||||||
context=context, settings=settings,
|
context=context, settings=settings,
|
||||||
|
|
@ -833,10 +867,8 @@ class TestStaticGenerator(unittest.TestCase):
|
||||||
TEMPLATE_STATIC_PATHS, not just directories."""
|
TEMPLATE_STATIC_PATHS, not just directories."""
|
||||||
settings = get_settings(
|
settings = get_settings(
|
||||||
PATH=self.content_path,
|
PATH=self.content_path,
|
||||||
THEME_STATIC_PATHS=['static/css/fonts.css', 'static/fonts/'],
|
THEME_STATIC_PATHS=['static/css/fonts.css', 'static/fonts/'],)
|
||||||
filenames={})
|
context = get_context(settings, staticfiles=[])
|
||||||
context = settings.copy()
|
|
||||||
context['staticfiles'] = []
|
|
||||||
|
|
||||||
StaticGenerator(
|
StaticGenerator(
|
||||||
context=context, settings=settings,
|
context=context, settings=settings,
|
||||||
|
|
@ -871,9 +903,8 @@ class TestStaticGenerator(unittest.TestCase):
|
||||||
settings = get_settings(
|
settings = get_settings(
|
||||||
STATIC_EXCLUDES=['subdir'],
|
STATIC_EXCLUDES=['subdir'],
|
||||||
PATH=self.content_path,
|
PATH=self.content_path,
|
||||||
STATIC_PATHS=[''],
|
STATIC_PATHS=[''],)
|
||||||
filenames={})
|
context = get_context(settings)
|
||||||
context = settings.copy()
|
|
||||||
|
|
||||||
StaticGenerator(
|
StaticGenerator(
|
||||||
context=context, settings=settings,
|
context=context, settings=settings,
|
||||||
|
|
@ -899,9 +930,8 @@ class TestStaticGenerator(unittest.TestCase):
|
||||||
PATH=self.content_path,
|
PATH=self.content_path,
|
||||||
PAGE_PATHS=[''],
|
PAGE_PATHS=[''],
|
||||||
STATIC_PATHS=[''],
|
STATIC_PATHS=[''],
|
||||||
CACHE_CONTENT=False,
|
CACHE_CONTENT=False,)
|
||||||
filenames={})
|
context = get_context(settings)
|
||||||
context = settings.copy()
|
|
||||||
|
|
||||||
for generator_class in (PagesGenerator, StaticGenerator):
|
for generator_class in (PagesGenerator, StaticGenerator):
|
||||||
generator_class(
|
generator_class(
|
||||||
|
|
@ -917,8 +947,7 @@ class TestStaticGenerator(unittest.TestCase):
|
||||||
"STATIC_EXCLUDE_SOURCES=True failed to exclude a markdown file")
|
"STATIC_EXCLUDE_SOURCES=True failed to exclude a markdown file")
|
||||||
|
|
||||||
settings.update(STATIC_EXCLUDE_SOURCES=False)
|
settings.update(STATIC_EXCLUDE_SOURCES=False)
|
||||||
context = settings.copy()
|
context = get_context(settings)
|
||||||
context['filenames'] = {}
|
|
||||||
|
|
||||||
for generator_class in (PagesGenerator, StaticGenerator):
|
for generator_class in (PagesGenerator, StaticGenerator):
|
||||||
generator_class(
|
generator_class(
|
||||||
|
|
@ -933,6 +962,40 @@ class TestStaticGenerator(unittest.TestCase):
|
||||||
any(name.endswith(".md") for name in staticnames),
|
any(name.endswith(".md") for name in staticnames),
|
||||||
"STATIC_EXCLUDE_SOURCES=False failed to include a markdown file")
|
"STATIC_EXCLUDE_SOURCES=False failed to include a markdown file")
|
||||||
|
|
||||||
|
def test_static_links(self):
|
||||||
|
"""Test that StaticGenerator uses files in static_links
|
||||||
|
"""
|
||||||
|
settings = get_settings(
|
||||||
|
STATIC_EXCLUDES=['subdir'],
|
||||||
|
PATH=self.content_path,
|
||||||
|
STATIC_PATHS=[],)
|
||||||
|
context = get_context(settings)
|
||||||
|
context['static_links'] |= {'short_page.md', 'subdir_fake_image.jpg'}
|
||||||
|
|
||||||
|
StaticGenerator(
|
||||||
|
context=context, settings=settings,
|
||||||
|
path=settings['PATH'], output_path=self.temp_output,
|
||||||
|
theme=settings['THEME']).generate_context()
|
||||||
|
|
||||||
|
staticfiles_names = [
|
||||||
|
os.path.basename(c.source_path) for c in context['staticfiles']]
|
||||||
|
|
||||||
|
static_content_names = [
|
||||||
|
os.path.basename(c) for c in context['static_content']]
|
||||||
|
|
||||||
|
self.assertIn(
|
||||||
|
'short_page.md', staticfiles_names,
|
||||||
|
"StaticGenerator skipped a file that it should have included")
|
||||||
|
self.assertIn(
|
||||||
|
'short_page.md', static_content_names,
|
||||||
|
"StaticGenerator skipped a file that it should have included")
|
||||||
|
self.assertIn(
|
||||||
|
'subdir_fake_image.jpg', staticfiles_names,
|
||||||
|
"StaticGenerator skipped a file that it should have included")
|
||||||
|
self.assertIn(
|
||||||
|
'subdir_fake_image.jpg', static_content_names,
|
||||||
|
"StaticGenerator skipped a file that it should have included")
|
||||||
|
|
||||||
def test_copy_one_file(self):
|
def test_copy_one_file(self):
|
||||||
with open(self.startfile, "w") as f:
|
with open(self.startfile, "w") as f:
|
||||||
f.write("staticcontent")
|
f.write("staticcontent")
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ class TestPelican(LoggedTestCase):
|
||||||
self.assertDirsEqual(
|
self.assertDirsEqual(
|
||||||
self.temp_path, os.path.join(OUTPUT_PATH, 'basic'))
|
self.temp_path, os.path.join(OUTPUT_PATH, 'basic'))
|
||||||
self.assertLogCountEqual(
|
self.assertLogCountEqual(
|
||||||
count=3,
|
count=1,
|
||||||
msg="Unable to find.*skipping url replacement",
|
msg="Unable to find.*skipping url replacement",
|
||||||
level=logging.WARNING)
|
level=logging.WARNING)
|
||||||
|
|
||||||
|
|
@ -225,3 +225,18 @@ class TestPelican(LoggedTestCase):
|
||||||
count=1,
|
count=1,
|
||||||
msg="MD_EXTENSIONS is deprecated use MARKDOWN instead.",
|
msg="MD_EXTENSIONS is deprecated use MARKDOWN instead.",
|
||||||
level=logging.WARNING)
|
level=logging.WARNING)
|
||||||
|
|
||||||
|
def test_parse_errors(self):
|
||||||
|
# Verify that just an error is printed and the application doesn't
|
||||||
|
# abort, exit or something.
|
||||||
|
settings = read_settings(path=None, override={
|
||||||
|
'PATH': os.path.abspath(os.path.join(CURRENT_DIR, 'parse_error')),
|
||||||
|
'OUTPUT_PATH': self.temp_path,
|
||||||
|
'CACHE_PATH': self.temp_cache,
|
||||||
|
})
|
||||||
|
pelican = Pelican(settings=settings)
|
||||||
|
mute(True)(pelican.run)()
|
||||||
|
self.assertLogCountEqual(
|
||||||
|
count=1,
|
||||||
|
msg="Could not process .*parse_error.rst",
|
||||||
|
level=logging.ERROR)
|
||||||
|
|
|
||||||
|
|
@ -410,6 +410,12 @@ class RstReaderTest(ReaderTest):
|
||||||
self.assertEqual(tuple_date.metadata['date'],
|
self.assertEqual(tuple_date.metadata['date'],
|
||||||
string_date.metadata['date'])
|
string_date.metadata['date'])
|
||||||
|
|
||||||
|
def test_parse_error(self):
|
||||||
|
# Verify that it raises an Exception, not nothing and not SystemExit or
|
||||||
|
# some such
|
||||||
|
with six.assertRaisesRegex(self, Exception, "underline too short"):
|
||||||
|
self.read_file(path='../parse_error/parse_error.rst')
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(readers.Markdown, "markdown isn't installed")
|
@unittest.skipUnless(readers.Markdown, "markdown isn't installed")
|
||||||
class MdReaderTest(ReaderTest):
|
class MdReaderTest(ReaderTest):
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,11 @@
|
||||||
{% for p in pages %}
|
{% for p in pages %}
|
||||||
<li{% if p == page %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ p.url }}">{{ p.title }}</a></li>
|
<li{% if p == page %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ p.url }}">{{ p.title }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% endif %}
|
||||||
{% if DISPLAY_CATEGORIES_ON_MENU %}
|
{% if DISPLAY_CATEGORIES_ON_MENU %}
|
||||||
{% for cat, null in categories %}
|
{% for cat, null in categories %}
|
||||||
<li{% if cat == category %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat }}</a></li>
|
<li{% if cat == category %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul></nav><!-- /#menu -->
|
</ul></nav><!-- /#menu -->
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
||||||
|
|
@ -761,7 +761,7 @@ def update_links_to_attached_files(content, attachments):
|
||||||
http_url = old_url.replace('https://', 'http://')
|
http_url = old_url.replace('https://', 'http://')
|
||||||
https_url = old_url.replace('http://', 'https://')
|
https_url = old_url.replace('http://', 'https://')
|
||||||
for url in [http_url, https_url]:
|
for url in [http_url, https_url]:
|
||||||
content = content.replace(url, '{filename}' + new_path)
|
content = content.replace(url, '{static}' + new_path)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ SITEURL = '{{siteurl}}'
|
||||||
RELATIVE_URLS = False
|
RELATIVE_URLS = False
|
||||||
|
|
||||||
FEED_ALL_ATOM = 'feeds/all.atom.xml'
|
FEED_ALL_ATOM = 'feeds/all.atom.xml'
|
||||||
CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
|
CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'
|
||||||
|
|
||||||
DELETE_OUTPUT_DIRECTORY = True
|
DELETE_OUTPUT_DIRECTORY = True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -435,7 +435,7 @@ def path_to_url(path):
|
||||||
|
|
||||||
def posixize_path(rel_path):
|
def posixize_path(rel_path):
|
||||||
"""Use '/' as path separator, so that source references,
|
"""Use '/' as path separator, so that source references,
|
||||||
like '{filename}/foo/bar.jpg' or 'extras/favicon.ico',
|
like '{static}/foo/bar.jpg' or 'extras/favicon.ico',
|
||||||
will work on Windows as well as on Mac and Linux."""
|
will work on Windows as well as on Mac and Linux."""
|
||||||
return rel_path.replace(os.sep, '/')
|
return rel_path.replace(os.sep, '/')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ Why not ?
|
||||||
After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
|
||||||
YEAH !
|
YEAH !
|
||||||
|
|
||||||
.. image:: |filename|/pictures/Sushi.jpg
|
.. image:: |static|/pictures/Sushi.jpg
|
||||||
:height: 450 px
|
:height: 450 px
|
||||||
:width: 600 px
|
:width: 600 px
|
||||||
:alt: alternate text
|
:alt: alternate text
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@ This is a simple title
|
||||||
|
|
||||||
And here comes the cool stuff_.
|
And here comes the cool stuff_.
|
||||||
|
|
||||||
.. image:: |filename|/pictures/Sushi.jpg
|
.. image:: |static|/pictures/Sushi.jpg
|
||||||
:height: 450 px
|
:height: 450 px
|
||||||
:width: 600 px
|
:width: 600 px
|
||||||
:alt: alternate text
|
:alt: alternate text
|
||||||
|
|
||||||
.. image:: |filename|/pictures/Sushi_Macro.jpg
|
.. image:: |static|/pictures/Sushi_Macro.jpg
|
||||||
:height: 450 px
|
:height: 450 px
|
||||||
:width: 600 px
|
:width: 600 px
|
||||||
:alt: alternate text
|
:alt: alternate text
|
||||||
|
|
|
||||||
2
samples/pelican.conf.py
vendored
2
samples/pelican.conf.py
vendored
|
|
@ -18,7 +18,7 @@ DEFAULT_PAGINATION = 4
|
||||||
DEFAULT_DATE = (2012, 3, 2, 14, 1, 1)
|
DEFAULT_DATE = (2012, 3, 2, 14, 1, 1)
|
||||||
|
|
||||||
FEED_ALL_RSS = 'feeds/all.rss.xml'
|
FEED_ALL_RSS = 'feeds/all.rss.xml'
|
||||||
CATEGORY_FEED_RSS = 'feeds/%s.rss.xml'
|
CATEGORY_FEED_RSS = 'feeds/{slug}.rss.xml'
|
||||||
|
|
||||||
LINKS = (('Biologeek', 'http://biologeek.org'),
|
LINKS = (('Biologeek', 'http://biologeek.org'),
|
||||||
('Filyb', "http://filyb.info/"),
|
('Filyb', "http://filyb.info/"),
|
||||||
|
|
|
||||||
2
samples/pelican.conf_FR.py
vendored
2
samples/pelican.conf_FR.py
vendored
|
|
@ -22,7 +22,7 @@ ARTICLE_URL = 'posts/{date:%Y}/{date:%B}/{date:%d}/{slug}/'
|
||||||
ARTICLE_SAVE_AS = ARTICLE_URL + 'index.html'
|
ARTICLE_SAVE_AS = ARTICLE_URL + 'index.html'
|
||||||
|
|
||||||
FEED_ALL_RSS = 'feeds/all.rss.xml'
|
FEED_ALL_RSS = 'feeds/all.rss.xml'
|
||||||
CATEGORY_FEED_RSS = 'feeds/%s.rss.xml'
|
CATEGORY_FEED_RSS = 'feeds/{slug}.rss.xml'
|
||||||
|
|
||||||
LINKS = (('Biologeek', 'http://biologeek.org'),
|
LINKS = (('Biologeek', 'http://biologeek.org'),
|
||||||
('Filyb', "http://filyb.info/"),
|
('Filyb', "http://filyb.info/"),
|
||||||
|
|
|
||||||
3
tox.ini
3
tox.ini
|
|
@ -1,5 +1,5 @@
|
||||||
[tox]
|
[tox]
|
||||||
envlist = py{27,34,35,36},docs,flake8
|
envlist = py{27,34,35,36,37},docs,flake8
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
basepython =
|
basepython =
|
||||||
|
|
@ -7,6 +7,7 @@ basepython =
|
||||||
py34: python3.4
|
py34: python3.4
|
||||||
py35: python3.5
|
py35: python3.5
|
||||||
py36: python3.6
|
py36: python3.6
|
||||||
|
py37: python3.7
|
||||||
passenv = *
|
passenv = *
|
||||||
usedevelop=True
|
usedevelop=True
|
||||||
deps =
|
deps =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue