-
Notifications
You must be signed in to change notification settings - Fork 202
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
Include xml in frontend attribution options #4499
Include xml in frontend attribution options #4499
Conversation
b446fab
to
a9c2b40
Compare
Hi @sarayourfriend your suggestions have been resolved. However, I see that playwright visual regression tests continue to fail, I'm not exactly sure how to go about updating them, I've looked at the docs referenced by the bot on playwright but it's not exactly clear how to come up with the new comparison screenshots e.t.c. I'd appreciate if I could get a step by step instruction on how to tackle this. |
@madewithkode here's a hack I've used in the past which can avoid the need to run the VR tests locally. Go to the workflow summary page https://github.com/WordPress/openverse/actions/runs/9564951682 and look for the artifacts named |
@madewithkode here are instructions for updating snapshots in tests: https://docs.openverse.org/frontend/guides/test.html#updating-snapshots. Run We should probably combine that document with the one the bot links in its comment. I've long struggled to know what the precise difference was between reference and guides in our docs, and it's often muddied things up a bit like it has here. Sorry for the confusion there. Here's an issue to fix that problem with the docs: #4514 |
Thanks @dhruvkb for the quick hack, going to try it out and hope it works, as running playwright locally appears to be a bit resource-intensive for me. @sarayourfriend Thanks for pointing to the actual documentation too and I totally agree that the information shared by the bot can really be improved to include the actual steps needed for updating snapshots. I might as well take up #4514 to fix this after this one is done. |
7306fda
to
fbfa4c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, thank you @madewithkode!
I do want to flag a concern for our designer @fcoveram: this change makes some of the tab labels occupy two lines on mobile instead of one. Here is an example:
Do you think that looks okay, or should we change the design a bit, perhaps reducing the font size slightly on mobile or some other change? It doesn't have to happen in this PR in my opinion, but is something we could fix later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a bit of a small suggestion which will, unfortunately, necessitate new snapshots for Arabic. Mostly everything else looks fine and I would've approved the PR except for this change.
0238d00
to
d2c080e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a number of snapshots in the PR that are the same before and after, like the audio search and error pages, because they do not have the attribution box. The snapshot tests will likely still pass if these files are dropped from the PR.
I have a minor nit that seems okay to ignore.
if (isXml) { | ||
isPlaintext = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might just be me, but this conflation of XML with plain text causes a bit of mental gymnastics in the logic below. I feel like using isXml
and isPlaintext
separately would've been clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we bypass the plaintext handling if we just use mediaItem.attribution
, too, by the way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could work, and it would cut down on the code the frontend duplicates from the API, but I'm not sure about localisation though. The frontend is capable of localising the attribution text in a way the API is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah true 😕 In that case, should we undo the change from this comment before merging? #4499 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't a simple revert will be adequate. I'm personally not well versed with the i18n situation of the attribution box and feel like looking into what currently happens (and I expect should happen) will need a bit of time. Part of that's because I'm not entirely sure if XML, which is more geared towards machines than people, should even be translated.
I was only referring to the rich and plain text versions, which should be translated imo and using mediaItem.attribution
is definitely not enough for the latter of those two types of attribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zackkrida suggested using just the license URL, and the DC standard recommendation matches that too:
Typically, rights information includes a statement about various property rights associated with the resource, including intellectual property rights. Recommended practice is to refer to a rights statement with a URI. If this is not possible or feasible, a literal value (name, label, or short text) may be provided.
Then we don't need to worry about i18n at all for this (ideal!).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@madewithkode would you be able to update this to use the license URL instead of the attribution text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhruvkb this would mean just switching <dc:rights>${mediaItem.attribution}</dc:rights>
in the XML attribution snippet to reference the CC license URL as in <dc:rights>${mediaItem.license_url}</dc:rights>
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reversing the snapshots that had not been changed, I feel like this PR is good to go.
Thanks for the contribution @madewithkode! This is a very valuable feature and your implementation has been very clear and thorough.
I would follow the common practice of replacing with a dropdown element. Tailwind addresses this pretty well. |
That's a great (and simple) idea, @fcoveram. I'll make a follow up issue for that! |
8d1062c
to
2c5e141
Compare
@madewithkode I pushed a change to revert some unneeded snapshot updates as well as to fix a bug I realised with unescaped elements in the title and other work meta data. Some works would have had broken XML due to unescaped XML (or XML-like) text. Take this work, for example, where the creator's included their email in their username: https://openverse.org/image/7be0e5cb-6308-4c11-b397-38baf2d0a4e7 The XML generated without escaping it (which is caused by setting <attribution xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:creator>Photographer: Richard Ling <wikipedia@rling.com></dc:creator>
<dc:title>Grey Nurse Shark at Fish Rock Cave, NSW</dc:title>
<dc:rights>https://creativecommons.org/licenses/by-sa/3.0/</dc:rights>
<dc:identifier>https://commons.wikimedia.org/w/index.php?curid=130380</dc:identifier>
<dc:type>StillImage</dc:type>
</attribution> That won't pass XML validation. Fix was easy though, just removed the lines setting I'm also rebasing and re-running the snapshot tests to fix the conflicts for you. |
2c5e141
to
ab61eb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you for the changes and for spotting this edge case @sarayourfriend |
Thanks for your hard work, @madewithkode 🙏 |
Fixes
Fixes #4430 by @midijohnny!
Description
This PR seeks to add an extra Dublin-Core-Conforming XML attribution option on the frontend, allowing users to be able to credit creators in XML.
Testing Instructions
This change can be observed by visiting the detail page of any media item on Openverse, under the "Credit the creator" section, you should see an extra XML option.
Checklist
Update index.md
).main
) or a parent feature branch.just catalog/generate-docs
for catalogPRs) or the media properties generator (
just catalog/generate-docs media-props
for the catalog or
just api/generate-docs
for the API) where applicable.Developer Certificate of Origin
Developer Certificate of Origin