]> Lady’s Gitweb - x_status_git/commitdiff
Support lookup by identifier 0.3.1
authorLady <redacted>
Sat, 16 Dec 2023 01:47:58 +0000 (20:47 -0500)
committerLady <redacted>
Sat, 23 Dec 2023 20:17:52 +0000 (15:17 -0500)
Caddyfile
README.markdown
post-receive

index 5b8aca551673ee1445a0b5358b7538106fad93fa..a430aae06c9d8691e330c11e48c60b98528645ba 100644 (file)
--- a/Caddyfile
+++ b/Caddyfile
@@ -29,6 +29,20 @@ status.site.example {
                header Link </statuses.atom>;rel=alternate;type="application/atom+xml"
        }
 
                header Link </statuses.atom>;rel=alternate;type="application/atom+xml"
        }
 
+       @iri {
+               path_regexp matcher ^/(?P<iri>[^/:]+:[^/]+)/?$
+       }
+
+       handle @iri {
+               handle @bare {
+                       rewrite * /.lookup.xhtml
+               }
+
+               handle @slash {
+                       redir * /{re.matcher.iri}
+               }
+       }
+
        handle /about {
                rewrite * /.about.html
                header Link </about.jsonld>;rel=meta;type="application/ld+json"
        handle /about {
                rewrite * /.about.html
                header Link </about.jsonld>;rel=meta;type="application/ld+json"
index a03f40a5f5a25b6e1eab3ff668e206780e56bbcd..0d7d027a28b3eb8ffd6bc885e647462d5277df71 100644 (file)
@@ -130,6 +130,16 @@ Note that these paths **do not** have a trailing slash.
       `</$TOPIC.jsonld>;rel=meta;type="application/ld+json"` (or
       equivalent) **must** be provided.
 
       `</$TOPIC.jsonld>;rel=meta;type="application/ld+json"` (or
       equivalent) **must** be provided.
 
+### X·H·T·M·L responses
+
+These responses **must** be served with a `Content-Type` of
+  `application/xhtml+xml` (or equivalent).
+Note that these paths **do not** have a trailing slash.
+
+ +  **`GET /$IRI`** (where `$IRI` contains a colon and no slash):
+    Serve the file at `/.lookup.xhtml`.
+    This can be used to look up statuses by their identifier.
+
 ### Json‐L·D responses
 
 These responses **should** be served with a `Content-Type` of
 ### Json‐L·D responses
 
 These responses **should** be served with a `Content-Type` of
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.
        cloneresult.check_returncode()
 
        # Set up various containers.
+       irimap = {}
        months = {}
        topics = {}
 
        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()
                        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
                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)
 
        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)
        # Remove the build directory.
        rmtree(BUILD_DIRECTORY)
This page took 0.055037 seconds and 4 git commands to generate.