Documentation for this module may be created at Module:Story info/doc
local getArgs = require('Module:Arguments').getArgs
local icons = require('Module:Icons')._main
local utils = require('Module:Utilities')
local p = {}
local function formatCharacters(characters)
local characterArr = utils.split(characters, ',')
local resArr = {}
for i,v in ipairs(characterArr) do
table.insert(resArr, icons({ v, size = '40px' }))
end
return table.concat(resArr, " ")
end
function p.main(frame)
local args = getArgs(frame)
local root = mw.html.create()
local box_css = {
['color'] = '#424362',
['margin'] = '20px 3px 20px 0',
['border'] = '2px solid #00cdba',
['border-radius'] = '10px',
['box-shadow'] = '2px 3px #00cdba',
['padding'] = '20px'
}
local image = ''
local title = string.format(
"'''%s: %s'''",
utils.editIfNil(args['chapter']),
utils.editIfNil(args['english'])
)
if args['japanese'] or args['romaji'] then
title = title .. string.format(
"<br>'''%s (%s)'''",
utils.editIfNil(args['japanese']),
utils.editIfNil(args['romaji'])
)
end
local top = root:tag('div')
:css(box_css)
:css({
['display'] = 'flex',
['flex-wrap'] = 'wrap',
['gap'] = '20px',
['justify-content'] = 'center'
})
:tag('div')
:css({
['align-self'] = 'center',
['width'] = '280px',
['text-align'] = 'center'
})
:wikitext(utils.editIfNil(
args['image'],
function (img)
return string.format(
'[[File:%s|280px|center]]',
img
)
end
))
:done()
:tag('div')
:css({
['flex-grow'] = 1,
['text-align'] = 'center',
})
:tag('div')
:css({
['border-bottom'] = '1px solid #00cdba',
['border-top-right-radius'] = '6px',
['color'] = '#424362',
['padding-bottom'] = '10px'
})
:wikitext(title)
:done()
:tag('div')
:css({
['color'] = '#424362',
['line-height'] = '2',
['padding-top'] = '10px'
})
:wikitext(
string.format(
"'''Characters that appear:'''<br/> %s",
utils.editIfNil(
args['characters'],
formatCharacters
)
)
)
:done()
:done()
:done()
local bottom = root:tag('div')
:css(box_css)
:css({
['display'] = 'grid',
['grid-template-columns'] = 'repeat(2, 1fr)',
['gap'] = '10px'
})
:tag('div'):css('text-align', 'right'):wikitext("'''Translator(s):'''"):done()
:tag('div'):wikitext(utils.editIfNil(args['translator'])):done()
:tag('div'):css('text-align', 'right'):wikitext("'''Source(s):'''"):done()
:tag('div'):wikitext(utils.editIfNil(args['source'])):done()
:done()
return tostring(root)
end
return p