Page MenuHomePhabricator

Sitelink badges invisible on mobile Wikidata
Closed, ResolvedPublic5 Estimated Story Points

Authored By
Lucas_Werkmeister_WMDE
Dec 13 2022, 5:43 PM
Referenced Files
F36077087: image.png
Jan 9 2023, 4:31 PM
F36077085: image.png
Jan 9 2023, 4:31 PM
F36077081: image.png
Jan 9 2023, 4:31 PM
F36077079: image.png
Jan 9 2023, 4:31 PM
F35861875: image.png
Dec 13 2022, 5:43 PM
F35861873: image.png
Dec 13 2022, 5:43 PM
F35861870: image.png
Dec 13 2022, 5:43 PM

Description

As a Wikidata mobile user I want to see which sitelinks of an Item have badges in order to discern which is good, featured, problematic etc. articles and also have a seamless experience across desktop and mobile devices

Problem:
Currently, sitelinks are displayed inconsistently across desktop and mobile.

Desktop uses badges for sitelinks, whereas those badges do not appear on mobile making it more difficult to discern for users.

This is because the relevant stylesheets are contained in desktop-only ResourceLoader modules, badges are invisible in mobile views (though their markup exists in the HTML source).

Example:
Compare the badges on dewiki, enwiki,eswiki and frwiki on Mary Shelley on desktop and on mobile:

image.png (459×576 px, 49 KB)
image.png (421×336 px, 36 KB)

Compare Special:AvailableBadges on desktop and on mobile

image.png (534×936 px, 175 KB)

This only is displayed as a plain list on mobile:

image.png (560×968 px, 135 KB)

BDD
GIVEN a mobile user visits an Item
WHEN they view the sitelinks
THEN they can see the badges assigned to the sitelinks

GIVEN a mobile user visits the Special:AvailableBadges page
AND
WHEN they view the the page
AND
THEN they can see the icons for the badges as they appear on the desktop site

Acceptance criteria:

  • item pages on mobile show badges on sitelinks
  • Special:AvailableBadges on mobile shows the badges’ icons

Notes:

  • This task requires enabling the following extensions in your local dev environment:
    • Wikibase
    • WikimediaBadges
    • Wikidata.org

Event Timeline

Copying from what I wrote in that change:

I think we should be able to fix this fully, by splitting the required styles out of wikibase.common into some module that can also be loaded on mobile. (Not sure what it should be called yet, since “common” is already so generic ^^)

We could of course call the module something like “badges”, but I think as part of the larger work on T324723: Fix the most common "Module not loadable on target mobile" warnings (December 2022), we’ll probably want to move other styles into this all-targets module as well, so that’s why I would prefer a fairly generic name if we can think of a good one. (It’s possible that the current contents of wikibase.common should eventually all move into the all-targets module, but I think that needs to be done gradually, so at least for a while we’ll need both modules to coexist under different names.)

Hm, this is a bit trickier than I thought because wikibase.common is a style module loaded with addModuleStyles(), which has some additional restrictions (see docs): the styles are directly referenced from the parser cached HTML (which may live for longer than a train deployment), and dependencies aren’t resolved. So we can’t just add a new “all targets” module and add it as a dependency of wikibase.common: the relevant addModuleStyles() calls (at least the one in HtmlPageLinkRendererEndHookHandler, I think) need to add the new module to the list of modules, and also, wikibase.common still needs to directly include the old styles at least until all the HTML that doesn’t load the new module has fallen out of the parser cache.

However, the style reference in the parser cached HTML takes the form of a URL like /w/load.php?lang=en&modules=...|wikibase.common|... – it’s not referencing individual files in the module. So I think we can shuffle around the files inside the module definition as much as we want, and potentially include the same file from more than one module, and the worst that happens is that some styles are sent to the client twice. (I think.)

So we could have modules like:

  • wikibase.alltargets
    • badges
    • language fallback indicators
    • other “really common” stuff
  • wikibase.desktop (or wikibase.entityview?)
    • everything else in wikibase.less
    • all the other files in wikibase.common: aliasesview, descriptionview, etc.
  • wikibase.mobile
    • unchanged
  • wikibase.common
    • badges
    • language fallback indicator
    • other “really common” stuff
    • everything else in wikibase.less
    • all the other files in wikibase.common: aliasesview, descriptionview, etc.

