mirror of
https://github.com/venthur/blag.git
synced 2025-11-25 20:52:43 +00:00
generate archive
This commit is contained in:
14
sg/sg.py
14
sg/sg.py
@@ -155,7 +155,21 @@ def convert_to_html(convertibles):
|
|||||||
|
|
||||||
with open('atom.xml', 'w') as fh:
|
with open('atom.xml', 'w') as fh:
|
||||||
feed.write(fh, encoding='utf8')
|
feed.write(fh, encoding='utf8')
|
||||||
|
|
||||||
# generate archive
|
# generate archive
|
||||||
|
ctx = {}
|
||||||
|
archive = []
|
||||||
|
for dst, context in articles:
|
||||||
|
entry = context.copy()
|
||||||
|
entry['dst'] = dst
|
||||||
|
archive.append(entry)
|
||||||
|
archive = sorted(archive, key=lambda x: x['date'], reverse=True)
|
||||||
|
ctx['archive'] = archive
|
||||||
|
template = env.get_template('archive.html')
|
||||||
|
result = template.render(ctx)
|
||||||
|
with open('archive.html', 'w') as fh:
|
||||||
|
fh.write(result)
|
||||||
|
|
||||||
# generate tags
|
# generate tags
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
5
sg/templates/archive.html
Normal file
5
sg/templates/archive.html
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<ul>
|
||||||
|
{% for entry in archive %}
|
||||||
|
<li><a href="{{entry.dst}}">{{entry.title}}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
Reference in New Issue
Block a user