Page MenuHomePhabricator

Pretty print for link to projects in Wikidata Query UI results
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):
For Wikimedia commons images, when seen in table format query result or other, a link to the image is displayed as ":commons:…". It could be great to have the same kind of features to better display links to projects such as "en:Victor Hugo" as compared to https://en.wikipedia.org/wiki/Victor_Hugo that it is now.

Alternatively, or as another option, the query service should provide a way to compute a label, which could be displayed as a HTML link "<a href="https://en.wikipedia.org/wiki/Victor_Hugo">?articleLabel</a>" where ?articleLabel is the variable name of the computed value

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
When Wikidata query is used to display results about a wikiproject, for a replacement of categories. The full link url are not very pretty and do not give an idea of the title of the link.

What triggers the ticket : writing the query https://w.wiki/8tqp to provide an alternative to someone who wanted to create a category "person with a puppet representing him" (searching a name for the category, see this discussion. A Wikidata query is perfect for such a usecase. There are many other one.

Benefits (why should this be implemented?):
It would provide better looking results for users, increasing the probability that Wikidata is considered an alternative to the Category system when relevant. It would also save space while displaying results by avoiding text redundancy in the results, while allowing user to easily go back to their home wiki.

Event Timeline

The image grid view, and (I think) most (all?) other non-table result views, already support using a ?somethingLabel variable as the text for a ?something link: adjusted puppets query (edit: note that the ?somethingLabel doesn’t have to come from the label service – here, I’m getting the title of the article via schema:name, see RDF Dump Format § Sitelinks)

For the table view, see T150937 for custom labels.

Automatically shortening https://en.wikipedia.org/wiki/Victor_Hugo to “en:Victor Hugo” is an interesting idea that I don’t remember being proposed before… though it has the problem that en: is ambiguous between English Wikipedia, English Wikibooks, English Wikisource, etc. (which isn’t a problem for commons:).

The ambiguity could be solved by using the standard wikimedia prefixes "w:en:Victor Hugo", this works as a wikilink. A bit obscure for a lot of course, but … An icon as for commons could help, a tooltip too.

"enwiki:Victor Hugo" would also work.

Automatically shortening https://en.wikipedia.org/wiki/Victor_Hugo to “en:Victor Hugo” is an interesting idea that I don’t remember being proposed before… though it has the problem that en: is ambiguous between English Wikipedia, English Wikibooks, English Wikisource, etc. (which isn’t a problem for commons:).

Commons would have a different problem: commons: is specifically for filenames (the values of Commons media statements).

More generally, I don't think we should use something which looks like an RDF prefix unless it actually is a defined RDF prefix. commons: is already confusing for me, I keep trying to do things like replace(str(?image), str(commons:), "") to remove the prefix and get the actual value of the statement, which fails because commons: isn't a real prefix.

Making use of prefixes would be useful though. If it used the prefixes which have been defined when displaying results, then people could define any they want. It would be really useful for federated queries too (e.g. the first link under "World" on https://www.wikidata.org/wiki/User:Nikki/TGN defines tgn: but the results still display the full URI)

It would actually make sense to add prefix like "commons:" into the default prefix.

I have also used the technique to define a prefix like "fr: https://fr.wikipedia.org/ when manually wrinting stuff like "?article schema:isPartOf fr:" and that actually works. This does not however with ":w:fr" unfortunately.