Content added Content deleted
(use templatestyles) |
mNo edit summary |
||
Line 41: | Line 41: | ||
local root = mw.html.create('div') |
local root = mw.html.create('div') |
||
:addClass('story-chapter') |
:addClass('story-chapter') |
||
local box_css = { |
|||
['margin'] = '20px 3px 20px 0', |
|||
['border'] = '2px solid #00cdba', |
|||
['border-radius'] = '10px', |
|||
['box-shadow'] = '2px 3px #00cdba', |
|||
['padding'] = '20px' |
|||
} |
|||
box_css = {} |
|||
local image = '' |
local image = '' |
||
Line 68: | Line 59: | ||
local top = root:tag('div') |
local top = root:tag('div') |
||
:addClass('chapter-info') |
|||
:css(box_css) |
|||
:css({ |
|||
['display'] = 'flex', |
|||
['flex-wrap'] = 'wrap', |
|||
['gap'] = '20px', |
|||
['justify-content'] = 'center', |
|||
['flex'] = '3 1 400px' |
|||
}) |
|||
:tag('div') |
:tag('div') |
||
:css({ |
:css({ |
||
Line 124: | Line 108: | ||
local bottom = root:tag('div') |
local bottom = root:tag('div') |
||
:addClass('translation-info') |
|||
:css(box_css) |
|||
: |
:tag('div') |
||
:css('text-align', 'right') |
|||
⚫ | |||
['grid-template-columns'] = 'repeat(2, 1fr)', |
|||
:done() |
|||
['gap'] = '10px', |
|||
:tag('div') |
|||
['flex-basis'] = '300px' |
|||
⚫ | |||
}) |
|||
:done() |
|||
⚫ | |||
:tag('div') |
|||
⚫ | |||
:css('text-align', 'right') |
|||
:wikitext("'''Source(s):'''") |
|||
⚫ | |||
:done() |
|||
:tag('div') |
|||
⚫ | |||
:done() |
|||
:done() |
:done() |
||
Revision as of 08:18, 15 April 2022
Documentation for this module may be created at Module:Story info/doc
local getArgs = require('Module:Arguments').getArgs
local cicon = require('Module:Character icon')._main
local utils = require('Module:Utilities')
local p = {}
local function splitStringWithDelim(delim)
return function(str)
if str == nil then
return nil
end
local list = mw.text.split(str, delim)
for i=1,#list do
list[i] = mw.text.trim(list[i])
end
return list
end
end
local function formatCharacters(characters)
local characterArr = splitStringWithDelim(',')(characters)
local charArr = splitStringWithDelim(';')(characters)
local resArr = {}
for _,v in ipairs(characterArr) do
table.insert(resArr, cicon({ v, size = '40px' }))
end
for _,v in ipairs(charArr) do
table.insert(resArr, cicon({ v, size = '40px' }))
end
return table.concat(resArr, " ")
end
function p.main(frame)
local args = getArgs(frame)
local root = mw.html.create('div')
:addClass('story-chapter')
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')
:addClass('chapter-info')
: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',
['padding-bottom'] = '10px'
})
:wikitext(title)
:done()
:tag('div')
:css({
['line-height'] = '2',
['padding-top'] = '10px'
})
:wikitext(
string.format(
"'''Character appearances:'''<br/> %s",
utils.editIfNil(
args['characters'],
formatCharacters
)
)
)
:done()
:done()
:done()
local bottom = root:tag('div')
:addClass('translation-info')
: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
mw.getCurrentFrame():extensionTag{
name = 'templatestyles',
args = { src = 'Template:Story chapter/styles.css' }
} .. tostring(root)
end
return p