3 ⁌ 📰 Caudex ∷ transforms/entry.xslt
5 © 2024 Lady [@ Lady’s Computer]
7 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
8 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/>.
11 <!ENTITY Caudex "urn:fdc:ladys.computer:20240204:Caudex:">
12 <!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML:">
13 <!ENTITY 书社 "urn:fdc:ladys.computer:20231231:Shu1She4:">
16 xmlns="http://www.w3.org/1999/XSL/Transform"
17 xmlns:Caudex="urn:fdc:ladys.computer:20240204:Caudex"
18 xmlns:exsl="http://exslt.org/common"
19 xmlns:html="http://www.w3.org/1999/xhtml"
20 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
21 exclude-result-prefixes="exsl"
24 <书社:id>&Caudex;index.xslt</书社:id>
25 <template match="/html:div[@书社:parsed-by='&Caudex;catalog.xslt'][@class='index' or @class='fullindex']">
27 <for-each select="@*[namespace-uri()!='urn:fdc:ladys.computer:20231231:Shu1She4']">
30 <variable name="metadata" select="html:div[@书社:parsed-by='&书社;record-jar.xslt']"/>
31 <html:meta itemprop="&书社;title" content="{$metadata//html:dt[string()='TITLE']/following-sibling::html:dd}"/>
35 <for-each select=".//html:div[@书社:parsed-by='&Caudex;catalog.xslt'][@class='category']">
36 <variable name="category-metadata" select="html:div[@id='@']/html:div[@书社:parsed-by='&书社;record-jar.xslt']"/>
40 <when test="$category-metadata//html:dt[string()='TITLE']">
41 <value-of select="$category-metadata//html:dt[string()='TITLE']/following-sibling::html:dd"/>
44 <value-of select="../@id"/>
49 <for-each select="html:div[@id!='@']/html:article[@书社:parsed-by='&LesML;parser.xslt']">
50 <sort select="html:footer[@class='head']/html:dl[1]//html:dt[string()='TITLE']/following-sibling::html:dd"/>
51 <sort select="../@id"/>
52 <variable name="entry-metadata" select="html:footer[@class='head']/html:dl[1]"/>
54 <html:a href="{../@id}.xhtml" data-identifier="{../@id}" data-cksum="{@书社:cksum}">
55 <value-of select="$entry-metadata//html:dt[string()='TITLE']/following-sibling::html:dd"/>
59 <value-of select="../@id"/>
71 <if test="@class='fullindex'">
72 <for-each select=".//html:div[@书社:parsed-by='&Caudex;catalog.xslt'][@class='category']/html:div[@id!='@']/html:article[@书社:parsed-by='&LesML;parser.xslt']">
73 <variable name="context" select="."/>
74 <variable name="entry">
75 <html:div 书社:parsed-by="&Caudex;catalog.xslt" class="entry">
81 <variable name="transformed-entry">
82 <apply-templates select="exsl:node-set($entry)/*"/>
84 <for-each select="exsl:node-set($transformed-entry)//html:article">
85 <html:article id="{$context/../@id}" hidden="hidden">
86 <copy-of select="@*|node()"/>
93 <html:script type="text/javascript">
95 <when test="@class='fullindex'">
96 <text><![CDATA[#!javascript
99 for(;i<links.length;++i){
101 var identifier=link.getAttribute("data-identifier")
102 var cksum=link.getAttribute("data-cksum")
103 if(!(identifier&&cksum))return
104 link.addEventListener("click",function(event){
107 var pane=document.getElementById("pane")
108 var articles=pane.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","article")
109 for(;j<articles.length;++j){
111 if(article.getAttribute("id")==identifier){
112 article.removeAttribute("hidden")
113 link.setAttribute("class","cached read")
115 localStorage.setItem(identifier,cksum)
118 else article.setAttribute("hidden","hidden")
121 for(;k<links.length;++k){
123 var parent=linkk.parentNode
124 if(linkk==link)parent.setAttribute("class","selected")
125 else parent.setAttribute("class","")
128 event.preventDefault()
132 var lastReadCksum=localStorage.getItem(identifier)
133 if(lastReadCksum==cksum)link.setAttribute("class","cached read")
134 else if(lastReadCksum)link.setAttribute("class","cached updated")
135 else link.setAttribute("class","cached new")
139 }(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","a"))
143 <text><![CDATA[#!javascript
147 for(;i<links.length;++i){
149 var identifier=link.getAttribute("data-identifier")
150 var cksum=link.getAttribute("data-cksum")
151 if(!(identifier&&cksum))return
152 link.addEventListener("click",function(event){
153 var pane=document.getElementById("pane")
155 if(identifier in cache){
157 pane.appendChild(document.importNode(cache[identifier],true))
159 pane.textContent="Loading…"
160 request=new XMLHttpRequest
161 request.open("GET",link.href)
162 request.addEventListener("load",function(){
164 var article=request.responseXML.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","article").item(0)
165 cache[identifier]=article
167 pane.appendChild(document.importNode(article,true))
168 for(;k<links.length;++k){
170 var parent=linkk.parentNode
171 if(linkk==link)parent.setAttribute("class","selected")
172 else parent.setAttribute("class","")
175 link.setAttribute("class","cached read")
177 localStorage.setItem(identifier,cksum)
180 request.responseType="document"
183 event.preventDefault()
187 var lastReadCksum=localStorage.getItem(identifier)
188 if(lastReadCksum==cksum)link.setAttribute("class","read")
189 else if(lastReadCksum)link.setAttribute("class","updated")
190 else link.setAttribute("class","new")
194 }(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","a"))