]> Lady’s Gitweb - x_status_git/blob - status.html
Add SIOC types to resources
[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 footer{ Border-Block-Start: Thin Solid; Padding-Block: 1REM; Text-Align: End }
8 footer p{ Margin-Block: 0 .5REM }
9 footer time:Not([datetime]),
10 footer small{ Font-Size: Inherit; Font-Style: Italic }
11 </STYLE>
12 <BODY>
13 <SCRIPT Type=module>
14 const parser = new DOMParser
15 fetch(`${new URL(".", location).toString().slice(0, -1)}.jsonld`)
16 .then($ => $.json())
17 .then(meta => {
18 const { items } = meta
19 const n = items.findIndex($ => new URL($["@id"]).pathname === location.pathname)
20 const status = items[n]
21 const src = status.content
22 const { documentElement: article } = parser.parseFromString(src, "application/xhtml+xml")
23 const { creator, created } = status
24 document.title = creator
25 ? `Status by ${creator.name} @ ${status.created}`
26 : `Status @ ${created}`
27 const footer = document.createElement("footer")
28 const authorshipP = footer.appendChild(document.createElement("p"))
29 if (creator) {
30 const authorLink = authorshipP.appendChild(document.createElement("a"))
31 authorLink.href = creator["@id"]
32 authorLink.textContent = creator.name
33 authorshipP.appendChild(document.createTextNode(" @ ")) }
34 authorshipP.appendChild(document.createElement("time")).textContent = created
35 footer
36 .appendChild(document.createElement("p"))
37 .appendChild(document.createElement("small"))
38 .textContent = status.identifier
39 const nav = footer.appendChild(document.createElement("nav"))
40 nav.appendChild(document.createTextNode("Up: "))
41 const upLink = nav.appendChild(document.createElement("a"))
42 upLink.href = meta["@id"]
43 upLink.textContent = meta.subject || meta["@id"].split("/").pop()
44 if (n > 0) {
45 nav.appendChild(document.createTextNode("; Previous: "))
46 const prevLink = nav.appendChild(document.createElement("a"))
47 prevLink.href = items[n - 1]["@id"]
48 const prevText = (() => {
49 try {
50 const prevD = parser.parseFromString(items[n - 1].content, "application/xhtml+xml")
51 const div = document.createElement("div")
52 div.appendChild(document.importNode(prevD.documentElement, true))
53 Object.assign(div.style,
54 { position: "absolute"
55 , top: "-2px"
56 , height: "1px"
57 , width: "1px"
58 , overflow: "hidden" })
59 document.body.appendChild(div)
60 const text = div.innerText
61 document.body.removeChild(div)
62 return text }
63 catch { } })() ?? items[n + 1].created;
64 const prevChars = Array.from(prevText.trim().replaceAll(/\s+/gu, " "))
65 prevLink.textContent = prevChars.length > 28
66 ? "".concat(...prevChars.slice(0, 27), "…")
67 : prevText }
68 if (n < items.length - 1) {
69 nav.appendChild(document.createTextNode("; Next: "))
70 const nextLink = nav.appendChild(document.createElement("a"))
71 nextLink.href = items[n + 1]["@id"]
72 const nextText = (() => {
73 try {
74 const nextD = parser.parseFromString(items[n + 1].content, "application/xhtml+xml")
75 const div = document.createElement("div")
76 div.appendChild(document.importNode(nextD.documentElement, true))
77 Object.assign(div.style,
78 { position: "absolute"
79 , top: "-2px"
80 , height: "1px"
81 , width: "1px"
82 , overflow: "hidden" })
83 document.body.appendChild(div)
84 const text = div.innerText
85 document.body.removeChild(div)
86 return text }
87 catch { } })() ?? items[n + 1].created;
88 const nextChars = Array.from(nextText.trim().replaceAll(/\s+/gu, " "))
89 nextLink.textContent = nextChars.length > 28
90 ? "".concat(...nextChars.slice(0, 27), "…")
91 : nextText }
92 nav.appendChild(document.createTextNode("."))
93 document.body.replaceChildren(document.importNode(article, true), footer) })
94 </SCRIPT>
This page took 0.056266 seconds and 5 git commands to generate.