]> git.draconx.ca Git - homepage.git/blobdiff - layouts/default.xsl
M48T59Y battery replacement
[homepage.git] / layouts / default.xsl
index d5be1039e5061cf8c8dc2eff408eeb306c35de0a..768193376d53c73156211540a26460a28e9e9b7a 100644 (file)
 </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>