317
редагувань
(Створена сторінка: 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...) |
Немає опису редагування |
||
| (Не показано 12 проміжних версій цього користувача) | |||
| Рядок 10: | Рядок 10: | ||
local common = require( 'Module:Common' ) | local common = require( 'Module:Common' ) | ||
local hatnote = require( 'Module:Hatnote' )._hatnote | local hatnote = require( 'Module:Hatnote' )._hatnote | ||
--- 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 | |||
--- Create the infobox | --- Create the infobox | ||
function methodtable.getInfobox( self ) | function methodtable.getInfobox( self, frame ) | ||
local infobox = require( 'Module:InfoboxNeue' ):new( { | local infobox = require( 'Module:InfoboxNeue' ):new( { | ||
placeholderImage = | placeholderImage = '' | ||
} ) | } ) | ||
local tabber = require( 'Module:Tabber' ).renderTabber | local tabber = require( 'Module:Tabber' ).renderTabber | ||
sectionTable = { | local sectionTable = { | ||
infobox:renderItem( { | infobox:renderItem( { | ||
label = 'Населеня', | label = 'Населеня', | ||
data = | data = self.frameArgs["населеня"], | ||
row = true, | row = true, | ||
spacebetween = true | spacebetween = true | ||
| Рядок 27: | Рядок 34: | ||
infobox:renderItem( { | infobox:renderItem( { | ||
label = 'Коордінаты', | label = 'Коордінаты', | ||
data = | data = self.frameArgs["коордінаты"], | ||
row = true, | row = true, | ||
spacebetween = true | spacebetween = true | ||
| Рядок 33: | Рядок 40: | ||
infobox:renderItem( { | infobox:renderItem( { | ||
label = 'Природна зона', | label = 'Природна зона', | ||
data = | data = self.frameArgs["природна зона"], | ||
row = true, | row = true, | ||
spacebetween = true | spacebetween = true | ||
| Рядок 39: | Рядок 46: | ||
infobox:renderItem( { | infobox:renderItem( { | ||
label = 'Закладеноє', | label = 'Закладеноє', | ||
data = | data = self.frameArgs["закладеноє"], | ||
row = true, | row = true, | ||
spacebetween = true | spacebetween = true | ||
| Рядок 45: | Рядок 52: | ||
infobox:renderItem( { | infobox:renderItem( { | ||
label = 'Голова', | label = 'Голова', | ||
data = | data = self.frameArgs["голова"], | ||
row = true, | row = true, | ||
spacebetween = true | spacebetween = true | ||
| Рядок 53: | Рядок 60: | ||
-- Create section with items | -- Create section with items | ||
infobox:renderSection( { | infobox:renderSection( { | ||
title = | title = self.frameArgs["назывка"], | ||
subtitle = | subtitle = self.frameArgs["тіп"], | ||
content = table.concat( sectionTable ) | content = table.concat( sectionTable ) | ||
} ) | } ) | ||
end | 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 ) | |||
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 | |||
return Village | |||