-<?xml version="1.0"?>
-<!--
-SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
-SPDX-License-Identifier: MPL-2.0
--->
-<!--
-⁌ 📰 Caudex ∷ transforms/index.xslt
-
-© 2024 Lady [@ Ladys Computer]
-
-This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
-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/>.
--->
-<!DOCTYPE transform [
- <!ENTITY Caudex "urn:fdc:ladys.computer:20240204:Caudex:">
- <!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML:">
- <!ENTITY 书社 "urn:fdc:ladys.computer:20231231:Shu1She4:">
-]>
-<transform
- xmlns="http://www.w3.org/1999/XSL/Transform"
- xmlns:Caudex="urn:fdc:ladys.computer:20240204:Caudex"
- xmlns:exsl="http://exslt.org/common"
- xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
- exclude-result-prefixes="exsl"
- version="1.0"
->
- <书社:id>&Caudex;index.xslt</书社:id>
- <template match="/html:div[@书社:parsed-by='&Caudex;catalog.xslt'][@class='index' or @class='fullindex']">
- <html:body>
- <for-each select="@*[namespace-uri()!='urn:fdc:ladys.computer:20231231:Shu1She4']">
- <copy/>
- </for-each>
- <variable name="metadata" select="html:div[@书社:parsed-by='&书社;record-jar.xslt']"/>
- <html:meta itemprop="&书社;title" content="{$metadata//html:dt[string()='TITLE']/following-sibling::html:dd}"/>
- <html:main>
- <html:nav>
- <html:ul>
- <for-each select=".//html:div[@书社:parsed-by='&Caudex;catalog.xslt'][@class='category']">
- <variable name="category-metadata" select="html:div[@id='@']/html:div[@书社:parsed-by='&书社;record-jar.xslt']"/>
- <html:li>
- <html:strong>
- <choose>
- <when test="$category-metadata//html:dt[string()='TITLE']">
- <value-of select="$category-metadata//html:dt[string()='TITLE']/following-sibling::html:dd"/>
- </when>
- <otherwise>
- <value-of select="../@id"/>
- </otherwise>
- </choose>
- </html:strong>
- <html:ul>
- <for-each select="html:div[@id!='@']/html:article[@书社:parsed-by='&LesML;parser.xslt']">
- <sort select="html:footer[@class='head']/html:dl[1]//html:dt[string()='TITLE']/following-sibling::html:dd"/>
- <sort select="../@id"/>
- <variable name="entry-metadata" select="html:footer[@class='head']/html:dl[1]"/>
- <html:li>
- <html:a href="{../@id}.xhtml" data-identifier="{../@id}" data-cksum="{@书社:cksum}">
- <value-of select="$entry-metadata//html:dt[string()='TITLE']/following-sibling::html:dd"/>
- <text> </text>
- <html:small>
- <text>(</text>
- <value-of select="../@id"/>
- <text>)</text>
- </html:small>
- </html:a>
- </html:li>
- </for-each>
- </html:ul>
- </html:li>
- </for-each>
- </html:ul>
- </html:nav>
- <html:div id="pane">
- <if test="@class='fullindex'">
- <for-each select=".//html:div[@书社:parsed-by='&Caudex;catalog.xslt'][@class='category']/html:div[@id!='@']/html:article[@书社:parsed-by='&LesML;parser.xslt']">
- <variable name="context" select="."/>
- <variable name="entry">
- <html:div 书社:parsed-by="&Caudex;catalog.xslt" class="entry">
- <html:div id="@">
- <copy-of select="."/>
- </html:div>
- </html:div>
- </variable>
- <variable name="transformed-entry">
- <apply-templates select="exsl:node-set($entry)/*"/>
- </variable>
- <for-each select="exsl:node-set($transformed-entry)//html:article">
- <html:article id="{$context/../@id}" hidden="hidden">
- <copy-of select="@*|node()"/>
- </html:article>
- </for-each>
- </for-each>
- </if>
- </html:div>
- </html:main>
- <html:script type="text/javascript">
- <choose>
- <when test="@class='fullindex'">
- <text><![CDATA[#!javascript
-~function(links){
- var i=0
- for(;i<links.length;++i){
- ~function(link){
- var identifier=link.getAttribute("data-identifier")
- var cksum=link.getAttribute("data-cksum")
- if(!(identifier&&cksum))return
- link.addEventListener("click",function(event){
- var j=0
- var k=0
- var pane=document.getElementById("pane")
- var articles=pane.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","article")
- for(;j<articles.length;++j){
- ~function(article){
- if(article.getAttribute("id")==identifier){
- article.removeAttribute("hidden")
- link.setAttribute("class","cached read")
- try{
- localStorage.setItem(identifier,cksum)
- }catch(e){}
- }
- else article.setAttribute("hidden","hidden")
- }(articles.item(j))
- }
- for(;k<links.length;++k){
- ~function(linkk){
- var parent=linkk.parentNode
- if(linkk==link)parent.setAttribute("class","selected")
- else parent.setAttribute("class","")
- }(links.item(k))
- }
- event.preventDefault()
- pane.focus()
- },false)
- try{
- var lastReadCksum=localStorage.getItem(identifier)
- if(lastReadCksum==cksum)link.setAttribute("class","cached read")
- else if(lastReadCksum)link.setAttribute("class","cached updated")
- else link.setAttribute("class","cached new")
- }catch(e){}
- }(links.item(i))
- }
-}(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","a"))
-]]></text>
- </when>
- <otherwise>
- <text><![CDATA[#!javascript
-~function(links){
- var i=0
- var cache={}
- for(;i<links.length;++i){
- ~function(link){
- var identifier=link.getAttribute("data-identifier")
- var cksum=link.getAttribute("data-cksum")
- if(!(identifier&&cksum))return
- link.addEventListener("click",function(event){
- var pane=document.getElementById("pane")
- var request
- if(identifier in cache){
- pane.textContent=""
- pane.appendChild(document.importNode(cache[identifier],true))
- }else{
- pane.textContent="Loading…"
- request=new XMLHttpRequest
- request.open("GET",link.href)
- request.addEventListener("load",function(){
- var k=0
- var article=request.responseXML.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","article").item(0)
- cache[identifier]=article
- pane.textContent=""
- pane.appendChild(document.importNode(article,true))
- for(;k<links.length;++k){
- ~function(linkk){
- var parent=linkk.parentNode
- if(linkk==link)parent.setAttribute("class","selected")
- else parent.setAttribute("class","")
- }(links.item(k))
- }
- link.setAttribute("class","cached read")
- try{
- localStorage.setItem(identifier,cksum)
- }catch(e){}
- },false)
- request.responseType="document"
- request.send()
- }
- event.preventDefault()
- pane.focus()
- },false)
- try{
- var lastReadCksum=localStorage.getItem(identifier)
- if(lastReadCksum==cksum)link.setAttribute("class","read")
- else if(lastReadCksum)link.setAttribute("class","updated")
- else link.setAttribute("class","new")
- }catch(e){}
- }(links[i])
- }
-}(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","a"))
-]]></text>
- </otherwise>
- </choose>
- </html:script>
- </html:body>
- </template>
-</transform>