mNo edit summary Tag: sourceedit |
mNo edit summary Tag: sourceedit |
||
Line 17: | Line 17: | ||
if type == "gender" then |
if type == "gender" then |
||
− | return string.format("[[File:Gender %s.svg|%spx|link=]]" |
+ | return string.format("[[File:Gender %s.svg|%spx|link=]]", size) |
end |
end |
||
Line 47: | Line 47: | ||
return ( |
return ( |
||
string.format("[[File:%s|%spx|link=%s|%s]]", n, size, link, text) .. |
string.format("[[File:%s|%spx|link=%s|%s]]", n, size, link, text) .. |
||
− | + | frame:callParserFunction('#set:Infobox Icon='..n).."}}[[Category:Infoboxes using unknown icon]]}}" |
|
) |
) |
||
end |
end |
||
Line 62: | Line 62: | ||
return ( |
return ( |
||
string.format("[[File:%s|%spx|link=%s|%s]]", n, size, link, text) .. |
string.format("[[File:%s|%spx|link=%s|%s]]", n, size, link, text) .. |
||
− | + | frame:callParserFunction('#set:Infobox Icon='..n).."[[Category:Infoboxes using unknown icon]]}}" |
|
) |
) |
||
end |
end |
||
Line 79: | Line 79: | ||
return ( |
return ( |
||
string.format("[[File:%s|%spx|link=%s|%s]]", n, size, link, text) .. |
string.format("[[File:%s|%spx|link=%s|%s]]", n, size, link, text) .. |
||
− | + | frame:callParserFunction('#set:Infobox Icon='..n).."}}[[Category:Infoboxes using unknown icon]]}}" |
|
) |
) |
||
end |
end |
Revision as of 10:53, 10 May 2015
Documentation for this module may be created at Module:Infobox/doc
local infobox = {}
local function ucfirst(name)
return string.gsub(name, "^%l", string.upper)
end
function infobox.icon(frame)
local args = frame:getParent().args
local name = string.lower(args[1])
local type = args[2] or args["Icon Type"]
local size = args.size or "18"
local link = args.link or args[1] or ""
local text = args.text or ""
if not name then return "" end
name = string.gsub(string.gsub(name, "ū", "u"), "ō", "o") -- Fix macrons
if type == "gender" then
return string.format("[[File:Gender %s.svg|%spx|link=]]", size)
end
if type == "Astrological Sign" then
return string.format("[[File:Astrological Sign "..frame:expandTemplate{ title = 'Astrological Sign', args = { name } }..".svg|%spx|link=]]", name, size)
end
if type == "Ninja rank" then
if name == "genin" then
return string.format("[[File:Genin Symbol.svg|%spx|link=%s|%s]]", size, link, text)
end
if name == "chunin" then
return string.format("[[File:Chunnin Symbol.svg|%spx|link=%s|%s]]", size, link, text)
end
if name == "jonin" then
return string.format("[[File:Jounin Symbol.svg|%spx|link=%s|%s]]", size, link, text)
end
end
-- Load the table of icons
local icons = mw.loadData('Module:Infobox/icons')
if type == "Kekkei Genkai" or type == "Nature" then
name = string.gsub(name, " release$", "")
if icons[name] == nil then
local n = "Nature Icon "..mw.text.split(ucfirst(name), " ")[1]..".svg"
if mw.title.new("File:"..n).exists then
return (
string.format("[[File:%s|%spx|link=%s|%s]]", n, size, link, text) ..
frame:callParserFunction('#set:Infobox Icon='..n).."}}[[Category:Infoboxes using unknown icon]]}}"
)
end
else return string.format("[[%s|%spx|link=%s|%s]]", icons[name], size, link, text)
end
end
if type == "Ninja clan" then
name = string.gsub(name, " clan$", "")
if icons[name] == nil then
local n = mw.text.split(ucfirst(name), " ")[1].." Symbol.svg"
if mw.title.new("File:"..n).exists then
return (
string.format("[[File:%s|%spx|link=%s|%s]]", n, size, link, text) ..
frame:callParserFunction('#set:Infobox Icon='..n).."[[Category:Infoboxes using unknown icon]]}}"
)
end
else return string.format("[[%s|%spx|link=%s|%s]]", icons[name], size, link, text)
end
end
if type == "Ninja loyalty" or type == "Team" then
-- For Loyalty
name = string.gsub(name, "^land of ", "")
name = string.gsub(name, "^land of the ", "")
if icons[name] == nil then
local n = args[1].." Symbol.svg"
if mw.title.new("File:"..n).exists then
return (
string.format("[[File:%s|%spx|link=%s|%s]]", n, size, link, text) ..
frame:callParserFunction('#set:Infobox Icon='..n).."}}[[Category:Infoboxes using unknown icon]]}}"
)
end
else return string.format("[[%s|%spx|link=%s|%s]]", icons[name], size, link, text)
end
end
if icons[name] ~= nil then
return string.format("[[%s|%spx|link=%s|%s]]", icons[name], size, link, text)
end
return ""
end
return infobox
--[[Category:Lua Modules]]