Main components:
- Wikibase-Lua
User story:
As a Wikipedia template editor / Lua programmer, I want to find the badges a specific Wikipedia article has using Lua in order to use it in my Lua module and template.
Problem:
Getting information about badges using Lua is currently possible, but it requires loading the whole entity. This is problematic in some items as it can cause Lua errors (e.g. needs too much memory).
Solution:
Add a Lua convenience function getBadges (similar to getSitelink).
See: https://doc.wikimedia.org/Wikibase/master/php/docs_topics_lua.html#mw.wikibase.getSitelink
This would be run similarly to the 'getSitelink' i.e.
-- @param {string} itemId -- @param {string} [globalSiteId] function wikibase.getBadges( itemId, globalSiteId )
and the return value is a Lua table (with numeric indices), containing zero or more badges (identified by the corresponding badge QID).
The globalSiteID can remain empty and this will default to the local wiki.
BDD:
GIVEN a Wikipedia article
AND a Wikidata Item has sitelinks with badges for this article
WHEN a Lua 'getBadges' convenience function is run
THEN a Lua table with the QIDs of the badges is returned
Acceptance criteria:
- A Lua 'getBadges' convenience function is available
- mark the function as expensive, unless we can figure out a fast way to retrieve the badges
- Wikibade: Lua page is updated with the information on how the 'getBadges' convenience function will operate
Notes
For engineers, you need to have:
- Scribunto extension installed
- configure at least one badge
- Configure a Lua console to call this function
See P43183 for example LocalSettings.php configurations