diff --git a/Makefile b/Makefile
index 34ea042..329037e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,17 @@
-index.json: index.html
- python3 scripts/extract_rdf.py > $@
-
-index_titles.html: index.json scripts/templates/index_titles.html scripts/index_new.py
- python3 scripts/index_new.py
-
venv/:
python3 -m venv venv
source venv/bin/activate
pip install html5lib jinja2 rdflib pyrdfa3
+index.json: index.html
+ python3 scripts/extract_rdf.py > $@
+
merge.json: index.json covers.json
python3 scripts/merge_json.py index.json covers.json > $@
+
+index_titles.html: merge.json scripts/templates/index_titles.html scripts/index_new.py
+ python3 scripts/index_new.py index_titles.html index_titles.html
+
+index_thesis.html: merge.json scripts/templates/index_thesis.html scripts/index_new.py
+ python3 scripts/index_new.py index_thesis.html index_thesis.html
+
diff --git a/index_thesis.html b/index_thesis.html
new file mode 100644
index 0000000..4b8ae90
--- /dev/null
+++ b/index_thesis.html
@@ -0,0 +1,84 @@
+
+
+
+
+
+ XPUB Projects
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scripts/index_new.py b/scripts/index_new.py
index 426d5b9..35143e3 100644
--- a/scripts/index_new.py
+++ b/scripts/index_new.py
@@ -1,20 +1,19 @@
import json
from jinja2 import Template, Environment, FileSystemLoader
-
-env = Environment(loader=FileSystemLoader("scripts/templates"))
-
-# import jinjafy.filters
-# for name, fn in jinjafy.filters.all.items():
-# env.filters[name] = fn
-
+import argparse
from common import load_json
-data = load_json()
-# with open("index.json") as fin:
-# data = json.load(fin)
-# data['projects'] = [x for x in data['@graph'] if x['type'] == 'project']
-# data['projects'].sort(key=lambda x: x['title'].strip('"').lower())
+ap = argparse.ArgumentParser("")
+ap.add_argument("template")
+ap.add_argument("output")
+args = ap.parse_args()
+
+env = Environment(loader=FileSystemLoader("scripts/templates"))
+import jinjafilters
+for name, fn in jinjafilters.all.items():
+ env.filters[name] = fn
-template = env.get_template("index_titles.html")
-with open("index_titles.html", "w") as fout:
+data = load_json("merge.json")
+template = env.get_template(args.template)
+with open(args.output, "w") as fout:
print (template.render(**data), file=fout)
diff --git a/scripts/jinjafilters.py b/scripts/jinjafilters.py
new file mode 100644
index 0000000..e47074b
--- /dev/null
+++ b/scripts/jinjafilters.py
@@ -0,0 +1,101 @@
+from itertools import zip_longest
+from urllib.parse import quote as urlquote, unquote as urlunquote
+import time
+from markdown import markdown as markdown_
+import json as json_
+import math
+
+
+
+
+def datetimeformat (t, format='%Y-%m-%d %H:%M:%S'):
+ return time.strftime(format, time.localtime(t))
+
+def append (t, at, rstrip=True):
+ if rstrip:
+ return t.rstrip() + at
+ else:
+ return t+at
+
+def append_edit_link (t, url=None):
+ #
+ if url:
+ return t.rstrip() + '✍'.format(urlquote(url))
+ else:
+ return t.rstrip() + '✍'
+
+def grouper(iterable, n, fillvalue=None):
+ "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
+ args = [iter(iterable)] * n
+ return zip_longest(fillvalue=fillvalue, *args)
+
+def humanize_bytes(bytesize, precision=2):
+ """
+ Humanize byte size figures
+ """
+ abbrevs = (
+ (1 << 50, 'PB'),
+ (1 << 40, 'TB'),
+ (1 << 30, 'GB'),
+ (1 << 20, 'MB'),
+ (1 << 10, 'kB'),
+ (1, 'bytes')
+ )
+ if bytesize == 1:
+ return '1 byte'
+ for factor, suffix in abbrevs:
+ if bytesize >= factor:
+ break
+ if factor == 1:
+ precision = 0
+ return '%.*f %s' % (precision, bytesize / float(factor), suffix)
+
+
+def timecode(rawsecs, fract=True, alwaysfract=True, fractdelim='.', alwayshours=True):
+ # returns a string in HH:MM:SS[.xxx] notation
+ # if fract is True, uses .xxx if either necessary (non-zero)
+ # OR alwaysfract is True
+ hours = math.floor(rawsecs / 3600)
+ rawsecs -= hours * 3600
+ mins = math.floor(rawsecs / 60)
+ rawsecs -= mins * 60
+ if fract:
+ secs = math.floor(rawsecs)
+ rawsecs -= secs
+ if (rawsecs > 0 or alwaysfract):
+ fract = "%.03f" % rawsecs
+ if hours or alwayshours:
+ return "%02d:%02d:%02d%s%s" % (hours, mins, secs, fractdelim, \
+ fract[2:])
+ else:
+ return "%02d:%02d%s%s" % (mins, secs, fractdelim, fract[2:])
+ else:
+ if hours or alwayshours:
+ return "%02d:%02d:%02d" % (hours, mins, secs)
+ else:
+ return "%02d:%02d" % (mins, secs)
+
+ else:
+ secs = round(rawsecs)
+ if hours or alwayshours:
+ return "%02d:%02d:%02d" % (hours, mins, secs)
+ else:
+ return "%02d:%02d" % (mins, secs)
+
+def markdown (src):
+ return markdown_(src)
+
+def json (src):
+ return json_.dumps(src, indent=2)
+
+all = {
+ 'datetimeformat': datetimeformat,
+ 'grouper': grouper,
+ 'timecode': timecode,
+ 'humanize_bytes': humanize_bytes,
+ 'urlquote': urlquote,
+ 'markdown': markdown,
+ 'append': append,
+ 'json': json,
+ 'append_edit_link': append_edit_link
+}
\ No newline at end of file
diff --git a/scripts/templates/index_thesis.html b/scripts/templates/index_thesis.html
new file mode 100644
index 0000000..58194ac
--- /dev/null
+++ b/scripts/templates/index_thesis.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+ XPUB Projects
+
+
+
+
+
+{% for project in projects %}
+
+{%- endfor %}
+
+
\ No newline at end of file