This would effectively split the current wikibase.common module into styles that we want on all targets, and styles that we only want for the desktop entity view; but it would also keep wikibase.common around for now, with the same contents as before (effectively wikibase.alltargets + wikibase.desktop). We would update the code to emit the new modules instead of the old ones, and eventually all references to wikibase.common would fall out of the parser cache, at which point we could remove it from the ResourceLoader modules definition. Also, we could change several places that currently emit wikibase.common, but only need the “really common” stuff (especially language fallback indicators), to emit wikibase.alltargets but not wikibase.desktop: there’s no reason why, e.g. “undo” (T267502) or Special:NewLexeme (T322687) should need styles for aliasesview, descriptionview, etc., all of which are part of wikibase.common at the moment.

But this seems like a bit too much of a change to do all at once, to be honest, even with the wikibase.common module kept for now…

This task requires enabling the following extensions in your local dev environment:

  • Wikibase
  • WikimediaBadges
  • Wikidata.org

WikimediaBadges is responsible for adding badge icons on client wikis; Wikidata.org is responsible for adding them on repo wikis (specifically Wikidata). They need a configuration like this:

$wgWBRepoSettings['badgeItems'] = [
    'Q7' => 'wb-badge-featuredarticle', // styled by Wikidata.org                                                                                                                                                                                                                                                                                          
];
$wgWBClientSettings['badgeClassNames'] = [
    'Q7' => 'badge-featuredarticle', // styled by WikimediaBadges                                                                                                                                                                                                                                                                                          
];

Where Q7 is the item ID of a “featured article” badge on your local Wikibase. Notice that the CSS class is different (wb-badge-* vs. badge-*).

Within the context of this task, the “client” part is actually irrelevant, but it’s probably best to test it as well, just to make sure it doesn’t break.

Change 881891 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] WIP: Split wikibase.common into wikibase.alltargets + wikibase.desktop

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

So we could have modules like:

I sketched that out in the above WIP change, but I’d like to discuss this with someone else before going further down this road, so putting the task back into the unified backlog in the meantime (I’ll only be back on Wednesday).

Task breakdown notes:

  • The overall approach above seems to be okay so far.
  • We want to make sure the scope of this task stays limited – the split of RL modules needs to happen, but we limit the amount of styles that we extract from wikibase/wikibase.less (in the wikibase.common / wikibase.desktop modules) into the wikibase.alltargets module; follow-up tasks should be made to move more styles, and be estimated separately.
  • See T325084#8543759 for some local testing information.
  • Left to do: Finish the WIP patch mentioned above, update the ext.wikidata-org.badges module definition in Wikidata.org to also target mobile (and maybe leave a pointer to the new wikibase.alltargets module somewhere in the extension code?).

Change 883967 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Replace wikibase.common with wikibase.alltargets + wikibase.desktop

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

Change 883968 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] SpecialAvailableBadges: add wikibase.alltargets module

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

Change 883969 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseLexeme@master] Replace wikibase.common with wikibase.alltargets + wikibase.desktop

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

Change 883970 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikidata.org@master] Add badge styles on mobile as well

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

Hey @LucasWerkmeister we're planning to push ahead with modules defaulting to desktop and mobile next week after the branch cut as every week we delay this, we're risking more migration work and breakage. Evaluating the ext.wikidata-org.badges module, the risk seems low here: there seems no harm in loading this CSS on mobile, as after gzip it's minimal and none of the CSS applies to a mobile page. Reminder that https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikidata.org/+/867209/4/extension.json exists if you'd rather set this to desktop only and avoid that. Thanks in advance and thanks for all your help with this work so far.

Okay, that sounds alright to me – the impact of the module being loaded on mobile prematurely should be limited.

  • We want to make sure the scope of this task stays limited – the split of RL modules needs to happen, but we limit the amount of styles that we extract from wikibase/wikibase.less (in the wikibase.common / wikibase.desktop modules) into the wikibase.alltargets module; follow-up tasks should be made to move more styles, and be estimated separately.

T328150: Language fallback indicators still shown for variant fallbacks on mobile Wikidata

Change 881891 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Split wikibase.common into wikibase.alltargets + wikibase.desktop

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

Change 883967 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Replace wikibase.common with wikibase.alltargets + wikibase.desktop

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

Change 883969 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] Replace wikibase.common with wikibase.alltargets + wikibase.desktop

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

Change 883970 merged by jenkins-bot:

[mediawiki/extensions/Wikidata.org@master] Add badge styles on mobile as well

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

Change 883968 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] SpecialAvailableBadges: add wikibase.alltargets module

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

Should be ready to verify with next week’s train; I’ll make a separate subtask for removing the deprecated wikibase.common module (which will have to wait for wikibase.common to be gone from the parser cache, so at least one month).

Arian_Bozorg subscribed.

This looks all good to me!

Thanks so much :)