ref: a88176164f054b435a6551e6c0006dabb96d2b74 hristoast/scripts/index.py -rwxr-xr-x 657 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3

# Forked from:
# https://github.com/dmbaturin/soupault.neocities.org/blob/314be103fb917edb06ca70f18b6f9370b120f5f5/scripts/index.py

import sys
import json

import pystache

template = """
<div class="entry">
<h3><a href="{{url}}">{{{title}}}</a></h3>
<p>Posted: {{date}}</p>
<p>{{{excerpt}}}</p>
<a href="{{url}}">Read more...</a>
</div>
"""

renderer = pystache.Renderer()

read = sys.stdin.readline()
index_entries = json.loads(read)

for entry in index_entries:
    # Don't try to list files that aren't blog posts.
    if entry["title"] is not None and entry["date"] is not None:
        print(renderer.render(template, entry))