[yelp-xsl] Added title attribute to HTML output for all links



commit 9a94436a1f73f8a64de08bfe8402787ada7235cc
Author: Shaun McCance <shaunm gnome org>
Date:   Sat May 14 17:47:06 2011 -0400

    Added title attribute to HTML output for all links

 xslt/mallard/common/mal-link.xsl    |   89 +++++++++++++++++++++-------------
 xslt/mallard/html/mal2html-page.xsl |   46 ++++++++++++++++--
 2 files changed, 95 insertions(+), 40 deletions(-)
---
diff --git a/xslt/mallard/common/mal-link.xsl b/xslt/mallard/common/mal-link.xsl
index 2f3f67e..1e7eb25 100644
--- a/xslt/mallard/common/mal-link.xsl
+++ b/xslt/mallard/common/mal-link.xsl
@@ -232,6 +232,61 @@ By default, it returns the string value of its input.  Stylesheets that use
 
 
 <!--**==========================================================================
+mal.link.tooltip
+Output a tooltip for a #{link} element.
+:Revision:version="1.0" date="2011-05-14" status="final"
+$node: The #{link} or other element creating the link.
+$xref: The #{xref} attribute of ${node}.
+$href: The #{href} attribute of ${node}.
+
+This template outputs a text-only tooltip for a link. If ${xref} points to a
+valid page or section, the text title from that page or section will be used.
+If the target does not specify a text title, the primary title is ued.
+
+If only ${href} is provided, that URL is used as the tooltip. If a target
+page or section cannot be found, ${xref} is used as the text content. Special
+tooltips may be provided for certain URI schemes.
+-->
+<xsl:template name="mal.link.tooltip">
+  <xsl:param name="node" select="."/>
+  <xsl:param name="xref" select="$node/@xref"/>
+  <xsl:param name="href" select="$node/@href"/>
+  <xsl:param name="role" select="''"/>
+  <xsl:variable name="linkid">
+    <xsl:call-template name="mal.link.xref.linkid">
+      <xsl:with-param name="node" select="$node"/>
+      <xsl:with-param name="xref" select="$xref"/>
+    </xsl:call-template>
+  </xsl:variable>
+  <xsl:for-each select="$mal.cache">
+    <xsl:variable name="target" select="key('mal.cache.key', $linkid)"/>
+    <xsl:choose>
+      <xsl:when test="$target/mal:info/mal:title[ type = 'text']">
+        <xsl:value-of select="normalize-space($target/mal:info/mal:title[ type = 'text'][1])"/>
+      </xsl:when>
+      <xsl:when test="$target/mal:title">
+        <xsl:value-of select="normalize-space($target/mal:title[1])"/>
+      </xsl:when>
+      <xsl:when test="starts-with($href, 'mailto:')">
+        <xsl:variable name="address" select="substring-after($href, 'mailto:')"/>
+        <xsl:call-template name="l10n.gettext">
+          <xsl:with-param name="msgid" select="'email.tooltip'"/>
+          <xsl:with-param name="string" select="$address"/>
+          <xsl:with-param name="format" select="true()"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:when test="$href">
+        <xsl:value-of select="$href"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$xref"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:for-each>
+</xsl:template>
+
+
+<!--**==========================================================================
 mal.link.target
 Output the target URL for a #{link} or other linking element.
 :Revision:version="1.0" date="2010-01-02" status="final"
@@ -276,40 +331,6 @@ Otherwise, the link will point to ${href}.
 
 
 <!--**==========================================================================
-mal.link.tooltip
-Output the tooltip for a #{link} or other linking element.
-:Revision:version="1.0" date="2010-01-02" status="final"
-$node: The #{link} or other element creating the link.
-$xref: The #{xref} attribute of ${node}.
-$href: The #{href} attribute of ${node}.
-
-This template outputs a tooltip for a link.  Currently, it only outputs a
-tooltip for #{mailto:} URLs in ${href}.
--->
-<xsl:template name="mal.link.tooltip">
-  <xsl:param name="node" select="."/>
-  <xsl:param name="xref" select="$node/@xref"/>
-  <xsl:param name="href" select="$node/@href"/>
-  <xsl:choose>
-    <xsl:when test="string($xref) != ''">
-      <!-- FIXME and make sure to update the docs -->
-    </xsl:when>
-    <xsl:when test="starts-with($href, 'mailto:')">
-      <xsl:variable name="address" select="substring-after($href, 'mailto:')"/>
-      <xsl:call-template name="l10n.gettext">
-        <xsl:with-param name="msgid" select="'email.tooltip'"/>
-        <xsl:with-param name="string" select="$address"/>
-        <xsl:with-param name="format" select="true()"/>
-      </xsl:call-template>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:value-of select="normalize-space($href)"/>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-
-<!--**==========================================================================
 mal.link.guidelinks
 Output the guide links for a page or section.
 :Revision:version="1.0" date="2010-03-19" status="final"
diff --git a/xslt/mallard/html/mal2html-page.xsl b/xslt/mallard/html/mal2html-page.xsl
index 42b465a..69bb614 100644
--- a/xslt/mallard/html/mal2html-page.xsl
+++ b/xslt/mallard/html/mal2html-page.xsl
@@ -92,6 +92,12 @@ REMARK: Describe this template
         <xsl:with-param name="xref" select="$target/@id"/>
       </xsl:call-template>
     </xsl:attribute>
