From: Lady Date: Sat, 16 Dec 2023 19:11:40 +0000 (-0500) Subject: Fix ⁊ improve creator display X-Git-Tag: 0.3.2~5 X-Git-Url: https://git.ladys.computer/x_status_git/commitdiff_plain/ef3a7dd331debfcd8d511e569984a8384cc70a56 Fix ⁊ improve creator display The creator was improperly assigned to the `author` property in the Json (which did not have a context definition). This is fixed, and there is a new header on status permalinks which gives the creator and topic of the status. --- diff --git a/post-receive b/post-receive index 9698ba4..948734d 100755 --- a/post-receive +++ b/post-receive @@ -76,9 +76,9 @@ if stdin.read().split()[-1] == f"refs/heads/{LIVE_BRANCH}": status["subject"] = topic author_path = next(path.parent.glob("1=*"), None) if author_path: - status["author"] = { "name": author_path.name[2:] } + status["creator"] = { "name": author_path.name[2:] } with author_path.open("r", encoding="utf-8") as text: - status["author"]["@id"] = text.read().strip() + 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: @@ -160,11 +160,11 @@ if stdin.read().split()[-1] == f"refs/heads/{LIVE_BRANCH}": publishedElt = entryElt.appendChild(doc.createElement("published")) publishedElt.appendChild(doc.createTextNode(item["created"])) authorElt = entryElt.appendChild(doc.createElement("author")) - if "author" in item: + if "creator" in item: nameElt = authorElt.appendChild(doc.createElement("name")) - nameElt.appendChild(doc.createTextNode(item["author"]["name"])) + nameElt.appendChild(doc.createTextNode(item["creator"]["name"])) uriElt = authorElt.appendChild(doc.createElement("uri")) - uriElt.appendChild(doc.createTextNode(item["author"]["@id"])) + uriElt.appendChild(doc.createTextNode(item["creator"]["@id"])) else: nameElt = authorElt.appendChild(doc.createElement("name")) nameElt.appendChild(doc.createTextNode("Anonymous")) diff --git a/status.html b/status.html index e1cbaee..1142555 100644 --- a/status.html +++ b/status.html @@ -6,6 +6,7 @@ body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1REM; 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]), @@ -17,7 +18,7 @@ const parser = new DOMParser fetch(`${new URL(".", location).toString().slice(0, -1)}.jsonld`) .then($ => $.json()) .then(meta => { - const { items } = meta + const { items, subject } = meta const n = items.findIndex($ => new URL($["@id"]).pathname === location.pathname) const status = items[n] const src = status.content @@ -26,14 +27,26 @@ fetch(`${new URL(".", location).toString().slice(0, -1)}.jsonld`) document.title = creator ? `Status by ${creator.name} @ ${status.created}` : `Status @ ${created}` + const header = document.createElement("header") const footer = document.createElement("footer") - const authorshipP = footer.appendChild(document.createElement("p")) + const headerChildren = + [ "A(n) " + , subject + ? (subjectLink => { + subjectLink.textContent = subject + subjectLink.href = meta["@id"] + return subjectLink })(document.createElement("a")) + : "status" + , " update" ] if (creator) { - const authorLink = authorshipP.appendChild(document.createElement("a")) - authorLink.href = creator["@id"] + const authorLink = document.createElement("@id" in creator ? "a" : "span") + if (authorLink.localName == "a") authorLink.href = creator["@id"] authorLink.textContent = creator.name - authorshipP.appendChild(document.createTextNode(" @ ")) } - authorshipP.appendChild(document.createElement("time")).textContent = created + 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")) @@ -99,6 +112,6 @@ fetch(`${new URL(".", location).toString().slice(0, -1)}.jsonld`) const summary = details.appendChild(document.createElement("summary")) summary.textContent = title details.append(...document.importNode(article, true).childNodes) - document.body.replaceChildren(wrapper, footer) } - else document.body.replaceChildren(document.importNode(article, true), footer) }) + document.body.replaceChildren(header, wrapper, footer) } + else document.body.replaceChildren(header, document.importNode(article, true), footer) })