Module:Infobox character/sandbox: Difference between revisions

From Sekaipedia
Content added Content deleted
mNo edit summary
No edit summary
Line 49: Line 49:
local infobox = InfoboxBuilder.new();
local infobox = InfoboxBuilder.new();
return mw.dump(args)
infobox:setName('Infobox character')
:setParams{
{ name = 'character name', default = mw.title.getCurrentTitle().text },
{ name = 'character image' },
{ name = 'japanese' },
{ name = 'romaji' },
{ name = 'english' },
{ name = 'unit' },
{ name = 'position' },
{ name = 'gender' },
{ name = 'birthday' },
{ name = 'height' },
{ name = 'school', fn = ProcessingFunctions.convertStringToArray('\n') },
{ name = 'hobbies', fn = ProcessingFunctions.convertStringToArray('\n') },
{ name = 'talents', fn = ProcessingFunctions.convertStringToArray('\n') },
{ name = 'dislikes', fn = ProcessingFunctions.convertStringToArray('\n') },
{ name = 'bad at', fn = ProcessingFunctions.convertStringToArray('\n') },
{ name = 'color' },
{ name = 'seiyuu', fn = ProcessingFunctions.convertStringToArray('\n') }
}
:setArgs(args)
:processArgs()
-- infobox:setName('Infobox character')
if args['color'] and args['color'] ~= '' then
-- :setParams{
infobox:setHeaderBackgroundColor(args['color'])
-- { name = 'character name', default = mw.title.getCurrentTitle().text },
end
-- { name = 'character image' },
-- { name = 'japanese' },
-- { name = 'romaji' },
-- { name = 'english' },
-- { name = 'unit' },
-- { name = 'position' },
-- { name = 'gender' },
-- { name = 'birthday' },
-- { name = 'height' },
-- { name = 'school', fn = ProcessingFunctions.convertStringToArray('\n') },
-- { name = 'hobbies', fn = ProcessingFunctions.convertStringToArray('\n') },
-- { name = 'talents', fn = ProcessingFunctions.convertStringToArray('\n') },
-- { name = 'dislikes', fn = ProcessingFunctions.convertStringToArray('\n') },
-- { name = 'bad at', fn = ProcessingFunctions.convertStringToArray('\n') },
-- { name = 'color' },
-- { name = 'seiyuu', fn = ProcessingFunctions.convertStringToArray('\n') }
-- }
-- :setArgs(args)
-- :processArgs()
-- if args['color'] and args['color'] ~= '' then
-- infobox:setHeaderBackgroundColor(args['color'])
-- end


