[yelp-xsl] Strip query string from email address in tooltip



commit f489e3c8b801e97672a8c81dd2a9047b8fafc921
Author: Shaun McCance <shaunm gnome org>
Date:   Wed Jan 18 18:39:47 2012 -0500

    Strip query string from email address in tooltip
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663185

 xslt/common/utils.xsl            |   25 +++++++++++++++++++++++++
 xslt/docbook/common/db-xref.xsl  |    7 +++++--
 xslt/mallard/common/mal-link.xsl |    7 +++++--
 3 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/xslt/common/utils.xsl b/xslt/common/utils.xsl
index 3196f88..007258f 100644
--- a/xslt/common/utils.xsl
+++ b/xslt/common/utils.xsl
@@ -148,4 +148,29 @@ be placed to the side of the verbatim output.
   </xsl:choose>
 </xsl:template>
 
+
+<!--**==========================================================================
+utils.email_address
+Get an email address from a mailto URL.
+:Revision:version="3.4" date="2012-01-18" status="final"
+$href: The mailto URL.
+
+This template takes a mailto URL and returns an email address, stripping the
+URL scheme as well as any query string.
+-->
+<xsl:template name="utils.email_address">
+  <xsl:param name="url"/>
+  <xsl:variable name="addy">
+    <xsl:value-of select="substring-after($url, 'mailto:')"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="contains($addy, '?')">
+      <xsl:value-of select="substring-before($addy, '?')"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$addy"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 </xsl:stylesheet>
diff --git a/xslt/docbook/common/db-xref.xsl b/xslt/docbook/common/db-xref.xsl
index afb823b..6f1a4c2 100644
--- a/xslt/docbook/common/db-xref.xsl
+++ b/xslt/docbook/common/db-xref.xsl
@@ -41,10 +41,13 @@ $url: The URL of the link, usually from the #{url} attribute
   <xsl:param name="url" select="$node/@url | $node/@xl:href"/>
   <xsl:choose>
     <xsl:when test="starts-with($url, 'mailto:')">
-      <xsl:variable name="addy" select="substring-after($url, 'mailto:')"/>
       <xsl:call-template name="l10n.gettext">
         <xsl:with-param name="msgid" select="'email.tooltip'"/>
-        <xsl:with-param name="string" select="$addy"/>
+        <xsl:with-param name="string">
+          <xsl:call-template name="utils.email_address">
+            <xsl:with-param name="url" select="$url"/>
+          </xsl:call-template>
+        </xsl:with-param>
         <xsl:with-param name="format" select="true()"/>
       </xsl:call-template>
     </xsl:when>
diff --git a/xslt/mallard/common/mal-link.xsl b/xslt/mallard/common/mal-link.xsl
index 0355fac..6b15033 100644
--- a/xslt/mallard/common/mal-link.xsl
+++ b/xslt/mallard/common/mal-link.xsl
@@ -382,10 +382,13 @@ tooltips may be provided for certain URI schemes.
             <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="string">
+                <xsl:call-template name="utils.email_address">
+                  <xsl:with-param name="url" select="$href"/>
+                </xsl:call-template>
+              </xsl:with-param>
               <xsl:with-param name="format" select="true()"/>
             </xsl:call-template>
           </xsl:when>



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