]> Lady’s Gitweb - x_status_git/blobdiff - post-receive
Support lookup by identifier
[x_status_git] / post-receive
index f6289dabf8303c50e5aa0b5fe0705f42e6bed47b..d273055f13a8bc2741fd70a0960898463fc6b886 100755 (executable)
@@ -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)
This page took 0.018291 seconds and 4 git commands to generate.