Page MenuHomePhabricator

Add Wikidata and Wikimedia Commons links to work page
Open, Needs TriagePublicFeature

Assigned To
None
Authored By
Pepe_piton
Oct 9 2025, 11:05 PM
Referenced Files
Restricted File
Mon, Oct 13, 8:08 PM
Restricted File
Mon, Oct 13, 3:07 PM
F66740637: Screen Shot 2025-10-10 at 1.17.24 AM.png
Oct 10 2025, 12:18 AM
F66740635: Screen Shot 2025-10-10 at 1.12.51 AM.png
Oct 10 2025, 12:18 AM
F66740631: Screen Shot 2025-10-10 at 1.13.05 AM.png
Oct 10 2025, 12:18 AM
F66740600: example-of-how-to-show-links.png
Oct 9 2025, 11:05 PM
F66740599: work-links-before.png
Oct 9 2025, 11:05 PM

Description

Feature summary: The goal of this task is to add the Wikidata and Wikimedia Commons links to the upper section of the work page. Currently, this section only displays the Wikipedia link. For instance:

work-links-before.png (275×592 px, 82 KB)

This task adds the Wikidata and Wikimedia Commons links (if they exist) to the work page, so they are shown in that upper section similarly to how the links are shown on the author page.

example-of-how-to-show-links.png (306×721 px, 109 KB)

Benefits: This feature will give users more options to navigate Wikimedia projects and learn more about the works.

Event Timeline

Hi @Pepe_piton

I have fixed this issue.

See the before:

Screen Shot 2025-10-10 at 1.13.05 AM.png (902×2 px, 492 KB)

See the after:

Screen Shot 2025-10-10 at 1.12.51 AM.png (902×2 px, 502 KB)

Screen Shot 2025-10-10 at 1.17.24 AM.png (902×2 px, 268 KB)

Here is the merge request
https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/23

Hi @Pepe_piton

I have completed the microtask, tested locally, and it works as expected. Screenshots are included, and a Merge Request has been submitted for review and feedback.

‎Merge Request link: https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/67

@Pepe_piton Here is a link to my Merge Request for this task: https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/68
Key Changes
pdclasses.py:

  • Implemented logic in the Work.init method to safely extract the Wikimedia Commons sitelink URL from the raw Wikidata item data (sitelinks['commonswiki']).

work.html:

  • Introduced new conditional blocks to display the Wikidata (work_wikidata_link) and Wikimedia Commons (work_commons_link) links.
  • Refactored the display style for all project links (Wikidata, Wikipedia, Commons) to remove icons and use a pipe (|) separator for a clean, compact inline list.
  • Used Jinja's whitespace control ({%- and -%}) to eliminate unwanted spacing, ensuring the pipe separator is correctly formatted with only a single space on either side.

app.py

  • The work_page view function is updated to pass the two new properties, work_commons_link and work_wikidata_link, from the instantiated Work object into the template context.

{F66747845}

@Oluwatumininu.m Thanks for your contribution! You managed to place the Wikidata link very well. However, with your current solution, the Wikimedia Commons link isn't displayed. This is because the work.html template doesn't receive a variable named "work_commons_link." For a clue on how to resolve this issue, it might be helpful to revisit the task of adding the "inception" field to the work page: T406949

@Nurah_Wakili The same thing happens with your solution as with that of @Oluwatumininu.m. For the Wikimedia Commons link to work, some changes need to be made to some other files.

@Lebogang Good job. You've managed to grasp the logic of the task, finding a way to add the link to Wikimedia Commons. It works well! As a side note, it's possible to simplify the if statements in the work.html template to correctly display the vertical bar symbol ("|"), given that the Wikidata link is present in 100% of works (if there's no Wikidata link, the item doesn't exist). You can see a simpler way of building the wikilink if statements in the author.html template.
By the way, some changes from the terms task were included in the MR diff, but it was easy to identify the changes corresponding to this task, so don't worry.

@Kimondorose The merge request link didn't appear in your message. Can you share it again?

@Oluwatumininu.m Thanks for your contribution! You managed to place the Wikidata link very well. However, with your current solution, the Wikimedia Commons link isn't displayed. This is because the work.html template doesn't receive a variable named "work_commons_link." For a clue on how to resolve this issue, it might be helpful to revisit the task of adding the "inception" field to the work page: T406949

