On 02/02/2010 03:51 PM, vmassol (SVN) wrote:
Author: vmassol
Date: 2010-02-02 15:51:13 +0100 (Tue, 02 Feb 2010)
New Revision: 26602
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/AttachURILabelGenerator.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/MailtoURILabelGenerator.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/renderer/URILabelGenerator.java
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/pom.xml
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultLinkLabelGenerator.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/DefaultXHTMLLinkRenderer.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/resources/META-INF/components.txt
platform/core/trunk/xwiki-rendering/xwiki-rendering-tests/src/test/java/org/xwiki/rendering/SimpleRenderingTests.java
Log:
XWIKI-4839: Improve labels for mailto and attach links
* Refactored to make the implementation more generic...
Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/pom.xml
===================================================================
--- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/pom.xml 2010-02-02 14:38:44
UTC (rev 26601)
+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/pom.xml 2010-02-02 14:51:13
UTC (rev 26602)
@@ -132,6 +132,9 @@
**/rendering/internal/macro/*.java,
**/rendering/internal/parser/*.java,
**/rendering/internal/renderer/BasicLinkRenderer.java,
It's a pity that we must manually list all the checked files...
+
**/rendering/internal/renderer/DefaultLinkLabelGenerator.java,
+ **/rendering/internal/renderer/AttachURILabelGenerator.java,
+ **/rendering/internal/renderer/MailtoURILabelGenerator.java,
**/rendering/listener/*.java,
**/rendering/listener/chaining/AbstractChainingListener.java,
**/rendering/listener/chaining/ChainingListener.java,
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/MailtoURILabelGenerator.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/MailtoURILabelGenerator.java
(rev 0)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/MailtoURILabelGenerator.java 2010-02-02
14:51:13 UTC (rev 26602)
+@Component("mailto")
+public class MailtoURILabelGenerator implements URILabelGenerator
+{
+ /**
+ * The MAILTO URI prefix (the scheme followed by ":").
+ */
+ private static final String MAILTO = "mailto:";
+
+ /**
+ * {@inheritDoc}
+ * @see
org.xwiki.rendering.renderer.URILabelGenerator#generateLabel(org.xwiki.rendering.listener.Link)
+ */
+ public String generateLabel(Link link)
+ {
+ String label = link.getReference().substring(MAILTO.length());
StringUtils.removeStart(label, MAILTO) is safer.
+ // Also remove the query string part
from the label (we only want the email address).
return StringUtils.substringBefore("?") is shorter.
> + int queryStringPosition = label.indexOf("?");
> + if (queryStringPosition> -1) {
> + label = label.substring(0, queryStringPosition);
> + }
> + return label;
> + }
> +}