Content added Content deleted
No edit summary |
mNo edit summary |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
------------------------ |
------------------------ |
||
local getArgs = require('Module:Arguments').getArgs |
local getArgs = require('Module:Arguments').getArgs |
||
local InfoboxBuilder = require('Module:InfoboxBuilder |
local InfoboxBuilder = require('Module:InfoboxBuilder') |
||
local DisplayFns = require('Module: |
local DisplayFns = require('Module:DisplayFunctions') |
||
local ProcessingFns = require('Module: |
local ProcessingFns = require('Module:ProcessingFunctions') |
||
local constants = require('Module:Constants') |
local constants = require('Module:Constants') |
||
local cicon = require('Module:Character icon')._main |
local cicon = require('Module:Character icon')._main |
||
Line 12: | Line 12: | ||
local function formatCharacters(characters) |
local function formatCharacters(characters) |
||
if characters == nil then return nil end |
|||
local resArr = {} |
local resArr = {} |
||
for _, character in ipairs(characters) do |
for _, character in ipairs(characters) do |
||
Line 44: | Line 46: | ||
:setCategoryMap({ |
:setCategoryMap({ |
||
['type'] = { |
['type'] = { |
||
['main'] = 'Main |
['main'] = 'Main Stories', |
||
['event'] = 'Event stories', |
['event'] = 'Event stories', |
||
['special'] = 'Special Stories', |
|||
}, |
}, |
||
}) |
}) |
||
Line 89: | Line 92: | ||
tag = 'argth', |
tag = 'argth', |
||
content = 'involved unit', |
content = 'involved unit', |
||
fn = DisplayFns. |
fn = DisplayFns.pluralHeader({ 'Unit involved', 'Units involved' }) |
||
}, |
}, |
||
{ |
{ |
||
Line 103: | Line 106: | ||
tag = 'argth', |
tag = 'argth', |
||
content = 'character', |
content = 'character', |
||
fn = DisplayFns. |
fn = DisplayFns.pluralHeader({ 'Character', 'Characters' }) |
||
}, |
}, |
||
{ |
{ |
Latest revision as of 15:46, 28 December 2023
This module depends on the following other modules: |
To generate {{Infobox story}}, invoke using the main function.
--------------------------
-- Module for [[Template:Infobox story]]
------------------------
local getArgs = require('Module:Arguments').getArgs
local InfoboxBuilder = require('Module:InfoboxBuilder')
local DisplayFns = require('Module:DisplayFunctions')
local ProcessingFns = require('Module:ProcessingFunctions')
local constants = require('Module:Constants')
local cicon = require('Module:Character icon')._main
local p = {}
local function formatCharacters(characters)
if characters == nil then return nil end
local resArr = {}
for _, character in ipairs(characters) do
table.insert(resArr, cicon({ character, size = '30px' }))
end
return table.concat(resArr, " ")
end
function p.main(frame)
local args = getArgs(frame)
local infobox = InfoboxBuilder.new()
infobox:setName('Infobox story')
:setParams{
{ name = 'story name', default = mw.title.getCurrentTitle().text },
{ name = 'type', fn = string.lower },
{ name = 'image' },
{ name = 'japanese' },
{ name = 'romaji' },
{ name = 'chapters' },
{ name = 'key unit', fn = ProcessingFns.stringToArray(';') },
{ name = 'involved unit', fn = ProcessingFns.stringToArray(';') },
{ name = 'character', fn = ProcessingFns.stringToArray(',') },
{ name = 'translator', fn = ProcessingFns.stringToArray(',') },
{ name = 'proofreader', fn = ProcessingFns.stringToArray(',') },
{ name = 'source', fn = ProcessingFns.stringToArray(',') }
}
:setArgs(args)
:processArgs()
:setCategoryMap({
['type'] = {
['main'] = 'Main Stories',
['event'] = 'Event stories',
['special'] = 'Special Stories',
},
})
infobox
:addHeader({ tag = 'argth', content = 'story name' })
:addImage({
{ tag = 'argtd', content = 'image', fn = DisplayFns.image('220px') },
})
:addRow(
{
{ tag = 'th', content = 'Japanese' },
{ tag = 'argtd', content = 'japanese' }
},
{ hideIfEmpty = { 'japanese' } }
)
:addRow(
{
{ tag = 'th', content = 'Romaji' },
{ tag = 'argtd', content = 'romaji' }
},
{ hideIfEmpty = { 'romaji' } }
)
:addHeader({ tag = 'th', content = 'Story Information' }, { subheader = true })
:addRow({
{ tag = 'th', content = 'Chapters' },
{ tag = 'argtd', content = 'chapters' }
})
:addRow(
{
{ tag = 'th', content = 'Key unit' },
{
tag = 'argtd',
content = 'key unit',
fn = DisplayFns.list('unbulleted')
}
},
{ hideIfEmpty = { 'key unit' } }
)
:addRow(
{
{
tag = 'argth',
content = 'involved unit',
fn = DisplayFns.pluralHeader({ 'Unit involved', 'Units involved' })
},
{
tag = 'argtd',
content = 'involved unit',
fn = DisplayFns.list('unbulleted')
}
},
{ hideIfEmpty = { 'involved unit' } }
)
:addRow({
{
tag = 'argth',
content = 'character',
fn = DisplayFns.pluralHeader({ 'Character', 'Characters' })
},
{
tag = 'argtd',
content = 'character',
fn = formatCharacters
}
})
:addHeader({ tag = 'th', content = 'Translation Information' }, { subheader = true })
:addRow(
{
{
tag = 'argth',
content = 'translator',
fn = DisplayFns.pluralHeader({ 'Translator', 'Translators' })
},
{
tag = 'argtd',
content = 'translator',
fn = DisplayFns.list('unbulleted')
}
},
{ hideIfEmpty = { 'translator' } }
)
:addRow(
{
{
tag = 'argth',
content = 'proofreader',
fn = DisplayFns.pluralHeader({ 'Proofreader', 'Proofreaders' })
},
{
tag = 'argtd',
content = 'proofreader',
fn = DisplayFns.list('unbulleted')
}
},
{ hideIfEmpty = { 'proofreader' } }
)
:addRow({
{
tag = 'argth',
content = 'source',
fn = DisplayFns.pluralHeader({ 'Source', 'Sources' })
},
{
tag = 'argtd',
content = 'source',
fn = DisplayFns.list('unbulleted')
}
})
local categories = ""
if mw.title.getCurrentTitle().namespace == 0 then
categories = "[[Category:Stories]]" .. infobox:getCategories()
end
return infobox:tostring() .. categories
end
return p