Make StaticGenerator skip content sources. Refs #1019.

This change partially addresses issue #1019, by teaching Pelican to distinguish
between static files and content source files. A user can now safely add the
same directory to both STATIC_PATHS and PAGE_PATHS (or ARTICLE_PATHS). Pelican
will then process the content source files in that directory normally, and
treat the remaining files as static, without copying the raw content source
files to the output directory. (The OUTPUT_SOURCES setting still works.)

In other words, images and markdown/reST files can now safely live together.

To keep those files together in the generated site, STATIC_SAVE_AS and
PAGE_SAVE_AS (or ARTICLE_SAVE_AS) should point to the same output directory.

There are two new configuration settings:

STATIC_EXCLUDES=[]  # This works just like PAGE_EXCLUDES and ARTICLE_EXCLUDES.
STATIC_EXCLUDE_SOURCES=True  # Set this to False to get the old behavior.

Two small but noteworthy internal changes:

StaticGenerator now runs after all the other generators. This allows it to see
which files are meant to be processed by other generators, and avoid them.

Generators now include files that they fail to process (e.g. those with missing
mandatory metadata) along with all the other paths in context['filenames'].
This allows such files to be excluded from StaticGenerator's file list, so they
won't end up accidentally published. Since these files have no Content object,
their value in context['filenames'] is None. The code that uses that dict has
been updated accordingly.
This commit is contained in:
Forest 2014-10-18 13:11:59 -07:00
commit 48f4f0850d
10 changed files with 131 additions and 10 deletions

View file

@ -142,10 +142,15 @@ Setting name (followed by default value, if any)
slash at the end. Example: ``SITEURL = 'http://mydomain.com'``
``TEMPLATE_PAGES = None`` A mapping containing template pages that will be rendered with
the blog entries. See :ref:`template_pages`.
``STATIC_PATHS = ['images']`` The static paths you want to have accessible
on the output path "static". By default,
Pelican will copy the "images" folder to the
output folder.
``STATIC_PATHS = ['images']`` A list of directories (relative to ``PATH``) in which to look for
static files. Such files will be copied to the output directory
without modification. Articles, pages, and other content source
files will normally be skipped, so it is safe for a directory to
appear both here and in ``PAGE_PATHS`` or ``ARTICLE_PATHS``.
Pelican's default settings include the "images" directory here.
``STATIC_EXCLUDES = []`` A list of directories to exclude when looking for static files.
``STATIC_EXCLUDE_SOURCES = True`` If set to False, content source files will not be skipped when
copying files found in ``STATIC_PATHS``.
``TIMEZONE`` The timezone used in the date information, to
generate Atom and RSS feeds. See the *Timezone*
section below for more info.