Content added Content deleted
(migrated to infoboxbuilder) |
(migrated to infoboxbuilder new) |
||
Line 3: | Line 3: | ||
------------------------ |
------------------------ |
||
local getArgs = require('Module:Arguments').getArgs |
local getArgs = require('Module:Arguments').getArgs |
||
local InfoboxBuilder |
local InfoboxBuilder = require('Module:InfoboxBuilder new') |
||
local |
local DisplayFns = require('Module:InfoboxBuilderDisplayFunctions') |
||
local |
local ProcessingFns = require('Module:InfoboxBuilderProcessingFunctions') |
||
local p = {} |
local p = {} |
||
⚫ | |||
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 |
|||
Line 34: | Line 18: | ||
{ name = 'gacha id' }, |
{ name = 'gacha id' }, |
||
{ name = 'gacha name', default = mw.title.getCurrentTitle().text }, |
{ name = 'gacha name', default = mw.title.getCurrentTitle().text }, |
||
{ name = 'logo' |
{ name = 'logo' }, |
||
{ name = 'banner' |
{ name = 'banner' }, |
||
{ name = 'japanese' }, |
{ name = 'japanese' }, |
||
{ name = 'romaji' }, |
{ name = 'romaji' }, |
||
Line 42: | Line 26: | ||
{ name = 'type' }, |
{ name = 'type' }, |
||
{ name = 'pity' }, |
{ name = 'pity' }, |
||
{ name = 'currency', |
{ name = 'currency', fn = ProcessingFns.stringToArray(',') } |
||
} |
} |
||
:setArgs(args) |
:setArgs(args) |
||
Line 55: | Line 39: | ||
:addHeader({ tag = 'argth', content = 'gacha name' }) |
:addHeader({ tag = 'argth', content = 'gacha name' }) |
||
:addImage({ |
:addImage({ |
||
{ |
|||
{ tag = 'argtd', content = 'logo', tabName = 'Logo' }, |
|||
tag = 'argtd', |
|||
content = 'logo', |
|||
fn = DisplayFns.image('x100px'), |
|||
tabName = 'Logo' |
|||
}, |
|||
{ |
|||
tag = 'argtd', |
|||
content = 'banner', |
|||
fn = DisplayFns.image('x100px'), |
|||
tabName = 'Banner' |
|||
} |
|||
}) |
}) |
||
:addRow({ |
:addRow({ |
||
Line 89: | Line 83: | ||
:addRow({ |
:addRow({ |
||
{ tag = 'th', content = 'Currency' }, |
{ tag = 'th', content = 'Currency' }, |
||
{ tag = 'argtd', content = 'currency' } |
{ tag = 'argtd', content = 'currency', fn = DisplayFns.list('unbulleted') } |
||
}) |
}) |
||
⚫ | |||
if mw.title.getCurrentTitle().namespace == 0 then |
if mw.title.getCurrentTitle().namespace == 0 then |
||
categories = "[[Category:Gachas]]" .. infobox:getCategories() |
categories = "[[Category:Gachas]]" .. infobox:getCategories() |
Revision as of 03:44, 18 October 2022
This module depends on the following other modules: |
To generate {{Infobox gacha}}, invoke using the main function.
--------------------------
-- Module for [[Template:Infobox gacha]]
------------------------
local getArgs = require('Module:Arguments').getArgs
local InfoboxBuilder = require('Module:InfoboxBuilder new')
local DisplayFns = require('Module:InfoboxBuilderDisplayFunctions')
local ProcessingFns = require('Module:InfoboxBuilderProcessingFunctions')
local p = {}
function p.main(frame)
local args = getArgs(frame)
local infobox = InfoboxBuilder.new()
infobox:setName('Infobox gacha')
:setParams{
{ name = 'gacha id' },
{ name = 'gacha name', default = mw.title.getCurrentTitle().text },
{ name = 'logo' },
{ name = 'banner' },
{ name = 'japanese' },
{ name = 'romaji' },
{ name = 'start' },
{ name = 'end' },
{ name = 'type' },
{ name = 'pity' },
{ name = 'currency', fn = ProcessingFns.stringToArray(',') }
}
:setArgs(args)
:processArgs()
:setCategoryMap({
['pity'] = {
['Yes'] = 'Gachas with pity'
}
})
infobox
:addHeader({ tag = 'argth', content = 'gacha name' })
:addImage({
{
tag = 'argtd',
content = 'logo',
fn = DisplayFns.image('x100px'),
tabName = 'Logo'
},
{
tag = 'argtd',
content = 'banner',
fn = DisplayFns.image('x100px'),
tabName = 'Banner'
}
})
:addRow({
{ tag = 'th', content = 'Japanese' },
{ tag = 'argtd', content = 'japanese' }
})
:addRow({
{ tag = 'th', content = 'Romaji' },
{ tag = 'argtd', content = 'romaji' }
})
:addHeader({ tag = 'th', content = 'Gacha Information' }, { subheader = true })
:addRow({
{ tag = 'th', content = 'Gacha ID' },
{ tag = 'argtd', content = 'gacha id' }
})
:addRow({
{ tag = 'th', content = 'Start date' },
{ tag = 'argtd', content = 'start' }
})
:addRow({
{ tag = 'th', content = 'End date' },
{ tag = 'argtd', content = 'end' }
})
:addRow({
{ tag = 'th', content = 'Gacha type' },
{ tag = 'argtd', content = 'type' }
})
:addRow({
{ tag = 'th', content = 'Has pity?' },
{ tag = 'argtd', content = 'pity' }
})
:addRow({
{ tag = 'th', content = 'Currency' },
{ tag = 'argtd', content = 'currency', fn = DisplayFns.list('unbulleted') }
})
local categories = ""
if mw.title.getCurrentTitle().namespace == 0 then
categories = "[[Category:Gachas]]" .. infobox:getCategories()
end
return infobox:tostring() .. categories
end
return p