Content added Content deleted
mNo edit summary |
(do not hide japanese, romaji, english if empty) |
||
Line 87: | Line 87: | ||
{ tag = 'th', content = 'Japanese', colspan = 12 }, |
{ tag = 'th', content = 'Japanese', colspan = 12 }, |
||
{ tag = 'argtd', content = 'japanese', colspan = 18 } |
{ tag = 'argtd', content = 'japanese', colspan = 18 } |
||
} |
} |
||
{ hideIfEmpty = { 'japanese' } } |
|||
) |
) |
||
:addRow( |
:addRow( |
||
Line 94: | Line 93: | ||
{ tag = 'th', content = 'Romaji', colspan = 12 }, |
{ tag = 'th', content = 'Romaji', colspan = 12 }, |
||
{ tag = 'argtd', content = 'romaji', colspan = 18 } |
{ tag = 'argtd', content = 'romaji', colspan = 18 } |
||
} |
} |
||
{ hideIfEmpty = { 'romaji' } } |
|||
) |
) |
||
:addRow( |
:addRow( |
||
Line 101: | Line 99: | ||
{ tag = 'th', content = 'English', colspan = 12 }, |
{ tag = 'th', content = 'English', colspan = 12 }, |
||
{ tag = 'argtd', content = 'english', colspan = 18 } |
{ tag = 'argtd', content = 'english', colspan = 18 } |
||
} |
} |
||
{ hideIfEmpty = { 'english' } } |
|||
) |
) |
||
:addHeader({ tag = 'th', content = 'Unit'}) |
:addHeader({ tag = 'th', content = 'Unit'}) |
Revision as of 04:19, 3 July 2021
This module depends on the following other modules: |
To generate {{Infobox character}}, invoke using the main function.
--------------------------
-- Module for [[Template:Infobox Character]]
------------------------
local builder = require('Module:InfoboxBuilder')
local p = {}
local categories = ""
-- https://stackoverflow.com/questions/1426954/split-string-in-lua
local function split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
local function formatImage(image_name)
return string.format("[[File:%s|x300px]]", image_name)
end
local function formatUnit(unit)
local units = {
vs = { image = 'Virtualsingerlogo.png', link = 'VIRTUAL SINGER' },
ln = { image = 'Leoneedlogo.png', link = 'Leo/need' },
mmj = { image = 'MMJ_logo.png', link = 'MORE MORE JUMP!'},
vbs = { image = 'Vivid_logo.png', link = 'Vivid BAD SQUAD'},
wxs = { image = 'Wonderlandsxswowtimelogo.png', link = 'Wonderlands×Showtime' },
['25ji'] = { image = '25ji-logo.png', link = '25-ji, Night Code de.' }
}
if units[unit] then
return string.format("[[File:%s|150px|link=%s]]",
units[unit].image,
units[unit].link)
end
return nil
end
local function breakLine(arg)
if arg and arg ~= '' then
return table.concat(split(arg, "\n"), "<br>")
else
return "<br>"
end
end
function p.main(frame)
local args = frame:getParent().args
local infobox = builder.new();
infobox:setName('Infobox Group')
:setWidth("330px")
infobox:setParams{
{ name = 'character name', default = mw.title.getCurrentTitle().text },
{ name = 'character image', func = formatImage },
{ name = 'japanese' },
{ name = 'romaji' },
{ name = 'english' },
{ name = 'unit', func = formatUnit },
{ name = 'position' },
{ name = 'gender' },
{ name = 'birthday' },
{ name = 'height' },
{ name = 'school', func = breakLine },
{ name = 'hobbies', func = breakLine },
{ name = 'talents', func = breakLine },
{ name = 'dislikes', func = breakLine },
{ name = 'seiyuu' }
}
infobox
:setArgs(args)
infobox
:addHeader({ tag = 'argth', content = 'character name' })
:addImage{{ tag = 'argtd', content = 'character 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 }
}
)
:addRow(
{
{ tag = 'th', content = 'English', colspan = 12 },
{ tag = 'argtd', content = 'english', colspan = 18 }
}
)
:addHeader({ tag = 'th', content = 'Unit'})
:addImage{{ tag = 'argtd', content = 'unit' }}
:addRow(
{
{ tag = 'th', content = 'Position', colspan = 12 },
{ tag = 'argtd', content = 'position', colspan = 18 }
},
{ hideIfEmpty = { 'position' } }
)
:addHeader({ tag = 'th', content = 'Profile' })
:addRow(
{
{ tag = 'th', content = 'Gender', colspan = 12 },
{ tag = 'argtd', content = 'gender', colspan = 18 }
}
)
:addRow(
{
{ tag = 'th', content = 'Birthday', colspan = 12 },
{ tag = 'argtd', content = 'birthday', colspan = 18 }
}
)
:addRow(
{
{ tag = 'th', content = 'Height', colspan = 12 },
{ tag = 'argtd', content = 'height', colspan = 18 }
}
)
:addRow(
{
{ tag = 'th', content = 'School', colspan = 12 },
{ tag = 'argtd', content = 'school', colspan = 18 }
},
{ hideIfEmpty = { 'school' } }
)
:addRow(
{
{ tag = 'th', content = 'Hobbies', colspan = 12 },
{ tag = 'argtd', content = 'hobbies', colspan = 18 }
},
{ hideIfEmpty = { 'hobbies' } }
)
:addRow(
{
{ tag = 'th', content = 'Talents', colspan = 12 },
{ tag = 'argtd', content = 'talents', colspan = 18 }
},
{ hideIfEmpty = { 'talents' } }
)
:addRow(
{
{ tag = 'th', content = 'Dislikes', colspan = 12 },
{ tag = 'argtd', content = 'dislikes', colspan = 18 }
},
{ hideIfEmpty = { 'dislikes' } }
)
:addRow(
{
{ tag = 'th', content = 'Image Color', colspan = 12 },
{ tag = 'argtd', content = 'bg color', colspan = 18 }
}
)
:addRow(
{
{ tag = 'th', content = 'Seiyuu', colspan = 12 },
{ tag = 'argtd', content = 'seiyuu', colspan = 18 }
}
)
if mw.title.getCurrentTitle().namespace == 0 then
categories = "[[Category:Characters]]" .. categories
end
return infobox:tostring() .. categories
end
return p