mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Fix #12
This commit is contained in:
parent
a3f0ded146
commit
5fda51de42
2 changed files with 6 additions and 10 deletions
|
|
@ -27,7 +27,6 @@ class ArticlesProcessor(Processor):
|
||||||
def __init__(self, settings=None):
|
def __init__(self, settings=None):
|
||||||
self.articles = []
|
self.articles = []
|
||||||
self.dates = {}
|
self.dates = {}
|
||||||
self.years = {}
|
|
||||||
self.tags = {}
|
self.tags = {}
|
||||||
self.categories = {}
|
self.categories = {}
|
||||||
|
|
||||||
|
|
@ -82,8 +81,6 @@ class ArticlesProcessor(Processor):
|
||||||
if not is_valid_content(article, f):
|
if not is_valid_content(article, f):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
update_dict(self.dates, article.date.strftime('%Y-%m-%d'), article)
|
|
||||||
update_dict(self.years, article.date.year, article)
|
|
||||||
update_dict(self.categories, article.category, article)
|
update_dict(self.categories, article.category, article)
|
||||||
if hasattr(article, 'tags'):
|
if hasattr(article, 'tags'):
|
||||||
for tag in article.tags:
|
for tag in article.tags:
|
||||||
|
|
@ -92,9 +89,10 @@ class ArticlesProcessor(Processor):
|
||||||
|
|
||||||
# sort the articles by date
|
# sort the articles by date
|
||||||
self.articles.sort(key=attrgetter('date'), reverse=True)
|
self.articles.sort(key=attrgetter('date'), reverse=True)
|
||||||
|
self.dates = self.articles
|
||||||
|
self.dates.sort(key=attrgetter('date'))
|
||||||
# and generate the output :)
|
# and generate the output :)
|
||||||
self._update_context(context, ('articles', 'dates', 'years',
|
self._update_context(context, ('articles', 'dates', 'tags', 'categories'))
|
||||||
'tags', 'categories'))
|
|
||||||
|
|
||||||
def process(self, context, generator):
|
def process(self, context, generator):
|
||||||
self.generate_feeds(context, generator)
|
self.generate_feeds(context, generator)
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,9 @@
|
||||||
<h1>Archives for {{ SITENAME }}</h1>
|
<h1>Archives for {{ SITENAME }}</h1>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
{% for date, articles in dates %}
|
{% for article in dates %}
|
||||||
{% for article in articles %}
|
<dt>{{ article.date.strftime('%a %d %B %Y') }}</dt>
|
||||||
<dt>{{ date }}</dt>
|
<dd><a href='{{ article.url }}'>{{ article.title }}</a></dd>
|
||||||
<dd><a href='{{ article.url }}'>{{ article.title }}</a></dd>
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</dl>
|
</dl>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue