Wikipedia:Lua/Modul/Vorlage:Seitenbewertung/en

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen
Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch English

Modul: Dokumentation

BadgesQuery – Module to query badges registered on Wikidata.

Functions for templates[Quelltext bearbeiten]

features
Present (linked) page, may be decorated with badges
Parameters of #invoke; optional if not explicitly requested:
1
Local page name, to retrieve badge
Default: current page
nsTransclude
Namespace number of a transcluded page for rendering
Default: 10 – “Template”
sTransclude
title of a transcluded page for rendering (mandatory)
link
1 – link page name
long
1 – exhaustive presentation
px
Number of pixels of an icon
space
CSS width distance between page name and badges
site
Site ID of a Wiki, where the badges of that page shall be retrieved which is connected to the local page name
Default: local site (dewiki)
Returns: Wikitext for linked page, may be decorated with badges
fulfils
Test badge requirement
Parameters of #invoke:
1
Local page name, to retrieve badges
Default: current page
match
Space separated list of item numbers to test registration
site
Site ID of a Wiki, where the badges of that page shall be retrieved which is connected to the local page name
Default: local site (dewiki)
Returns: 1 if registered badge, otherwise empty
failsafe
Version management: 2022-10-19

The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to

  • ensure, that a library module required by a template or another module available as local copy does support certain functionality, or complain if not.
  • administrate global updating and linking of module codes via Wikidata.

The Failsafe interface is present both at template level and for direct Lua access.

The functions in detail are (not all supported yet completely by every library):

Parameter
Value Result current
nothing
false
local version ID »2022-10-19«
Minimal version version ID required at least
date in ISO format

It will be compared whether the current local implementation matches this version or later.

  • empty, if minimal version not achieved
  • 2001-01-01 → »2022-10-19«
  • 2099-01-01 → »«
wikidata version ID of global upstream
  • version ID at Wikidata
  • local, if not found there
»2022-10-19«
item ID of the Wikidata item
  • empty if not defined
  • Q114773646
~ Corresponding version ID locally and registered at Wikidata
  • empty, if up to date
  • version ID at Wikidata, if not equal
»«
@ Is the current (module) page linked correctly with Wikidata item?
  • empty, if linked to the item which is supposed
  • Iitem ID, if not
»Q114773646«
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described.

From features a page is transcluded, which receives the following parameters; with arbitrary examples:

  • subject=local page name
  • linked=1 if link=1 but not itself
  • space=2em
  • px=18
  • long=1
  • q17437796=1 – excellent
  • q17437798=1 – good article
  • q17506997=1 – informative list
  • q17580674=1 – informative portal
  • site=

Functions for Lua modules (API)[Quelltext bearbeiten]

The functions described above can be used by other modules per require() :

local lucky, BadgesQuery = pcall( require, "Module:Vorlage:Seitenbewertung" )
if type( BadgesQuery ) == "table" then
    BadgesQuery = BadgesQuery()
else
    -- failure; BadgesQuery is the error message
    return "<span class=\"error\">" .. BadgesQuery .. "</span>"
end

Then there is available:

BadgesQuery.features( arglist, frame )
  • arglist – table, with all options similar template transclusion
    • subject – local page name, string or false
    • nsTranscludenumber
    • sTranscludestring (mandatory)
    • linkboolean
    • longboolean
    • pxnumber
    • spacestring
    • sitestring
Returns: string with wikitext
BadgesQuery.fulfils( ask, array, another )
  • ask – string, with local page name (optional), or false
  • array – sequence table, with number elements of badge item codes
  • another – string, with foreign site ID (optional)
Returns: boolean
BadgesQuery.failsafe( atleast )
Version management
Returns: string oder false

Dependencies[Quelltext bearbeiten]

None.