]> Lady’s Gitweb - x_status_git/blob - topic.html
Make prev, next take priority over first, current
[x_status_git] / 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><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 const { first, prev, next, current, items } = meta
22 if (first && first != location && first != prev) {
23 const a = nav
24 .insertBefore(document.createElement("p"), dl)
25 .appendChild(document.createElement("a"))
26 a.href = first
27 a.textContent = "First Page" }
28 if (prev) {
29 const a = nav
30 .insertBefore(document.createElement("p"), dl)
31 .appendChild(document.createElement("a"))
32 a.href = prev
33 a.textContent = "Previous Page" }
34 let prevDate = undefined
35 for (const status of items) {
36 if (status.created != prevDate) dl.appendChild(document.createElement("dt")).textContent = status.created
37 const a = dl
38 .appendChild(document.createElement("dd"))
39 .appendChild(document.createElement("a"))
40 a.href = status["@id"]
41 const summaryText = (() => {
42 try {
43 const d = parser.parseFromString(status.content, "application/xhtml+xml")
44 const div = document.createElement("div")
45 div.appendChild(document.importNode(d.documentElement, true))
46 Object.assign(div.style,
47 { position: "absolute"
48 , top: "-2px"
49 , height: "1px"
50 , width: "1px"
51 , overflow: "hidden" })
52 document.body.appendChild(div)
53 const text = div.innerText
54 document.body.removeChild(div)
55 return text }
56 catch { } })() || "";
57 const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu, " "))
58 a.textContent = chars.length > 28
59 ? "".concat(...chars.slice(0, 27), "…")
60 : summaryText || status.identifier }
61 if (next) {
62 const a = nav
63 .appendChild(document.createElement("p"))
64 .appendChild(document.createElement("a"))
65 a.href = next
66 a.textContent = "Next Page" }
67 if (current && current != location && current != next) {
68 const a = nav
69 .appendChild(document.createElement("p"))
70 .appendChild(document.createElement("a"))
71 a.href = current
72 a.textContent = "Latest Page" } })
73 </SCRIPT>
This page took 0.14243 seconds and 5 git commands to generate.