cloneresult.check_returncode()
# Set up various containers.
+ irimap = {}
months = {}
topics = {}
status["@id"] = f"{PUBLIC_URL}/topics/{topic}/{identifier}" if topic else f"{PUBLIC_URL}/statuses/{datetime[0:7]}/{identifier}"
with identifier_path.open("r", encoding="utf-8") as text:
status["identifier"] = text.read().strip()
+ irimap[status["identifier"]] = status["@id"]
else:
warn(f"Missing identifier for {path}; skipping.")
return None
with open(f"{PUBLIC_DIRECTORY}/topics/index.jsonld", "w", encoding="utf-8") as f:
json.dump({ "@context": { "@language": LANG, "activity": "https://www.w3.org/ns/activitystreams#", "dct": "http://purl.org/dc/terms/", "sioc": "http://rdfs.org/sioc/ns#", "Collection": "activity:Collection", "Forum": "sioc:Forum", "items": { "@id": "activity:items", "@type": "@id" }, "has_parent": { "@id": "sioc:has_parent", "@type": "id" }, "subject": "dct:subject" }, "@id": f"{PUBLIC_URL}/topics", "@type": ["Collection", "Forum"], "items": list(map(lambda a: { "@id": a["@id"], "subject": a["subject"] }, topics.values())), "has_parent": f"{PUBLIC_URL}" }, f, ensure_ascii=False, allow_nan=False)
+ # Output the I·R·I redirection page
+ with open(f"{PUBLIC_DIRECTORY}/.lookup.xhtml", "w", encoding="utf-8") as f:
+ doc = getDOMImplementation().createDocument(None, "xml", None)
+ htmlElt = doc.documentElement
+ htmlElt.setAttribute("xmlns", XHTML_NAMESPACE)
+ htmlElt.setAttribute("lang", LANG)
+ headElt = htmlElt.appendChild(doc.createElement("head"))
+ titleElt = headElt.appendChild(doc.createElement("title"))
+ titleElt.appendChild(doc.createTextNode("Redirecting…"))
+ scriptElt = headElt.appendChild(doc.createElement("script"))
+ scriptElt.setAttribute("type", "text/javascript")
+ scriptElt.appendChild(doc.createTextNode(f"location={json.dumps(irimap)}[location.pathname.substring(1)]??`/`"))
+ bodyElt = htmlElt.appendChild(doc.createElement("body"))
+ bodyElt.appendChild(doc.createTextNode("Attempting to redirect to the proper page… (Requires Javascript.)"))
+ f.write(doc.toxml())
+
# Remove the build directory.
rmtree(BUILD_DIRECTORY)