Skip to content

Commit

Permalink
add all entries page
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuyukimakoto committed Feb 23, 2024
1 parent 531adcf commit 8478874
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions biisan/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ def write_sitemaps(story_list):
f.write(sitemap)


def write_all_entry(story_list):
last_modified_iso_8601 = max(map(lambda x: x.date, story_list)).isoformat()
env = get_environment(config)
all_entry = env.get_template('blog_all.html')
all_entries = all_entry.render(config=config,
story_list=story_list,
last_modified=last_modified_iso_8601)
all_entry_dir = os.path.join(
config.settings.dir.output, 'blog', 'all')
os.makedirs(all_entry_dir, exist_ok=True)
with codecs.open(os.path.join(all_entry_dir, 'index.html'), 'w', 'utf8') as f:
f.write(all_entries)

def register_directives():
for directive in config.settings.directives:
directive_class = get_klass(directive)
Expand Down Expand Up @@ -214,6 +227,7 @@ def main():
write_blog_archive(story_list)
write_rss20(story_list)
write_sitemaps(story_list)
write_all_entry(story_list)


if __name__ == '__main__':
Expand Down
12 changes: 12 additions & 0 deletions biisan/templates/blog_all.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends 'base.html' %}

{% block title %}All Entry{% endblock title %}

{% block contents %}
<section class="recent">
<h2>All Entry</h2>
<ul>{% for story in story_list|reverse %}
<li>{{ loop.revindex }} : {{ story.published_datetime }} <a href="{{ story.url }}">{{ story.title }}</a></li>
{% endfor %}</ul>
</section>
{% endblock contents %}

0 comments on commit 8478874

Please sign in to comment.