モジュール:Multiple releases
表示
モジュールの解説[作成]
local infobox = require ('Module:Infobox').infobox
local getArgs = require ('Module:Arguments').getArgs
local p = {}
p.InfoboxArgs = {}
function p.original( args )
local a = 1
local IsEmpty = true
local KeepCheckingForArgs = true
local InfoboxArgs = p.InfoboxArgs
while KeepCheckingForArgs == true do
local thisBranch = "branch" .. a
local thisVersion = "version" .. a
local thisDate = "date" .. a
local CurLabel = "label" .. a
local CurData = "data" .. a
if args[thisBranch] and args[thisVersion] then
InfoboxArgs[CurLabel] = args[thisBranch]
InfoboxArgs[CurData] = args[thisVersion]
if args[thisDate] then InfoboxArgs[CurData] = InfoboxArgs[CurData] .. " / " .. args[thisDate] end
else
KeepCheckingForArgs = false
if a > 1 then IsEmpty = false end
end
a = a + 1
end
return IsEmpty
end
function p.flat( args )
local a = 1
local b = 1
local IsEmpty = true
local KeepCheckingForArgs = true
local InfoboxArgs = p.InfoboxArgs
while KeepCheckingForArgs == true do
local thisBranch = "branch" .. a
local thisVersion = "version" .. a
local thisDate = "date" .. a
local thisEdit = "edit" .. a
local CurHeader = "header" .. b
local CurData = "data" .. b + 1
InfoboxArgs.headerstyle = "text-align:left;"
InfoboxArgs.datastyle= "text-align:left;"
if args[thisBranch] and args[thisVersion] then
InfoboxArgs[CurHeader] = args[thisBranch]
InfoboxArgs[CurData] = args[thisVersion]
if args[thisDate] then InfoboxArgs[CurData] = InfoboxArgs[CurData] .. " / " .. args[thisDate] end
if args[thisEdit] then InfoboxArgs[CurData] = InfoboxArgs[CurData] .. "<small> <span class=\"plainlinks\">[" .. tostring(mw.uri.fullUrl(args[thisEdit], "action=edit")) .. " [±]]</span></small>" end
b = b + 2
else
KeepCheckingForArgs = false
if a > 1 then IsEmpty = false end
end
a = a + 1
end
return IsEmpty
end
function p.main( frame )
local args = getArgs (frame)
local InfoboxArgs = p.InfoboxArgs
InfoboxArgs["subbox"] = "yes"
local IsEmpty = true
if args["flat"] == "yes" then
IsEmpty = p.flat(args)
else
IsEmpty = p.original(args)
end
if IsEmpty == false then
return infobox(InfoboxArgs)
else
return nil
end
end
return p