@Nurah_Wakili The same thing happens with your solution as with that of @Oluwatumininu.m. For the Wikimedia Commons link to work, some changes need to be made to some other files.

@Lebogang Good job. You've managed to grasp the logic of the task, finding a way to add the link to Wikimedia Commons. It works well! As a side note, it's possible to simplify the if statements in the work.html template to correctly display the vertical bar symbol ("|"), given that the Wikidata link is present in 100% of works (if there's no Wikidata link, the item doesn't exist). You can see a simpler way of building the wikilink if statements in the author.html template.
By the way, some changes from the terms task were included in the MR diff, but it was easy to identify the changes corresponding to this task, so don't worry.

@Kimondorose The merge request link didn't appear in your message. Can you share it again?

@Pepe_piton Here is the link to my Merge Request: https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/68 I have also updated it in my original comment.

Excellent @Kimondorose! Your solution works well and you understood the logic. Anyway, you might be interested in reading the comment I left for @Lebogang , since there are slightly simpler conditional solutions for adding the vertical bar separator in the template.

@Oluwatumininu.m Thanks for your contribution! You managed to place the Wikidata link very well. However, with your current solution, the Wikimedia Commons link isn't displayed. This is because the work.html template doesn't receive a variable named "work_commons_link." For a clue on how to resolve this issue, it might be helpful to revisit the task of adding the "inception" field to the work page: T406949

Thank you so much for the feedback! I have made changes and a new commit. Here is the link: https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/23/commits

The Wikimedia Commons link now displays correctly.
{F66748307}

Hello @Pepe_piton , Thank you so much for your feedback. I have made the changes to fix the issue with getting the Wikicommons link.

Kindly review the updated MR: https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/24.

Thank you.

Hellooo everyone!

I have completed this task!
I very much enjoyed navigating through the different files and learning more about how the data is travelling between each files.

Please find attached my Merge Request for this microtask.

Looking forward for any feedback, comments, area of improvements from you @Nat_WDU and @Pepe_piton .

Best regards,
Farmata.

As a side note, it's possible to simplify the if statements in the work.html template to correctly display the vertical bar symbol ("|"), given that the Wikidata link is present in 100% of works (if there's no Wikidata link, the item doesn't exist). You can see a simpler way of building the wikilink if statements in the author.html template.

Oups! Thank you for that comment @Pepe_piton, I just realised that I might have some separator lying around…

I need to fix this first thing in the morning 👍

Edit: I have updated my code, here is the link to the updated Merge Request! Placing the separator has been a bit challenging... I reordered the links to first have Wikidata, then Wikipedia, then Wikimedia Commons... This seems to be working so far. What do you think? I will try and see if I can find a better solution

@Lebogang Good job. You've managed to grasp the logic of the task, finding a way to add the link to Wikimedia Commons. It works well! As a side note, it's possible to simplify the if statements in the work.html template to correctly display the vertical bar symbol ("|"), given that the Wikidata link is present in 100% of works (if there's no Wikidata link, the item doesn't exist). You can see a simpler way of building the wikilink if statements in the author.html template.
By the way, some changes from the terms task were included in the MR diff, but it was easy to identify the changes corresponding to this task, so don't worry.

@Pepe_piton Thanks for the feedback! I have simplified the link logic as suggested, and I will make sure to keep future MRs isolated to the relevant task changes.

Excellent @Kimondorose! Your solution works well and you understood the logic. Anyway, you might be interested in reading the comment I left for @Lebogang , since there are slightly simpler conditional solutions for adding the vertical bar separator in the template.

Thank you @Pepe_piton for the feedback. I will look at how to simplify the vertical bar separator addition.

Good evening @Pepe_piton, @Nat_WDU and @DidiCoronel
i made a merge request related this issue:-https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/154
Changes made:-
Updated pdclasses.py to fetch Wikimedia Commons link.
Updated app.py to pass commons link to the template.
Updated work.html to display Wikidata, Wikipedia, and Wikimedia Commons links.

Please review when you have time and share any feedback — thank you!