mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add the EXTRA_PATH_METADATA setting
Useful for altering static output paths when you don't want to encode extra metadata in the static file's source path.
This commit is contained in:
parent
1ca0e06a27
commit
d43dc1b9d6
3 changed files with 8 additions and 3 deletions
|
|
@ -64,6 +64,7 @@ Setting name (default value) What doe
|
||||||
``'(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)'``.
|
``'(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)'``.
|
||||||
`PATH_METADATA` (``''``) Like ``FILENAME_METADATA``, but parsed from a page's
|
`PATH_METADATA` (``''``) Like ``FILENAME_METADATA``, but parsed from a page's
|
||||||
full path relative to the content source directory.
|
full path relative to the content source directory.
|
||||||
|
`EXTRA_PATH_METADATA` (``{}``) Extra metadata dictionaries keyed by relative path.
|
||||||
`DELETE_OUTPUT_DIRECTORY` (``False``) Delete the output directory, and **all** of its contents, before
|
`DELETE_OUTPUT_DIRECTORY` (``False``) Delete the output directory, and **all** of its contents, before
|
||||||
generating new files. This can be useful in preventing older,
|
generating new files. This can be useful in preventing older,
|
||||||
unnecessary files from persisting in your output. However, **this is
|
unnecessary files from persisting in your output. However, **this is
|
||||||
|
|
|
||||||
|
|
@ -413,9 +413,12 @@ def default_metadata(settings=None, process=None):
|
||||||
|
|
||||||
def path_metadata(full_path, source_path, settings=None):
|
def path_metadata(full_path, source_path, settings=None):
|
||||||
metadata = {}
|
metadata = {}
|
||||||
if settings and settings.get('DEFAULT_DATE', None) == 'fs':
|
if settings:
|
||||||
metadata['date'] = datetime.datetime.fromtimestamp(
|
if settings.get('DEFAULT_DATE', None) == 'fs':
|
||||||
os.stat(path).st_ctime)
|
metadata['date'] = datetime.datetime.fromtimestamp(
|
||||||
|
os.stat(full_path).st_ctime)
|
||||||
|
metadata.update(settings.get('EXTRA_PATH_METADATA', {}).get(
|
||||||
|
source_path, {}))
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ DEFAULT_CONFIG = {
|
||||||
'DEFAULT_METADATA': (),
|
'DEFAULT_METADATA': (),
|
||||||
'FILENAME_METADATA': '(?P<date>\d{4}-\d{2}-\d{2}).*',
|
'FILENAME_METADATA': '(?P<date>\d{4}-\d{2}-\d{2}).*',
|
||||||
'PATH_METADATA': '',
|
'PATH_METADATA': '',
|
||||||
|
'EXTRA_PATH_METADATA': {},
|
||||||
'DEFAULT_STATUS': 'published',
|
'DEFAULT_STATUS': 'published',
|
||||||
'ARTICLE_PERMALINK_STRUCTURE': '',
|
'ARTICLE_PERMALINK_STRUCTURE': '',
|
||||||
'TYPOGRIFY': False,
|
'TYPOGRIFY': False,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue