From 8381449d2482479f57d645ce49c2d89dfa8027fd Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Tue, 28 Feb 2023 14:32:08 +0100 Subject: [PATCH 01/16] XWIKI-19383: Display a title on createlink * Changed generation in the class editor on the platform --- .../src/main/resources/AppWithinMinutes/ClassEditSheet.xml | 5 ++++- .../src/main/resources/ApplicationResources.properties | 1 + .../src/main/resources/templates/displayer_page.vm | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml index 47eb7153cd22..90b2975de98b 100644 --- a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml +++ b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml @@ -256,7 +256,10 @@ xcontext.put('propertyCustomDisplayer', new PropertyCustomDisplayer(xcontext)) #set ($action = 'create') #set ($discard = $params.put('parent', $doc.fullName)) #end - <span class="$class"><a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))" + <span class="$class"> + <a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))" + title="$services.localization.render('platform.', + ['#pageLink($translationsReference)']" >$escapetool.xml($reference.name)</a></span>## #end diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties index 3fdc7d4328e2..31ce676483df 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties @@ -791,6 +791,7 @@ core.create.name.hint=Name of the new page core.create.name.placeholder=NewPage core.create.template=Template +core.create.inline.label=Create page: {0} core.create.page.template.hint=Template to use for the new page core.create.page.template.empty=Empty Wiki Page core.create.template.allowedspaces=Pages created from the template [{0}] must be created in one of the following spaces: {1} diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm index c88b398773ea..0bf24bf24fc9 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm @@ -57,7 +57,8 @@ #else #set ($title = $escapetool.xml($pageDoc.plainTitle)) #if ($pageDoc.isNew()) - $title + $title #else $title #end From bc0ab507e753db1e3635afb1f62240be45ecf545 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Thu, 2 Mar 2023 15:50:46 +0100 Subject: [PATCH 02/16] XWIKI-19383: Display a title on createlink * Added an extension for rendering default behavior. --- .../xwiki-platform-rendering-xwiki/pom.xml | 5 ++ .../XWikiPageAttachmentURITitleGenerator.java | 63 +++++++++++++++++++ .../main/resources/META-INF/components.txt | 1 + 3 files changed, 69 insertions(+) create mode 100644 xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml index 64532e15b16f..3a3df4cd99e3 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml @@ -52,6 +52,11 @@ xwiki-platform-template-api ${project.version} + + org.xwiki.platform + xwiki-platform-localization-api + ${project.version} + org.xwiki.platform xwiki-platform-bridge diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java new file mode 100644 index 000000000000..ee579d881b40 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java @@ -0,0 +1,63 @@ +/* + * 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.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.model.reference.PageAttachmentReference; +import org.xwiki.model.reference.PageAttachmentReferenceResolver; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.rendering.renderer.reference.link.URITitleGenerator; + +/** + * Generate link labels for ATTACH URIs. + * + * @version $Id$ + * @since 15.1-RC1 + */ +@Component +@Named("pageAttach") +@Singleton +public class XWikiPageAttachmentURITitleGenerator implements URITitleGenerator +{ + @Inject + private ContextualLocalizationManager contextLocalization; + /** + * Used to extract the attachment name part in an Attachment reference. + */ + @Inject + @Named("current") + private PageAttachmentReferenceResolver currentAttachmentReferenceResolver; + + + + @Override + public String generateCreateTitle(ResourceReference reference) + { + PageAttachmentReference attachmentReference = + this.currentAttachmentReferenceResolver.resolve(reference.getReference()); + return this.contextLocalization.getTranslationPlain("rendering.internal.renderer.link.create.title", + attachmentReference.getName()); + } +} diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt index d740d4adf1ca..098d8c013e11 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt @@ -1,6 +1,7 @@ 500:org.xwiki.rendering.internal.renderer.XWikiAttachmentURILabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiLinkLabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiPageAttachmentURILabelGenerator +500:org.xwiki.rendering.internal.renderer.XWikiPageAttachmentURITitleGenerator 500:org.xwiki.rendering.internal.util.XWikiErrorBlockGenerator 500:org.xwiki.rendering.internal.wiki.XWikiWikiModel 500:org.xwiki.rendering.internal.macro.XWikiHTMLRawBlockFilter From 38d8f97efd02ed0556d7964ed64579f4dbb7b346 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Mon, 6 Mar 2023 15:59:55 +0100 Subject: [PATCH 03/16] XWIKI-19450: Several nav tags are used without aria-label * Fixed wrong version tag --- .../renderer/XWikiPageAttachmentURITitleGenerator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java index ee579d881b40..6ec788bf87b2 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java @@ -31,10 +31,10 @@ import org.xwiki.rendering.renderer.reference.link.URITitleGenerator; /** - * Generate link labels for ATTACH URIs. + * Generate link titles for ATTACH URIs. * * @version $Id$ - * @since 15.1-RC1 + * @since 15.2RC1 */ @Component @Named("pageAttach") @@ -57,7 +57,7 @@ public String generateCreateTitle(ResourceReference reference) { PageAttachmentReference attachmentReference = this.currentAttachmentReferenceResolver.resolve(reference.getReference()); - return this.contextLocalization.getTranslationPlain("rendering.internal.renderer.link.create.title", + return this.contextLocalization.getTranslationPlain("core.create.inline.label", attachmentReference.getName()); } } From c54d4637104e1ad1bed54ddf9a1a75090bb140a7 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Mon, 6 Mar 2023 15:59:55 +0100 Subject: [PATCH 04/16] XWIKI-19383: Display a title on createlink * Fixed wrong version tag --- .../renderer/XWikiPageAttachmentURITitleGenerator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java index ee579d881b40..6ec788bf87b2 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java @@ -31,10 +31,10 @@ import org.xwiki.rendering.renderer.reference.link.URITitleGenerator; /** - * Generate link labels for ATTACH URIs. + * Generate link titles for ATTACH URIs. * * @version $Id$ - * @since 15.1-RC1 + * @since 15.2RC1 */ @Component @Named("pageAttach") @@ -57,7 +57,7 @@ public String generateCreateTitle(ResourceReference reference) { PageAttachmentReference attachmentReference = this.currentAttachmentReferenceResolver.resolve(reference.getReference()); - return this.contextLocalization.getTranslationPlain("rendering.internal.renderer.link.create.title", + return this.contextLocalization.getTranslationPlain("core.create.inline.label", attachmentReference.getName()); } } From d6c8fa0e067ef8596f174be2beeb58bcf1d2ad1a Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Tue, 28 Feb 2023 14:32:08 +0100 Subject: [PATCH 05/16] XWIKI-19383: Display a title on createlink * Changed generation in the class editor on the platform --- .../src/main/resources/AppWithinMinutes/ClassEditSheet.xml | 5 ++++- .../src/main/resources/ApplicationResources.properties | 1 + .../src/main/resources/templates/displayer_page.vm | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml index 47eb7153cd22..90b2975de98b 100644 --- a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml +++ b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml @@ -256,7 +256,10 @@ xcontext.put('propertyCustomDisplayer', new PropertyCustomDisplayer(xcontext)) #set ($action = 'create') #set ($discard = $params.put('parent', $doc.fullName)) #end - <span class="$class"><a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))" + <span class="$class"> + <a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))" + title="$services.localization.render('platform.', + ['#pageLink($translationsReference)']" >$escapetool.xml($reference.name)</a></span>## #end diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties index f4247f9367b3..6cadf4d70e7f 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties @@ -793,6 +793,7 @@ core.create.name.hint=Name of the new page core.create.name.placeholder=NewPage core.create.template=Template +core.create.inline.label=Create page: {0} core.create.page.template.hint=Template to use for the new page core.create.page.template.empty=Empty Wiki Page core.create.template.allowedspaces=Pages created from the template [{0}] must be created in one of the following spaces: {1} diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm index c88b398773ea..0bf24bf24fc9 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm @@ -57,7 +57,8 @@ #else #set ($title = $escapetool.xml($pageDoc.plainTitle)) #if ($pageDoc.isNew()) - $title + $title #else $title #end From 50548b29393a16e021f15cc3cf1089f824c8edfb Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Thu, 2 Mar 2023 15:50:46 +0100 Subject: [PATCH 06/16] XWIKI-19383: Display a title on createlink * Added an extension for rendering default behavior. --- .../xwiki-platform-rendering-xwiki/pom.xml | 5 ++ .../XWikiPageAttachmentURITitleGenerator.java | 63 +++++++++++++++++++ .../main/resources/META-INF/components.txt | 1 + 3 files changed, 69 insertions(+) create mode 100644 xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml index 64532e15b16f..3a3df4cd99e3 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml @@ -52,6 +52,11 @@ xwiki-platform-template-api ${project.version} + + org.xwiki.platform + xwiki-platform-localization-api + ${project.version} + org.xwiki.platform xwiki-platform-bridge diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java new file mode 100644 index 000000000000..ee579d881b40 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java @@ -0,0 +1,63 @@ +/* + * 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.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.model.reference.PageAttachmentReference; +import org.xwiki.model.reference.PageAttachmentReferenceResolver; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.rendering.renderer.reference.link.URITitleGenerator; + +/** + * Generate link labels for ATTACH URIs. + * + * @version $Id$ + * @since 15.1-RC1 + */ +@Component +@Named("pageAttach") +@Singleton +public class XWikiPageAttachmentURITitleGenerator implements URITitleGenerator +{ + @Inject + private ContextualLocalizationManager contextLocalization; + /** + * Used to extract the attachment name part in an Attachment reference. + */ + @Inject + @Named("current") + private PageAttachmentReferenceResolver currentAttachmentReferenceResolver; + + + + @Override + public String generateCreateTitle(ResourceReference reference) + { + PageAttachmentReference attachmentReference = + this.currentAttachmentReferenceResolver.resolve(reference.getReference()); + return this.contextLocalization.getTranslationPlain("rendering.internal.renderer.link.create.title", + attachmentReference.getName()); + } +} diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt index 8efe2f7fb177..e1937f44df58 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt @@ -1,6 +1,7 @@ 500:org.xwiki.rendering.internal.renderer.XWikiAttachmentURILabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiLinkLabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiPageAttachmentURILabelGenerator +500:org.xwiki.rendering.internal.renderer.XWikiPageAttachmentURITitleGenerator 500:org.xwiki.rendering.internal.util.XWikiErrorBlockGenerator 500:org.xwiki.rendering.internal.wiki.XWikiWikiModel 500:org.xwiki.rendering.internal.macro.XWikiHTMLRawBlockFilter From d85e48f3744f866fb3ee710f4e248ae8b0289bd4 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Mon, 6 Mar 2023 15:59:55 +0100 Subject: [PATCH 07/16] XWIKI-19383: Display a title on createlink * Fixed wrong version tag --- .../renderer/XWikiPageAttachmentURITitleGenerator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java index ee579d881b40..6ec788bf87b2 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java @@ -31,10 +31,10 @@ import org.xwiki.rendering.renderer.reference.link.URITitleGenerator; /** - * Generate link labels for ATTACH URIs. + * Generate link titles for ATTACH URIs. * * @version $Id$ - * @since 15.1-RC1 + * @since 15.2RC1 */ @Component @Named("pageAttach") @@ -57,7 +57,7 @@ public String generateCreateTitle(ResourceReference reference) { PageAttachmentReference attachmentReference = this.currentAttachmentReferenceResolver.resolve(reference.getReference()); - return this.contextLocalization.getTranslationPlain("rendering.internal.renderer.link.create.title", + return this.contextLocalization.getTranslationPlain("core.create.inline.label", attachmentReference.getName()); } } From 68639a65b4c3a4550e2fc3e0f1407c4a006d62a9 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Thu, 16 Mar 2023 15:58:34 +0100 Subject: [PATCH 08/16] XWIKI-19383: Display a title on createlink * Added an hint on the URITitleGenerator component --- .../internal/renderer/XWikiPageAttachmentURITitleGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java index 6ec788bf87b2..6f4efdf1873e 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java @@ -36,7 +36,7 @@ * @version $Id$ * @since 15.2RC1 */ -@Component +@Component(hints = {"doc", "page"}) @Named("pageAttach") @Singleton public class XWikiPageAttachmentURITitleGenerator implements URITitleGenerator From 79fc276ba085daaa56c3efad5aca94265b9ca8b8 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Thu, 16 Mar 2023 17:02:46 +0100 Subject: [PATCH 09/16] XWIKI-19383: Display a title on createlink * Fixed the hint of the URITitleGenerator implementation --- .../renderer/XWikiPageAttachmentURITitleGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java index 6f4efdf1873e..d80e06c1b6d3 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java @@ -36,8 +36,8 @@ * @version $Id$ * @since 15.2RC1 */ -@Component(hints = {"doc", "page"}) -@Named("pageAttach") +@Component +@Named("doc") @Singleton public class XWikiPageAttachmentURITitleGenerator implements URITitleGenerator { From a88f48de358e99920773a10c90161aa30d0d04d3 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Mon, 20 Mar 2023 11:46:31 +0100 Subject: [PATCH 10/16] XWIKI-19383: Display a title on createlink * Refactored name and fixed hint to match DocumentXHTMLLinkTypeRenderer in xwiki-render. --- ...Generator.java => XWikiDocumentURITitleGenerator.java} | 8 +++----- .../src/main/resources/META-INF/components.txt | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) rename xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/{XWikiPageAttachmentURITitleGenerator.java => XWikiDocumentURITitleGenerator.java} (95%) diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java similarity index 95% rename from xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java rename to xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java index d80e06c1b6d3..55d23b26a913 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiPageAttachmentURITitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java @@ -36,13 +36,13 @@ * @version $Id$ * @since 15.2RC1 */ -@Component -@Named("doc") +@Component(hints = {"doc", "page"}) @Singleton -public class XWikiPageAttachmentURITitleGenerator implements URITitleGenerator +public class XWikiDocumentURITitleGenerator implements URITitleGenerator { @Inject private ContextualLocalizationManager contextLocalization; + /** * Used to extract the attachment name part in an Attachment reference. */ @@ -50,8 +50,6 @@ public class XWikiPageAttachmentURITitleGenerator implements URITitleGenerator @Named("current") private PageAttachmentReferenceResolver currentAttachmentReferenceResolver; - - @Override public String generateCreateTitle(ResourceReference reference) { diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt index e1937f44df58..7d28a9349bdc 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt @@ -1,7 +1,7 @@ 500:org.xwiki.rendering.internal.renderer.XWikiAttachmentURILabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiLinkLabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiPageAttachmentURILabelGenerator -500:org.xwiki.rendering.internal.renderer.XWikiPageAttachmentURITitleGenerator +500:org.xwiki.rendering.internal.renderer.XWikiDocumentURITitleGenerator 500:org.xwiki.rendering.internal.util.XWikiErrorBlockGenerator 500:org.xwiki.rendering.internal.wiki.XWikiWikiModel 500:org.xwiki.rendering.internal.macro.XWikiHTMLRawBlockFilter From 9b503b327a076a5009c23149d6a88d16c5d35c41 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Mon, 20 Mar 2023 14:23:12 +0100 Subject: [PATCH 11/16] XWIKI-19383: Display a title on createlink * Fixed escaping on title. * Properly formatted changes. --- .../src/main/resources/templates/displayer_page.vm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm index 0bf24bf24fc9..d2d2dac4abc9 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm @@ -55,10 +55,14 @@ ## The view displayer generates HTML so we need to escape the XML special characters from the page reference. $escapetool.xml($pageReference) #else - #set ($title = $escapetool.xml($pageDoc.plainTitle)) + #set ($title = $escapetool.velocity($pageDoc.plainTitle)) #if ($pageDoc.isNew()) - $title + + + $title + + #else $title #end From 3cd61d74e20cb807d731d5d5df74b976c93235c9 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Wed, 29 Mar 2023 12:02:29 +0200 Subject: [PATCH 12/16] XWIKI-19383: Display a title on createlink * Fixed indents * Fixed documentation * Fixed the ClassEditSheet.xml call. --- .../AppWithinMinutes/ClassEditSheet.xml | 9 ++++----- .../XWikiDocumentURITitleGenerator.java | 18 +++++++++--------- .../main/resources/templates/displayer_page.vm | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml index 90b2975de98b..0547b42d9dad 100644 --- a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml +++ b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml @@ -255,12 +255,11 @@ xcontext.put('propertyCustomDisplayer', new PropertyCustomDisplayer(xcontext)) #set ($class = 'wikicreatelink') #set ($action = 'create') #set ($discard = $params.put('parent', $doc.fullName)) + #set ($title = $services.localization.render('core.create.inline.label',[$reference.name])) #end - <span class="$class"> - <a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))" - title="$services.localization.render('platform.', - ['#pageLink($translationsReference)']" - >$escapetool.xml($reference.name)</a></span>## + <span class="$class"><a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))" + #if (!$xwiki.exists($reference))title="$title"#end> + $escapetool.xml($reference.name)</a></span>## #end #** diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java index 55d23b26a913..01cd4d5fc4aa 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java @@ -24,17 +24,17 @@ import javax.inject.Singleton; import org.xwiki.component.annotation.Component; -import org.xwiki.model.reference.PageAttachmentReference; -import org.xwiki.model.reference.PageAttachmentReferenceResolver; +import org.xwiki.model.reference.DocumentReference; +import org.xwiki.model.reference.DocumentReferenceResolver; import org.xwiki.rendering.listener.reference.ResourceReference; import org.xwiki.localization.ContextualLocalizationManager; import org.xwiki.rendering.renderer.reference.link.URITitleGenerator; /** - * Generate link titles for ATTACH URIs. + * Generate link titles for document URIs. * * @version $Id$ - * @since 15.2RC1 + * @since 15.3RC1 */ @Component(hints = {"doc", "page"}) @Singleton @@ -44,18 +44,18 @@ public class XWikiDocumentURITitleGenerator implements URITitleGenerator private ContextualLocalizationManager contextLocalization; /** - * Used to extract the attachment name part in an Attachment reference. + * Used to extract the document name part in a document reference. */ @Inject @Named("current") - private PageAttachmentReferenceResolver currentAttachmentReferenceResolver; + private DocumentReferenceResolver currentDocumentReferenceResolver; @Override public String generateCreateTitle(ResourceReference reference) { - PageAttachmentReference attachmentReference = - this.currentAttachmentReferenceResolver.resolve(reference.getReference()); + DocumentReference documentReference = + this.currentDocumentReferenceResolver.resolve(reference.getReference()); return this.contextLocalization.getTranslationPlain("core.create.inline.label", - attachmentReference.getName()); + documentReference.getName()); } } diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm index d2d2dac4abc9..9266c3698c6a 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm @@ -55,7 +55,7 @@ ## The view displayer generates HTML so we need to escape the XML special characters from the page reference. $escapetool.xml($pageReference) #else - #set ($title = $escapetool.velocity($pageDoc.plainTitle)) + #set ($title = $escapetool.xml($pageDoc.plainTitle)) #if ($pageDoc.isNew()) Date: Fri, 31 Mar 2023 13:13:54 +0200 Subject: [PATCH 13/16] XWIKI-19383: Display a title on createlink * Added implementations for other resource reference types. * Changed the l10n key names to be more specific TODO: * Fix tests --- .../resources/ApplicationResources.properties | 9 ++- ...ikiAttachmentWantedLinkTitleGenerator.java | 62 ++++++++++++++++++ .../XWikiDefaultWantedLinkTitleGenerator.java | 52 +++++++++++++++ ...WikiDocumentWantedLinkTitleGenerator.java} | 11 ++-- .../XWikiSpaceWantedLinkTitleGenerator.java | 63 +++++++++++++++++++ .../main/resources/META-INF/components.txt | 5 +- .../resources/templates/displayer_page.vm | 2 +- 7 files changed, 196 insertions(+), 8 deletions(-) create mode 100644 xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java create mode 100644 xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java rename xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/{XWikiDocumentURITitleGenerator.java => XWikiDocumentWantedLinkTitleGenerator.java} (79%) create mode 100644 xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties index 6cadf4d70e7f..0c34ad3753f3 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties @@ -793,7 +793,6 @@ core.create.name.hint=Name of the new page core.create.name.placeholder=NewPage core.create.template=Template -core.create.inline.label=Create page: {0} core.create.page.template.hint=Template to use for the new page core.create.page.template.empty=Empty Wiki Page core.create.template.allowedspaces=Pages created from the template [{0}] must be created in one of the following spaces: {1} @@ -2052,6 +2051,14 @@ rendering.async.context.entry.user=User rendering.async.error.failed=Failed to execute asynchronous content +#################### +# XWiki Syntax +#################### +rendering.xwiki.wantedLink.default.label=Create reference: {0} +rendering.xwiki.wantedLink.page.label=Create page: {0} +rendering.xwiki.wantedLink.space.label=Create space: {0} +rendering.xwiki.wantedLink.attachment.label=Create attachment: {0} + #################### # Plugins #################### diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java new file mode 100644 index 000000000000..9c9e747be6a2 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java @@ -0,0 +1,62 @@ +/* + * 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.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.model.reference.AttachmentReference; +import org.xwiki.model.reference.AttachmentReferenceResolver; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; + +/** + * Generates a wanted link title for an attachment resource reference. + * This implementation uses translations to generate localized titles. + * + * @version $Id$ + * @since 15.3RC1 + */ +@Component(hints = {"pageAttach", "attach"}) +@Singleton +public class XWikiAttachmentWantedLinkTitleGenerator implements WantedLinkTitleGenerator +{ + @Inject + private ContextualLocalizationManager contextLocalization; + + /** + * Used to extract the attachment name part in an attachment reference. + */ + @Inject + @Named("current") + private AttachmentReferenceResolver currentAttachmentReferenceResolver; + + @Override + public String generateWantedLinkTitle(ResourceReference reference) + { + AttachmentReference attachmentReference = + this.currentAttachmentReferenceResolver.resolve(reference.getReference()); + return this.contextLocalization.getTranslationPlain("rendering.xwiki.wantedLink.attachment.label", + attachmentReference.getName()); + } +} diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java new file mode 100644 index 000000000000..47ac3a516f74 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java @@ -0,0 +1,52 @@ +/* + * 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.Inject; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; + +/** + * Fallback to generate a wanted link title for a resource which type doesn't have a specific implementation yet. + * This implementation uses translations to generate localized titles. + * This implementation uses the reference itself, it should be overridden by type specific implementations using a + * human-readable name instead. E.g. {@link XWikiDocumentWantedLinkTitleGenerator} + * + * @version $Id$ + * @since 15.3RC1 + */ +@Component +@Singleton +public class XWikiDefaultWantedLinkTitleGenerator implements WantedLinkTitleGenerator +{ + @Inject + private ContextualLocalizationManager contextLocalization; + + @Override + public String generateWantedLinkTitle(ResourceReference reference) + { + return this.contextLocalization.getTranslationPlain("rendering.xwiki.wantedLink.default.label", + reference.getReference()); + } +} diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java similarity index 79% rename from xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java rename to xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java index 01cd4d5fc4aa..f6f1fdcc56b4 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentURITitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java @@ -28,17 +28,18 @@ import org.xwiki.model.reference.DocumentReferenceResolver; import org.xwiki.rendering.listener.reference.ResourceReference; import org.xwiki.localization.ContextualLocalizationManager; -import org.xwiki.rendering.renderer.reference.link.URITitleGenerator; +import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; /** - * Generate link titles for document URIs. + * Generates a wanted link title for a document resource reference. + * This implementation uses translations to generate localized titles. * * @version $Id$ * @since 15.3RC1 */ @Component(hints = {"doc", "page"}) @Singleton -public class XWikiDocumentURITitleGenerator implements URITitleGenerator +public class XWikiDocumentWantedLinkTitleGenerator implements WantedLinkTitleGenerator { @Inject private ContextualLocalizationManager contextLocalization; @@ -51,11 +52,11 @@ public class XWikiDocumentURITitleGenerator implements URITitleGenerator private DocumentReferenceResolver currentDocumentReferenceResolver; @Override - public String generateCreateTitle(ResourceReference reference) + public String generateWantedLinkTitle(ResourceReference reference) { DocumentReference documentReference = this.currentDocumentReferenceResolver.resolve(reference.getReference()); - return this.contextLocalization.getTranslationPlain("core.create.inline.label", + return this.contextLocalization.getTranslationPlain("rendering.xwiki.wantedLink.document.label", documentReference.getName()); } } diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java new file mode 100644 index 000000000000..bd0102f52002 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java @@ -0,0 +1,63 @@ +/* + * 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.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.model.reference.SpaceReference; +import org.xwiki.model.reference.SpaceReferenceResolver; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; + +/** + * Generates a wanted link title for a space resource reference. + * This implementation uses translations to generate localized titles. + * + * @version $Id$ + * @since 15.3RC1 + */ +@Component +@Named("space") +@Singleton +public class XWikiSpaceWantedLinkTitleGenerator implements WantedLinkTitleGenerator +{ + @Inject + private ContextualLocalizationManager contextLocalization; + + /** + * Used to extract the space name part in a space reference. + */ + @Inject + @Named("current") + private SpaceReferenceResolver currentSpaceReferenceResolver; + + @Override + public String generateWantedLinkTitle(ResourceReference reference) + { + SpaceReference spaceReference = + this.currentSpaceReferenceResolver.resolve(reference.getReference()); + return this.contextLocalization.getTranslationPlain("rendering.xwiki.wantedLink.space.label", + spaceReference.getName()); + } +} diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt index 7d28a9349bdc..6664a767def2 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt @@ -1,7 +1,10 @@ 500:org.xwiki.rendering.internal.renderer.XWikiAttachmentURILabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiLinkLabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiPageAttachmentURILabelGenerator -500:org.xwiki.rendering.internal.renderer.XWikiDocumentURITitleGenerator +480:org.xwiki.rendering.internal.renderer.XWikiDefaultWantedLinkTitleGenerator +500:org.xwiki.rendering.internal.renderer.XWikiDocumentWantedLinkTitleGenerator +500:org.xwiki.rendering.internal.renderer.XWikiSpaceWantedLinkTitleGenerator +500:org.xwiki.rendering.internal.renderer.XWikiAttachmentWantedLinkTitleGenerator 500:org.xwiki.rendering.internal.util.XWikiErrorBlockGenerator 500:org.xwiki.rendering.internal.wiki.XWikiWikiModel 500:org.xwiki.rendering.internal.macro.XWikiHTMLRawBlockFilter diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm index 9266c3698c6a..52ce5a341aa2 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm @@ -59,7 +59,7 @@ #if ($pageDoc.isNew()) + title="$escapetool.xml($services.localization.render('rendering.xwiki.wantedLink.page.label', [$title]))"> $title From 1bcb011d576b56eab95af52fc1424fce62f46488 Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Fri, 31 Mar 2023 16:46:04 +0200 Subject: [PATCH 14/16] XWIKI-19383: Display a title on createlink * Fixed the title on the wrong object in ClassEditSheet.xml * Took care of different cases in XWikiAttachmentWantedLinkTitleGenerator and XWikiDocumentWantedLinkTitleGenerator --- .../AppWithinMinutes/ClassEditSheet.xml | 8 +++--- ...ikiAttachmentWantedLinkTitleGenerator.java | 25 +++++++++++++++---- ...XWikiDocumentWantedLinkTitleGenerator.java | 25 +++++++++++++++---- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml index 8812b95fd21e..90a6f7ca432e 100644 --- a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml +++ b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml @@ -258,9 +258,11 @@ xcontext.put('propertyCustomDisplayer', new PropertyCustomDisplayer(xcontext)) #set ($discard = $params.put('parent', $doc.fullName)) #set ($title = $services.localization.render('core.create.inline.label',[$reference.name])) #end - <span class="$class"><a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))" - #if (!$xwiki.exists($reference))title="$title"#end> - $escapetool.xml($reference.name)</a></span>## + <span class="$class" #if(!$xwiki.exists($reference))title="$title"#end> + <a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))"> + $escapetool.xml($reference.name) + </a> + </span>## #end #** diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java index 9c9e747be6a2..57fb1b655e4c 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java @@ -25,9 +25,10 @@ import org.xwiki.component.annotation.Component; import org.xwiki.localization.ContextualLocalizationManager; -import org.xwiki.model.reference.AttachmentReference; import org.xwiki.model.reference.AttachmentReferenceResolver; +import org.xwiki.model.reference.PageAttachmentReferenceResolver; import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.rendering.listener.reference.ResourceType; import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; /** @@ -51,12 +52,26 @@ public class XWikiAttachmentWantedLinkTitleGenerator implements WantedLinkTitleG @Named("current") private AttachmentReferenceResolver currentAttachmentReferenceResolver; + /** + * Used to extract the page attachment name part in a page attachment reference. + */ + @Inject + @Named("current") + private PageAttachmentReferenceResolver currentPageAttachmentReferenceResolver; + @Override public String generateWantedLinkTitle(ResourceReference reference) { - AttachmentReference attachmentReference = - this.currentAttachmentReferenceResolver.resolve(reference.getReference()); - return this.contextLocalization.getTranslationPlain("rendering.xwiki.wantedLink.attachment.label", - attachmentReference.getName()); + String attachmentTitleTranslationKey = "rendering.xwiki.wantedLink.attachment.label"; + String attachmentName; + if (reference.isTyped() && reference.getType() == ResourceType.ATTACHMENT) { + attachmentName = this.currentAttachmentReferenceResolver.resolve(reference.getReference()).getName(); + } else if (reference.isTyped() && reference.getType() == ResourceType.PAGE_ATTACHMENT) { + attachmentName = this.currentPageAttachmentReferenceResolver.resolve(reference.getReference()).getName(); + } else { + attachmentName = reference.getReference(); + } + return this.contextLocalization.getTranslationPlain(attachmentTitleTranslationKey, + attachmentName); } } diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java index f6f1fdcc56b4..19fbdd1c32dc 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java @@ -24,10 +24,11 @@ import javax.inject.Singleton; import org.xwiki.component.annotation.Component; -import org.xwiki.model.reference.DocumentReference; import org.xwiki.model.reference.DocumentReferenceResolver; +import org.xwiki.model.reference.PageReferenceResolver; import org.xwiki.rendering.listener.reference.ResourceReference; import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.rendering.listener.reference.ResourceType; import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; /** @@ -51,12 +52,26 @@ public class XWikiDocumentWantedLinkTitleGenerator implements WantedLinkTitleGen @Named("current") private DocumentReferenceResolver currentDocumentReferenceResolver; + /** + * Used to extract the page name part in a page reference. + */ + @Inject + @Named("current") + private PageReferenceResolver currentPageReferenceResolver; + @Override public String generateWantedLinkTitle(ResourceReference reference) { - DocumentReference documentReference = - this.currentDocumentReferenceResolver.resolve(reference.getReference()); - return this.contextLocalization.getTranslationPlain("rendering.xwiki.wantedLink.document.label", - documentReference.getName()); + String documentTitleTranslationKey = "rendering.xwiki.wantedLink.document.label"; + String documentName; + if (reference.isTyped() && reference.getType() == ResourceType.DOCUMENT) { + documentName = this.currentDocumentReferenceResolver.resolve(reference.getReference()).getName(); + } else if (reference.isTyped() && reference.getType() == ResourceType.PAGE) { + documentName = this.currentPageReferenceResolver.resolve(reference.getReference()).getName(); + } else { + documentName = reference.getReference(); + } + return this.contextLocalization.getTranslationPlain(documentTitleTranslationKey, + documentName); } } From 45a7315dbb73d755e991db33c3ad681c20022d3d Mon Sep 17 00:00:00 2001 From: Sereza7 Date: Fri, 18 Aug 2023 16:41:06 +0200 Subject: [PATCH 15/16] XWIKI-19383: Display a title on createlink * Escaped properly a title --- .../src/main/resources/AppWithinMinutes/ClassEditSheet.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml index 90a6f7ca432e..818df538f282 100644 --- a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml +++ b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml @@ -256,7 +256,7 @@ xcontext.put('propertyCustomDisplayer', new PropertyCustomDisplayer(xcontext)) #set ($class = 'wikicreatelink') #set ($action = 'create') #set ($discard = $params.put('parent', $doc.fullName)) - #set ($title = $services.localization.render('core.create.inline.label',[$reference.name])) + #set ($title = $escapetool.xml($services.localization.render('core.create.inline.label',[$reference.name]))) #end <span class="$class" #if(!$xwiki.exists($reference))title="$title"#end> <a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))"> From 61c387b175b8442e313350e1c168217d48b089b8 Mon Sep 17 00:00:00 2001 From: LucasC Date: Mon, 8 Apr 2024 14:41:44 +0200 Subject: [PATCH 16/16] XWIKI-19383: Display a title on createlink * Updated since versions --- .../renderer/XWikiAttachmentWantedLinkTitleGenerator.java | 2 +- .../internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java | 2 +- .../renderer/XWikiDocumentWantedLinkTitleGenerator.java | 2 +- .../internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java index 57fb1b655e4c..126c73eea034 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java @@ -36,7 +36,7 @@ * This implementation uses translations to generate localized titles. * * @version $Id$ - * @since 15.3RC1 + * @since 16.3.0RC1 */ @Component(hints = {"pageAttach", "attach"}) @Singleton diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java index 47ac3a516f74..f03ebf7d5537 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java @@ -34,7 +34,7 @@ * human-readable name instead. E.g. {@link XWikiDocumentWantedLinkTitleGenerator} * * @version $Id$ - * @since 15.3RC1 + * @since 16.3.0RC1 */ @Component @Singleton diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java index 19fbdd1c32dc..e1bb4b1d7c67 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java @@ -36,7 +36,7 @@ * This implementation uses translations to generate localized titles. * * @version $Id$ - * @since 15.3RC1 + * @since 16.3.0RC1 */ @Component(hints = {"doc", "page"}) @Singleton diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java index bd0102f52002..9ff4da393783 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java @@ -35,7 +35,7 @@ * This implementation uses translations to generate localized titles. * * @version $Id$ - * @since 15.3RC1 + * @since 16.3.0RC1 */ @Component @Named("space")