3 SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
7 ⁌ 📰 Caudex ∷ transforms/index.xslt
9 © 2024 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 Caudex "urn:fdc:ladys.computer:20240204:Caudex:">
16 <!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML:">
17 <!ENTITY 书社 "urn:fdc:ladys.computer:20231231:Shu1She4:">
20 xmlns="http://www.w3.org/1999/XSL/Transform"
21 xmlns:Caudex="urn:fdc:ladys.computer:20240204:Caudex"
22 xmlns:exsl="http://exslt.org/common"
23 xmlns:html="http://www.w3.org/1999/xhtml"
24 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
25 exclude-result-prefixes="exsl"
28 <书社:id>&Caudex;index.xslt</书社:id>
29 <template match="/html:div[@书社:parsed-by='&Caudex;catalog.xslt'][@class='index' or @class='fullindex']">
31 <for-each select="@*[namespace-uri()!='urn:fdc:ladys.computer:20231231:Shu1She4']">
34 <variable name="metadata" select="html:div[@书社:parsed-by='&书社;record-jar.xslt']"/>
35 <html:meta itemprop="&书社;title" content="{$metadata//html:dt[string()='TITLE']/following-sibling::html:dd}"/>
39 <for-each select=".//html:div[@书社:parsed-by='&Caudex;catalog.xslt'][@class='category']">
40 <variable name="category-metadata" select="html:div[@id='@']/html:div[@书社:parsed-by='&书社;record-jar.xslt']"/>
44 <when test="$category-metadata//html:dt[string()='TITLE']">
45 <value-of select="$category-metadata//html:dt[string()='TITLE']/following-sibling::html:dd"/>
48 <value-of select="../@id"/>
53 <for-each select="html:div[@id!='@']/html:article[@书社:parsed-by='&LesML;parser.xslt']">
54 <sort select="html:footer[@class='head']/html:dl[1]//html:dt[string()='TITLE']/following-sibling::html:dd"/>
55 <sort select="../@id"/>
56 <variable name="entry-metadata" select="html:footer[@class='head']/html:dl[1]"/>
58 <html:a href="{../@id}.xhtml" data-identifier="{../@id}" data-cksum="{@书社:cksum}">
59 <value-of select="$entry-metadata//html:dt[string()='TITLE']/following-sibling::html:dd"/>
63 <value-of select="../@id"/>
75 <if test="@class='fullindex'">
76 <for-each select=".//html:div[@书社:parsed-by='&Caudex;catalog.xslt'][@class='category']/html:div[@id!='@']/html:article[@书社:parsed-by='&LesML;parser.xslt']">
77 <variable name="context" select="."/>
78 <variable name="entry">
79 <html:div 书社:parsed-by="&Caudex;catalog.xslt" class="entry">
85 <variable name="transformed-entry">
86 <apply-templates select="exsl:node-set($entry)/*"/>
88 <for-each select="exsl:node-set($transformed-entry)//html:article">
89 <html:article id="{$context/../@id}" hidden="hidden">
90 <copy-of select="@*|node()"/>
97 <html:script type="text/javascript">
99 <when test="@class='fullindex'">
100 <text><![CDATA[#!javascript
103 for(;i<links.length;++i){
105 var identifier=link.getAttribute("data-identifier")
106 var cksum=link.getAttribute("data-cksum")
107 if(!(identifier&&cksum))return
108 link.addEventListener("click",function(event){
111 var pane=document.getElementById("pane")
112 var articles=pane.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","article")
113 for(;j<articles.length;++j){
115 if(article.getAttribute("id")==identifier){
116 article.removeAttribute("hidden")
117 link.setAttribute("class","cached read")
119 localStorage.setItem(identifier,cksum)
122 else article.setAttribute("hidden","hidden")
125 for(;k<links.length;++k){
127 var parent=linkk.parentNode
128 if(linkk==link)parent.setAttribute("class","selected")
129 else parent.setAttribute("class","")
132 event.preventDefault()
136 var lastReadCksum=localStorage.getItem(identifier)
137 if(lastReadCksum==cksum)link.setAttribute("class","cached read")
138 else if(lastReadCksum)link.setAttribute("class","cached updated")
139 else link.setAttribute("class","cached new")
143 }(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","a"))
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("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","a"))