infobox
-- infobox
:addHeader({ tag = 'argth', content = 'character name' })
-- :addHeader({ tag = 'argth', content = 'character name' })
:addImage{{
-- :addImage{{
tag = 'argtd',
-- tag = 'argtd',
content = 'character image',
-- content = 'character image',
fn = DisplayFunctions.generateImage('315px')
-- fn = DisplayFunctions.generateImage('315px')
}}
-- }}
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Japanese' },
-- { tag = 'th', content = 'Japanese' },
{ tag = 'argtd', content = 'japanese' }
-- { tag = 'argtd', content = 'japanese' }
}
-- }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Romaji' },
-- { tag = 'th', content = 'Romaji' },
{ tag = 'argtd', content = 'romaji' }
-- { tag = 'argtd', content = 'romaji' }
}
-- }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'English' },
-- { tag = 'th', content = 'English' },
{ tag = 'argtd', content = 'english' }
-- { tag = 'argtd', content = 'english' }
}
-- }
)
-- )
:addHeader({ tag = 'th', content = 'Unit'}, { subheader = true })
-- :addHeader({ tag = 'th', content = 'Unit'}, { subheader = true })
:addImage{{
-- :addImage{{
tag = 'argtd',
-- tag = 'argtd',
content = 'unit',
-- content = 'unit',
fn = formatUnit
-- fn = formatUnit
}}
-- }}
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Position' },
-- { tag = 'th', content = 'Position' },
{ tag = 'argtd', content = 'position' }
-- { tag = 'argtd', content = 'position' }
},
-- },
{ hideIfEmpty = { 'position' } }
-- { hideIfEmpty = { 'position' } }
)
-- )
:addHeader({ tag = 'th', content = 'Profile' }, { subheader = true })
-- :addHeader({ tag = 'th', content = 'Profile' }, { subheader = true })
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Gender' },
-- { tag = 'th', content = 'Gender' },
{ tag = 'argtd', content = 'gender' }
-- { tag = 'argtd', content = 'gender' }
}
-- }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Birthday' },
-- { tag = 'th', content = 'Birthday' },
{ tag = 'argtd', content = 'birthday' }
-- { tag = 'argtd', content = 'birthday' }
}
-- }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Height' },
-- { tag = 'th', content = 'Height' },
{ tag = 'argtd', content = 'height' }
-- { tag = 'argtd', content = 'height' }
}
-- }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'School' },
-- { tag = 'th', content = 'School' },
{ tag = 'argtd', content = 'school', fn = displayList }
-- { tag = 'argtd', content = 'school', fn = displayList }
},
-- },
{ hideIfEmpty = { 'school' } }
-- { hideIfEmpty = { 'school' } }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Hobbies' },
-- { tag = 'th', content = 'Hobbies' },
{ tag = 'argtd', content = 'hobbies', fn = DisplayFunctions.generateList('unbulleted') }
-- { tag = 'argtd', content = 'hobbies', fn = DisplayFunctions.generateList('unbulleted') }
},
-- },
{ hideIfEmpty = { 'hobbies' } }
-- { hideIfEmpty = { 'hobbies' } }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Talents' },
-- { tag = 'th', content = 'Talents' },
{ tag = 'argtd', content = 'talents', fn = DisplayFunctions.generateList('unbulleted') }
-- { tag = 'argtd', content = 'talents', fn = DisplayFunctions.generateList('unbulleted') }
},
-- },
{ hideIfEmpty = { 'talents' } }
-- { hideIfEmpty = { 'talents' } }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Dislikes' },
-- { tag = 'th', content = 'Dislikes' },
{ tag = 'argtd', content = 'dislikes', fn = DisplayFunctions.generateList('unbulleted') }
-- { tag = 'argtd', content = 'dislikes', fn = DisplayFunctions.generateList('unbulleted') }
},
-- },
{ hideIfEmpty = { 'dislikes' } }
-- { hideIfEmpty = { 'dislikes' } }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Bad at' },
-- { tag = 'th', content = 'Bad at' },
{ tag = 'argtd', content = 'bad at', fn = DisplayFunctions.generateList('unbulleted') }
-- { tag = 'argtd', content = 'bad at', fn = DisplayFunctions.generateList('unbulleted') }
},
-- },
{ hideIfEmpty = { 'bad at' } }
-- { hideIfEmpty = { 'bad at' } }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Image color' },
-- { tag = 'th', content = 'Image color' },
{ tag = 'argtd', content = 'color', fn = formatColor }
-- { tag = 'argtd', content = 'color', fn = formatColor }
}
-- }
)
-- )
:addRow(
-- :addRow(
{
-- {
{ tag = 'th', content = 'Seiyuu' },
-- { tag = 'th', content = 'Seiyuu' },
{ tag = 'argtd', content = 'seiyuu', fn = DisplayFunctions.generateList('unbulleted') }
-- { tag = 'argtd', content = 'seiyuu', fn = DisplayFunctions.generateList('unbulleted') }
}
-- }
)
-- )
local categories = ""
-- local categories = ""
if mw.title.getCurrentTitle().namespace == 0 then
-- if mw.title.getCurrentTitle().namespace == 0 then
categories = "[[Category:Characters]]" .. categories
-- categories = "[[Category:Characters]]" .. categories
end
-- end


return infobox:tostring() .. categories
-- return infobox:tostring() .. categories
end
end



Revision as of 21:49, 17 October 2022

Documentation for this module may be created at Module:Infobox character/sandbox/doc

--------------------------
-- Module for [[Template:Infobox character]]
------------------------
local getArgs   = require('Module:Arguments').getArgs
local InfoboxBuilder      = require('Module:InfoboxBuilder new')
local DisplayFunctions    = require('Module:InfoboxBuilderDisplayFunctions')
local ProcessingFunctions = require('Module:InfoboxBuilderProcessingFunctions')
local IB_NIL = require('Module:InfoboxBuilderNil')
local constants = require('Module:Constants')

local p = {}

local function formatUnit(unit)
	if unit and unit ~= IB_NIL then
		return string.format("[[File:%s|150px|link=%s]]",
			constants.get_unit_image(unit),
			constants.get_unit(unit))
	end
	
	return nil
end

local function formatColor(color)
	return string.format(
		"%s <span style=\"height: 10px; width: 10px; background: %s; display: inline-block;margin-left: 5px; border:1px solid;\"></span>",
		color,
		color
	);
end

local function displayList(list)
	if #list < 2 then
		return list[1]
	end
	
	local ul = mw.html.create('ul')
	
	for i=1,#list do
		ul:tag('li')
			:wikitext(list[i])
	end
	
	return tostring(ul)
end


