X-Git-Url: https://git.ladys.computer/x_status_git/blobdiff_plain/760145cc6cea91fe442ac247c0d947b455320276..6b8de961c3f0e23435afe54d072951d9dd007f79:/post-receive?ds=inline diff --git a/post-receive b/post-receive index f6289da..d273055 100755 --- a/post-receive +++ b/post-receive @@ -38,6 +38,7 @@ if stdin.read().split()[-1] == f"refs/heads/{LIVE_BRANCH}": cloneresult.check_returncode() # Set up various containers. + irimap = {} months = {} topics = {} @@ -99,6 +100,7 @@ if stdin.read().split()[-1] == f"refs/heads/{LIVE_BRANCH}": 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 @@ -251,5 +253,21 @@ if stdin.read().split()[-1] == f"refs/heads/{LIVE_BRANCH}": 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)