Author: cdupoirieux
Date: Wed Dec 7 08:34:33 2005
New Revision: 354793
URL: http://svn.apache.org/viewcvs?rev=354793&view=rev
Log:
Add the ability to "escape" mailto addresses or links in order to avoid they
are automatically rewritten by forrest.
If a link or an address must appear in the text of the site, but the user does
not need a real link he can prefix both by '\' character.
Examples :
- [EMAIL PROTECTED] will not be rewritten as a mailto link but just like text -
without the \ -
This corrects the http://issues.apache.org/jira/browse/FOR-743
Modified:
forrest/trunk/main/webapp/resources/chaperon/grammars/link.xlex
forrest/trunk/main/webapp/resources/chaperon/stylesheets/pattern2link.xsl
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.themer/resources/themes/common/html/siteinfo-feedback.ft
Modified: forrest/trunk/main/webapp/resources/chaperon/grammars/link.xlex
URL:
http://svn.apache.org/viewcvs/forrest/trunk/main/webapp/resources/chaperon/grammars/link.xlex?rev=354793&r1=354792&r2=354793&view=diff
==============================================================================
--- forrest/trunk/main/webapp/resources/chaperon/grammars/link.xlex (original)
+++ forrest/trunk/main/webapp/resources/chaperon/grammars/link.xlex Wed Dec 7
08:34:33 2005
@@ -19,6 +19,10 @@
<!-- (([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? -->
<lexeme symbol="link">
<concat>
+ <concat minOccurs="0" maxOccurs="1">
+ <cstring content="\"/>
+ </concat>
+ <group>
<concat>
<cclass maxOccurs="*">
<cinterval min="A" max="Z"/>
@@ -64,6 +68,7 @@
<cset content="._-:/?#"/>
</cclass>
</concat>
+ </group>
</concat>
</lexeme>
@@ -152,6 +157,9 @@
<lexeme symbol="email">
<concat>
<concat>
+ <concat minOccurs="0" maxOccurs="1">
+ <cstring content="\"/>
+ </concat>
<group>
<cclass maxOccurs="*">
<cinterval min="A" max="Z"/>
Modified:
forrest/trunk/main/webapp/resources/chaperon/stylesheets/pattern2link.xsl
URL:
http://svn.apache.org/viewcvs/forrest/trunk/main/webapp/resources/chaperon/stylesheets/pattern2link.xsl?rev=354793&r1=354792&r2=354793&view=diff
==============================================================================
--- forrest/trunk/main/webapp/resources/chaperon/stylesheets/pattern2link.xsl
(original)
+++ forrest/trunk/main/webapp/resources/chaperon/stylesheets/pattern2link.xsl
Wed Dec 7 08:34:33 2005
@@ -21,16 +21,32 @@
xmlns:lex="http://chaperon.sourceforge.net/schema/lexemes/2.0">
<xsl:template match="lex:[EMAIL PROTECTED]'link']">
- <a href="[EMAIL PROTECTED]">
- <xsl:value-of select="@text"/>
- </a>
+ <xsl:choose>
+ <!-- it is possible to disable link writing by prefixing by '\' -->
+ <xsl:when test="not( starts-with( @text, '\') )">
+ <a href="[EMAIL PROTECTED]">
+ <xsl:value-of select="@text"/>
+ </a>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="lex:group[2]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
</xsl:template>
<xsl:template match="lex:[EMAIL PROTECTED]'email']">
- <a href="mailto:[EMAIL PROTECTED]">
- <xsl:value-of select="lex:group[2]"/> at
- <xsl:value-of select="lex:group[3]"/>
- </a>
+ <xsl:choose>
+ <!-- it is possible to disable link writing by prefixing by '\' -->
+ <xsl:when test="not( starts-with( @text, '\') )">
+ <a href="mailto:[EMAIL PROTECTED]">
+ <xsl:value-of select="lex:group[2]"/> at <xsl:value-of
select="lex:group[3]"/>
+ </a>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="lex:group[2]"/>@<xsl:value-of
select="lex:group[3]"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template match="lex:[EMAIL PROTECTED]'cssurl']">
Modified:
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.themer/resources/themes/common/html/siteinfo-feedback.ft
URL:
http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.themer/resources/themes/common/html/siteinfo-feedback.ft?rev=354793&r1=354792&r2=354793&view=diff
==============================================================================
---
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.themer/resources/themes/common/html/siteinfo-feedback.ft
(original)
+++
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.themer/resources/themes/common/html/siteinfo-feedback.ft
Wed Dec 7 08:34:33 2005
@@ -19,14 +19,24 @@
<forrest:contract name="siteinfo-feedback" type="nugget"
xmlns:forrest="http://apache.org/forrest/templates/1.0">
<description>
- <p>siteinfo-feedback<br/> The feedback element will be used to construct a
+ <p>The feedback element will be used to construct a
feedback link in the page appending: <a href="@href">[EMAIL
PROTECTED]</a> </p>
+ <div class="note">
+ <div class="label">Beware the link rewritting !</div>
+ <div class="content">
+ <p>Forrest recognise links or e-mail address in the text of the site
and automatically converts them into real links or mailto.<br/>
+ if the <em>to</em> attribute is of the following form : <code>[EMAIL
PROTECTED]</code> it is recognised as a mailto link and will be converted
too.<br/>
+ </p>
+ <p>To avoid this, you can <em>escape</em> the conversion by prefixing
the email adress by the '\' character : <strong>\</strong><code>[EMAIL
PROTECTED]</code> will not be converted.<br/>
+ (Note that none of the previous examples are rewritten because we used
the '\' character in the source !).</p>
+ </div>
+ </div>
</description>
<usage><![CDATA[<forrest:contract name="siteinfo-feedback">
<forrest:properties contract="siteinfo-feedback">
<forrest:property name="siteinfo-feedback">
- <feedback to="[EMAIL PROTECTED]"
- href="mailto:[EMAIL PROTECTED] " >
+ <feedback to="[EMAIL PROTECTED]"
+ href="\mailto:[EMAIL PROTECTED] " >
Send feedback about the website to:
</feedback>
</forrest:property>