]> Lady’s Gitweb - Status/blob - topic.html
Add Makefile rule for updating upstream
[Status] / topic.html
1 <!dOcTyPe html>
2 <META Charset=utf-8>
3 <TITLE>Topic Feed</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 </STYLE>
7 <H1>Topic Feed</H1>
8 <NAV><P><A HRef=/>Home</A></P><DL></DL></NAV>
9 <SCRIPT Type=module>
10 const nav = document.body.querySelector("nav")
11 const dl = nav.querySelector("dl")
12 const parser = new DOMParser
13 fetch(`${location}.jsonld`)
14 .then($ => $.json())
15 .then(meta => {
16 const topic = meta.subject || meta["@id"].split("/").pop()
17 document.title = topic
18 document.body.querySelector("h1").textContent = "subject" in meta
19 ? `#${topic}`
20 : `@${topic}`
21 if ("subject" in meta) {
22 const a = nav
23 .insertBefore(document.createElement("p"), dl)
24 .appendChild(document.createElement("a"))
25 a.href = "/topics"
26 a.textContent = "Topics" }
27 const { first, prev, next, current, items } = meta
28 if (first && first != location && first != prev) {
29 const a = nav
30 .insertBefore(document.createElement("p"), dl)
31 .appendChild(document.createElement("a"))
32 a.href = first
33 a.textContent = "First Page" }
34 if (prev) {
35 const a = nav
36 .insertBefore(document.createElement("p"), dl)
37 .appendChild(document.createElement("a"))
38 a.href = prev
39 a.textContent = "Previous Page" }
40 let prevDate = undefined
41 for (const status of items) {
42 if (status.created != prevDate) dl.appendChild(document.createElement("dt")).textContent = status.created
43 const a = dl
44 .appendChild(document.createElement("dd"))
45 .appendChild(document.createElement("a"))
46 a.href = status["@id"]
47 const { title } = status
48 if (title) a.textContent = title.length > 28
49 ? "".concat(...title.slice(0, 27), "…")
50 : title
51 else {
52 const summaryText = (() => {
53 try {
54 const d = parser.parseFromString(status.content, "application/xhtml+xml")
55 const div = document.createElement("div")
56 div.appendChild(document.importNode(d.documentElement, true))
57 Object.assign(div.style,
58 { position: "absolute"
59 , top: "-2px"
60 , height: "1px"
61 , width: "1px"
62 , overflow: "hidden" })
63 document.body.appendChild(div)
64 const text = div.innerText
65 document.body.removeChild(div)
66 return text }
67 catch { } })() || "";
68 const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu, " "))
69 a.textContent = chars.length > 28
70 ? "".concat(...chars.slice(0, 27), "…")
71 : summaryText || status.identifier } }
72 if (next) {
73 const a = nav
74 .appendChild(document.createElement("p"))
75 .appendChild(document.createElement("a"))
76 a.href = next
77 a.textContent = "Next Page" }
78 if (current && current != location && current != next) {
79 const a = nav
80 .appendChild(document.createElement("p"))
81 .appendChild(document.createElement("a"))
82 a.href = current
83 a.textContent = "Latest Page" } })
84 </SCRIPT>
This page took 0.126969 seconds and 5 git commands to generate.