+    <xsl:attribute name="title">
+      <xsl:call-template name="mal.link.tooltip">
+        <xsl:with-param name="node" select="$source"/>
+        <xsl:with-param name="xref" select="$target/@id"/>
+      </xsl:call-template>
+    </xsl:attribute>
     <xsl:copy-of select="exsl:node-set($attrs)/*/@*"/>
     <div class="linkdiv">
       <div class="title">
@@ -146,6 +152,11 @@ REMARK: Describe this template
             <xsl:with-param name="xref" select="$xref"/>
           </xsl:call-template>
         </xsl:attribute>
+        <xsl:attribute name="title">
+          <xsl:call-template name="mal.link.tooltip">
+            <xsl:with-param name="xref" select="$xref"/>
+          </xsl:call-template>
+        </xsl:attribute>
         <xsl:call-template name="mal.link.content">
           <xsl:with-param name="node" select="."/>
           <xsl:with-param name="xref" select="$xref"/>
@@ -231,6 +242,11 @@ REMARK: Describe this template
         <xsl:with-param name="xref" select="$node/@xref"/>
       </xsl:call-template>
     </xsl:attribute>
+    <xsl:attribute name="title">
+      <xsl:call-template name="mal.link.tooltip">
+        <xsl:with-param name="xref" select="$node/@xref"/>
+      </xsl:call-template>
+    </xsl:attribute>
     <xsl:call-template name="mal.link.content">
       <xsl:with-param name="node" select="$node"/>
       <xsl:with-param name="xref" select="$node/@xref"/>
@@ -290,7 +306,7 @@ REMARK: Describe this template
               </xsl:call-template>
             </xsl:attribute>
             <xsl:attribute name="title">
-              <xsl:call-template name="mal.link.content">
+              <xsl:call-template name="mal.link.tooltip">
                 <xsl:with-param name="node" select="$prev"/>
                 <xsl:with-param name="xref" select="$prev/../../@id"/>
               </xsl:call-template>
@@ -314,7 +330,7 @@ REMARK: Describe this template
               </xsl:call-template>
             </xsl:attribute>
             <xsl:attribute name="title">
-              <xsl:call-template name="mal.link.content">
+              <xsl:call-template name="mal.link.tooltip">
                 <xsl:with-param name="node" select="$next"/>
                 <xsl:with-param name="xref" select="$next/@xref"/>
               </xsl:call-template>
@@ -352,6 +368,12 @@ REMARK: Describe this template
               <xsl:with-param name="xref" select="$prev/../../@id"/>
             </xsl:call-template>
           </xsl:attribute>
+          <xsl:attribute name="title">
+            <xsl:call-template name="mal.link.tooltip">
+              <xsl:with-param name="node" select="$prev"/>
+              <xsl:with-param name="xref" select="$prev/../../@id"/>
+            </xsl:call-template>
+          </xsl:attribute>
           <xsl:call-template name="mal.link.content">
             <xsl:with-param name="node" select="$prev"/>
             <xsl:with-param name="xref" select="$prev/../../@id"/>
@@ -380,6 +402,12 @@ REMARK: Describe this template
               <xsl:with-param name="xref" select="$next/@xref"/>
             </xsl:call-template>
           </xsl:attribute>
+          <xsl:attribute name="title">
+            <xsl:call-template name="mal.link.tooltip">
+              <xsl:with-param name="node" select="$next"/>
+              <xsl:with-param name="xref" select="$next/@xref"/>
+            </xsl:call-template>
+          </xsl:attribute>
           <xsl:call-template name="mal.link.content">
             <xsl:with-param name="node" select="$next"/>
             <xsl:with-param name="xref" select="$next/@xref"/>
@@ -824,6 +852,11 @@ REMARK: Describe this template
                           <xsl:with-param name="xref" select="$xref"/>
                         </xsl:call-template>
                       </xsl:attribute>
+                      <xsl:attribute name="title">
+                        <xsl:call-template name="mal.link.tooltip">
+                          <xsl:with-param name="xref" select="$xref"/>
+                        </xsl:call-template>
+                      </xsl:attribute>
                       <xsl:for-each select="$node/e:mouseover[ match = $xref]">
                         <img>
                           <xsl:copy-of select="@src | @width | @height"/>
@@ -838,10 +871,6 @@ REMARK: Describe this template
                   </li>
                 </xsl:for-each>
               </xsl:for-each>
-
-
-
-
             </ul>
           </xsl:when>
           <xsl:when test="contains($style, ' toronto ')">
@@ -865,6 +894,11 @@ REMARK: Describe this template
                                 <xsl:with-param name="xref" select="$xref"/>
                               </xsl:call-template>
                             </xsl:attribute>
+                            <xsl:attribute name="title">
+                              <xsl:call-template name="mal.link.tooltip">
+                                <xsl:with-param name="xref" select="$xref"/>
+                              </xsl:call-template>
+                            </xsl:attribute>
                             <xsl:call-template name="mal.link.content">
                               <xsl:with-param name="node" select="."/>
                               <xsl:with-param name="xref" select="$xref"/>



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