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:ore="http://www.openarchives.org/ore/terms/"
27 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
28 xmlns:skos="http://www.w3.org/2004/02/skos/core#"
30 extension-element-prefixes="exsl exslstr"
33 <书社:id>urn:fdc:ladys.computer:20240204:Caudex:transform.xslt</书社:id>
34 <template match="@id" mode="Caudex:codex-entry" priority="0">
36 <value-of select="ancestor::*[skos:notation][1]/skos:notation"/>
38 <value-of select="."/>
41 <template match="@href[starts-with(., '#')]" mode="Caudex:codex-entry" priority="0">
42 <attribute name="href">
44 <value-of select="ancestor::*[skos:notation][1]/skos:notation"/>
46 <value-of select="substring-after(., '#')"/>
49 <template match="@*|node()" mode="Caudex:codex-entry" priority="-1">
51 <apply-templates select="@*|node()" mode="Caudex:codex-entry"/>
54 <template match="Caudex:codex" mode="书社:expand" priority="1">
55 <variable name="codex-fragment">
56 <apply-templates select="node()" mode="书社:expand"/>
58 <variable name="codex" select="exsl:node-set($codex-fragment)"/>
59 <variable name="codex-rdf" select="$codex//ore:Aggregation[@rdf:nodeID='codex']"/>
60 <element name="书社:archive">
61 <attribute name="书社:expanded"/>
62 <for-each select="$codex-rdf">
63 <variable name="title-fragment">
64 <if test="@dcterms:title">
65 <element name="meta" namespace="&xhtml;">
66 <attribute name="itemprop">
67 <text>urn:fdc:ladys.computer:20231231:Shu1She4:title</text>
69 <attribute name="content">
70 <value-of select="@dcterms:title"/>
75 <variable name="navigation-fragment">
76 <element name="nav" namespace="&xhtml;">
77 <element name="ul" namespace="&xhtml;">
78 <for-each select="$codex//awol:Category">
79 <variable name="category-id" select="string(@rdf:nodeID)"/>
80 <element name="li" namespace="&xhtml;">
81 <element name="strong" namespace="&xhtml;">
82 <value-of select="@awol:term"/>
84 <element name="ul" namespace="&xhtml;">
85 <for-each select="$codex//ore:Proxy[ore:proxyIn/@rdf:nodeID='codex' and awol:category/@rdf:nodeID=$category-id]">
86 <sort select="@dcterms:title"/>
87 <sort select="skos:notation"/>
88 <element name="li" namespace="&xhtml;">
89 <element name="a" namespace="&xhtml;">
90 <attribute name="href">
92 <value-of select="skos:notation"/>
95 <attribute name="data-identifier">
96 <value-of select="skos:notation"/>
98 <attribute name="data-cksum">
99 <value-of select="@书社:cksum"/>
101 <if test="@dcterms:title">
102 <value-of select="@dcterms:title"/>
105 <element name="small" namespace="&xhtml;">
107 <element name="code" namespace="&xhtml;">
108 <attribute name="lang">
111 <attribute name="xml:lang">
114 <value-of select="skos:notation"/>
127 <element name="div" namespace="&xhtml;">
128 <attribute name="Caudex:page">
131 <attribute name="书社:archived-as">
132 <text>index.xhtml</text>
134 <copy-of select="$title-fragment"/>
135 <element name="main" namespace="&xhtml;">
136 <copy-of select="$navigation-fragment"/>
137 <element name="div" namespace="&xhtml;">
138 <attribute name="id">
139 <text>Caudex.pane</text>
143 <element name="script" namespace="&xhtml;">
144 <attribute name="type">
145 <text>text/javascript</text>
147 <text><![CDATA[#!javascript
151 for(;i<links.length;++i){
153 var identifier=link.getAttribute("data-identifier")
154 var cksum=link.getAttribute("data-cksum")
155 if(!(identifier&&cksum))return
156 link.addEventListener("click",function(event){
157 var pane=document.getElementById("Caudex.pane")
159 if(identifier in cache){
161 pane.appendChild(document.importNode(cache[identifier],true))
163 pane.textContent="Loading…"
164 request=new XMLHttpRequest
165 request.open("GET",link.href)
166 request.addEventListener("load",function(){
168 var article=request.responseXML.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","article").item(0)
169 cache[identifier]=article
171 pane.appendChild(document.importNode(article,true))
172 for(;k<links.length;++k){
174 var parent=linkk.parentNode
175 if(linkk==link)parent.setAttribute("class","selected")
176 else parent.setAttribute("class","")
179 link.setAttribute("class","cached read")
181 localStorage.setItem(identifier,cksum)
184 request.responseType="document"
187 event.preventDefault()
191 var lastReadCksum=localStorage.getItem(identifier)
192 if(lastReadCksum==cksum)link.setAttribute("class","read")
193 else if(lastReadCksum)link.setAttribute("class","updated")
194 else link.setAttribute("class","new")
198 }(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","main")[0].children[0].getElementsByTagNameNS("http://www.w3.org/1999/xhtml","a"))
202 <element name="div" namespace="&xhtml;">
203 <attribute name="Caudex:page">
204 <text>standalone</text>
206 <attribute name="书社:archived-as">
207 <text>standalone.xhtml</text>
209 <copy-of select="$title-fragment"/>
210 <element name="main" namespace="&xhtml;">
211 <copy-of select="$navigation-fragment"/>
212 <element name="div" namespace="&xhtml;">
213 <attribute name="id">
214 <text>Caudex.pane</text>
216 <for-each select="$codex//ore:Proxy">
217 <element name="article" namespace="&xhtml;">
218 <attribute name="id">
219 <value-of select="skos:notation"/>
221 <attribute name="hidden">
224 <apply-templates select="ore:proxyFor/*/awol:content/awol:body/node()" mode="Caudex:codex-entry"/>
229 <element name="script" namespace="&xhtml;">
230 <attribute name="type">
231 <text>text/javascript</text>
233 <text><![CDATA[#!javascript
236 for(;i<links.length;++i){
238 var identifier=link.getAttribute("data-identifier")
239 var cksum=link.getAttribute("data-cksum")
240 if(!(identifier&&cksum))return
241 link.addEventListener("click",function(event){
244 var pane=document.getElementById("Caudex.pane")
245 var articles=pane.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","article")
246 for(;j<articles.length;++j){
248 if(article.getAttribute("id")==identifier){
249 article.removeAttribute("hidden")
250 link.setAttribute("class","cached read")
252 localStorage.setItem(identifier,cksum)
255 else article.setAttribute("hidden","hidden")
258 for(;k<links.length;++k){
260 var parent=linkk.parentNode
261 if(linkk==link)parent.setAttribute("class","selected")
262 else parent.setAttribute("class","")
265 event.preventDefault()
269 var lastReadCksum=localStorage.getItem(identifier)
270 if(lastReadCksum==cksum)link.setAttribute("class","cached read")
271 else if(lastReadCksum)link.setAttribute("class","cached updated")
272 else link.setAttribute("class","cached new")
276 }(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","main")[0].children[0].getElementsByTagNameNS("http://www.w3.org/1999/xhtml","a"))
281 <for-each select="$codex//ore:Proxy">
282 <element name="article" namespace="&xhtml;">
283 <attribute name="Caudex:page">
284 <value-of select="skos:notation"/>
286 <attribute name="书社:archived-as">
287 <value-of select="skos:notation"/>
290 <if test="@dcterms:title">
291 <element name="meta" namespace="&xhtml;">
292 <attribute name="itemprop">
293 <text>urn:fdc:ladys.computer:20231231:Shu1She4:title</text>
295 <attribute name="content">
296 <value-of select="@dcterms:title"/>
300 <apply-templates select="ore:proxyFor/*/awol:content/awol:body/node()" mode="Caudex:codex-entry"/>
305 <template match="html:div[@itemtype='&书社;:document' and @Caudex:page]" mode="书社:metadata" priority="0">
306 <element name="style" namespace="&xhtml;">
307 <text><![CDATA[@charset "UTF-8";
308 @namespace "http://www.w3.org/1999/xhtml";
309 *[hidden]{Display:None}
311 <if test="@Caudex:page='index' or @Caudex:page='standalone'">
312 <text><![CDATA[/*Index styling*/
313 main{Display:Block;Width:100%;Height:100%}
314 main>*{Display:Inline-Block;Box-Sizing:Border-Box;Border:.5EM Transparent None;Height:100%;Width:50%;Vertical-Align:Top;Overflow:Auto}
315 main>nav{Border-Right-Style:Solid;Overflow:Scroll}
316 main>div{Border-Left-Style:Solid}