3 SPDX-FileCopyrightText: 2024, 2025 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
7 ⁌ 📰 Caudex ∷ transform.xslt
9 © 2024–2025 Lady [@ Ladys Computer]
11 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
12 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
15 <!ENTITY xhtml 'http://www.w3.org/1999/xhtml'>
16 <!ENTITY 书社 'urn:fdc:ladys.computer:20231231:Shu1She4'>
19 xmlns="http://www.w3.org/1999/XSL/Transform"
20 xmlns:Caudex="urn:fdc:ladys.computer:20240204:Caudex"
21 xmlns:awol="http://bblfish.net/work/atom-owl/2006-06-06/#"
22 xmlns:dcterms="http://purl.org/dc/terms/"
23 xmlns:exsl="http://exslt.org/common"
24 xmlns:exslstr="http://exslt.org/strings"
26 xmlns:ladys="https://vocab.ladys.computer/terms/"
27 xmlns:ore="http://www.openarchives.org/ore/terms/"
28 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
29 xmlns:skos="http://www.w3.org/2004/02/skos/core#"
31 extension-element-prefixes="exsl exslstr"
34 <书社:id>urn:fdc:ladys.computer:20240204:Caudex:transform.xslt</书社:id>
35 <template match="@id" mode="Caudex:codex-entry" priority="0">
37 <value-of select="ancestor::*[skos:notation][1]/skos:notation"/>
39 <value-of select="."/>
42 <template match="@href[starts-with(., '#')]" mode="Caudex:codex-entry" priority="0">
43 <attribute name="href">
45 <value-of select="ancestor::*[skos:notation][1]/skos:notation"/>
47 <value-of select="substring-after(., '#')"/>
50 <template match="@*|node()" mode="Caudex:codex-entry" priority="-1">
52 <apply-templates select="@*|node()" mode="Caudex:codex-entry"/>
55 <template match="Caudex:codex" mode="书社:expand" priority="1">
56 <variable name="codex-fragment">
57 <apply-templates select="node()" mode="书社:expand"/>
59 <variable name="codex" select="exsl:node-set($codex-fragment)"/>
60 <variable name="codex-rdf" select="$codex//ore:Aggregation[@rdf:nodeID='codex']"/>
61 <element name="书社:archive">
62 <attribute name="书社:expanded"/>
63 <for-each select="$codex-rdf">
64 <variable name="title-fragment">
65 <if test="@dcterms:title">
66 <element name="meta" namespace="&xhtml;">
67 <attribute name="itemprop">
68 <text>urn:fdc:ladys.computer:20231231:Shu1She4:title</text>
70 <attribute name="content">
71 <value-of select="@dcterms:title"/>
76 <variable name="navigation-fragment">
77 <element name="nav" namespace="&xhtml;">
78 <element name="ul" namespace="&xhtml;">
79 <for-each select="$codex//awol:Category">
80 <sort select="ladys:order" data-type="number"/>
81 <sort select="@awol:term"/>
82 <variable name="category-id" select="string(@rdf:nodeID)"/>
83 <element name="li" namespace="&xhtml;">
84 <element name="strong" namespace="&xhtml;">
85 <value-of select="@awol:term"/>
87 <element name="ul" namespace="&xhtml;">
88 <for-each select="$codex//ore:Proxy[ore:proxyIn/@rdf:nodeID='codex' and awol:category/@rdf:nodeID=$category-id]">
89 <sort select="ladys:order" data-type="number"/>
90 <sort select="@dcterms:title"/>
91 <sort select="skos:notation"/>
92 <element name="li" namespace="&xhtml;">
93 <element name="a" namespace="&xhtml;">
94 <attribute name="href">
96 <value-of select="skos:notation"/>
99 <attribute name="data-identifier">
100 <value-of select="skos:notation"/>
102 <attribute name="data-cksum">
103 <value-of select="@书社:cksum"/>
105 <if test="@dcterms:title">
106 <value-of select="@dcterms:title"/>
109 <element name="small" namespace="&xhtml;">
111 <element name="code" namespace="&xhtml;">
112 <attribute name="lang">
115 <attribute name="xml:lang">
118 <value-of select="skos:notation"/>
131 <element name="div" namespace="&xhtml;">
132 <attribute name="Caudex:page">
135 <attribute name="书社:archived-as">
136 <text>index.xhtml</text>
138 <copy-of select="$title-fragment"/>
139 <element name="main" namespace="&xhtml;">
140 <copy-of select="$navigation-fragment"/>
141 <element name="div" namespace="&xhtml;">
142 <attribute name="id">
143 <text>Caudex.pane</text>
147 <element name="script" namespace="&xhtml;">
148 <attribute name="type">
149 <text>text/javascript</text>
151 <text><![CDATA[#!javascript
155 for(;i<links.length;++i){
157 var identifier=link.getAttribute("data-identifier")
158 var cksum=link.getAttribute("data-cksum")
159 if(!(identifier&&cksum))return
160 link.addEventListener("click",function(event){
161 var pane=document.getElementById("Caudex.pane")
163 if(identifier in cache){
165 pane.appendChild(document.importNode(cache[identifier],true))
167 pane.textContent="Loading…"
168 request=new XMLHttpRequest
169 request.open("GET",link.href)
170 request.addEventListener("load",function(){
172 var article=request.responseXML.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","article").item(0)
173 cache[identifier]=article
175 pane.appendChild(document.importNode(article,true))
176 for(;k<links.length;++k){
178 var parent=linkk.parentNode
179 if(linkk==link)parent.setAttribute("class","selected")
180 else parent.setAttribute("class","")
183 link.setAttribute("class","cached read")
185 localStorage.setItem(identifier,cksum)
188 request.responseType="document"
191 event.preventDefault()
195 var lastReadCksum=localStorage.getItem(identifier)
196 if(lastReadCksum==cksum)link.setAttribute("class","read")
197 else if(lastReadCksum)link.setAttribute("class","updated")
198 else link.setAttribute("class","new")
202 }(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","main")[0].children[0].getElementsByTagNameNS("http://www.w3.org/1999/xhtml","a"))
206 <element name="div" namespace="&xhtml;">
207 <attribute name="Caudex:page">
208 <text>standalone</text>
210 <attribute name="书社:archived-as">
211 <text>standalone.xhtml</text>
213 <copy-of select="$title-fragment"/>
214 <element name="main" namespace="&xhtml;">
215 <copy-of select="$navigation-fragment"/>
216 <element name="div" namespace="&xhtml;">
217 <attribute name="id">
218 <text>Caudex.pane</text>
220 <for-each select="$codex//ore:Proxy">
221 <element name="article" namespace="&xhtml;">
222 <attribute name="id">
223 <value-of select="skos:notation"/>
225 <attribute name="hidden">
228 <apply-templates select="ore:proxyFor/*/awol:content/awol:body/node()" mode="Caudex:codex-entry"/>
233 <element name="script" namespace="&xhtml;">
234 <attribute name="type">
235 <text>text/javascript</text>
237 <text><![CDATA[#!javascript
240 for(;i<links.length;++i){
242 var identifier=link.getAttribute("data-identifier")
243 var cksum=link.getAttribute("data-cksum")
244 if(!(identifier&&cksum))return
245 link.addEventListener("click",function(event){
248 var pane=document.getElementById("Caudex.pane")
249 var articles=pane.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","article")
250 for(;j<articles.length;++j){
252 if(article.getAttribute("id")==identifier){
253 article.removeAttribute("hidden")
254 link.setAttribute("class","cached read")
256 localStorage.setItem(identifier,cksum)
259 else article.setAttribute("hidden","hidden")
262 for(;k<links.length;++k){
264 var parent=linkk.parentNode
265 if(linkk==link)parent.setAttribute("class","selected")
266 else parent.setAttribute("class","")
269 event.preventDefault()
273 var lastReadCksum=localStorage.getItem(identifier)
274 if(lastReadCksum==cksum)link.setAttribute("class","cached read")
275 else if(lastReadCksum)link.setAttribute("class","cached updated")
276 else link.setAttribute("class","cached new")
280 }(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","main")[0].children[0].getElementsByTagNameNS("http://www.w3.org/1999/xhtml","a"))
285 <for-each select="$codex//ore:Proxy">
286 <element name="article" namespace="&xhtml;">
287 <attribute name="Caudex:page">
288 <value-of select="skos:notation"/>
290 <attribute name="书社:archived-as">
291 <value-of select="skos:notation"/>
294 <if test="@dcterms:title">
295 <element name="meta" namespace="&xhtml;">
296 <attribute name="itemprop">
297 <text>urn:fdc:ladys.computer:20231231:Shu1She4:title</text>
299 <attribute name="content">
300 <value-of select="@dcterms:title"/>
304 <apply-templates select="ore:proxyFor/*/awol:content/awol:body/node()" mode="Caudex:codex-entry"/>
309 <template match="html:div[@itemtype='&书社;:document' and @Caudex:page]" mode="书社:metadata" priority="0">
310 <element name="style" namespace="&xhtml;">
311 <text><![CDATA[@charset "UTF-8";
312 @namespace "http://www.w3.org/1999/xhtml";
313 *[hidden]{Display:None}
315 <if test="@Caudex:page='index' or @Caudex:page='standalone'">
316 <text><![CDATA[/*Index styling*/
317 main{Display:Block;Width:100%;Height:100%}
318 main>*{Display:Inline-Block;Box-Sizing:Border-Box;Border:.5EM Transparent None;Height:100%;Width:50%;Vertical-Align:Top;Overflow:Auto}
319 main>nav{Border-Right-Style:Solid;Overflow:Scroll}
320 main>div{Border-Left-Style:Solid}