]> Lady’s Gitweb - x_status_git/blob - status.html
e1c68ad306aab8e9c17d026b9868d51f668205da
[x_status_git] / status.html
1 <!dOcTyPe hTmL>
2 <HTML Lang=en>
3 <TITLE>Status</TITLE>
4 <STYLE>
5 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 }
6 article{ Font-Size: Larger }
7 summary{ Padding-Block: 1REM; Font-Weight: Bold }
8 details[open]>summary{ Border-Block-End: Thin Solid }
9 header{ Border-Block-End: Thin Solid; Padding-Block: 1REM; Text-Align: Start }
10 footer{ Border-Block-Start: Thin Solid; Padding-Block: 1REM; Text-Align: End }
11 footer p{ Margin-Block: 0 .5REM }
12 footer time:Not([datetime]),
13 footer small{ Font-Size: Inherit; Font-Style: Italic }
14 </STYLE>
15 <BODY>
16 <SCRIPT Type=module>
17 const parser = new DOMParser
18 const index = `${new URL(".", location).toString().slice(0, -1)}.jsonld`
19 fetch(index)
20 .then($ => $.json())
21 .then(meta => {
22 const { items } = meta
23 if (items.find($ => new URL($["@id"]).pathname === location.pathname)) return meta
24 else return fetch(index, { cache: "reload" }).then($ => $.json()) })
25 .then(meta => {
26 const { items, subject } = meta
27 const n = items.findIndex($ => new URL($["@id"]).pathname === location.pathname)
28 const status = items[n]
29 const src = status.content
30 const { documentElement: article } = parser.parseFromString(src, "application/xhtml+xml")
31 const { creator, created, title } = status
32 document.title = creator
33 ? `Status by ${creator.name} @ ${status.created}`
34 : `Status @ ${created}`
35 const header = document.createElement("header")
36 const footer = document.createElement("footer")
37 const headerChildren =
38 [ "A(n) "
39 , subject
40 ? (subjectLink => {
41 subjectLink.textContent = subject
42 subjectLink.href = meta["@id"]
43 return subjectLink })(document.createElement("a"))
44 : "status"
45 , " update" ]
46 if (creator) {
47 const authorLink = document.createElement("@id" in creator ? "a" : "span")
48 if (authorLink.localName == "a") authorLink.href = creator["@id"]
49 authorLink.textContent = creator.name
50 headerChildren.push(" by ", authorLink, "…") }
51 else headerChildren.push("…")
52 header.append(...headerChildren)
53 const timestampP = footer.appendChild(document.createElement("p"))
54 timestampP.appendChild(document.createElement("time")).textContent = created
55 footer
56 .appendChild(document.createElement("p"))
57 .appendChild(document.createElement("small"))
58 .textContent = status.identifier
59 const nav = footer.appendChild(document.createElement("nav"))
60 nav.appendChild(document.createTextNode("Up: "))
61 const upLink = nav.appendChild(document.createElement("a"))
62 upLink.href = meta["@id"]
63 upLink.textContent = meta.subject || meta["@id"].split("/").pop()
64 if (n > 0) {
65 nav.appendChild(document.createTextNode("; Previous: "))
66 const prevLink = nav.appendChild(document.createElement("a"))
67 prevLink.href = items[n - 1]["@id"]
68 const prevText = (() => {
69 try {
70 const prevD = parser.parseFromString(items[n - 1].content, "application/xhtml+xml")
71 const div = document.createElement("div")
72 div.appendChild(document.importNode(prevD.documentElement, true))
73 Object.assign(div.style,
74 { position: "absolute"
75 , top: "-2px"
76 , height: "1px"
77 , width: "1px"
78 , overflow: "hidden" })
79 document.body.appendChild(div)
80 const text = div.innerText
81 document.body.removeChild(div)
82 return text }
83 catch { } })() ?? items[n + 1].created;
84 const prevChars = Array.from(prevText.trim().replaceAll(/\s+/gu, " "))
85 prevLink.textContent = prevChars.length > 28
86 ? "".concat(...prevChars.slice(0, 27), "…")
87 : prevText }
88 if (n < items.length - 1) {
89 nav.appendChild(document.createTextNode("; Next: "))
90 const nextLink = nav.appendChild(document.createElement("a"))
91 nextLink.href = items[n + 1]["@id"]
92 const nextText = (() => {
93 try {
94 const nextD = parser.parseFromString(items[n + 1].content, "application/xhtml+xml")
95 const div = document.createElement("div")
96 div.appendChild(document.importNode(nextD.documentElement, true))
97 Object.assign(div.style,
98 { position: "absolute"
99 , top: "-2px"
100 , height: "1px"
101 , width: "1px"
102 , overflow: "hidden" })
103 document.body.appendChild(div)
104 const text = div.innerText
105 document.body.removeChild(div)
106 return text }
107 catch { } })() ?? items[n + 1].created;
108 const nextChars = Array.from(nextText.trim().replaceAll(/\s+/gu, " "))
109 nextLink.textContent = nextChars.length > 28
110 ? "".concat(...nextChars.slice(0, 27), "…")
111 : nextText }
112 nav.appendChild(document.createTextNode("."))
113 if (title) {
114 const wrapper = document.createElement("article")
115 const details = wrapper.appendChild(document.createElement("details"))
116 details.setAttribute("open", "")
117 const summary = details.appendChild(document.createElement("summary"))
118 summary.textContent = title
119 details.append(...document.importNode(article, true).childNodes)
120 document.body.replaceChildren(header, wrapper, footer) }
121 else document.body.replaceChildren(header, document.importNode(article, true), footer) })
122 </SCRIPT>
This page took 0.101692 seconds and 3 git commands to generate.