(Створена сторінка: require( 'strict' ) local Village = {} local metatable = {} local methodtable = {} metatable.__index = methodtable local common = require( 'Module:Common' ) local hatnote = require( 'Module:Hatnote' )._hatnote --- Create the infobox function methodtable.getInfobox( self ) local infobox = require( 'Module:InfoboxNeue' ):new( { placeholderImage = config.placeholder_image } ) local tabber = require( 'Module:Tabber' ).renderTabber sectionTabl...) |
Немає опису редагування |
||
| Рядок 54: | Рядок 54: | ||
infobox:renderSection( { | infobox:renderSection( { | ||
title = frame.args["назывка"], | title = frame.args["назывка"], | ||
subtitle = frame.args[" | subtitle = frame.args["пуднаголовок"], | ||
content = table.concat( sectionTable ) | content = table.concat( sectionTable ) | ||
} ) | } ) | ||
end | |||
--- Set the frame and load args | |||
--- @param frame table | |||
function methodtable.setFrame( self, frame ) | |||
self.currentFrame = frame | |||
self.frameArgs = require( 'Module:Arguments' ).getArgs( frame ) | |||
end | |||
--- New Instance | |||
function Village.new( self ) | |||
local instance = { | |||
categories = {} | |||
} | |||
setmetatable( instance, metatable ) | |||
return instance | |||
end | |||
--- Generates an infobox based on passed frame args and SMW data | |||
--- | |||
--- @param frame table Invocation frame | |||
--- @return string | |||
function Village.infobox( frame ) | |||
local instance = Village:new() | |||
instance:setFrame( frame ) | |||
local debugOutput = '' | |||
if instance.frameArgs[ 'debug' ] ~= nil then | |||
debugOutput = instance:makeDebugOutput() | |||
end | |||
return tostring( instance:getInfobox() ) .. debugOutput | |||
end | |||
--- "Main" entry point for templates that saves the API Data and outputs the infobox | |||
--- | |||
--- @param frame table Invocation frame | |||
--- @return string | |||
function Village.main( frame ) | |||
local instance = Village:new() | |||
instance:setFrame( frame ) | |||
instance:saveApiData() | |||
local debugOutput = '' | |||
if instance.frameArgs[ 'debug' ] ~= nil then | |||
debugOutput = instance:makeDebugOutput() | |||
end | |||
local infobox = tostring( instance:getInfobox() ) | |||
return infobox .. debugOutput .. table.concat( instance.categories ) | |||
end | end | ||
Ревізія 01:58, 18 октовбра 2023
Документацію для цього модуля можна створити у Модуль:Village/документація
require( 'strict' )
local Village = {}
local metatable = {}
local methodtable = {}
metatable.__index = methodtable
local common = require( 'Module:Common' )
local hatnote = require( 'Module:Hatnote' )._hatnote
--- Create the infobox
function methodtable.getInfobox( self )
local infobox = require( 'Module:InfoboxNeue' ):new( {
placeholderImage = config.placeholder_image
} )
local tabber = require( 'Module:Tabber' ).renderTabber
sectionTable = {
infobox:renderItem( {
label = 'Населеня',
data = frame.args["населеня"],
row = true,
spacebetween = true
} ),
infobox:renderItem( {
label = 'Коордінаты',
data = frame.args["коордінаты"],
row = true,
spacebetween = true
} ),
infobox:renderItem( {
label = 'Природна зона',
data = frame.args["природна зона"],
row = true,
spacebetween = true
} ),
infobox:renderItem( {
label = 'Закладеноє',
data = frame.args["закладеноє"],
row = true,
spacebetween = true
} ),
infobox:renderItem( {
label = 'Голова',
data = frame.args["голова"],
row = true,
spacebetween = true
} )
}
-- Create section with items
infobox:renderSection( {
title = frame.args["назывка"],
subtitle = frame.args["пуднаголовок"],
content = table.concat( sectionTable )
} )
end
--- Set the frame and load args
--- @param frame table
function methodtable.setFrame( self, frame )
self.currentFrame = frame
self.frameArgs = require( 'Module:Arguments' ).getArgs( frame )
end
--- New Instance
function Village.new( self )
local instance = {
categories = {}
}
setmetatable( instance, metatable )
return instance
end
--- Generates an infobox based on passed frame args and SMW data
---
--- @param frame table Invocation frame
--- @return string
function Village.infobox( frame )
local instance = Village:new()
instance:setFrame( frame )
local debugOutput = ''
if instance.frameArgs[ 'debug' ] ~= nil then
debugOutput = instance:makeDebugOutput()
end
return tostring( instance:getInfobox() ) .. debugOutput
end
--- "Main" entry point for templates that saves the API Data and outputs the infobox
---
--- @param frame table Invocation frame
--- @return string
function Village.main( frame )
local instance = Village:new()
instance:setFrame( frame )
instance:saveApiData()
local debugOutput = ''
if instance.frameArgs[ 'debug' ] ~= nil then
debugOutput = instance:makeDebugOutput()
end
local infobox = tostring( instance:getInfobox() )
return infobox .. debugOutput .. table.concat( instance.categories )
end