diff --git a/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultWantedLinkTitleGenerator.java b/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultWantedLinkTitleGenerator.java new file mode 100644 index 0000000000..6c7e587b82 --- /dev/null +++ b/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultWantedLinkTitleGenerator.java @@ -0,0 +1,53 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.rendering.internal.renderer; + +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; + +/** + * Generates wanted link titles for resource references. + * Using this implementation should be avoided, another implementation should be used instead. + * E.g. XWikiDocumentWantedLinkTitleGenerator in xwiki-platform which is used to provide translations. + * This implementation is a fallback and should only be used when xwiki-rendering is running by itself. + * This implementation uses the reference as the title. + * @version $Id$ + * @since 16.3.0RC1 + */ +@Component +@Singleton +public class DefaultWantedLinkTitleGenerator implements WantedLinkTitleGenerator +{ + private static final String DEFAULT_TITLE = "Create resource: %s"; + + /** + * Generates wanted link titles for resource references. + * @param reference the reference for which we want to generate a wanted link title + * @return the wanted link title used when rendering a resource reference. + */ + @Override + public String generateWantedLinkTitle(ResourceReference reference) + { + return String.format(DEFAULT_TITLE, reference.getReference()); + } +} diff --git a/xwiki-rendering-api/src/main/java/org/xwiki/rendering/renderer/reference/link/WantedLinkTitleGenerator.java b/xwiki-rendering-api/src/main/java/org/xwiki/rendering/renderer/reference/link/WantedLinkTitleGenerator.java new file mode 100644 index 0000000000..60750bfe8b --- /dev/null +++ b/xwiki-rendering-api/src/main/java/org/xwiki/rendering/renderer/reference/link/WantedLinkTitleGenerator.java @@ -0,0 +1,42 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.rendering.renderer.reference.link; + +import org.xwiki.component.annotation.Role; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.stability.Unstable; + +/** + * Generate Resource Reference titles for wanted links. + * The implementations should be named according to the kind of reference they process. + * + * @version $Id$ + * @since 16.3.0RC1 + */ +@Role +@Unstable +public interface WantedLinkTitleGenerator +{ + /** + * @param reference the reference for which we want to generate a wanted link title + * @return the title to display when rendering the resource reference wanted link + */ + String generateWantedLinkTitle(ResourceReference reference); +} diff --git a/xwiki-rendering-api/src/main/resources/META-INF/components.txt b/xwiki-rendering-api/src/main/resources/META-INF/components.txt index a8e6bab0fb..6c233d52e4 100644 --- a/xwiki-rendering-api/src/main/resources/META-INF/components.txt +++ b/xwiki-rendering-api/src/main/resources/META-INF/components.txt @@ -29,6 +29,7 @@ org.xwiki.rendering.internal.renderer.DefaultAttachmentURILabelGenerator org.xwiki.rendering.internal.renderer.MailtoURILabelGenerator org.xwiki.rendering.internal.renderer.DataURILabelGenerator org.xwiki.rendering.internal.renderer.DefaultPageAttachmentURILabelGenerator +org.xwiki.rendering.internal.renderer.DefaultWantedLinkTitleGenerator org.xwiki.rendering.internal.renderer.reference.DefaultResourceReferenceTypeSerializer org.xwiki.rendering.internal.syntax.SyntaxConverter org.xwiki.rendering.internal.syntax.DefaultSyntaxRegistry diff --git a/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links20.test b/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links20.test index 1369b09032..709600fd7a 100644 --- a/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links20.test +++ b/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links20.test @@ -15,11 +15,11 @@ endDocument .#----------------------------------------------------- .expect|xhtml/1.0 .#----------------------------------------------------- -
+ .#----------------------------------------------------- .expect|annotatedxhtml/1.0 .#----------------------------------------------------- - + .#----------------------------------------------------- .expect|xwiki/2.0 .#----------------------------------------------------- @@ -27,4 +27,4 @@ endDocument .#----------------------------------------------------- .input|xhtml/1.0 .#----------------------------------------------------- - \ No newline at end of file + \ No newline at end of file diff --git a/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links22.test b/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links22.test index dd1d428621..304a598ae8 100644 --- a/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links22.test +++ b/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links22.test @@ -6,4 +6,4 @@ .#----------------------------------------------------- .expect|xhtml/1.0 .#----------------------------------------------------- - \ No newline at end of file + \ No newline at end of file diff --git a/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links3.test b/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links3.test index 6838c3bf81..9f47b1177d 100644 --- a/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links3.test +++ b/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links3.test @@ -15,11 +15,11 @@ endDocument .#----------------------------------------------------- .expect|xhtml/1.0 .#----------------------------------------------------- - + .#----------------------------------------------------- .expect|annotatedxhtml/1.0 .#----------------------------------------------------- - + .#----------------------------------------------------- .expect|xwiki/2.0 .#----------------------------------------------------- @@ -27,7 +27,7 @@ endDocument .#----------------------------------------------------- .input|xhtml/1.0 .#----------------------------------------------------- - + .#----------------------------------------------------- .expect|plain/1.0 .#----------------------------------------------------- diff --git a/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links6.test b/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links6.test index 2a281b92f7..0c5adf17e0 100644 --- a/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links6.test +++ b/xwiki-rendering-integration-tests/src/test/resources/wiki/link/links6.test @@ -51,11 +51,11 @@ endDocument .#----------------------------------------------------- .expect|xhtml/1.0 .#----------------------------------------------------- -{{macro}}
Label>Reference
Reference|Param=Value
[[no link>>Not Reference]]
[[
not:link
{{macro}}
Label>Reference
Reference|Param=Value
[[no link>>Not Reference]]
[[
not:link
{{macro}}
Label>Reference
Reference|Param=Value
[[no link>>Not Reference]]
[[
not:link
{{macro}}
Label>Reference
Reference|Param=Value
[[no link>>Not Reference]]
[[
not:link
{{macro}}
Label>Reference
Reference|Param=Value
[[no link>>Not Reference]]
[[
not:link
{{macro}}
Label>Reference
Reference|Param=Value
[[no link>>Not Reference]]
[[
not:link