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