Page MenuHomePhabricator

Add support for linking to a particular statement
Closed, ResolvedPublic

Description

Currently, you can link to the statement group for a particular property (e. g. https://www.wikidata.org/wiki/Q42#P31), but not to a particular statement. Adding support for this would be useful for:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 29 2017, 2:15 PM

The simplest fix for this is trivial:

diff --git a/view/resources/templates.php b/view/resources/templates.php
index 5efe5bd65..5da5e66e7 100644
--- a/view/resources/templates.php
+++ b/view/resources/templates.php
@@ -90,7 +90,7 @@
 
 	$templates['wikibase-statementview'] =
 <<<HTML
-<div class="wikibase-statementview wikibase-statement-$1 wb-$2">
+<div id="$1" class="wikibase-statementview wikibase-statement-$1 wb-$2">
 	<div class="wikibase-statementview-rankselector">$3</div>
 	<div class="wikibase-statementview-mainsnak-container">
 		<div class="wikibase-statementview-mainsnak" dir="auto"><!-- wikibase-snakview -->$4</div>

HTML5 allows any characters in the id attribute, including $. MDN warns against this because it wasn’t allowed in HTML4, but does anyone know what old browsers do in that case? As long as they don’t crash, I’m not convinced this is something we need to watch out for.

Change 440850 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Add statement ID as id attribute to statements

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

Ladsgroup moved this task from incoming to in progress on the Wikidata board.
Ladsgroup edited projects, added Wikidata-Campsite; removed Patch-For-Review.
Ladsgroup moved this task from Incoming to Test (Verification) on the Wikidata-Campsite board.

Change 440850 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add statement ID as id attribute to statements

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

Could you give an example link please? (A bit hard to test :D)
Also: Does this work fine with several statement sections on the same page potentially having the same statement like on Lexemes)?

Thanks! I guess it is not rolled out on Wikidata yet?

Marsupium added a subscriber: Marsupium.

Change 445977 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Link to constraint statement instead of statement group

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

Change 445977 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Link to constraint statement instead of statement group

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

@Lucas_Werkmeister_WMDE Just a question for the announcement: how people are supposed to generate the link? Is there something clickable somewhere? How are they supposed to find out the part at the end of the URL?

I don’t think we have anything to make that easy for the moment :/ you can get statement IDs from the query service, but we haven’t updated the redirect yet to make use of this feature.

Personally, when I want to link to a statement, I use the browser’s dev tools to copy the statement ID, but that’s not a good answer for the announcement :/

you can get statement IDs from the query service

Well, that's a start :) Can you build an example of query that I can share?

Hm… how about a query that also showcases T172380: Query constraint violations with WDQS? :)

Some mandatory constraint violations:

SELECT ?constraintTypeLabel ?statementLink WHERE {
  ?statement wikibase:hasViolationForConstraint ?constraint.
  ?constraint ps:P2302 ?constraintType;
              pq:P2316 wd:Q21502408.
  BIND(IRI(REPLACE(STR(?statement), "http://www.wikidata.org/entity/statement/(.*)-([^-]*-[^-]*-[^-]*-[^-]*-[^-]*)", "https://www.wikidata.org/wiki/Special:EntityPage/$1#$1\\$$2")) AS ?statementLink)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
LIMIT 10

The BIND(… AS ?statementLink) is the ugly part – ideally, the statement IRI would directly redirect you to the link including anchor, so that you end up at the right statement, but that’s not implemented yet.

Lydia_Pintscher closed this task as Resolved.Aug 9 2018, 1:06 PM