mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Delib. overriding and overwrite detect. Fixes #938
Make deliberate overriding (*) works with overwrites detection. (*) first introduced byd0e9c52410The following are decided to be deliberate override: - articles using the `save_as` metadata - pages using the `save_as` metadata - template pages (always) Pelican now exits in the following 2 cases: - at least 2 not deliberate writes to the same file name (behaviour introduced by the overwrite detection featureff7410ce2a) - at least 2 deliberate writes to the same file name (new behaviour) Also added info logging when deliberate overrides are performed. Switched to StandardError instead of IOError, thanks to @ametaireau and @russkel.
This commit is contained in:
parent
0999d4d691
commit
a495527e2b
2 changed files with 33 additions and 12 deletions
|
|
@ -168,7 +168,8 @@ class TemplatePagesGenerator(Generator):
|
|||
try:
|
||||
template = self.env.get_template(source)
|
||||
rurls = self.settings['RELATIVE_URLS']
|
||||
writer.write_file(dest, template, self.context, rurls)
|
||||
writer.write_file(dest, template, self.context, rurls,
|
||||
override_output=True)
|
||||
finally:
|
||||
del self.env.loader.loaders[0]
|
||||
|
||||
|
|
@ -262,7 +263,8 @@ class ArticlesGenerator(Generator):
|
|||
"""Generate the articles."""
|
||||
for article in chain(self.translations, self.articles):
|
||||
write(article.save_as, self.get_template(article.template),
|
||||
self.context, article=article, category=article.category)
|
||||
self.context, article=article, category=article.category,
|
||||
override_output=hasattr(article, 'override_save_as'))
|
||||
|
||||
def generate_period_archives(self, write):
|
||||
"""Generate per-year, per-month, and per-day archives."""
|
||||
|
|
@ -533,7 +535,8 @@ class PagesGenerator(Generator):
|
|||
self.hidden_translations, self.hidden_pages):
|
||||
writer.write_file(page.save_as, self.get_template(page.template),
|
||||
self.context, page=page,
|
||||
relative_urls=self.settings['RELATIVE_URLS'])
|
||||
relative_urls=self.settings['RELATIVE_URLS'],
|
||||
override_output=hasattr(page, 'override_save_as'))
|
||||
|
||||
|
||||
class StaticGenerator(Generator):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue