mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
generators: Use the static format to read Static metadata
This cuts down on the remaining difference between static files and articles/pages. The main difference is that path-based metadata is now parsed for static content.
This commit is contained in:
parent
f147d9ec4a
commit
29cdb37af3
2 changed files with 10 additions and 7 deletions
|
|
@ -563,21 +563,24 @@ class StaticGenerator(Generator):
|
||||||
for f in self.get_files(
|
for f in self.get_files(
|
||||||
os.path.join(self.path, static_path), extensions=False):
|
os.path.join(self.path, static_path), extensions=False):
|
||||||
f_rel = os.path.relpath(f, self.path)
|
f_rel = os.path.relpath(f, self.path)
|
||||||
|
content, metadata = read_file(
|
||||||
|
f, fmt='static', settings=self.settings)
|
||||||
# TODO remove this hardcoded 'static' subdirectory
|
# TODO remove this hardcoded 'static' subdirectory
|
||||||
dest = os.path.join('static', f_rel)
|
metadata['save_as'] = os.path.join('static', f_rel)
|
||||||
url = pelican.utils.path_to_url(dest)
|
metadata['url'] = pelican.utils.path_to_url(metadata['save_as'])
|
||||||
sc = Static(
|
sc = Static(
|
||||||
content=None,
|
content=None,
|
||||||
metadata={
|
metadata=metadata,
|
||||||
'save_as': dest,
|
|
||||||
'url': url,
|
|
||||||
},
|
|
||||||
settings=self.settings,
|
settings=self.settings,
|
||||||
source_path=f_rel)
|
source_path=f_rel)
|
||||||
self.staticfiles.append(sc)
|
self.staticfiles.append(sc)
|
||||||
self.add_source_path(sc)
|
self.add_source_path(sc)
|
||||||
# same thing for FILES_TO_COPY
|
# same thing for FILES_TO_COPY
|
||||||
for src, dest in self.settings['FILES_TO_COPY']:
|
for src, dest in self.settings['FILES_TO_COPY']:
|
||||||
|
content, metadata = read_file(
|
||||||
|
src, fmt='static', settings=self.settings)
|
||||||
|
metadata['save_as'] = dest
|
||||||
|
metadata['url'] = pelican.utils.path_to_url(metadata['save_as'])
|
||||||
sc = Static(
|
sc = Static(
|
||||||
content=None,
|
content=None,
|
||||||
metadata={'save_as': dest},
|
metadata={'save_as': dest},
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,7 @@ def read_file(path, fmt=None, settings=None):
|
||||||
metadata.update(reader_metadata)
|
metadata.update(reader_metadata)
|
||||||
|
|
||||||
# eventually filter the content with typogrify if asked so
|
# eventually filter the content with typogrify if asked so
|
||||||
if settings and settings.get('TYPOGRIFY'):
|
if content and settings and settings.get('TYPOGRIFY'):
|
||||||
from typogrify.filters import typogrify
|
from typogrify.filters import typogrify
|
||||||
content = typogrify(content)
|
content = typogrify(content)
|
||||||
metadata['title'] = typogrify(metadata['title'])
|
metadata['title'] = typogrify(metadata['title'])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue