]> git.draconx.ca Git - homepage.git/blobdiff - layouts/default.xsl
M48T59Y battery replacement
[homepage.git] / layouts / default.xsl
index 837a792e4c7f734b8b8f591a77b87955a8a8519f..768193376d53c73156211540a26460a28e9e9b7a 100644 (file)
@@ -2,7 +2,7 @@
 <!--
   Nick's web site: XHTML output stage
 
-  Copyright © 2018-2021 Nick Bowler
+  Copyright © 2018-2022 Nick Bowler
 
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 </xsl:template>
 
 <!-- For paragraphs containing only kbd elements, wrap in blockquote. -->
-<xsl:template match='xhtml:p[*[last()=count(../xhtml:kbd)]]'>
+<xsl:template match='xhtml:p[*[last()=count(../xhtml:kbd|../xhtml:br)]]'>
   <blockquote>
     <xsl:copy>
       <xsl:apply-templates select='node()|@*' />
   </p>
 </xsl:template>
 
+<!-- Article info block inserted between heading and main contents -->
 <xsl:template match='xhtml:h1[not(preceding::xhtml:h1)]'>
+  <xsl:variable name='nodes'
+    select='/document/article/published|//xhtml:*[@article-info]' />
+
   <xsl:copy><xsl:apply-templates select='node()|@*' /></xsl:copy>
-  <xsl:if test='/document/article/published'>
+
+  <xsl:if test='$nodes'>
     <div id='article-info'>
-      <p>
-        <xsl:text>Posted </xsl:text>
-        <xsl:value-of select='/document/article/published' />
-      </p>
+      <xsl:apply-templates mode='article-info' select='$nodes'>
+        <xsl:sort data-type='number'
+          select='number(generate-id(..)=generate-id(/document/article))' />
+      </xsl:apply-templates>
     </div>
   </xsl:if>
 </xsl:template>
 
+<xsl:template mode='article-info' match='/document/article/published'>
+  <p>
+    <xsl:text>Posted </xsl:text>
+    <xsl:value-of select='/document/article/published' />
+    <xsl:if test='/document/article/updated'>
+      <xsl:text>, last updated </xsl:text>
+      <xsl:value-of select='/document/article/updated' />
+    </xsl:if>
+  </p>
+</xsl:template>
+
+<xsl:template match='*[@article-info]' />
+<xsl:template mode='article-info' match='*[@article-info]'>
+  <xsl:copy>
+    <xsl:apply-templates select='@*[local-name() != "article-info"]' />
+    <xsl:apply-templates select='node()' />
+  </xsl:copy>
+</xsl:template>
+
 <xsl:template name='imgpara' match='xhtml:p[count(*)=1]
                                            [normalize-space(text())=""]
                                            [descendant::xhtml:img]'>
   <xsl:variable name='images' select='key("gallery", generate-id(.))' />
   <xsl:choose>
     <xsl:when test='count($images) > 1'>
-      <div class='gallery'>
+      <div>
+        <xsl:attribute name='class'>
+          <xsl:text>gallery</xsl:text>
+          <xsl:if test='//xhtml:a[f:contains-token(@class, "left")
+                                  or f:contains-token(@class, "right")]'>
+            <xsl:text> inline</xsl:text>
+          </xsl:if>
+        </xsl:attribute>
         <xsl:for-each select='$images'>
           <xsl:call-template name='imgpara' />
         </xsl:for-each>
     <head>
       <meta name='viewport' content='width=device-width, initial-scale=1' />
       <link rel='stylesheet' type='text/css' href='/style.css' />
+      <link rel='alternate stylesheet' type='text/css' href='/dark.css'
+        title='Dark Style' />
       <link rel="icon" href="data:," />
       <title>
         <xsl:variable name='page-title' select='string(/document/title)' />