Module:Infobox story

From Sekaipedia
Revision as of 21:06, 15 August 2021 by ChaoticShadow (talk | contribs) (created infobox story)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

To generate {{Infobox story}}, invoke using the main function.


--------------------------
-- Module for [[Template:Infobox Story]]
------------------------
local getArgs   = require('Module:Arguments').getArgs
local builder   = require('Module:InfoboxBuilder')

local p = {}

local function formatImage(image_name)
	return string.format("[[File:%s|220px]]", image_name)
end


function p.main(frame)
	local args = getArgs(frame)
	local infobox = builder.new()
	
	infobox:setName('Infobox Story')
		:setWidth("330px")
		:setParams{
			{ name = 'story name', default = mw.title.getCurrentTitle().text },
			{ name = 'image', func = formatImage },
			{ name = 'japanese' },
			{ name = 'romaji' },
			{ name = 'chapters' },
			{ name = 'translators' },
			{ name = 'groups' },
			{ name = 'characters' },
		}
		:setArgs(args)
		:setHeaderColors({
			['background-color'] = '#00cdba',
			['color'] = '#000'
		})

	infobox
		:addHeader({ tag = 'argth', content = 'story name' })
		:addImage({
			{ tag = 'argtd', content = 'image' },
		})
		:addRow({
			{ tag = 'th', content = 'Japanese', colspan = 12 },
			{ tag = 'argtd', content = 'japanese', colspan = 18 }
		})
		:addRow({
			{ tag = 'th', content = 'Romaji', colspan = 12 },
			{ tag = 'argtd', content = 'romaji', colspan = 18 }
		})
		:addHeader({ tag = 'th', content = 'Story Information' }, { subheader = true })
		:addRow({
			{ tag = 'th', content = 'Chapters', colspan = 12 },
			{ tag = 'argtd', content = 'chapters', colspan = 18 }
		})
		:addRow({
			{ tag = 'th', content = 'Translators', colspan = 12 },
			{ tag = 'argtd', content = 'translators', colspan = 18 }
		})
		:addRow({
			{ tag = 'th', content = 'Groups', colspan = 12 },
			{ tag = 'argtd', content = 'groups', colspan = 18 }
		})
		:addRow({
			{ tag = 'th', content = 'Characters', colspan = 12 },
			{ tag = 'argtd', content = 'characters', colspan = 18 }
		})

	return infobox:tostring()
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.