]> git.draconx.ca Git - homepage.git/blobdiff - layouts/default.xsl
Solar Eclipse in Ottawa on 2021-06-10.
[homepage.git] / layouts / default.xsl
index a97f784c2d3e2cb63a4446e4b6eaadf0ed2f7f21..2e14ce8e29fa93cb737624d069474c95548040db 100644 (file)
@@ -22,8 +22,9 @@
   xmlns:xhtml='http://www.w3.org/1999/xhtml'
   xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
   xmlns:func='http://exslt.org/functions'
+  xmlns:exslt='http://exslt.org/common'
   xmlns:f='http://draconx.ca/my-functions'
-  extension-element-prefixes='func f'
+  extension-element-prefixes='exslt func f'
   exclude-result-prefixes='xhtml'>
 
 <xsl:import href='layouts/functions.xsl' />
   <xsl:copy><xsl:apply-templates select='node()|@*' /></xsl:copy>
 </xsl:template>
 
+<xsl:template name='notransform' mode='notransform' match='node()|@*'>
+  <xsl:copy>
+    <xsl:apply-templates mode='notransform' select='node()|@*' />
+  </xsl:copy>
+</xsl:template>
+
 <!--
   Nokogiri's pretty-printer is a bit weird.  Regardless of the indentation
   setting, if an element has no child text nodes then it will be pretty-
 </xsl:template>
 
 <xsl:template match='license'>
+  <xsl:variable name='node' select='.' />
   <p>
-    <xsl:text>Copying and distribution of this material</xsl:text>
+    <xsl:choose>
+      <xsl:when test='/document/image[license != $node]'>
+        <xsl:text>Except as otherwise noted, copying</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>Copying</xsl:otherwise>
+    </xsl:choose>
+    <xsl:text> and distribution of this material</xsl:text>
     <xsl:if test='normalize-space(modification-allowed)="yes"'>
       <xsl:text>, with or without modification,</xsl:text>
     </xsl:if>
 </xsl:template>
 
 <xsl:template name='image-attribution'>
-<!--
-  <xsl:variable name='x' select='/document/image[copyright-holder="Nick Bowler"][1]' />
-  <xsl:variable name='y' select='/document/image[copyright-holder="Nick Bowler"][4]' />
--->
   <xsl:variable name='images-fragment'>
     <xsl:for-each select='/document/image'>
       <xsl:sort select='number(copyright-holder = /document/copyright-holder)'
   </xsl:if>
 </xsl:template>
 
+<xsl:template match='xhtml:p[count(*)=1 and normalize-space(text())=""
+                             and descendant::xhtml:img]'>
+  <xsl:copy>
+    <xsl:apply-templates select='@*[local-name() != "class"]' />
+    <xsl:attribute name='class'>
+      <xsl:if test='@class'>
+        <xsl:value-of select='concat(@class, " ")' />
+      </xsl:if>
+      <xsl:text>img</xsl:text>
+    </xsl:attribute>
+    <xsl:apply-templates select='node()' />
+  </xsl:copy>
+</xsl:template>
+
 <xsl:template match='/'>
   <html>
     <head>
       <div id='footer'>
         <xsl:apply-templates select='/document/copyright' />
         <xsl:apply-templates select='/document/license' />
+        <xsl:if test='/document/image'>
+          <xsl:call-template name='image-attribution' />
+        </xsl:if>
         <xsl:apply-templates select='/document/source' />
       </div>
     </body>