Page MenuHomePhabricator

Allow linking to specific statements in Structured data on Commons
Closed, ResolvedPublic

Description

On Wikidata you can have a link like https://www.wikidata.org/wiki/Q56051850#P6216 that links to P6216 property of Q56051850 item. On Commons link like https://commons.wikimedia.org/wiki/File:Arbeiderswoning_Oostwold_4.jpg#P6216 should also link to P6216 property of Arbeiderswoning_Oostwold_4.jpg file.

COVID-19 Deployment Criteria

  • Can you roll back this change without lasting impact?
    1. A recovery plan is required as this will help identify our capacity for recovering from the failure
    2. THIS IS A KEY QUESTION, if you can’t answer it, you shouldn’t deploy
  • Probably it can be simply rolled back without any impact other than a bit of cache pollution.
  • Is specialized knowledge required to support this change in production? If so, are there multiple people with this knowledge?
  • Not required. This is a nice-to-have on the one hand, and used by on-wiki module on the other hand. The nice-to-have part doesn’t require any support; the module change is ready and already deployed.
  • Is there a way to increase confidence about the correctness of this change?
    1. Reviews (Design, Code, etc)
    2. Testing coverage (unit tests, integration tests)
    3. Manual testing (e.g. Beta, vagrant, docker)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

In T222321 @dcausse also thought we should have

direct reference to a particular statement (like the statement id anchor on wikibase entity e.g. https://www.wikidata.org/wiki/Q1#Q1$8983b0ea-4a9c-0902-c0db-785db33f767c)

I would like to have it so if an infobox pulls some informatio from SDC than I would like to add an edit icon to it, which when clicked would lead to the statement where the information come from.

In the next version of {{information}} template we are planning to add SDC icons to fields which were filled by information from SDC. I think those icons should link to properties where the data is stored. Can we at least agree, if we are going to be able to link to specific properties and if so what would be the format? The actual implementation can follow later. That way I can add it to the next release. I am trying to have only occasional updates to template used on 50+ M pages.

@matthiasmullie if I recall correctly, we talked about this a while ago and there was a problem with using anchor tags because of the tab on the file page. Does that sound familiar? Any way we might be able to work around this?

Correct: we can't rely on default browser behaviour of scrolling to anchors, because the content is hidden.
But we can implement a similar behavior on our own.

@Jarekt would you want to link to the specific statement (i.e. File:Something.jpg#M63$b81f5051-4288-a4d9-cc31-ba8b200b5e0e - the statement's GUID), or just the property level (i.e. File:Something.jpg#P180 or something similar)

I would also say possibility to set language in the URL is important as default is english and many WD objects miss english label and you get just a Q number which is a mess

  1. Property level with a language parameter eg. File:Something.jpg?uselang=zh#P180 compare WD Q1231009?uselang=zh#P608 and fallback language en

@Jarekt would you want to link to the specific statement (i.e. File:Something.jpg#M63$b81f5051-4288-a4d9-cc31-ba8b200b5e0e - the statement's GUID), or just the property level (i.e. File:Something.jpg#P180 or something similar)

What I need is property level links (i.e. File:Something.jpg#P180)

Example:
{{Information}} template in this file looks like

Screenshot_2020-03-03 File Midsummer Sunset at Underhoull, Shetland Islands, Great Britain - geograph org uk - 6000005 jpg [...].png (182×839 px, 19 KB)

and most fields, like author, date, source, etc., are not set in wikitext but in SDC. The template has SDC icons to the right of field names, like source, and I would like this icon to link to SDC's P7482, since that is the place where source info can be modified. On Wikidata such link would be done by adding "#P7482" to the page url, so ideally the link would be File:Something.jpg#P7482.

Correct: we can't rely on default browser behaviour of scrolling to anchors, because the content is hidden.
But we can implement a similar behavior on our own.

But we should add an HTML ID, even if it doesn’t work on its own in the default experience: in the JavaScript-less experience, the custom JS won’t do anything, but there aren’t any tabs, either, so the anchor-based solution does work. (And the anchor can be used in the custom JS as well, by the way.)

Change 583091 had a related patch set uploaded (by Matthias Mullie; owner: Matthias Mullie):
[mediawiki/extensions/WikibaseMediaInfo@master] Allow linking to specific statements

https://gerrit.wikimedia.org/r/583091

Change 583091 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Allow linking to specific statements

https://gerrit.wikimedia.org/r/583091

@Ramsey-WMF - I looked at the anchors on e.g. https://commons.wikimedia.beta.wmflabs.org/wiki/File:Lion_fountain_statue.png (Structured data tab), and there are only few anchors. No anchors for added property, e.g. d:Special:EntityPage/P740 (athe "coordinate location" property on the page and on the screenshot:

Screen Shot 2020-04-15 at 5.01.48 PM.png (509×920 px, 75 KB)

As per comment https://phabricator.wikimedia.org/T241338#5939601, the summary does have anchors:

Screen Shot 2020-04-15 at 5.02.06 PM.png (502×1 px, 83 KB)

Comparing the link form the task description - https://www.wikidata.org/wiki/Q56051850#P6216 - the anchor is also outlined and each property on the page will its anchor link.

Screen Shot 2020-04-15 at 5.18.32 PM.png (646×1 px, 100 KB)

I noticed that this is deployed now. That is great! Two questions:

  • I thing the anchor to captions is "#ooui-php-4". Is that going to be true for all the files? Is there some better name for it? And if not, can we rename it to something like "#captions"?
  • As @Etonkovidova mentioned above, links to Wikidata properties are nicely outlined. Can we do the same on Commons? Without the outline it is hard to tell which property are we were linking to.

Checked in production (test-commons.wiki, commonswiki - wmf.28) - @Ramsey - there are two things for review and please let me know if some follow-up ticket(s) are needed (along with @Jarekt 's comment above) :

  • the statements get anchors (not qualifiers where the properties are present too) - which was the scope of this task
betalabs commons wmf.28
Screen Shot 2020-04-16 at 9.37.28 PM.png (342×1 px, 48 KB)
Screen Shot 2020-04-16 at 9.45.03 PM.png (561×969 px, 125 KB)

That’s most probably just a cache issue, which will go away as caches expire—https://commons.wikimedia.org/wiki/File:18-as_villamos_(4097).jpg#P1259 didn’t work either, but a purge (action=purge) fixed it. (By the way, it jumps quite a lot up and down as all the JavaScript stuff loads, but that’s another task.)

That’s most probably just a cache issue, which will go away as caches expire—https://commons.wikimedia.org/wiki/File:18-as_villamos_(4097).jpg#P1259 didn’t work either, but a purge (action=purge) fixed it. (By the way, it jumps quite a lot up and down as all the JavaScript stuff loads, but that’s another task.)

@Tacsipacsi - you're right; re-checked and all seems to be fine with anchoring old statements. And yes, there is an issue with loading the page (showing the File information page, showing the fields in the Edit mode etc). The animated gif below (click to see it running) illustrate the page reload:

re-Load_page_issue.gif (678×957 px, 270 KB)

Thanks, everyone. I think the original task in this ticket is addressed and working on production. But the new issues that were brought up now have their own separate tasks set up as subtasks of this one.