|
@@ -8,6 +8,7 @@ import pystache
|
|
|
import shutil
|
|
|
import sys
|
|
|
import tempfile
|
|
|
+from typing import Optional
|
|
|
import yaml
|
|
|
|
|
|
class Datum:
|
|
@@ -39,6 +40,7 @@ class Work:
|
|
|
title: str
|
|
|
date: str
|
|
|
contents: str
|
|
|
+ description: Optional[str] = None
|
|
|
|
|
|
class Path:
|
|
|
OUTDIR=tempfile.TemporaryDirectory()
|
|
@@ -68,13 +70,13 @@ class Path:
|
|
|
|
|
|
@classmethod
|
|
|
def list(cls, *paths):
|
|
|
- stuff = []
|
|
|
+ stuff = set()
|
|
|
tgt = f'{os.path.join(*paths)}/'
|
|
|
for path in sys.argv[2:]:
|
|
|
if tgt in path:
|
|
|
chunks = path.split('/')
|
|
|
idx = chunks.index(paths[-1])
|
|
|
- stuff.append(chunks[idx +1])
|
|
|
+ stuff.add(chunks[idx +1])
|
|
|
return stuff
|
|
|
|
|
|
class Template:
|
|
@@ -94,7 +96,7 @@ def main():
|
|
|
out_file = sys.argv[1]
|
|
|
|
|
|
year = datetime.datetime.now().year
|
|
|
- std_copy = f'© Getty Ritter {year}'
|
|
|
+ std_copy = f'©{year} Getty Ritter'
|
|
|
no_copy = 'all rights reversed'
|
|
|
|
|
|
# gather the quips and make their individual pages
|
|
@@ -104,9 +106,14 @@ def main():
|
|
|
quips.append(q)
|
|
|
with Path.write('quips', uuid, 'index.html') as f:
|
|
|
f.write(Template.main({
|
|
|
- 'title': f"Quip {uuid}",
|
|
|
+ 'title': f"Quip",
|
|
|
'contents': Template.quote({'quotelist': [q]}),
|
|
|
'copy': no_copy,
|
|
|
+ 'opengraph': {
|
|
|
+ 'title': f'quip:{uuid}',
|
|
|
+ 'url': f'/quip/{uuid}/',
|
|
|
+ 'description': q.content,
|
|
|
+ },
|
|
|
}))
|
|
|
|
|
|
# sort 'em and make the combined page
|
|
@@ -124,10 +131,16 @@ def main():
|
|
|
q = Quote.from_file(Path.data('quotes', uuid))
|
|
|
quotes.append(q)
|
|
|
with Path.write('quotes', uuid, 'index.html') as f:
|
|
|
+ contents = Template.quote({'quotelist': [q]})
|
|
|
f.write(Template.main({
|
|
|
- 'title': f"Quote {uuid}",
|
|
|
- 'contents': Template.quote({'quotelist': [q]}),
|
|
|
+ 'title': f"Quote",
|
|
|
+ 'contents': contents,
|
|
|
'copy': no_copy,
|
|
|
+ 'opengraph': {
|
|
|
+ 'title': f'quote:{uuid}',
|
|
|
+ 'url': f'/quote/{uuid}/',
|
|
|
+ 'description': f'{q.content}\n---{q.author}',
|
|
|
+ },
|
|
|
}))
|
|
|
|
|
|
# sort 'em and make their combined page
|
|
@@ -143,6 +156,8 @@ def main():
|
|
|
with open(Path.data('works.json')) as f:
|
|
|
categories = yaml.safe_load(f)
|
|
|
|
|
|
+ category_lookup = {c['slug']: c for c in categories}
|
|
|
+
|
|
|
# make an index page for each category
|
|
|
with Path.write('category', 'index.html') as f:
|
|
|
f.write(Template.main({
|
|
@@ -153,7 +168,7 @@ def main():
|
|
|
for c in categories
|
|
|
]
|
|
|
}),
|
|
|
- 'copy': 'whatever',
|
|
|
+ 'copy': std_copy,
|
|
|
}))
|
|
|
|
|
|
# create each category page
|
|
@@ -181,11 +196,23 @@ def main():
|
|
|
# report other works in their own year
|
|
|
copy = f'© Getty Ritter {w.date}'
|
|
|
|
|
|
+ if w.description is not None:
|
|
|
+ description = w.description
|
|
|
+ elif slug in category_lookup:
|
|
|
+ singular = category_lookup[slug]['singular']
|
|
|
+ description = f'{w.title}: a {singular}'
|
|
|
+ else:
|
|
|
+ description = '...'
|
|
|
with Path.write(w.slug, 'index.html') as f:
|
|
|
f.write(Template.main({
|
|
|
'title': w.title,
|
|
|
'contents': text,
|
|
|
'copy': copy,
|
|
|
+ 'opengraph': {
|
|
|
+ 'title': w.title,
|
|
|
+ 'url': f'/{w.slug}/',
|
|
|
+ 'description': description,
|
|
|
+ },
|
|
|
}))
|
|
|
works.append(w)
|
|
|
works.sort(key=lambda w: w.slug)
|