]> Lady’s Gitweb - x_status_git/blob - index.html
44698ed810095a5144735f47d9b1b24d65656164
[x_status_git] / index.html
1 <!dOcTyPe html>
2 <HTML Lang=en>
3 <TITLE>Index</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 #status{ Font-Size: Larger }
7 #topics{ Display: Grid; Margin-Block: 1REM; Grid: Auto-Flow / 1FR 1FR; Gap: 0 1REM }
8 #topics h2{ Margin-Block-End: 0; Grid-Column: 1 / Span 2; Text-Align: Center }
9 #topics h2:Last-Child{ Display: None }
10 div.STATUS{ Border: Thin Solid; Padding-Inline: 1REM; Border-Radius: .5REM }
11 summary{ Padding-Block: 1REM; Font-Weight: Bold }
12 details[open]>summary{ Border-Block-End: Thin Solid }
13 footer{ Border-Block-Start: Thin Solid; Padding-Block: 1REM; Font-Size: Smaller; 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 <H1>Index</H1>
19 <DIV Class=STATUS ID=status>
20 </DIV>
21 <SECTION ID=topics>
22 <H2>Topics</H2>
23 </SECTION>
24 <SCRIPT Type=module>
25 const parser = new DOMParser
26 document.title = location.hostname
27 document.documentElement.querySelector("body>h1").textContent = location.hostname
28 const renderLatest = (path, container) => fetch(`${path}.jsonld`)
29 .then($ => $.json())
30 .then(meta => {
31 const { items } = meta
32 const status = items.pop()
33 const src = status.content
34 const { documentElement: article } = parser.parseFromString(src, "application/xhtml+xml")
35 const footer = document.createElement("footer")
36 const authorshipP = footer.appendChild(document.createElement("p"))
37 const { creator, title } = status
38 if (creator) {
39 const authorLink = authorshipP.appendChild(document.createElement("a"))
40 authorLink.href = creator["@id"]
41 authorLink.textContent = creator.name
42 authorshipP.appendChild(document.createTextNode(" @ ")) }
43 authorshipP.appendChild(document.createElement("time")).textContent = status.created
44 const nav = footer.appendChild(document.createElement("nav"))
45 const permalink = nav.appendChild(document.createElement("a"))
46 permalink.href = status["@id"]
47 permalink.textContent = "Permalink."
48 nav.appendChild(document.createTextNode(" "))
49 const upLink = nav.appendChild(document.createElement("a"))
50 upLink.href = meta["@id"]
51 upLink.textContent = `See more ${ status.subject ? `“${status.subject}” posts` : "statuses" }.`
52 if (title) {
53 const wrapper = document.createElement("article")
54 const details = wrapper.appendChild(document.createElement("details"))
55 details.setAttribute("open", "")
56 const summary = details.appendChild(document.createElement("summary"))
57 summary.textContent = title
58 details.append(...document.importNode(article, true).childNodes)
59 container.replaceChildren(wrapper, footer) }
60 else container.replaceChildren(document.importNode(article, true), footer) })
61 fetch("statuses.jsonld")
62 .then($ => $.json())
63 .then(meta => renderLatest(meta.current, document.getElementById("status")))
64 fetch("topics.jsonld")
65 .then($ => $.json())
66 .then(meta => {
67 const topics = document.getElementById("topics")
68 for (const topicID of meta.items.map($ => $["@id"] ?? $)) {
69 const section = topics.appendChild(document.createElement("section"))
70 fetch(`${topicID}.jsonld`)
71 .then($ => $.json())
72 .then(topic => {
73 section.appendChild(document.createElement("h3")).textContent = topic.subject
74 const div = section.appendChild(document.createElement("div"))
75 div.className = "STATUS"
76 renderLatest(new URL(topic["@id"]).pathname, div)
77 }) } })
78 </SCRIPT>
This page took 0.050044 seconds and 3 git commands to generate.