Extension:ArticlePlaceholder/Module:AboutTopic
The ArticlePlaceholder extensions provides the option to override the functions used to render an entity to display it on a generated local page (placeholder).
The module Module:AboutTopic per default uses the entityRenderer provided by the ArticlePlaceholder extension. It is possible to use a custom entityRenderer or to overwrite each part of ArticlePlaceholder's entityRenderer separately.
The following diagram represents all available functions and their connections. The blue ovals are the functions provided by Wikibase Client's Lua Scribunto interface.
For every function in the graphic there are setters and getters. Following is the documentation of the default functions provided by the entityRenderer, the setter functions as well as a list of all getters. All setter functions take a function as parameter. The getter functions return a function.
Example
editIn case that all top images should be exchanged with a certain kitten image the topImageRenderer (see Default functions) would be overwritten using the function setTopImageRenderer (see Setter functions) and the module Module:AboutTopic would look like the following:
local p = {}
p.showData = function(frame)
entityRenderer = require( 'mw.ext.articlePlaceholder.entityRenderer' )
-- new function for the topImageRenderer, that returns a static image with the appropriate CSS class
local newTopImg = function()
return '<div class="articleplaceholder-topimage">[[File:Cute_grey_kitten.jpg|thumb|right|300px]]</div>'
end
-- set the new function to override the default topImageRenderer
entityRenderer.setTopImageRenderer( newTopImg )
return entityRenderer.render( frame )
end
return p
Default functions
editThe functions, that can be get and set in the Module:AboutTopic are depending on each other. Therefore it might be useful to read through the default functions' documentation when overwriting these.
- The
topImageRenderer( entity, propertyId, orientationImage )
renders the image on the top right (in left to right languages) and takes a table and two strings as arguments. It is one of the four functions the renderEntity() calls. statementListRenderer( entity )
: render a list of statements, takes a table as argumentidentifierListRenderer( entity )
: render a list of external identifier, takes a table as argumentdescriptionRenderer( entity )
: render the description of an item, takes an string as argumentbestStatementRenderer( entity, propertyId )
: render the best (preferred rank if present, otherwise all normal rank) statement, takes a table and a string as argumentstatementRenderer( statement )
: render a given statement, takes a table as argumentimageStatementRenderer( imageStatement, orientationImage )
: render a statement containing images, takes a table and a string as argumentsqualifierRenderer( qualifierSnak )
: render the qualifier of a statement, takes a table as argumentreferenceRenderer( references )
: render the references of a statement, takes a table as argumentlabelRenderer( entityId )
: render the labels of entities, takes a string as argumentsnaksRenderer( snaks )
: render the snaks, takes a table as argument
Setter functions
editsetTopImageRenderer( function )
setStatementListRenderer( function )
setIdentifierListRenderer( function )
setDescriptionRenderer( function )
setBestStatementRenderer( function )
setStatementRenderer( function )
setImageStatementRenderer( function )
setQualifierRenderer( function )
setReferenceRenderer( function )
setLabelRenderer( function )
setSnaksRenderer( function )
Getter functions
editgetTopImageRenderer()
getStatementListRenderer()
getIdentifierListRenderer()
getDescriptionRenderer()
getBestStatementRenderer()
getStatementRenderer()
getImageStatementRenderer()
getQualifierRenderer()
getReferenceRenderer()
getLabelRenderer()
getSnaksRenderer()