Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
MediaWiki help
Creopedia
Search
Search
Appearance
Log in
Personal tools
Log in
View source for Module:Location/Components/Infobox
Module
Discussion
English
Read
View source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
View source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
←
Module:Location/Components/Infobox
require( 'strict' ) local DIRECTIONS = { 'north', 'east', 'south', 'west' } local infoboxLua = require( 'Module:InfoboxLua' ) local buttonLua = require( 'Module:ButtonLua' ) local p = {} --- @param dir string --- @param location string --- @return mw.html|nil local function getConnectionHtml( dir, location ) if not location then return nil end local html = mw.html.create( 'div' ) html :addClass( 't-location-infobox-connections-item' ) :addClass( 't-location-infobox-connections-item--' .. dir ) :wikitext( buttonLua.render( { label = location, link = location } ) ) return html end --- @param args table --- @return string local function getConnections( args ) local html = mw.html.create( 'div' ):addClass( 't-location-infobox-connections' ) html:node( getConnectionHtml( 'current', args.name ) ) for _, dir in ipairs( DIRECTIONS ) do local connectionHtml = getConnectionHtml( dir, args[dir] ) if connectionHtml then html:node( connectionHtml ) end end return tostring( html ) end --- @param args table --- @return string|nil local function getMap( args ) if not args.map then return nil end local html = mw.html.create( 'div' ):addClass( 't-location-infobox-map' ) html:wikitext( string.format( '[[File:%s|320px]]', args.map ) ) return tostring( html ) end --- Build the infobox data needed from the raw data --- --- @param context table --- @return table local function getInfoboxData( context ) local args = context.args or {} return { title = args.name, subtitle = args.region, image = args.image, sections = { { content = getConnections( args ) }, { content = getMap( args ) } } } end --- @param context ComponentContext --- @return string function p.render( context ) return infoboxLua.render( getInfoboxData( context ) ) end return p
Templates used on this page:
Template:Documentation
(
view source
)
Module:Location/Components/Infobox/doc
(
view source
)
Return to
Module:Location/Components/Infobox
.