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

Conversation

Sereza7
Copy link
Contributor

@Sereza7 Sereza7 commented Mar 6, 2023

Jira: https://jira.xwiki.org/browse/XWIKI-19383
See xwiki/xwiki-rendering#256 for the changes on xwiki-rendering.
PR Changes:

  • Fixed the platform generated wikicreatelink spans
  • Created an implementation of URITitleGenerator

* Changed generation in the class editor on the platform
* Added an extension for rendering default behavior.
@Sereza7 Sereza7 marked this pull request as draft March 6, 2023 15:07
@Sereza7 Sereza7 marked this pull request as ready for review March 16, 2023 16:16
@Sereza7
Copy link
Contributor Author

Sereza7 commented Mar 16, 2023

PR Changes:

  • Solved the mismatch in hints for the URITitleGenerator implementation

NOTE: This commit needs to be merged with/after xwiki/xwiki-rendering#256

View:
19383-InitialPRState

* Refactored name and fixed hint to match DocumentXHTMLLinkTypeRenderer in xwiki-render.
Comment on lines 60 to 61
<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>

* Fixed escaping on title.
* Properly formatted changes.
@Sereza7
Copy link
Contributor Author

Sereza7 commented Mar 20, 2023

PR Changes:

  • Fixed escaping on title.
  • Properly formatted changes.

Copy link
Member

@mflorea mflorea left a comment

Choose a reason for hiding this comment

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

This PR looks unfinished.

Comment on lines 261 to 262
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.

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?

* Generate link titles for ATTACH URIs.
*
* @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.

Comment on lines 58 to 59
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

@@ -55,9 +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))
Copy link
Member

Choose a reason for hiding this comment

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

This is wrong. You need XML escaping because you're printing the value below in HTML.

* Fixed indents
* Fixed documentation
* Fixed the ClassEditSheet.xml call.
@vmassol
Copy link
Member

vmassol commented Mar 29, 2023

Please add to the jira issue the exact WCAG problem (link to it) + mention if it's auto detected by Axe core or not, and if not, do we need to define a best practice for developers to avoid regressing on this (or other use cases) in the future.

* @version $Id$
* @since 15.3RC1
*/
@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.

public String generateCreateTitle(ResourceReference reference)
{
DocumentReference documentReference =
this.currentDocumentReferenceResolver.resolve(reference.getReference());
Copy link
Member

@vmassol vmassol Mar 29, 2023

Choose a reason for hiding this comment

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

This will only work for DocumentResourceReference and for other types, it'll cause a bug. For example SpaceResourceReference references won't be resolved correctly. Same problem for a page ResourceReference.

Sereza7 and others added 3 commits March 31, 2023 13:13
* Added implementations for other resource reference types.
* Changed the l10n key names to be more specific

TODO:
* Fix tests
* Fixed the title on the wrong object in ClassEditSheet.xml
* Took care of different cases in XWikiAttachmentWantedLinkTitleGenerator and XWikiDocumentWantedLinkTitleGenerator
Copy link
Contributor

@michitux michitux left a comment

Choose a reason for hiding this comment

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

There is one missing escaping (see comment). I'm not 100% sure regarding the different resolver implementations but it looks good.

@@ -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 = $services.localization.render('core.create.inline.label',[$reference.name]))
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing escaping (either here or where it is used).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 45a7315

@Sereza7 Sereza7 marked this pull request as draft May 30, 2023 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants