forked from github/pelican
Add support for hidden articles
This commit is contained in:
parent
487da3550b
commit
add3628a64
8 changed files with 70 additions and 14 deletions
|
|
@ -285,15 +285,20 @@ class ArticlesGenerator(CachingGenerator):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""initialize properties"""
|
||||
# Published, listed articles
|
||||
self.articles = [] # only articles in default language
|
||||
self.translations = []
|
||||
# Published, unlisted articles
|
||||
self.hidden_articles = []
|
||||
self.hidden_translations = []
|
||||
# Draft articles
|
||||
self.drafts = [] # only drafts in default language
|
||||
self.drafts_translations = []
|
||||
self.dates = {}
|
||||
self.tags = defaultdict(list)
|
||||
self.categories = defaultdict(list)
|
||||
self.related_posts = []
|
||||
self.authors = defaultdict(list)
|
||||
self.drafts = [] # only drafts in default language
|
||||
self.drafts_translations = []
|
||||
super().__init__(*args, **kwargs)
|
||||
signals.article_generator_init.send(self)
|
||||
|
||||
|
|
@ -461,7 +466,10 @@ class ArticlesGenerator(CachingGenerator):
|
|||
|
||||
def generate_articles(self, write):
|
||||
"""Generate the articles."""
|
||||
for article in chain(self.translations, self.articles):
|
||||
for article in chain(
|
||||
self.translations, self.articles,
|
||||
self.hidden_translations, self.hidden_articles
|
||||
):
|
||||
signals.article_generator_write_article.send(self, content=article)
|
||||
write(article.save_as, self.get_template(article.template),
|
||||
self.context, article=article, category=article.category,
|
||||
|
|
@ -609,6 +617,7 @@ class ArticlesGenerator(CachingGenerator):
|
|||
|
||||
all_articles = []
|
||||
all_drafts = []
|
||||
hidden_articles = []
|
||||
for f in self.get_files(
|
||||
self.settings['ARTICLE_PATHS'],
|
||||
exclude=self.settings['ARTICLE_EXCLUDES']):
|
||||
|
|
@ -639,6 +648,9 @@ class ArticlesGenerator(CachingGenerator):
|
|||
all_articles.append(article)
|
||||
elif article.status == "draft":
|
||||
all_drafts.append(article)
|
||||
elif article.status == "hidden":
|
||||
hidden_articles.append(article)
|
||||
|
||||
self.add_source_path(article)
|
||||
self.add_static_links(article)
|
||||
|
||||
|
|
@ -649,13 +661,14 @@ class ArticlesGenerator(CachingGenerator):
|
|||
return origs, translations
|
||||
|
||||
self.articles, self.translations = _process(all_articles)
|
||||
self.hidden_articles, self.hidden_translations = _process(hidden_articles)
|
||||
self.drafts, self.drafts_translations = _process(all_drafts)
|
||||
|
||||
signals.article_generator_pretaxonomy.send(self)
|
||||
|
||||
for article in self.articles:
|
||||
# only main articles are listed in categories and tags
|
||||
# not translations
|
||||
# not translations or hidden articles
|
||||
self.categories[article.category].append(article)
|
||||
if hasattr(article, 'tags'):
|
||||
for tag in article.tags:
|
||||
|
|
@ -677,8 +690,10 @@ class ArticlesGenerator(CachingGenerator):
|
|||
self.authors = list(self.authors.items())
|
||||
self.authors.sort()
|
||||
|
||||
self._update_context(('articles', 'dates', 'tags', 'categories',
|
||||
'authors', 'related_posts', 'drafts'))
|
||||
self._update_context((
|
||||
'articles', 'drafts', 'hidden_articles',
|
||||
'dates', 'tags', 'categories',
|
||||
'authors', 'related_posts'))
|
||||
self.save_cache()
|
||||
self.readers.save_cache()
|
||||
signals.article_generator_finalized.send(self)
|
||||
|
|
@ -692,7 +707,9 @@ class ArticlesGenerator(CachingGenerator):
|
|||
for e in chain(self.articles,
|
||||
self.translations,
|
||||
self.drafts,
|
||||
self.drafts_translations):
|
||||
self.drafts_translations,
|
||||
self.hidden_articles,
|
||||
self.hidden_translations):
|
||||
if hasattr(e, 'refresh_metadata_intersite_links'):
|
||||
e.refresh_metadata_intersite_links()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue