]> Lady’s Gitweb - Status/commitdiff
From <https://git.ladys.computer/x_status_git.git>
authorLady <redacted>
Sat, 27 Aug 2022 22:55:00 +0000 (15:55 -0700)
committerLady <redacted>
Sat, 23 Dec 2023 20:27:36 +0000 (15:27 -0500)
This commit squashes all of the commits in the upstream `x_status_git`
repository to ensure that this repository remains focused on status
content and local changes. See there for further commit history.

Caddyfile [new file with mode: 0644]
Makefile [new file with mode: 0644]
README.markdown [new file with mode: 0644]
about.html [new file with mode: 0644]
index.html [new file with mode: 0644]
post-receive [new file with mode: 0755]
status.html [new file with mode: 0644]
statuses.html [new file with mode: 0644]
topic.html [new file with mode: 0644]
topics.html [new file with mode: 0644]

diff --git a/Caddyfile b/Caddyfile
new file mode 100644 (file)
index 0000000..95fed0e
--- /dev/null
+++ b/Caddyfile
@@ -0,0 +1,164 @@
+status.site.example {
+       root * /home/USERNAME/status.site.example/public
+
+       @slash {
+               path_regexp slash /$
+       }
+
+       @jsonld {
+               path_regexp jsonld \.jsonld$
+       }
+
+       @atom {
+               path_regexp atom \.atom$
+       }
+
+       @bare {
+               not path_regexp /$
+               not path_regexp \.jsonld$
+               not path_regexp \.atom$
+       }
+
+       @empty {
+               expression {re.matcher.suffix} == ""
+       }
+
+       handle / {
+               rewrite * /index.html
+               header Link </about.jsonld>;rel=meta;type="application/ld+json"
+               header Link </statuses.atom>;rel=alternate;type="application/atom+xml"
+       }
+
+       @iri {
+               path_regexp matcher ^/(?P<iri>[^/:]+:[^/]+)/?$
+       }
+
+       handle @iri {
+               handle @bare {
+                       rewrite * /.lookup.xhtml
+                       header Cache-Control max-age=0
+               }
+
+               handle @slash {
+                       redir * /{re.matcher.iri}
+               }
+       }
+
+       handle /about {
+               rewrite * /.about.html
+               header Link </about.jsonld>;rel=meta;type="application/ld+json"
+               header Link </statuses.atom>;rel=alternate;type="application/atom+xml"
+       }
+
+       redir /about/ /about
+
+       rewrite /about.jsonld /about/index.jsonld
+
+       handle /statuses {
+               rewrite * /.statuses.html
+               header Link </statuses.jsonld>;rel=meta;type="application/ld+json"
+               header Link </statuses.atom>;rel=alternate;type="application/atom+xml"
+       }
+
+       redir /statuses/ /statuses
+
+       rewrite /statuses.jsonld /statuses/index.jsonld
+
+       rewrite /statuses.atom /statuses/index.atom
+
+       @dated {
+               path_regexp matcher ^/statuses/(?P<ym>\d{4}-\d{2})(?P<suffix>/[^/.]+)?(?:\..*|/)?$
+               not path_regexp ^/statuses/index[/.]?
+       }
+
+       handle @dated {
+               handle @empty {
+                       handle @bare {
+                               rewrite * /.topic.html
+                               header Link </statuses/{re.matcher.ym}.jsonld>;rel=meta;type="application/ld+json"
+                               header Link </statuses.atom>;rel=alternate;type="application/atom+xml"
+                       }
+
+                       handle @slash {
+                               redir * /statuses/{re.matcher.ym}
+                       }
+
+                       handle @jsonld {
+                               rewrite * /statuses/{re.matcher.ym}/index.jsonld
+                       }
+
+                       handle @atom {
+                               rewrite * /statuses/{re.matcher.ym}/index.atom
+                       }
+               }
+
+               handle {
+                       handle @bare {
+                               rewrite * /.status.html
+                               header Link </statuses/{re.matcher.ym}.jsonld>;rel=meta;type="application/ld+json"
+                               header Link </statuses.atom>;rel=alternate;type="application/atom+xml"
+                       }
+
+                       handle @slash {
+                               redir * /statuses/{re.matcher.ym}{re.matcher.suffix}
+                       }
+               }
+       }
+
+       handle /topics {
+               rewrite * /.topics.html
+               header Link </topics.jsonld>;rel=meta;type="application/ld+json"
+       }
+
+       redir /topics/ /topics
+
+       rewrite /topics.jsonld /topics/index.jsonld
+
+       @topics {
+               path_regexp matcher ^/topics/(?P<topic>[0-9A-Za-z_-]+)(?P<suffix>/[^/.]+)?(?:\..*|/)?$
+               not path_regexp ^/topics/index[/.]?
+       }
+
+       handle @topics {
+               handle @empty {
+                       handle @bare {
+                               rewrite * /.topic.html
+                               header Link </topics/{re.matcher.topic}.jsonld>;rel=meta;type="application/ld+json"
+                               header Link </topics/{re.matcher.topic}.atom>;rel=alternate;type="application/atom+xml"
+                       }
+
+                       handle @slash {
+                               redir * /topics/{re.matcher.topic}
+                       }
+
+                       handle @jsonld {
+                               rewrite * /topics/{re.matcher.topic}/index.jsonld
+                       }
+
+                       handle @atom {
+                               rewrite * /topics/{re.matcher.topic}/index.atom
+                       }
+               }
+
+               handle {
+                       handle @bare {
+                               rewrite * /.status.html
+                               header Link </topics/{re.matcher.topic}.jsonld>;rel=meta;type="application/ld+json"
+                               header Link </topics/{re.matcher.topic}.atom>;rel=alternate;type="application/atom+xml"
+                       }
+
+                       handle @slash {
+                               redir * /topics/{re.matcher.topic}{re.matcher.suffix}
+                       }
+               }
+       }
+
+       header {
+               Access-Control-Allow-Origin "*"
+               ?Cache-Control max-age=3600
+       }
+
+       file_server {
+               index index.xml index.xhtml index.html index.rdf index.txt
+       }
+}
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..6e6d778
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,11 @@
+USERNAME := USERNAME
+DOMAIN := DOMAIN
+GIT_REPOSITORY := /home/$(USERNAME)/Status.git
+
+nothing:
+       @echo 'Type `make remote` to update the remote post-receive script.'
+
+remote:
+       scp post-receive $(USERNAME)@$(DOMAIN):$(GIT_REPOSITORY)/hooks/post-receive
+
+.PHONY: nothing remote ;
diff --git a/README.markdown b/README.markdown
new file mode 100644 (file)
index 0000000..0d7d027
--- /dev/null
@@ -0,0 +1,384 @@
+# x_status_git
+
+A minimal git‐based microblog.
+
+## What It Is
+
+ +  A Python script, `post-receive`, suitable for use as a post‐receive
+      Git hook, which generates a number of `.jsonld` files from a
+      source repository of text posts.
+
+ +  A small collection of H·T·M·L files designed to display the
+      generated `.jsonld` in a human‐readable fashion.
+
+## What It Is Not
+
+ +  A server or server configuration (you will need to supply these
+      yourself; see below).
+
+ +  Suitable for deployment on a simple filesystem server like
+      NeoCities or GitHub Pages (it requires both Git hooks and H·T·T·P
+      routing).
+
+ +  Interactive in any way (i·e “social media”).
+
+ +  Compatible with the ActivityPub fediverse (or any other push‐based
+      social media platform).
+
+## Script Configuration
+
+You will need to edit the `post-receive` script to adjust the following
+  constants to match your setup :—
+
+ +  **`GIT_DIRECTORY`**:
+    The absolute path to this Git repository on your server.
+    It is expected that this will be a bare repository (ending in
+      `.git`).
+
+ +  **`BUILD_DIRECTORY`**:
+    In order to access the files when you push, the repository will be
+      checked out here.
+    **This directory will be deleted on every push.**
+
+ +  **`PUBLIC_DIRECTORY`**:
+    The directory that your server serves files from.
+    **This directory will be deleted on every push,** so if you need to
+      serve additional files (i·e those not generated by this script),
+      you should place those files in a different directory and adjust
+      your server configuration accordingly.
+    Note that the `post-receive` script and associted H·T·M·L files
+      provided by this repository expect a certain server configuration
+      described below.
+
+  +  **`PUBLIC_URL`**:
+     The U·R·L that you are serving your site from (with no trailing
+       slash).
+     You cannot serve Status.git from a subdirectory.
+
+A `Makefile` is provided to make installing the `post-receive` script
+  on your server easy (assuming you have `ssh` access).
+You’ll need to supply some variables there, too :—
+
+ +  **`USERNAME`**:
+    Your SSH username.
+
+ +  **`DOMAIN`**:
+    The domain or other address of your site.
+
+ +  **`GIT_REPOSITORY`**:
+    The absolute path to this Git repository, as above.
+
+## Server Configuration
+
+Your server should be configured to serve the following files from the
+  provided `PUBLIC_DIRECTORY` in response to the following requests.
+For people using Caddy to serve their content, a sample `Caddyfile` is
+  included in this repository.
+
+### H·T·M·L responses
+
+These responses **must** be served with a `Content-Type` of
+  `text/html;charset=UTF-8` (or equivalent).
+Note that these paths **do not** have a trailing slash.
+
+ +  **`GET /`**:
+    Serve the file at `/index.html`.
+    A `Link` header with the value
+      `</about.jsonld>;rel=meta;type="application/ld+json"` (or
+      equivalent) **must** be provided.
+
+ +  **`GET /about`**:
+    Serve the file at `/.about.html`.
+    A `Link` header with the value
+      `</about.jsonld>;rel=meta;type="application/ld+json"` (or
+      equivalent) **must** be provided.
+
+ +  **`GET /statuses`**:
+    Serve the file at `/.statuses.html`.
+    A `Link` header with the value
+      `</statuses.jsonld>;rel=meta;type="application/ld+json"` (or
+      equivalent) **must** be provided.
+
+ +  **`GET /statuses/$YYYY-MM`** (where `$YYYY-MM` is an `xsd:gYearMonth`):
+    Serve the file at `/.topic.html`.
+    A `Link` header with the value
+      `</$YYYY-MM.jsonld>;rel=meta;type="application/ld+json"` (or
+      equivalent) **must** be provided.
+
+ +  **`GET /statuses/$YYYY-MM/*`** (where `$YYYY-MM` is an `xsd:gYearMonth`):
+    Serve the file at `/.status.html`.
+    A `Link` header with the value
+      `</$YYYY-MM.jsonld>;rel=meta;type="application/ld+json"` (or
+      equivalent) **must** be provided.
+
+ +  **`GET /topics`**:
+    Serve the file at `/.topics.html`.
+    A `Link` header with the value
+      `</topics.jsonld>;rel=meta;type="application/ld+json"` (or
+      equivalent) **must** be provided.
+
+ +  **`GET /topics/$TOPIC`** (where `$TOPIC` matches `[0-9A-Za-z_-]+`):
+    Serve the file at `/.topic.html`.
+    A `Link` header with the value
+      `</$TOPIC.jsonld>;rel=meta;type="application/ld+json"` (or
+      equivalent) **must** be provided.
+
+ +  **`GET /topics/$TOPIC/*`** (where `$TOPIC` matches
+      `[0-9A-Za-z_-]+`):
+    Serve the file at `/.status.html`.
+    A `Link` header with the value
+      `</$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
+  `application/ld+json`.
+In all cases, for `/$PATH.jsonld`, this just serves the file at
+  `/$PATH/index.jsonld`.
+
+ +  **`GET /about.jsonld`**:
+    Serve the file at `/about/index.jsonld`.
+
+ +  **`GET /statuses.jsonld`**:
+    Serve the file at `/statuses/index.jsonld`.
+
+ +  **`GET /statuses/$YYYY-MM.jsonld`** (where `$YYYY-MM` is an
+      `xsd:gYearMonth`):
+    Serve the file at `/$YYYY-MM/index.jsonld`.
+
+ +  **`GET /topics.jsonld`**:
+    Serve the file at `/topics/index.jsonld`.
+
+ +  **`GET /topics/$TOPIC.jsonld`** (where `$TOPIC` matches
+      `[0-9A-Za-z_-]+`):
+    Serve the file at `/topics/$TOPIC/index.jsonld`.
+
+### Atom responses
+
+These responses **should** be served with a `Content-Type` of
+  `application/atom+xml`.
+In all cases, for `/$PATH.atom`, this just serves the file at
+  `/$PATH/index.atom`.
+
+ +  **`GET /statuses.atom`**:
+    Serve the file at `/statuses/index.atom`.
+
+ +  **`GET /statuses/$YYYY-MM.atom`** (where `$YYYY-MM` is an
+      `xsd:gYearMonth`):
+    Serve the file at `/$YYYY-MM/index.atom`.
+
+ +  **`GET /topics/$TOPIC.atom`** (where `$TOPIC` matches
+      `[0-9A-Za-z_-]+`):
+    Serve the file at `/topics/$TOPIC/index.atom`.
+
+### Other Headers
+
+All responses **should** have a `Access-Control-Allow-Origin` header
+  with a value of `*` (assuming your server does not use credentials
+  and is not being served behind a firewall).
+
+## Committing Statuses To Git
+
+The `post-receive` script will run whenever you make a commit to the
+  `live` branch, which should be set as your default.
+Statuses are represented by a small collection of files committed to
+  particular locations in this repository :—
+
+ +  Files committed to `/YYYY/MM/DD/HH.MM.SSZ/` (the final component
+      can actually take any form but a time is **recommended**) are
+      ordinary statuses.
+
+ +  Files committed to `/topic/TOPICNAME/a/b/c/d/xxxx` (where `a`, `b`,
+      `c`, and `d` are lowercase hexadecimal digits and `xxxx` can be
+      anything) is a status posted to a specific topic (`TOPICNAME`).
+    It is **recommended** that you make `a/b/c/d` the first four digits
+      of an MD5 hash of the status content and `xxxx` the remaining
+      digits (security is not an issue here, so MD5 is fine).
+    `TOPICNAME` should have the form `[0-9A-Za-z_-]+`.
+
+The intent is that “ordinary statuses” are a bit more ephemeral whereas
+  “topic statuses” can serve as reference material.
+Using an MD5 hash for topic statuses ensures you don’t post the same
+  thing twice.
+
+The files which represent a status are as follows :—
+
+ +  **`text`**:
+    The text of the status.
+    Blank lines separate paragraphs; linebreaks will be preserved.
+    There is a special markup for links: `<https://link.example>`, or
+      `<https://link.example>="link text"` if you want to supply link
+      text.
+    At present, no other markup is supported.
+
+ +  **`0=x_status_git_1.0`**:
+    This file is **optional** and not currently used for anything, but
+      indicates that the post follows the `1.0` format.
+    The contents of this file, if present, **must** be
+      `x_status_git_1.0`, optionally followed by a trailing newline.
+
+ +  **`1=NAME`** (where `NAME` might be anything):
+    This file is **recommended** and indicates the author of the
+      status.
+    Only one author is currently supported.
+    The value of `NAME` **must** give the name of the author of the
+      status.
+    The contents of this file **must** give the author’s URL,
+      optionally followed by a trailing newline.
+
+ +  **`2=TITLE`** (where `TITLE` might be anything):
+    This file is **optional** and indicates the title of the status.
+    The value of `TITLE` **should** be a file·system‐friendly version
+      of the title, but is ignored.
+    The contents of this file **must** give the title of the status,
+      optionally followed by a trailing newline.
+
+ +  **`3=YYYY-MM-DD`** (where `YYYY-MM-DD` is a date):
+    This file is **required** and indicates the date of the status.
+    Only one date is currently supported.
+    The value of `YYYY-MM-DD` **should** give the date of the status,
+      although this is not used (in favour of the full timestamp).
+    The contents of this file **must** give the full `xsd:dateTime`
+      timestamp of the status, optionally followed by a trailing
+      newline.
+
+ +  **`4=IDENTIFIER`** (where `IDENTIFIER` might be anything):
+    This file is **required** and provides an identifier for the
+      status.
+    Only one identifier is currently supported.
+    The contents of this file **must** be an I·R·I which uniquely
+      identifies the status (for example, a U·U·I·D or `tag:` URI).
+    The value of `IDENTIFIER` **must** be a locally‐unique identifier
+      for the status and **should** resemble the contents where
+      possible.
+    (Note, however, that `IDENTIFIER` cannot contain slashes and need
+      not be a valid I·R·I.)
+
+Files with names that begin with the strings `2=` or `x_status_git_`
+  are reserved for backwards‐compatible extensions.
+
+x_status_git has no opinion on how these files make their way into the
+  Git repository, except that all the files for a single status should
+  be added in the same commit.
+The intention is that the simple nature of these files will make them
+  easy to automate.
+
+## I Am Computer, How Do I Get Status?
+
+Assume you are given a U·R·L `resource_url` which you think points to
+  some kind of x_status_git resource.
+Start by resolving it as follows :—
+
+01. Make a `HEAD` request to `resource_url`.
+
+02. If there is a `Link` header with a `rel` of `meta` and a `type` of
+      `application/ld+json`, set `resource_url` to the URL provided in
+      that header and restart these steps from step 1.
+
+03. Make a `GET` request to `resource_url` and let `response` be the
+      response.
+
+04. Set `document` as follows :—
+
+    01. If the `Content-Type` header of `response` has a type of `text`
+          and subtype of `html`, let `document` be the result of
+          processing the body of `response` into a D·O·M tree as an
+          H·T·M·L document .
+        It is an error if this process fails.
+
+    02. If the `Content-Type` header of `response` has a type of
+          `application` and a subtype which is `xml` or which ends in
+          `+xml`, let `document` be the result of processing the body
+          of `response` into a D·O·M tree as an X·M·L document .
+        It is an error if this process fails.
+
+    03. Otherwise, let `document` be null.
+
+05. If `document` is not null :—
+
+    01. If there is a `<link>` element in either the H·T·M·L namespace
+          or the Atom namespace in `document` with a `rel` of `meta`
+          and a `type` of `application/ld+json`, set `resource_url` to
+          the `href` of that `<link>` element and restart these steps
+          from step 1.
+        If multiple such elements exist, choose the first one.
+
+    02. Otherwise, it is an error.
+
+06. If the body of `response` is not a Json document, it is an error.
+
+Assuming the U·R·L you were given was valid, you will end this
+  algorithm with a Json‐L·D response, and you can use the `@type`
+  attribute to determine the response type.
+`@type` will be either a string or an array.
+
+ +  If the `@type` is or contains `Forum`, the resource is a collection
+      of topics.
+
+ +  If the `@type` is or contains `Thread`, the resource is a
+      collection of statuses.
+
+ +  If the `@type` is or contains `Microblog`, the resource describes
+      this site as a whole.
+    The `streams` property will contain a list of available `Forum`s
+      and `Thread`s, as objects with an `@id` and `@type`.
+
+The items in the collection (`Forum` or `Thread`) may be determined
+  through one of the following methods :—
+
+ +  If the `@type` is or contains `CollectionPage` or
+      `OrderedCollectionPage`, then its `items` will contain resources.
+    This is a partial collection, and the `prev` and `next` properties
+      can be used to access further items from the parent collection
+      (indicated by `partOf`).
+    `first` and `current`, in this scenario, point “horizontally” to
+      the first and latest pages of items, not to subpages.
+
+ +  If the `@type` is or contains `Collection` or `OrderedCollection`
+      and the resource has `first` and/or `current` properties, then
+      the `items` property will not be present.
+    `first` and `current` can be accessed to provide
+      `OrderedCollectionPage`s listing the items of the collection.
+
+ +  Otherwise, the `items` property will contain every item in the
+      collection.
+
+Statuses themselves have the following properties :—
+
+ +  **`@id`**:
+    The identifier of the status.
+
+ +  **`@type`**:
+    The value `MicroblogPost`.
+
+ +  **`created`** [`dcterms:created`]:
+    The creation date for the status, as an `xsd:dateTime`.
+
+ +  **`creator`** [`dcterms:creator`] (optional):
+    The author of the status, as an object with an `@id` and `name`
+      [`foaf:name`].
+
+ +  **`identifier`** [`dcterms:identifier`]:
+    An I·R·I which uniquely identifies the status.
+    This differs from the `@id` in that it is not expected to be
+      dereferenceable.
+
+ +  **`subject`** [`dcterms:subject`] (optional):
+    The topic of the status, for topic statuses.
+
+ +  **`title`** [`dcterms:title`] (optional):
+    The title of the status.
+
+ +  **`content`** [`sioc:content`]:
+    The content of the status, as an `rdf:XMLLiteral`.
diff --git a/about.html b/about.html
new file mode 100644 (file)
index 0000000..c12dfa5
--- /dev/null
@@ -0,0 +1,26 @@
+<!dOcTyPe html>
+<HTML Lang=en>
+<TITLE>About</TITLE>
+<STYLE>
+body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1REM; Min-Block-Size: 100VH; Inline-Size: 100%; Max-Inline-Size: 45REM; Align-Content: Center; Justify-Content: Stretch; Font-Family: Sans-Serif }
+</STYLE>
+<H1>About</H1>
+<NAV><UL></UL></NAV>
+<SCRIPT Type=module>
+document.title = location.hostname
+document.body.querySelector("h1").textContent = location.hostname
+const ul = document.body.querySelector("nav>ul")
+fetch(`${location}.jsonld`)
+.then($ => $.json())
+.then(meta => {
+  { const a = ul
+    .appendChild(document.createElement("li"))
+    .appendChild(document.createElement("a"))
+    a.href = meta.streams.find($ => $["@type"] == "Thread")["@id"]
+    a.textContent = "Updates" }
+  { const a = ul
+    .appendChild(document.createElement("li"))
+    .appendChild(document.createElement("a"))
+    a.href = meta.streams.find($ => $["@type"] == "Forum")["@id"]
+    a.textContent = "Topics" } })
+</SCRIPT>
diff --git a/index.html b/index.html
new file mode 100644 (file)
index 0000000..4be8239
--- /dev/null
@@ -0,0 +1,88 @@
+<!dOcTyPe html>
+<HTML Lang=en>
+<TITLE>Index</TITLE>
+<STYLE>
+body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1REM; Min-Block-Size: 100VH; Inline-Size: 100%; Max-Inline-Size: 45REM; Align-Content: Center; Justify-Content: Stretch; Font-Family: Sans-Serif }
+#status{ Font-Size: Larger }
+#topics{ Display: Grid; Margin-Block: 1REM; Grid: Auto-Flow / 1FR 1FR; Gap: 0 1REM }
+#topics h2{ Margin-Block-End: 0; Grid-Column: 1 / Span 2; Text-Align: Center }
+#topics h2:Last-Child{ Display: None }
+div.STATUS{ Border: Thin Solid; Padding-Inline: 1REM; Border-Radius: .5REM }
+summary{ Padding-Block: 1REM; Font-Weight: Bold }
+details[open]>summary{ Border-Block-End: Thin Solid }
+footer{ Border-Block-Start: Thin Solid; Padding-Block: 1REM; Font-Size: Smaller; Text-Align: End }
+footer p{ Margin-Block: 0 .5REM }
+footer time:Not([datetime]),
+footer small{ Font-Size: Inherit; Font-Style: Italic }
+svg{ Display: Inline-Block; Vertical-Align: Middle; Block-Size: 1EM; Inline-Size: 1EM; Fill: #FFF }
+</STYLE>
+<H1>Index</H1>
+<DIV Class=STATUS ID=status>
+</DIV>
+<SECTION ID=topics>
+       <H2>Topics</H2>
+</SECTION>
+<DIV Hidden><SVG ID=feedicon Version=1.1 ViewBox="0 0 256 256"><RECT Width=256 Height=256 RX=55 RY=55 X=0 Y=0 Fill=CurrentColor /><RECT Width=236 Height=236 RX=47 RY=47 X=10 Y=10 Style="Fill: Inherit" /><CIRCLE CX=68 CY=189 R=24 Fill=CurrentColor /><PATH D="M 160 213 h -34 a 82 82 0 0 0 -82 -82 v -34 a 116 116 0 0 1 116 116 z" Fill=CurrentColor /><PATH D="M 184 213 A 140 140 0 0 0 44 73 V 38 a 175 175 0 0 1 175 175 z" Fill=CurrentColor /></SVG>
+<SCRIPT Type=module>
+const parser = new DOMParser
+document.title = location.hostname
+document.documentElement.querySelector("body>h1").textContent = location.hostname
+const renderLatest = (meta, container) => {
+  const { feed, items } = meta
+  const status = items.pop()
+  const src = status.content
+  const { documentElement: article } = parser.parseFromString(src, "application/xhtml+xml")
+  const footer = document.createElement("footer")
+  const authorshipP = footer.appendChild(document.createElement("p"))
+  const { creator, title } = status
+  if (creator) {
+    const authorLink = authorshipP.appendChild(document.createElement("a"))
+    authorLink.href = creator["@id"]
+    authorLink.textContent = creator.name
+    authorshipP.appendChild(document.createTextNode(" @ ")) }
+  authorshipP.appendChild(document.createElement("time")).textContent = status.created
+  const nav = footer.appendChild(document.createElement("nav"))
+  const atomLink = nav.appendChild(document.createElement("a"))
+  atomLink.href = feed
+  const atomSVG = document.createElementNS("http://www.w3.org/2000/svg", "svg")
+  atomSVG.setAttribute("version", "1.1")
+  atomSVG.setAttribute("viewBox", "0 0 256 256")
+  const atomUse = atomSVG.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "use"))
+  atomUse.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#feedicon")
+  atomLink.append(atomSVG, " Atom feed.")
+  nav.appendChild(document.createTextNode(" "))
+  const permalink = nav.appendChild(document.createElement("a"))
+  permalink.href = status["@id"]
+  permalink.textContent = "Permalink."
+  nav.appendChild(document.createTextNode(" "))
+  const upLink = nav.appendChild(document.createElement("a"))
+  upLink.href = meta["@id"]
+  upLink.textContent = `See more ${ status.subject ? `${status.subject}` : "status" } updates.`
+  if (title) {
+    const wrapper = document.createElement("article")
+    const details = wrapper.appendChild(document.createElement("details"))
+    details.setAttribute("open", "")
+    const summary = details.appendChild(document.createElement("summary"))
+    summary.textContent = title
+    details.append(...document.importNode(article, true).childNodes)
+    container.replaceChildren(wrapper, footer) }
+  else container.replaceChildren(document.importNode(article, true), footer) }
+fetch("statuses.jsonld")
+.then($ => $.json())
+.then(meta => fetch(`${meta.current}.jsonld`))
+.then($ => $.json())
+.then(meta => renderLatest(meta, document.getElementById("status")))
+fetch("topics.jsonld")
+.then($ => $.json())
+.then(meta => {
+  const topics = document.getElementById("topics")
+  for (const topicID of meta.items.map($ => $["@id"] ?? $)) {
+    const section = topics.appendChild(document.createElement("section"))
+    fetch(`${topicID}.jsonld`)
+    .then($ => $.json())
+    .then(topic => {
+      section.appendChild(document.createElement("h3")).textContent = topic.subject
+      const div = section.appendChild(document.createElement("div"))
+      div.className = "STATUS"
+      renderLatest(topic, div) }) } })
+</SCRIPT>
diff --git a/post-receive b/post-receive
new file mode 100755 (executable)
index 0000000..b07ad47
--- /dev/null
@@ -0,0 +1,279 @@
+#!/usr/bin/env python3
+from datetime import datetime as dt, timezone
+from glob import iglob
+from itertools import starmap
+import json
+from os import mkdir
+from os.path import exists
+from pathlib import Path
+import re
+from shutil import copy2, rmtree
+from subprocess import run
+from sys import stdin
+from warnings import warn
+from xml.dom import XHTML_NAMESPACE
+from xml.dom.minidom import getDOMImplementation, parseString
+
+GIT_DIRECTORY = "/home/USERNAME/Status.git"
+BUILD_DIRECTORY = "/home/USERNAME/status.site.example/.build"
+PUBLIC_DIRECTORY = "/home/USERNAME/status.site.example/public"
+PUBLIC_URL = "https://status.site.example"
+LANG = "en"
+LIVE_BRANCH = "live"
+
+UTC = timezone.utc
+CURRENT_DATETIME = f"{dt.now(UTC).replace(tzinfo=None).isoformat(timespec='seconds')}Z"
+ATOM_NAMESPACE = "http://www.w3.org/2005/Atom"
+
+if stdin.read().split()[-1] == f"refs/heads/{LIVE_BRANCH}":
+
+       print(f"This is an update to the '{LIVE_BRANCH}' branch; regenerating site…")
+
+       # Set up the build directory.
+       if exists(BUILD_DIRECTORY):
+               rmtree(BUILD_DIRECTORY)
+       cloneresult = run(["git", "clone", "--local", "--branch", LIVE_BRANCH, GIT_DIRECTORY, BUILD_DIRECTORY], capture_output=True, encoding="utf-8")
+       # if cloneresult.stderr:
+               # print(cloneresult.stderr)
+       cloneresult.check_returncode()
+
+       # Set up various containers.
+       irimap = {}
+       months = {}
+       topics = {}
+
+       # Create an XML representation of the provided status text.
+       def statusxml (text, version="1.0"):
+               doc = getDOMImplementation().createDocument(None, "article", None)
+               articleElt = doc.documentElement
+               articleElt.setAttribute("xmlns", XHTML_NAMESPACE)
+               articleElt.setAttribute("lang", LANG)
+               for para in text.split("\n\n"):
+                       paraElt = articleElt.appendChild(doc.createElement("p"))
+                       for component in re.findall(r'<[a-z]+:[^\s]*>(?:="[^\n"]+")?|\n|[^<\n]+|<(?![a-z]+:[^\s]*>)', para):
+                               if component == "\n":
+                                       paraElt.appendChild(doc.createElement("br"))
+                               elif re.fullmatch(r'<[a-z]+:[^\s]*>(?:="[^\n"]+")?', component):
+                                       href = component.split(">", maxsplit=1)[0][1:]
+                                       anchorElt = paraElt.appendChild(doc.createElement("a"))
+                                       anchorElt.setAttribute("href", href)
+                                       anchorElt.setAttribute("rel", "noreferrer")
+                                       anchorElt.appendChild(doc.createTextNode(component if len(href) == len(component) - 2 else component[len(href)+4:-1]))
+                               else:
+                                       paraElt.appendChild(doc.createTextNode(component))
+               return articleElt.toxml()
+
+       # Map status paths to status objects, or None if there is an error.
+       #
+       # The provided path must be to a `text` object.
+       def statusmap (topic, path):
+               status = { "@type": "MicroblogPost" }
+               version_path = next(path.parent.glob("0=*"), None)
+               if version_path and version_path.name != "0=x_status_git_1.0":
+                       warn(f"Unrecognized version for {path}; skipping.")
+                       return None
+               if topic:
+                       status["subject"] = topic
+               author_path = next(path.parent.glob("1=*"), None)
+               if author_path:
+                       status["creator"] = { "name": author_path.name[2:] }
+                       with author_path.open("r", encoding="utf-8") as text:
+                               status["creator"]["@id"] = text.read().strip()
+               title_path = next(path.parent.glob("2=*"), None)
+               if title_path:
+                       with title_path.open("r", encoding="utf-8") as text:
+                               title = text.read().strip()
+                               status["title"] = title
+               date_path = next(path.parent.glob("3=*"), None)
+               datetime = ""
+               if date_path:
+                       with date_path.open("r", encoding="utf-8") as text:
+                               datetime = text.read().strip()
+                               status["created"] = datetime
+               else:
+                       warn(f"Missing date for {path}; skipping.")
+                       return None
+               identifier_path = next(path.parent.glob("4=*"), None)
+               identifier = ""
+               if identifier_path:
+                       identifier = identifier_path.name[2:]
+                       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 path.open("r", encoding="utf-8") as text:
+                       source = text.read().strip()
+                       status["content"] = statusxml(source)
+                       status["source"] = { "content": source, "mediaType": "text/plain" }
+               return (datetime, identifier, status)
+
+       def atomForLD (ld):
+               doc = getDOMImplementation().createDocument(None, "feed", None)
+               atomElt = doc.documentElement
+               atomElt.setAttribute("xmlns", ATOM_NAMESPACE)
+               atomElt.setAttribute("xml:lang", LANG)
+               subject = ld["subject"] if "subject" in ld else "Statuses"
+               titleElt = atomElt.appendChild(doc.createElement("title"))
+               titleElt.appendChild(doc.createTextNode(f"{subject} @ {PUBLIC_URL}"))
+               updatedElt = atomElt.appendChild(doc.createElement("updated"))
+               updatedElt.appendChild(doc.createTextNode(CURRENT_DATETIME))
+               generatorElt = atomElt.appendChild(doc.createElement("generator"))
+               generatorElt.appendChild(doc.createTextNode("x_status_git"))
+               generatorElt.setAttribute("uri", "https://git.ladys.computer/x_status_git")
+               atomLinks = {}
+               if "OrderedCollectionPage" in ld["@type"]:
+                       idElt = atomElt.appendChild(doc.createElement("id"))
+                       idElt.appendChild(doc.createTextNode(f"{PUBLIC_URL}/statuses"))
+                       atomLinks["alternate"] = f"{PUBLIC_URL}/statuses"
+                       atomLinks["current"] = f"{PUBLIC_URL}/statuses.atom"
+                       atomLinks["self"] = atomLinks["current"] if ld["@id"] == ld["current"] else f"{ld['@id']}.atom"
+                       if "prev" in ld:
+                               atomLinks["prev-archive"] = f"{ld['prev']}.atom"
+                       if "next" in ld and ld["next"] != ld["current"]:
+                               atomLinks["next-archive"] = f"{ld['next']}.atom"
+               else:
+                       idElt = atomElt.appendChild(doc.createElement("id"))
+                       idElt.appendChild(doc.createTextNode(ld["@id"]))
+                       atomLinks["alternate"] = ld["@id"]
+                       atomLinks["self"] = f"{ld['@id']}.atom"
+               for (rel, href) in atomLinks.items():
+                       linkElt = atomElt.appendChild(doc.createElement("link"))
+                       linkElt.setAttribute("rel", rel)
+                       linkElt.setAttribute("href", href)
+               for item in ld["items"]:
+                       entryElt = atomElt.appendChild(doc.createElement("entry"))
+                       title = item["source"]["content"].partition("\n")[0]
+                       if "title" in item:
+                               title = item["title"]
+                       elif len(title) >= 28:
+                               title = title[0:27] + "…"
+                       titleElt = entryElt.appendChild(doc.createElement("title"))
+                       titleElt.appendChild(doc.createTextNode(title))
+                       idElt = entryElt.appendChild(doc.createElement("id"))
+                       idElt.appendChild(doc.createTextNode(item["@id"]))
+                       updatedElt = entryElt.appendChild(doc.createElement("updated"))
+                       updatedElt.appendChild(doc.createTextNode(CURRENT_DATETIME))
+                       if "created" in item:
+                               publishedElt = entryElt.appendChild(doc.createElement("published"))
+                               publishedElt.appendChild(doc.createTextNode(item["created"]))
+                       authorElt = entryElt.appendChild(doc.createElement("author"))
+                       if "creator" in item:
+                               nameElt = authorElt.appendChild(doc.createElement("name"))
+                               nameElt.appendChild(doc.createTextNode(item["creator"]["name"]))
+                               uriElt = authorElt.appendChild(doc.createElement("uri"))
+                               uriElt.appendChild(doc.createTextNode(item["creator"]["@id"]))
+                       else:
+                               nameElt = authorElt.appendChild(doc.createElement("name"))
+                               nameElt.appendChild(doc.createTextNode("Anonymous"))
+                       contentElt = entryElt.appendChild(doc.createElement("content"))
+                       contentElt.setAttribute("type", "xhtml")
+                       contentDiv = contentElt.appendChild(doc.createElement("div"))
+                       contentDiv.setAttribute("xmlns", XHTML_NAMESPACE)
+                       contentDiv.setAttribute("lang", LANG)
+                       for child in list(parseString(item["content"]).documentElement.childNodes):
+                               contentDiv.appendChild(child)
+               return (atomLinks["self"], atomElt.toxml())
+
+       # Get status paths.
+       status_paths = []
+       for yearpath in Path(f"{BUILD_DIRECTORY}/").glob("[0-9][0-9][0-9][0-9]"):
+               for monthpath in yearpath.glob("[0-9][0-9]"):
+                       for daypath in monthpath.glob("[0-9][0-9]"):
+                               for statuspath in daypath.glob("*/text"):
+                                       status_paths.append((None, statuspath))
+       for topicpath in Path(f"{BUILD_DIRECTORY}/").glob("topic/*"):
+               for hash0path in topicpath.glob("[0-9a-f]"):
+                       for hash1path in hash0path.glob("[0-9a-f]"):
+                               for hash2path in hash1path.glob("[0-9a-f]"):
+                                       for hash3path in hash2path.glob("[0-9a-f]"):
+                                               for statuspath in hash3path.glob("*/text"):
+                                                       status_paths.append((topicpath.name, statuspath))
+
+       # Build status objects and listings.
+       for (datetime, identifier, status) in sorted(filter(None, starmap(statusmap, status_paths))):
+               if "subject" in status:
+                       topic = status["subject"]
+                       if topic not in topics:
+                               topics[topic] = { "@context": { "@language": LANG, "activity": "https://www.w3.org/ns/activitystreams#", "dct": "http://purl.org/dc/terms/", "foaf": "http://xmlns.com/foaf/0.1/", "sioc": "http://rdfs.org/sioc/ns#", "sioct": "http://rdfs.org/sioc/types#", "OrderedCollection": "activity:OrderedCollection", "Thread": "sioc:Thread", "MicroblogPost": "sioct:MicroblogPost", "items": { "@id": "activity:items", "@type": "@id", "@container": "@list" }, "source": { "@id": "activity:source", "@type": "@id", "@context": { "content": { "@id": "activity:content", "@type": "http://www.w3.org/2001/XMLSchema#string" }, "mediaType": "activity:mediaType" } }, "created": { "@id": "dct:created", "@type": "http://www.w3.org/2001/XMLSchema#dateTime" }, "creator": { "@id": "dct:creator", "@type": "@id" }, "identifier": { "@id":  "dct:identifier", "@type": "http://www.w3.org/2001/XMLSchema#anyURI" }, "subject": "dct:subject", "title": "dct:title", "name": "foaf:name", "content": { "@id": "sioc:content", "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral" }, "feed": { "@id": "sioc:feed", "@type": "@id" } }, "@id": f"{PUBLIC_URL}/topics/{topic}", "@type": ["OrderedCollection", "Thread"], "feed": f"{PUBLIC_URL}/topics/{topic}.atom", "items": [], "subject": topic }
+                       topics[topic]["items"].append(status)
+               else:
+                       yyyy_mm = datetime[0:7]
+                       if yyyy_mm not in months:
+                               months[yyyy_mm] = { "@context": { "@language": LANG, "activity": "https://www.w3.org/ns/activitystreams#", "dct": "http://purl.org/dc/terms/", "foaf": "http://xmlns.com/foaf/0.1/", "sioc": "http://rdfs.org/sioc/ns#", "sioct": "http://rdfs.org/sioc/types#", "OrderedCollectionPage": "activity:OrderedCollectionPage", "Thread": "sioc:Thread", "MicroblogPost": "sioct:MicroblogPost", "current": { "@id": "activity:current", "@type": "@id" }, "first": { "@id": "activity:first", "@type": "@id" }, "items": { "@id": "activity:items", "@type": "@id", "@container": "@list" }, "partOf": { "@id": "activity:partOf", "@type": "@id" }, "prev": { "@id": "activity:prev", "@type": "@id" }, "next": { "@id": "activity:next", "@type": "@id" }, "source": { "@id": "activity:source", "@type": "@id", "@context": { "content": { "@id": "activity:content", "@type": "http://www.w3.org/2001/XMLSchema#string" }, "mediaType": "activity:mediaType" } }, "created": { "@id": "dct:created", "@type": "http://www.w3.org/2001/XMLSchema#dateTime" }, "creator": { "@id": "dct:creator", "@type": "@id" }, "identifier": { "@id":  "dct:identifier", "@type": "http://www.w3.org/2001/XMLSchema#anyURI" }, "title": "dct:title", "name": "foaf:name", "content": { "@id": "sioc:content", "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral" } }, "@id": f"{PUBLIC_URL}/statuses/{yyyy_mm}", "@type": ["OrderedCollectionPage", "Thread"], "feed": f"{PUBLIC_URL}/statuses.atom", "items": [], "partOf": f"{PUBLIC_URL}/statuses" }
+                       months[yyyy_mm]["items"].append(status)
+
+       # Set up the public directory.
+       if exists(PUBLIC_DIRECTORY):
+               rmtree(PUBLIC_DIRECTORY)
+       mkdir(PUBLIC_DIRECTORY)
+
+       # Copy H·T·M·L files to their expected locations.
+       copy2(f"{BUILD_DIRECTORY}/index.html", f"{PUBLIC_DIRECTORY}/index.html")
+       copy2(f"{BUILD_DIRECTORY}/about.html", f"{PUBLIC_DIRECTORY}/.about.html")
+       copy2(f"{BUILD_DIRECTORY}/status.html", f"{PUBLIC_DIRECTORY}/.status.html")
+       copy2(f"{BUILD_DIRECTORY}/statuses.html", f"{PUBLIC_DIRECTORY}/.statuses.html")
+       copy2(f"{BUILD_DIRECTORY}/topic.html", f"{PUBLIC_DIRECTORY}/.topic.html")
+       copy2(f"{BUILD_DIRECTORY}/topics.html", f"{PUBLIC_DIRECTORY}/.topics.html")
+
+       # Output “about” metadata
+       if not exists(f"{PUBLIC_DIRECTORY}/about"):
+               mkdir(f"{PUBLIC_DIRECTORY}/about")
+       with open(f"{PUBLIC_DIRECTORY}/about/index.jsonld", "w", encoding="utf-8") as f:
+               json.dump({ "@context": { "@language": LANG, "activity": "https://www.w3.org/ns/activitystreams#", "sioc": "http://rdfs.org/sioc/ns#", "sioct": "http://rdfs.org/sioc/types#", "Forum": "sioc:Forum", "Thread": "sioc:Thread", "Microblog": "sioct:Microblog", "streams": { "@id": "activity:streams", "@type": "@id" } }, "@id": f"{PUBLIC_URL}", "@type": "Microblog", "streams": [{ "@id": f"{PUBLIC_URL}/statuses", "@type": "Thread" }, { "@id": f"{PUBLIC_URL}/topics", "@type": "Forum" }] }, f, ensure_ascii=False, allow_nan=False)
+
+       # Output month‐based listings and the non‐topic index
+       if not exists(f"{PUBLIC_DIRECTORY}/statuses"):
+               mkdir(f"{PUBLIC_DIRECTORY}/statuses")
+       statuspairs = list(enumerate(months.items()))
+       for (index, (yyyy_mm, ld)) in statuspairs:
+               if not exists(f"{PUBLIC_DIRECTORY}/statuses/{yyyy_mm}"):
+                       mkdir(f"{PUBLIC_DIRECTORY}/statuses/{yyyy_mm}")
+               ld["first"] = f"{PUBLIC_URL}/statuses/{statuspairs[0][1][0]}"
+               ld["current"] = f"{PUBLIC_URL}/statuses/{statuspairs[-1][1][0]}"
+               if index > 0:
+                       ld["prev"] = f"{PUBLIC_URL}/statuses/{statuspairs[index - 1][1][0]}"
+               if index < len(statuspairs) - 1:
+                       ld["next"] = f"{PUBLIC_URL}/statuses/{statuspairs[index + 1][1][0]}"
+               with open(f"{PUBLIC_DIRECTORY}/statuses/{yyyy_mm}/index.jsonld", "w", encoding="utf-8") as f:
+                       json.dump(ld, f, ensure_ascii=False, allow_nan=False)
+               atomlink, atomxml = atomForLD(ld)
+               with open(f"{PUBLIC_DIRECTORY}/{atomlink[len(PUBLIC_URL):-5]}/index.atom", "w", encoding="utf-8") as f:
+                       f.write(atomxml)
+       with open(f"{PUBLIC_DIRECTORY}/statuses/index.jsonld", "w", encoding="utf-8") as f:
+               json.dump({ "@context": { "@language": LANG, "activity": "https://www.w3.org/ns/activitystreams#", "sioc": "http://rdfs.org/sioc/ns#", "OrderedCollection": "activity:OrderedCollection", "Thread": "sioc:Thread", "current": { "@id": "activity:current", "@type": "@id" }, "first": { "@id": "activity:first", "@type": "@id" }, "has_parent": { "@id": "sioc:has_parent", "@type": "@id" }, "feed": { "@id": "sioc:feed", "@type": "@id" } }, "@id": f"{PUBLIC_URL}/statuses", "@type": ["OrderedCollection", "Thread"], "feed": f"{PUBLIC_URL}/statuses.atom", "first": f"{PUBLIC_URL}/statuses/{statuspairs[0][1][0]}", "current": f"{PUBLIC_URL}/statuses/{statuspairs[-1][1][0]}", "has_parent": f"{PUBLIC_URL}" }, f, ensure_ascii=False, allow_nan=False)
+
+       # Output topic‐based listings and the topic index
+       if not exists(f"{PUBLIC_DIRECTORY}/topics"):
+               mkdir(f"{PUBLIC_DIRECTORY}/topics")
+       for (topic, ld) in topics.items():
+               if not exists(f"{PUBLIC_DIRECTORY}/topics/{topic}"):
+                       mkdir(f"{PUBLIC_DIRECTORY}/topics/{topic}")
+               with open(f"{PUBLIC_DIRECTORY}/topics/{topic}/index.jsonld", "w", encoding="utf-8") as f:
+                       json.dump(ld, f, ensure_ascii=False, allow_nan=False)
+               atomlink, atomxml = atomForLD(ld)
+               with open(f"{PUBLIC_DIRECTORY}/{atomlink[len(PUBLIC_URL):-5]}/index.atom", "w", encoding="utf-8") as f:
+                       f.write(atomxml)
+       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)
diff --git a/status.html b/status.html
new file mode 100644 (file)
index 0000000..dbc899c
--- /dev/null
@@ -0,0 +1,132 @@
+<!dOcTyPe hTmL>
+<HTML Lang=en>
+<TITLE>Status</TITLE>
+<STYLE>
+body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1REM; Min-Block-Size: 100VH; Inline-Size: 100%; Max-Inline-Size: 45REM; Align-Content: Center; Justify-Content: Stretch; Font-Family: Sans-Serif }
+article{ Font-Size: Larger }
+summary{ Padding-Block: 1REM; Font-Weight: Bold }
+details[open]>summary{ Border-Block-End: Thin Solid }
+header{ Border-Block-End: Thin Solid; Padding-Block: 1REM; Text-Align: Start }
+footer{ Border-Block-Start: Thin Solid; Padding-Block: 1REM; Text-Align: End }
+footer p{ Margin-Block: 0 .5REM }
+footer time:Not([datetime]),
+footer small{ Font-Size: Inherit; Font-Style: Italic }
+</STYLE>
+<BODY>
+<SCRIPT Type=module>
+const parser = new DOMParser
+const index = `${new URL(".", location).toString().slice(0, -1)}.jsonld`
+fetch(index)
+.then($ => $.json())
+.then(meta => {
+  const { items } = meta
+  if (items.find($ => new URL($["@id"]).pathname === location.pathname)) return meta
+  else return fetch(index, { cache: "reload" }).then($ => $.json()) })
+.then(meta => {
+  const { items, subject } = meta
+  const n = items.findIndex($ => new URL($["@id"]).pathname === location.pathname)
+  const status = items[n]
+  const src = status.content
+  const { documentElement: article } = parser.parseFromString(src, "application/xhtml+xml")
+  const { creator, created, title } = status
+  document.title = creator
+  ? `Status by ${creator.name} @ ${status.created}`
+  : `Status @ ${created}`
+  const header = document.createElement("header")
+  const footer = document.createElement("footer")
+  const headerChildren =
+  [ "A(n) "
+  , subject
+  ? (subjectLink => {
+    subjectLink.textContent = subject
+    subjectLink.href = meta["@id"]
+    return subjectLink })(document.createElement("a"))
+  : "status"
+  , " update" ]
+  if (creator) {
+    const authorLink = document.createElement("@id" in creator ? "a" : "span")
+    if (authorLink.localName == "a") authorLink.href = creator["@id"]
+    authorLink.textContent = creator.name
+    headerChildren.push(" by ", authorLink, "…") }
+  else headerChildren.push("…")
+  header.append(...headerChildren)
+  const timestampP = footer.appendChild(document.createElement("p"))
+  timestampP.appendChild(document.createElement("time")).textContent = created
+  footer
+  .appendChild(document.createElement("p"))
+  .appendChild(document.createElement("small"))
+  .textContent = status.identifier
+  const nav = footer.appendChild(document.createElement("nav"))
+  nav.appendChild(document.createTextNode("Up: "))
+  const upLink = nav.appendChild(document.createElement("a"))
+  upLink.href = meta["@id"]
+  upLink.textContent = meta.subject || meta["@id"].split("/").pop()
+  if (n > 0) {
+    nav.appendChild(document.createTextNode("; Previous: "))
+    const prevLink = nav.appendChild(document.createElement("a"))
+    prevLink.href = items[n - 1]["@id"]
+    const { title: prevTitle } = items[n - 1]
+    if (prevTitle) prevLink.textContent = prevTitle.length > 28
+    ? "".concat(...prevTitle.slice(0, 27), "…")
+    : prevTitle
+    else {
+      const prevText = (() => {
+        try {
+          const prevD = parser.parseFromString(items[n - 1].content, "application/xhtml+xml")
+          const div = document.createElement("div")
+          div.appendChild(document.importNode(prevD.documentElement, true))
+          Object.assign(div.style,
+            { position: "absolute"
+            , top: "-2px"
+            , height: "1px"
+            , width: "1px"
+            , overflow: "hidden" })
+          document.body.appendChild(div)
+          const text = div.innerText
+          document.body.removeChild(div)
+          return text }
+        catch { } })() ?? items[n + 1].created;
+      const prevChars = Array.from(prevText.trim().replaceAll(/\s+/gu, " "))
+      prevLink.textContent = prevChars.length > 28
+      ? "".concat(...prevChars.slice(0, 27), "…")
+      : prevText } }
+  if (n < items.length - 1) {
+    nav.appendChild(document.createTextNode("; Next: "))
+    const nextLink = nav.appendChild(document.createElement("a"))
+    nextLink.href = items[n + 1]["@id"]
+    const { title: nextTitle } = items[n + 1]
+    if (nextTitle) nextLink.textContent = nextTitle.length > 28
+    ? "".concat(...nextTitle.slice(0, 27), "…")
+    : nextTitle
+    else {
+      const nextText = (() => {
+        try {
+          const nextD = parser.parseFromString(items[n + 1].content, "application/xhtml+xml")
+          const div = document.createElement("div")
+          div.appendChild(document.importNode(nextD.documentElement, true))
+          Object.assign(div.style,
+            { position: "absolute"
+            , top: "-2px"
+            , height: "1px"
+            , width: "1px"
+            , overflow: "hidden" })
+          document.body.appendChild(div)
+          const text = div.innerText
+          document.body.removeChild(div)
+          return text }
+        catch { } })() ?? items[n + 1].created;
+      const nextChars = Array.from(nextText.trim().replaceAll(/\s+/gu, " "))
+      nextLink.textContent = nextChars.length > 28
+      ? "".concat(...nextChars.slice(0, 27), "…")
+      : nextText } }
+  nav.appendChild(document.createTextNode("."))
+  if (title) {
+    const wrapper = document.createElement("article")
+    const details = wrapper.appendChild(document.createElement("details"))
+    details.setAttribute("open", "")
+    const summary = details.appendChild(document.createElement("summary"))
+    summary.textContent = title
+    details.append(...document.importNode(article, true).childNodes)
+    document.body.replaceChildren(header, wrapper, footer) }
+  else document.body.replaceChildren(header, document.importNode(article, true), footer) })
+</SCRIPT>
diff --git a/statuses.html b/statuses.html
new file mode 100644 (file)
index 0000000..7571990
--- /dev/null
@@ -0,0 +1,24 @@
+<!dOcTyPe html>
+<HTML Lang=en>
+<TITLE>Statuses</TITLE>
+<STYLE>
+body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1REM; Min-Block-Size: 100VH; Inline-Size: 100%; Max-Inline-Size: 45REM; Align-Content: Center; Justify-Content: Stretch; Font-Family: Sans-Serif }
+</STYLE>
+<H1>Statuses</H1>
+<NAV><P><A HRef=/>Home</A></P><UL></UL></NAV>
+<SCRIPT Type=module>
+const ul = document.body.querySelector("nav>ul")
+fetch(`${location}.jsonld`)
+.then($ => $.json())
+.then(meta => {
+  { const a = ul
+    .appendChild(document.createElement("li"))
+    .appendChild(document.createElement("a"))
+    a.href = meta.first
+    a.textContent = "First Page" }
+  { const a = ul
+    .appendChild(document.createElement("li"))
+    .appendChild(document.createElement("a"))
+    a.href = meta.current
+    a.textContent = "Latest Page" } })
+</SCRIPT>
diff --git a/topic.html b/topic.html
new file mode 100644 (file)
index 0000000..f0a4a9e
--- /dev/null
@@ -0,0 +1,84 @@
+<!dOcTyPe html>
+<META Charset=utf-8>
+<TITLE>Topic Feed</TITLE>
+<STYLE>
+body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1REM; Min-Block-Size: 100VH; Inline-Size: 100%; Max-Inline-Size: 45REM; Align-Content: Center; Justify-Content: Stretch; Font-Family: Sans-Serif }
+</STYLE>
+<H1>Topic Feed</H1>
+<NAV><P><A HRef=/>Home</A></P><DL></DL></NAV>
+<SCRIPT Type=module>
+const nav = document.body.querySelector("nav")
+const dl = nav.querySelector("dl")
+const parser = new DOMParser
+fetch(`${location}.jsonld`)
+.then($ => $.json())
+.then(meta => {
+  const topic = meta.subject || meta["@id"].split("/").pop()
+  document.title = topic
+  document.body.querySelector("h1").textContent = "subject" in meta
+  ? `#${topic}`
+  : `@${topic}`
+  if ("subject" in meta) {
+    const a = nav
+    .insertBefore(document.createElement("p"), dl)
+    .appendChild(document.createElement("a"))
+    a.href = "/topics"
+    a.textContent = "Topics" }
+  const { first, prev, next, current, items } = meta
+  if (first && first != location && first != prev) {
+    const a = nav
+    .insertBefore(document.createElement("p"), dl)
+    .appendChild(document.createElement("a"))
+    a.href = first
+    a.textContent = "First Page" }
+  if (prev) {
+    const a = nav
+    .insertBefore(document.createElement("p"), dl)
+    .appendChild(document.createElement("a"))
+    a.href = prev
+    a.textContent = "Previous Page" }
+  let prevDate = undefined
+  for (const status of items) {
+    if (status.created != prevDate) dl.appendChild(document.createElement("dt")).textContent = status.created
+    const a = dl
+    .appendChild(document.createElement("dd"))
+    .appendChild(document.createElement("a"))
+    a.href = status["@id"]
+    const { title } = status
+    if (title) a.textContent = title.length > 28
+    ? "".concat(...title.slice(0, 27), "…")
+    : title
+    else {
+      const summaryText = (() => {
+        try {
+          const d = parser.parseFromString(status.content, "application/xhtml+xml")
+          const div = document.createElement("div")
+          div.appendChild(document.importNode(d.documentElement, true))
+          Object.assign(div.style,
+            { position: "absolute"
+            , top: "-2px"
+            , height: "1px"
+            , width: "1px"
+            , overflow: "hidden" })
+          document.body.appendChild(div)
+          const text = div.innerText
+          document.body.removeChild(div)
+          return text }
+        catch { } })() || "";
+      const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu, " "))
+      a.textContent = chars.length > 28
+      ? "".concat(...chars.slice(0, 27), "…")
+      : summaryText || status.identifier } }
+  if (next) {
+    const a = nav
+    .appendChild(document.createElement("p"))
+    .appendChild(document.createElement("a"))
+    a.href = next
+    a.textContent = "Next Page" }
+  if (current && current != location && current != next) {
+    const a = nav
+    .appendChild(document.createElement("p"))
+    .appendChild(document.createElement("a"))
+    a.href = current
+    a.textContent = "Latest Page" } })
+</SCRIPT>
diff --git a/topics.html b/topics.html
new file mode 100644 (file)
index 0000000..7643195
--- /dev/null
@@ -0,0 +1,20 @@
+<!dOcTyPe html>
+<HTML Lang=en>
+<TITLE>Topics</TITLE>
+<STYLE>
+body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1REM; Min-Block-Size: 100VH; Inline-Size: 100%; Max-Inline-Size: 45REM; Align-Content: Center; Justify-Content: Stretch; Font-Family: Sans-Serif }
+</STYLE>
+<H1>Topics</H1>
+<NAV><P><A HRef=/>Home</A></P><UL></UL></NAV>
+<SCRIPT Type=module>
+const ul = document.body.querySelector("nav>ul")
+fetch(`${location}.jsonld`)
+.then($ => $.json())
+.then(meta => {
+  for (const topic of meta.items) {
+    const a = ul
+    .appendChild(document.createElement("li"))
+    .appendChild(document.createElement("a"))
+    a.href = typeof topic == "string" ? topic : topic["@id"]
+    a.textContent = topic.subject || topic["@id"].split("/").pop() } })
+</SCRIPT>
This page took 0.094266 seconds and 4 git commands to generate.