function p.main(frame)
	local args = getArgs(frame)
	local infobox = InfoboxBuilder.new();
	
	return mw.dump(args)
	
	-- infobox:setName('Infobox character')
	-- 	:setParams{
	-- 		{ name = 'character name', default = mw.title.getCurrentTitle().text },
	-- 		{ name = 'character image' },
	-- 		{ name = 'japanese' },
	-- 		{ name = 'romaji' },
	-- 		{ name = 'english' },
	-- 		{ name = 'unit' },
	-- 		{ name = 'position' },
	-- 		{ name = 'gender' },
	-- 		{ name = 'birthday' },
	-- 		{ name = 'height' },
	-- 		{ name = 'school', fn = ProcessingFunctions.convertStringToArray('\n') },
	-- 		{ name = 'hobbies', fn = ProcessingFunctions.convertStringToArray('\n') },
	-- 		{ name = 'talents', fn = ProcessingFunctions.convertStringToArray('\n') },
	-- 		{ name = 'dislikes', fn = ProcessingFunctions.convertStringToArray('\n') },
	-- 		{ name = 'bad at', fn = ProcessingFunctions.convertStringToArray('\n') },
	-- 		{ name = 'color' },
	-- 		{ name = 'seiyuu', fn = ProcessingFunctions.convertStringToArray('\n') }
	-- 	}
	-- 	:setArgs(args)
	-- 	:processArgs()
	
	-- if args['color'] and args['color'] ~= '' then
	-- 	infobox:setHeaderBackgroundColor(args['color'])
	-- end

	-- infobox
	-- 	:addHeader({ tag = 'argth', content = 'character name' })
	-- 	:addImage{{
	-- 		tag = 'argtd',
	-- 		content = 'character image',
	-- 		fn = DisplayFunctions.generateImage('315px')
	-- 	}}
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Japanese' },
	-- 			{ tag = 'argtd', content = 'japanese' }
	-- 		}
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Romaji' },
	-- 			{ tag = 'argtd', content = 'romaji' }
	-- 		}
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'English' },
	-- 			{ tag = 'argtd', content = 'english' }
	-- 		}
	-- 	)
	-- 	:addHeader({ tag = 'th', content = 'Unit'}, { subheader = true })
	-- 	:addImage{{
	-- 		tag = 'argtd',
	-- 		content = 'unit',
	-- 		fn = formatUnit
	-- 	}}
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Position' },
	-- 			{ tag = 'argtd', content = 'position' }
	-- 		},
	-- 		{ hideIfEmpty = { 'position' } }
	-- 	)
	-- 	:addHeader({ tag = 'th', content = 'Profile' }, { subheader = true })
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Gender' },
	-- 			{ tag = 'argtd', content = 'gender' }
	-- 		}
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Birthday' },
	-- 			{ tag = 'argtd', content = 'birthday' }
	-- 		}
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Height' },
	-- 			{ tag = 'argtd', content = 'height' }
	-- 		}
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'School' },
	-- 			{ tag = 'argtd', content = 'school', fn = displayList }
	-- 		},
	-- 		{ hideIfEmpty = { 'school' } }
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Hobbies' },
	-- 			{ tag = 'argtd', content = 'hobbies', fn = DisplayFunctions.generateList('unbulleted') }
	-- 		},
	-- 		{ hideIfEmpty = { 'hobbies' } }
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Talents' },
	-- 			{ tag = 'argtd', content = 'talents', fn = DisplayFunctions.generateList('unbulleted') }
	-- 		},
	-- 		{ hideIfEmpty = { 'talents' } }
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Dislikes' },
	-- 			{ tag = 'argtd', content = 'dislikes', fn = DisplayFunctions.generateList('unbulleted') }
	-- 		},
	-- 		{ hideIfEmpty = { 'dislikes' } }
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Bad at' },
	-- 			{ tag = 'argtd', content = 'bad at', fn = DisplayFunctions.generateList('unbulleted') }
	-- 		},
	-- 		{ hideIfEmpty = { 'bad at' } }
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Image color' },
	-- 			{ tag = 'argtd', content = 'color', fn = formatColor }
	-- 		}
	-- 	)
	-- 	:addRow(
	-- 		{
	-- 			{ tag = 'th', content = 'Seiyuu' },
	-- 			{ tag = 'argtd', content = 'seiyuu', fn = DisplayFunctions.generateList('unbulleted') }
	-- 		}
	-- 	)
		
	-- local categories = ""
	
	-- if mw.title.getCurrentTitle().namespace == 0 then
	-- 	categories = "[[Category:Characters]]" .. categories
	-- end

	-- return infobox:tostring() .. categories
end

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