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 13 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,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)))"
Sereza7 marked this conversation as resolved.
Show resolved Hide resolved
title="$services.localization.render('platform.',
['#pageLink($translationsReference)']"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong. The translation key is incomplete and there's a bracket missing.

>$escapetool.xml($reference.name)</a></span>##
#end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
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,61 @@
/*
* 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 titles for ATTACH URIs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match the class name. Is this about pages or attachments?

*
* @version $Id$
* @since 15.2RC1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be updated.

*/
@Component(hints = {"doc", "page"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed.

@Singleton
public class XWikiDocumentURITitleGenerator implements URITitleGenerator
{
@Inject
private ContextualLocalizationManager contextLocalization;

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

@Override
public String generateCreateTitle(ResourceReference reference)
{
PageAttachmentReference attachmentReference =
this.currentAttachmentReferenceResolver.resolve(reference.getReference());
return this.contextLocalization.getTranslationPlain("core.create.inline.label",
attachmentReference.getName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, you're returning "Create page: attachmentName"? Doesn't make any sense. Also bad formatting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for the formatting.
When used on a rendered link, it seems to me like it works properly, the reference name is the name of the page we're looking to create. What should I use in its stead?

For reference, I just checked again this code in action:

[[Dead link>>The dead page that should be created]]

19383-titleGenerator

}
}
Original file line number Diff line number Diff line change
@@ -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.XWikiDocumentURITitleGenerator
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,8 @@
#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="$services.localization.render('core.create.inline.label', [$title])">$title</a></span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong formatting + escaping missing.

Suggested change
<span class="wikicreatelink"><a href="$pageDoc.getURL('create')"
title="$services.localization.render('core.create.inline.label', [$title])">$title</a></span>
<span class="wikicreatelink">
<a href="$pageDoc.getURL('create')" title="$services.localization.render('core.create.inline.label', [$title])">$title</a>
</span>

#else
<a href="$pageDoc.URL">$title</a>
#end
Expand Down