~hristoast/hristoast

ref: 49893c9af5470d894990de5bd58734de8c714061 hristoast/scripts/index.py -rwxr-xr-x 630 bytes
49893c9aHristos N. Triantafillou Filter out pages without a title as well as a date 1 year, 11 months ago
                                                                                
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
#!/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 = """
<h3><a href="{{url}}">{{{title}}}</a></h3>
<p>Posted: {{date}}</p>
<p>{{{excerpt}}}</p>
<a href="{{url}}">Read more...</a>
"""

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))