]> Lady’s Gitweb - Status/blob - status.html
Improve styling on topic pages
[Status] / status.html
1 <!dOcTyPe hTmL>
2 <HTML Lang=en>
3 <TITLE>Status</TITLE>
4 <STYLE>
5 html{ Color: #E3E3E3; Background: #700020; Font-Family: UI-Rounded, 'Hiragino Maru Gothic ProN', Quicksand, Comfortaa, Manjari, 'Arial Rounded MT', 'Arial Rounded MT Bold', Calibri, Sans-Serif; Line-Height: 1.5; Text-Shadow: Calc(1EM / 12) Calc(1EM / 12) #000000 }
6 body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1CH; Min-Block-Size: 100VH; Inline-Size: 100%; Max-Inline-Size: 48REM; Align-Content: Center; Justify-Content: Stretch }
7 :Any-Link{ Color: #87E6DD }
8 article{ Border: Thin Solid; Padding-Inline: 1REM; Border-Radius: .5REM; Color: #F3DEE3; Background: #1A1A1A; Font-Size: Larger; Text-Shadow: None }
9 article :Any-Link{ Color: #D6B7BF }
10 summary{ Padding-Block: 1REM; Font-Weight: Bold }
11 details[open]>summary{ Border-Block-End: Thin Solid }
12 header{ Padding-Block: 1REM; Text-Align: Start }
13 footer{ Padding-Block: 1REM; Text-Align: End }
14 footer p{ Margin-Block: 0 .5REM }
15 footer time:Not([datetime]),
16 footer small{ Font-Size: Inherit; Font-Style: Italic }
17 </STYLE>
18 <BODY>
19 <SCRIPT Type=module>
20 const parser = new DOMParser
21 const index = `${new URL(".", location).toString().slice(0, -1)}.jsonld`
22 fetch(index)
23 .then($ => $.json())
24 .then(meta => {
25 const { items } = meta
26 if (items.find($ => new URL($["@id"]).pathname === location.pathname)) return meta
27 else return fetch(index, { cache: "reload" }).then($ => $.json()) })
28 .then(meta => {
29 const { items, subject } = meta
30 const n = items.findIndex($ => new URL($["@id"]).pathname === location.pathname)
31 const status = items[n]
32 const src = status.content
33 const { documentElement: article } = parser.parseFromString(src, "application/xhtml+xml")
34 const { creator, created, title } = status
35 document.title = creator
36 ? `Status by ${creator.name} @ ${status.created}`
37 : `Status @ ${created}`
38 const header = document.createElement("header")
39 const footer = document.createElement("footer")
40 const headerChildren =
41 [ "A(n) "
42 , subject
43 ? (subjectLink => {
44 subjectLink.textContent = subject
45 subjectLink.href = meta["@id"]
46 return subjectLink })(document.createElement("a"))
47 : "status"
48 , " update" ]
49 if (creator) {
50 const authorLink = document.createElement("@id" in creator ? "a" : "span")
51 if (authorLink.localName == "a") authorLink.href = creator["@id"]
52 authorLink.textContent = creator.name
53 headerChildren.push(" by ", authorLink, "…") }
54 else headerChildren.push("…")
55 header.append(...headerChildren)
56 const timestampP = footer.appendChild(document.createElement("p"))
57 timestampP.appendChild(document.createElement("time")).textContent = created
58 footer
59 .appendChild(document.createElement("p"))
60 .appendChild(document.createElement("small"))
61 .textContent = status.identifier
62 const nav = footer.appendChild(document.createElement("nav"))
63 nav.appendChild(document.createTextNode("Up: "))
64 const upLink = nav.appendChild(document.createElement("a"))
65 upLink.href = meta["@id"]
66 upLink.textContent = meta.subject || meta["@id"].split("/").pop()
67 if (n > 0) {
68 nav.appendChild(document.createTextNode("; Previous: "))
69 const prevLink = nav.appendChild(document.createElement("a"))
70 prevLink.href = items[n - 1]["@id"]
71 const { title: prevTitle } = items[n - 1]
72 if (prevTitle) prevLink.textContent = prevTitle.length > 28
73 ? "".concat(...prevTitle.slice(0, 27), "…")
74 : prevTitle
75 else {
76 const prevText = (() => {
77 try {
78 const prevD = parser.parseFromString(items[n - 1].content, "application/xhtml+xml")
79 const div = document.createElement("div")
80 div.appendChild(document.importNode(prevD.documentElement, true))
81 Object.assign(div.style,
82 { position: "absolute"
83 , top: "-2px"
84 , height: "1px"
85 , width: "1px"
86 , overflow: "hidden" })
87 document.body.appendChild(div)
88 const text = div.innerText
89 document.body.removeChild(div)
90 return text }
91 catch { } })() ?? items[n + 1].created;
92 const prevChars = Array.from(prevText.trim().replaceAll(/\s+/gu, " "))
93 prevLink.textContent = prevChars.length > 28
94 ? "".concat(...prevChars.slice(0, 27), "…")
95 : prevText } }
96 if (n < items.length - 1) {
97 nav.appendChild(document.createTextNode("; Next: "))
98 const nextLink = nav.appendChild(document.createElement("a"))
99 nextLink.href = items[n + 1]["@id"]
100 const { title: nextTitle } = items[n + 1]
101 if (nextTitle) nextLink.textContent = nextTitle.length > 28
102 ? "".concat(...nextTitle.slice(0, 27), "…")
103 : nextTitle
104 else {
105 const nextText = (() => {
106 try {
107 const nextD = parser.parseFromString(items[n + 1].content, "application/xhtml+xml")
108 const div = document.createElement("div")
109 div.appendChild(document.importNode(nextD.documentElement, true))
110 Object.assign(div.style,
111 { position: "absolute"
112 , top: "-2px"
113 , height: "1px"
114 , width: "1px"
115 , overflow: "hidden" })
116 document.body.appendChild(div)
117 const text = div.innerText
118 document.body.removeChild(div)
119 return text }
120 catch { } })() ?? items[n + 1].created;
121 const nextChars = Array.from(nextText.trim().replaceAll(/\s+/gu, " "))
122 nextLink.textContent = nextChars.length > 28
123 ? "".concat(...nextChars.slice(0, 27), "…")
124 : nextText } }
125 nav.appendChild(document.createTextNode("."))
126 if (title) {
127 const wrapper = document.createElement("article")
128 const details = wrapper.appendChild(document.createElement("details"))
129 details.setAttribute("open", "")
130 const summary = details.appendChild(document.createElement("summary"))
131 summary.textContent = title
132 details.append(...document.importNode(article, true).childNodes)
133 document.body.replaceChildren(header, wrapper, footer) }
134 else document.body.replaceChildren(header, document.importNode(article, true), footer) })
135 </SCRIPT>
This page took 0.079905 seconds and 5 git commands to generate.