Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-19383: Display a title on createlink #2104

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8381449
XWIKI-19383: Display a title on createlink
Sereza7 Feb 28, 2023
bc0ab50
XWIKI-19383: Display a title on createlink
Sereza7 Mar 2, 2023
38d8f97
XWIKI-19450: Several nav tags are used without aria-label
Sereza7 Mar 6, 2023
c54d463
XWIKI-19383: Display a title on createlink
Sereza7 Mar 6, 2023
b4205eb
Merge remote-tracking branch 'origin/XWIKI-19383' into XWIKI-19383
Sereza7 Mar 13, 2023
d6c8fa0
XWIKI-19383: Display a title on createlink
Sereza7 Feb 28, 2023
50548b2
XWIKI-19383: Display a title on createlink
Sereza7 Mar 2, 2023
d85e48f
XWIKI-19383: Display a title on createlink
Sereza7 Mar 6, 2023
9f7c059
Merge branch 'xwiki:master' into XWIKI-19383
Sereza7 Mar 16, 2023
e6e1304
Merge remote-tracking branch 'origin/XWIKI-19383' into XWIKI-19383
Sereza7 Mar 16, 2023
68639a6
XWIKI-19383: Display a title on createlink
Sereza7 Mar 16, 2023
79fc276
XWIKI-19383: Display a title on createlink
Sereza7 Mar 16, 2023
a88f48d
XWIKI-19383: Display a title on createlink
Sereza7 Mar 20, 2023
9b503b3
XWIKI-19383: Display a title on createlink
Sereza7 Mar 20, 2023
3cd61d7
XWIKI-19383: Display a title on createlink
Sereza7 Mar 29, 2023
8501c6a
XWIKI-19383: Display a title on createlink
Sereza7 Mar 31, 2023
069e949
Merge branch 'xwiki:master' into XWIKI-19383
Sereza7 Mar 31, 2023
1bcb011
XWIKI-19383: Display a title on createlink
Sereza7 Mar 31, 2023
1d2c7d7
Merge branch 'xwiki:master' into XWIKI-19383
Sereza7 Aug 18, 2023
45a7315
XWIKI-19383: Display a title on createlink
Sereza7 Aug 18, 2023
375bb2c
Merge branch 'xwiki:master' into XWIKI-19383
Sereza7 Apr 5, 2024
112f9f7
Merge branch 'xwiki:master' into XWIKI-19383
Sereza7 Apr 5, 2024
61c387b
XWIKI-19383: Display a title on createlink
Sereza7 Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,13 @@ xcontext.put('propertyCustomDisplayer', new PropertyCustomDisplayer(xcontext))
#set ($class = 'wikicreatelink')
#set ($action = 'create')
#set ($discard = $params.put('parent', $doc.fullName))
#set ($title = $escapetool.xml($services.localization.render('core.create.inline.label',[$reference.name])))
#end
<span class="$class"><a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))"
>$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

#**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,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
####################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
<artifactId>xwiki-platform-template-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-localization-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-bridge</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.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;

/**
* Generates a wanted link title for an attachment resource reference.
* This implementation uses translations to generate localized titles.
*
* @version $Id$
* @since 16.3.0RC1
*/
@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<String> currentAttachmentReferenceResolver;

/**
* Used to extract the page attachment name part in a page attachment reference.
*/
@Inject
@Named("current")
private PageAttachmentReferenceResolver<String> currentPageAttachmentReferenceResolver;

@Override
public String generateWantedLinkTitle(ResourceReference reference)
{
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);
}
}
Original file line number Diff line number Diff line change
@@ -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 16.3.0RC1
*/
@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());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.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;

/**
* Generates a wanted link title for a document resource reference.
* This implementation uses translations to generate localized titles.
*
* @version $Id$
* @since 16.3.0RC1
*/
@Component(hints = {"doc", "page"})
@Singleton
public class XWikiDocumentWantedLinkTitleGenerator implements WantedLinkTitleGenerator
{
@Inject
private ContextualLocalizationManager contextLocalization;

/**
* Used to extract the document name part in a document reference.
*/
@Inject
@Named("current")
private DocumentReferenceResolver<String> currentDocumentReferenceResolver;

/**
* Used to extract the page name part in a page reference.
*/
@Inject
@Named("current")
private PageReferenceResolver<String> currentPageReferenceResolver;

@Override
public String generateWantedLinkTitle(ResourceReference reference)
{
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);
}
}
Original file line number Diff line number Diff line change
@@ -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 16.3.0RC1
*/
@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<String> 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());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
500:org.xwiki.rendering.internal.renderer.XWikiAttachmentURILabelGenerator
500:org.xwiki.rendering.internal.renderer.XWikiLinkLabelGenerator
500:org.xwiki.rendering.internal.renderer.XWikiPageAttachmentURILabelGenerator
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@
#else
#set ($title = $escapetool.xml($pageDoc.plainTitle))
#if ($pageDoc.isNew())
<span class="wikicreatelink"><a href="$pageDoc.getURL('create')">$title</a></span>
<span class="wikicreatelink">
<a href="$pageDoc.getURL('create')"
title="$escapetool.xml($services.localization.render('rendering.xwiki.wantedLink.page.label', [$title]))">
$title
</a>
</span>
#else
<a href="$pageDoc.URL">$title</a>
#end
Expand Down