mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge 031cad0b00 into df70fa8596
This commit is contained in:
commit
0536bacde6
1 changed files with 34 additions and 2 deletions
|
|
@ -346,7 +346,7 @@ 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.article_subparts):
|
||||
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,
|
||||
|
|
@ -537,6 +537,30 @@ class ArticlesGenerator(CachingGenerator):
|
|||
|
||||
signals.article_generator_pretaxonomy.send(self)
|
||||
|
||||
slugs= {}
|
||||
for article in self.articles:
|
||||
slugs[article.slug]= article
|
||||
self.article_subparts= []
|
||||
articles_main= []
|
||||
for article in self.articles:
|
||||
if '--' in article.slug:
|
||||
(pslug, _)= article.slug.split('--', 1)
|
||||
if pslug in slugs:
|
||||
parent= slugs[pslug]
|
||||
if not hasattr(parent, 'subparts'):
|
||||
parent.subparts= []
|
||||
parent.subparts.append(article)
|
||||
article.subpart_of= parent
|
||||
self.article_subparts.append(article)
|
||||
article.subtitle= article.title
|
||||
article.title= article.title + ", " + parent.title
|
||||
else:
|
||||
logger.error('No parent for {}'.format(pslug))
|
||||
articles_main.append(article)
|
||||
else:
|
||||
articles_main.append(article)
|
||||
self.articles= articles_main
|
||||
|
||||
for article in self.articles:
|
||||
# only main articles are listed in categories and tags
|
||||
# not translations
|
||||
|
|
@ -548,6 +572,13 @@ class ArticlesGenerator(CachingGenerator):
|
|||
for author in getattr(article, 'authors', []):
|
||||
if author.name != '':
|
||||
self.authors[author].append(article)
|
||||
|
||||
for article in self.article_subparts:
|
||||
# But parts should also show in tags
|
||||
if hasattr(article, 'tags'):
|
||||
for tag in article.tags:
|
||||
self.tags[tag].append(article)
|
||||
|
||||
# sort the articles by date
|
||||
self.articles.sort(key=attrgetter('date'), reverse=True)
|
||||
self.dates = list(self.articles)
|
||||
|
|
@ -591,7 +622,8 @@ class ArticlesGenerator(CachingGenerator):
|
|||
self.authors.sort()
|
||||
|
||||
self._update_context(('articles', 'dates', 'tags', 'categories',
|
||||
'tag_cloud', 'authors', 'related_posts'))
|
||||
'tag_cloud', 'authors', 'related_posts',
|
||||
'article_subparts'))
|
||||
self.save_cache()
|
||||
self.readers.save_cache()
|
||||
signals.article_generator_finalized.send(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue