Wikipedia:Lua/Modul/Vorlage:Seitenbewertung/en
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):
Value | Result | current |
---|---|---|
nothingfalse
|
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.
|
|
wikidata
|
version ID of global upstream
|
»2022-10-19« |
item
|
ID of the Wikidata item
|
Q114773646
|
~
|
Corresponding version ID locally and registered at Wikidata
|
»« |
@
|
Is the current (module) page linked correctly with Wikidata item?
|
|
The return value is in template programming empty or under Lua false , otherwis a non-empty string as described.
|
Rendering
[Quelltext bearbeiten]From features
a page is transcluded, which receives the following parameters; with arbitrary examples:
subject=
local page namelinked=1
iflink=1
but not itselfspace=2em
px=18
long=1
q17437796=1
– excellentq17437798=1
– good articleq17506997=1
– informative listq17580674=1
– informative portalsite=
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 orfalse
nsTransclude
– numbersTransclude
– string (mandatory)link
– booleanlong
– booleanpx
– numberspace
– stringsite
– string
- arglist – table, with all options similar template transclusion
- 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)
- ask – string, with local page name (optional), or
- Returns: boolean
- BadgesQuery.failsafe( atleast )
- Version management
- Returns: string oder
false
Dependencies
[Quelltext bearbeiten]None.