From: Lady Date: Fri, 15 Dec 2023 03:01:23 +0000 (-0500) Subject: Support titles on statuses X-Git-Tag: 0.2.0~2 X-Git-Url: https://git.ladys.computer/x_status_git/commitdiff_plain/3394dfeb4194ca630becdb4d34538a3370d47ca8 Support titles on statuses Titles can be used akin to fediverse C·W’s/“summaries” and provide a better display for the status in listings. --- diff --git a/README.markdown b/README.markdown index 657527d..9cd2346 100644 --- a/README.markdown +++ b/README.markdown @@ -209,6 +209,13 @@ The files which represent a status are as follows :— 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. diff --git a/index.html b/index.html index b315183..44698ed 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,8 @@ body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 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]), @@ -32,7 +34,7 @@ const renderLatest = (path, container) => fetch(`${path}.jsonld`) const { documentElement: article } = parser.parseFromString(src, "application/xhtml+xml") const footer = document.createElement("footer") const authorshipP = footer.appendChild(document.createElement("p")) - const { creator } = status + const { creator, title } = status if (creator) { const authorLink = authorshipP.appendChild(document.createElement("a")) authorLink.href = creator["@id"] @@ -47,7 +49,15 @@ const renderLatest = (path, container) => fetch(`${path}.jsonld`) const upLink = nav.appendChild(document.createElement("a")) upLink.href = meta["@id"] upLink.textContent = `See more ${ status.subject ? `“${status.subject}” posts` : "statuses" }.` - container.replaceChildren(document.importNode(article, true), footer) }) + 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 => renderLatest(meta.current, document.getElementById("status"))) diff --git a/post-receive b/post-receive index bc16a55..e1da847 100755 --- a/post-receive +++ b/post-receive @@ -70,6 +70,11 @@ if stdin.read().split()[-1] == f"refs/heads/{LIVE_BRANCH}": status["author"] = { "name": author_path.name[2:] } with author_path.open("r", encoding="utf-8") as text: status["author"]["@id"] = text.read().strip() + title_path = next(path.parent.glob("2=*")) + 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=*")) datetime = "" if date_path: diff --git a/status.html b/status.html index a56276e..e1cbaee 100644 --- a/status.html +++ b/status.html @@ -4,6 +4,8 @@