[gnome-doc-utils/mallard: 45/87] Adding optional two-column layout for page links



commit a7a655c2716c4b3165f529272ff8e133e3951124
Author: Shaun McCance <shaunm gnome org>
Date:   Fri Nov 14 12:34:53 2008 -0600

    Adding optional two-column layout for page links
---
 doc/mallard/C/mal_inline.xml        |    2 +-
 xslt/mallard/html/mal2html-css.xsl  |   14 ++++
 xslt/mallard/html/mal2html-page.xsl |  133 +++++++++++++++++++++++++++--------
 3 files changed, 119 insertions(+), 30 deletions(-)

diff --git a/doc/mallard/C/mal_inline.xml b/doc/mallard/C/mal_inline.xml
index 7d05c22..fbd380f 100644
--- a/doc/mallard/C/mal_inline.xml
+++ b/doc/mallard/C/mal_inline.xml
@@ -38,7 +38,7 @@ mal_inline = mixed {
   <p>Add some intro text and general processing expectations</p>
 </comment>
 
-<section id="elements">
+<section id="elements" style="2column">
   <info>
     <title type="link">Inline Elements</title>
   </info>
diff --git a/xslt/mallard/html/mal2html-css.xsl b/xslt/mallard/html/mal2html-css.xsl
index 79efa89..bf99d5d 100644
--- a/xslt/mallard/html/mal2html-css.xsl
+++ b/xslt/mallard/html/mal2html-css.xsl
@@ -178,6 +178,7 @@ div.header {
   </xsl:call-template>
   <xsl:text>;
 }
+table { border-collapse: collapse; }
 div.section div.section div.header { border: none; }
 h1, h2, h3, h4, h5, h6, h7 { margin: 0; }
 h1.title { font-size: 1.44em; }
@@ -188,6 +189,19 @@ h5.title { font-size: 1em; }
 h6.title { font-size: 1em; }
 h7.title { font-size: 1em; }
 
+td.twocolumnleft {
+  width: 48%;
+  vertical-align: top;
+  padding: 0;
+  margin: 0;
+}
+td.twocolumnright {
+  width: 52%;
+  vertical-align: top;
+  padding: 0 0 0 1em;
+  margin: 0;
+}
+
 div.pagelink div.title {
   font-size: 1em;
   color: inherit;
diff --git a/xslt/mallard/html/mal2html-page.xsl b/xslt/mallard/html/mal2html-page.xsl
index a8f7033..776d0c5 100644
--- a/xslt/mallard/html/mal2html-page.xsl
+++ b/xslt/mallard/html/mal2html-page.xsl
@@ -75,35 +75,110 @@ REMARK: Describe this template
                 select="$cache//*[mal:info/mal:link[ type = 'guide'][ xref = $id]][not(@id = $pagelinks/@xref)]"/>
   <xsl:if test="$pagelinks or $guidelinks">
     <div class="pagelinks">
-      <xsl:for-each select="$pagelinks">
-        <xsl:variable name="linkid">
-          <xsl:choose>
-            <xsl:when test="contains(@xref, '#')">
-              <xsl:value-of select="@xref"/>
-            </xsl:when>
-            <xsl:otherwise>
-              <xsl:value-of select="concat(@xref, '#', @xref)"/>
-            </xsl:otherwise>
-          </xsl:choose>
-        </xsl:variable>
-        <xsl:for-each select="$cache">
-          <xsl:call-template name="mal2html.page.pagelink">
-            <xsl:with-param name="node" select="$node"/>
-            <xsl:with-param name="page" select="key('cache_key', $linkid)"/>
-          </xsl:call-template>
-        </xsl:for-each>
-      </xsl:for-each>
-      <xsl:for-each select="$guidelinks">
-        <xsl:sort select="mal:info/mal:link[ type = 'guide'][ xref = $id]/@weight"
-                  data-type="number" order="descending"/>
-        <!-- FIXME: lang -->
-        <xsl:sort select="mal:info/mal:title[ type = 'sort']"
-                  data-type="text" order="ascending"/>
-        <xsl:call-template name="mal2html.page.pagelink">
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="page" select="."/>
-        </xsl:call-template>
-      </xsl:for-each>
+      <xsl:choose>
+        <xsl:when test="contains(concat(' ', $node/@style, ' '), ' 2column ')">
+          <xsl:variable name="coltot" select="ceiling(count($pagelinks | $guidelinks) div 2)"/>
+          <table class="twocolumn"><tr>
+            <td class="twocolumnleft">
+              <xsl:for-each select="$pagelinks[position() &lt;= $coltot]">
+                <xsl:variable name="linkid">
+                  <xsl:choose>
+                    <xsl:when test="contains(@xref, '#')">
+                      <xsl:value-of select="@xref"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                      <xsl:value-of select="concat(@xref, '#', @xref)"/>
+                    </xsl:otherwise>
+                  </xsl:choose>
+                </xsl:variable>
+                <xsl:for-each select="$cache">
+                  <xsl:call-template name="mal2html.page.pagelink">
+                    <xsl:with-param name="node" select="$node"/>
+                    <xsl:with-param name="page" select="key('cache_key', $linkid)"/>
+                  </xsl:call-template>
+                </xsl:for-each>
+              </xsl:for-each>
+              <xsl:for-each select="$guidelinks">
+                <xsl:sort select="mal:info/mal:link[ type = 'guide'][ xref = $id]/@weight"
+                          data-type="number" order="descending"/>
+                <!-- FIXME: lang -->
+                <xsl:sort select="mal:info/mal:title[ type = 'sort']"
+                          data-type="text" order="ascending"/>
+                <xsl:if test="(position() + count($pagelinks)) &lt;= $coltot">
+                  <xsl:call-template name="mal2html.page.pagelink">
+                    <xsl:with-param name="node" select="$node"/>
+                    <xsl:with-param name="page" select="."/>
+                  </xsl:call-template>
+                </xsl:if>
+              </xsl:for-each>
+            </td>
+            <td class="twocolumnright">
+              <xsl:for-each select="$pagelinks[position() &gt; $coltot]">
+                <xsl:variable name="linkid">
+                  <xsl:choose>
+                    <xsl:when test="contains(@xref, '#')">
+                      <xsl:value-of select="@xref"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                      <xsl:value-of select="concat(@xref, '#', @xref)"/>
+                    </xsl:otherwise>
+                  </xsl:choose>
+                </xsl:variable>
+                <xsl:for-each select="$cache">
+                  <xsl:call-template name="mal2html.page.pagelink">
+                    <xsl:with-param name="node" select="$node"/>
+                    <xsl:with-param name="page" select="key('cache_key', $linkid)"/>
+                  </xsl:call-template>
+                </xsl:for-each>
+              </xsl:for-each>
+              <xsl:for-each select="$guidelinks">
+                <xsl:sort select="mal:info/mal:link[ type = 'guide'][ xref = $id]/@weight"
+                          data-type="number" order="descending"/>
+                <!-- FIXME: lang -->
+                <xsl:sort select="mal:info/mal:title[ type = 'sort']"
+                          data-type="text" order="ascending"/>
+                <xsl:if test="(position() + count($pagelinks)) &gt; $coltot">
+                  <xsl:call-template name="mal2html.page.pagelink">
+                    <xsl:with-param name="node" select="$node"/>
+                    <xsl:with-param name="page" select="."/>
+                  </xsl:call-template>
+                </xsl:if>
+              </xsl:for-each>
+            </td>
+          </tr></table>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:for-each select="$pagelinks">
+            <xsl:variable name="linkid">
+              <xsl:choose>
+                <xsl:when test="contains(@xref, '#')">
+                  <xsl:value-of select="@xref"/>
+                </xsl:when>
+                <xsl:otherwise>
+                  <xsl:value-of select="concat(@xref, '#', @xref)"/>
+                </xsl:otherwise>
+              </xsl:choose>
+            </xsl:variable>
+            <xsl:for-each select="$cache">
+              <xsl:call-template name="mal2html.page.pagelink">
+                <xsl:with-param name="node" select="$node"/>
+                <xsl:with-param name="page" select="key('cache_key', $linkid)"/>
+              </xsl:call-template>
+            </xsl:for-each>
+          </xsl:for-each>
+          <xsl:for-each select="$guidelinks">
+            <xsl:sort select="mal:info/mal:link[ type = 'guide'][ xref = $id]/@weight"
+                      data-type="number" order="descending"/>
+            <!-- FIXME: lang -->
+            <xsl:sort select="mal:info/mal:title[ type = 'sort']"
+                      data-type="text" order="ascending"/>
+            <xsl:call-template name="mal2html.page.pagelink">
+              <xsl:with-param name="node" select="$node"/>
+              <xsl:with-param name="page" select="."/>
+            </xsl:call-template>
+          </xsl:for-each>
+        </xsl:otherwise>
+      </xsl:choose>
     </div>
   </xsl:if>
 </xsl:template>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]