]> git.draconx.ca Git - homepage.git/blobdiff - layouts/default.xsl
Use a denser style for gallery images.
[homepage.git] / layouts / default.xsl
index 2e14ce8e29fa93cb737624d069474c95548040db..7325708557a89089d76469a80a5fb11b9f78f610 100644 (file)
   </xsl:if>
 </xsl:template>
 
-<xsl:template match='xhtml:p[count(*)=1 and normalize-space(text())=""
-                             and descendant::xhtml:img]'>
+<xsl:template name='imgpara' match='xhtml:p[count(*)=1]
+                                           [normalize-space(text())=""]
+                                           [descendant::xhtml:img]'>
   <xsl:copy>
     <xsl:apply-templates select='@*[local-name() != "class"]' />
     <xsl:attribute name='class'>
   </xsl:copy>
 </xsl:template>
 
+<xsl:key name='gallery'
+  match='xhtml:html/xhtml:p[descendant::*[@generate-gallery]]'
+  use='generate-id(
+        ( ( preceding-sibling::*[not(descendant::*[@generate-gallery])][1]
+          /following-sibling::* ) | self::* ) [1])' />
+
+<xsl:template match='@generate-gallery' />
+<xsl:template match='xhtml:html/xhtml:p[descendant::*[@generate-gallery]]' />
+<xsl:template match='xhtml:html/xhtml:p[key("gallery", generate-id(.))]'>
+  <xsl:variable name='images' select='key("gallery", generate-id(.))' />
+  <xsl:choose>
+    <xsl:when test='count($images) > 1'>
+      <div class='gallery'>
+        <xsl:for-each select='$images'>
+          <xsl:call-template name='imgpara' />
+        </xsl:for-each>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name='imgpara' />
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 <xsl:template match='/'>
   <html>
     <head>