Content added Content deleted
(using new builder) |
No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
------------------------ |
------------------------ |
||
local getArgs = require('Module:Arguments').getArgs |
local getArgs = require('Module:Arguments').getArgs |
||
local |
local InfoboxBuilder = require('Module:InfoboxBuilder') |
||
local DisplayFns = require('Module:DisplayFunctions') |
|||
local p = {} |
local p = {} |
||
local function formatImage(image_name) |
|||
return string.format("[[File:%s|128px]]", image_name) |
|||
end |
|||
function p.main(frame) |
function p.main(frame) |
||
local args = getArgs(frame) |
local args = getArgs(frame) |
||
local infobox = |
local infobox = InfoboxBuilder.new(); |
||
infobox:setName('Infobox item') |
infobox:setName('Infobox item') |
||
:setParams{ |
:setParams{ |
||
{ name = 'item name', default = mw.title.getCurrentTitle().text }, |
{ name = 'item name', default = mw.title.getCurrentTitle().text }, |
||
{ name = 'image' |
{ name = 'image' }, |
||
{ name = 'japanese' }, |
{ name = 'japanese' }, |
||
{ name = 'romaji' }, |
{ name = 'romaji' }, |
||
Line 30: | Line 27: | ||
infobox |
infobox |
||
:addHeader({ tag = 'argth', content = 'item name' }) |
:addHeader({ tag = 'argth', content = 'item name' }) |
||
:addImage( |
:addImage({ |
||
⚫ | |||
}) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
) |
|||
⚫ | |||
⚫ | |||
}) |
|||
⚫ | |||
⚫ | |||
{ tag = 'th', content = 'Romaji' }, |
|||
⚫ | |||
} |
|||
) |
}) |
||
⚫ | |||
{ |
|||
⚫ | |||
⚫ | |||
} |
|||
) |
|||
:addRow( |
:addRow( |
||
{ |
{ |
||
Line 55: | Line 46: | ||
) |
) |
||
:addHeader({ tag = 'th', content = 'Item Description' }, { subheader = true }) |
:addHeader({ tag = 'th', content = 'Item Description' }, { subheader = true }) |
||
:addRow( |
:addRow({ |
||
⚫ | |||
{ |
|||
⚫ | |||
⚫ | |||
} |
|||
) |
|||
local categories = "" |
local categories = "" |
Latest revision as of 15:20, 19 October 2022
This module depends on the following other modules: |
To generate {{Infobox item}}, invoke using the main function.
--------------------------
-- Module for [[Template:Infobox item]]
------------------------
local getArgs = require('Module:Arguments').getArgs
local InfoboxBuilder = require('Module:InfoboxBuilder')
local DisplayFns = require('Module:DisplayFunctions')
local p = {}
function p.main(frame)
local args = getArgs(frame)
local infobox = InfoboxBuilder.new();
infobox:setName('Infobox item')
:setParams{
{ name = 'item name', default = mw.title.getCurrentTitle().text },
{ name = 'image' },
{ name = 'japanese' },
{ name = 'romaji' },
{ name = 'english' },
{ name = 'description' },
{ name = 'date' }
}
:setArgs(args)
:processArgs()
infobox
:addHeader({ tag = 'argth', content = 'item name' })
:addImage({
{ tag = 'argtd', content = 'image', fn = DisplayFns.image('128px') },
})
:addRow({
{ tag = 'th', content = 'Japanese' },
{ tag = 'argtd', content = 'japanese' }
})
:addRow({
{ tag = 'th', content = 'Romaji' },
{ tag = 'argtd', content = 'romaji' }
})
:addRow(
{
{ tag = 'th', content = 'English' },
{ tag = 'argtd', content = 'english' }
},
{ hideIfEmpty = { 'english' } }
)
:addHeader({ tag = 'th', content = 'Item Description' }, { subheader = true })
:addRow({
{ tag = 'argtd', content = 'description', css = { ['text-align'] = 'center' } }
})
local categories = ""
if mw.title.getCurrentTitle().namespace == 0 then
categories = "[[Category:Items]]" .. categories
end
return infobox:tostring() .. categories
end
return p