Module:Source

local utilsArg = require("Module:UtilsArg") local utilsMarkup = require("Module:UtilsMarkup")

local p = {} local h = {}

function p.Main(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates.Source) if err then return utilsMarkup.categories(err.categories) end return h[args.sourceType](args.authors, args.url) end

function h.Original(authors) local authorLinks = {} for i, author in ipairs(authors) do		authorLinks[i] = utilsMarkup.link(string.format("Special:ListFiles/%s", author), author, true) end local authors1 = mw.text.listToText(authorLinks) local authors2 = #authors == 1 and authors[1] or "them" local message = string.format("This file was retrieved directly by %s for Zelda Wiki. If you wish to distribute this image on another site, we kindly ask that you attribute the retrieval to %s and to Zelda Wiki.", authors1, authors2) return utilsMarkup.italic(message) end

function h.YT(author, url) local result = utilsMarkup.link(url, "YouTube") if author[1] ~= "" then result = result .. " | " .. utilsMarkup.link(author[2], author[1]) end return result end

function h.TSR(authors, url) local authorLinks = {} for i, author in ipairs(authors) do		authorLinks[i] = utilsMarkup.link("https://www.spriters-resource.com/submitter/"..author, author) end local result = utilsMarkup.link(url, "The Spriters Resource") if authors[1] ~= "" then result = result .. " | " .. mw.text.listToText(authorLinks) end return result end

p.Templates = { Source = { purpose = "Citing file sources in Template:FileInfo.", format = "inline", params = { [1] = {				name = "sourceType", type = "string", required = true, enum = {"Original", "YT", "TSR"}, desc = "One of: " },			[2] = {				name = "authors", type = "string", required = true, desc = "Depends on the source type: ", split = true, },			[3] = {				name = "url", type = "string", desc = "The url of the web resource.", }		},		examples = { {				desc = "Zelda Wiki", args = {"Original", "Dany36"}, },			{				args = {"Original", "Dany36, Abdullah, HTW"}, },			{				desc = "YouTube", args = {"YT", "Desilent49, https://www.youtube.com/channel/UC5uT3OL7x_lrrch77m4y0uw", "https://www.youtube.com/watch?v=fVEgS3Skids"}, },			{				args = {"YT", "", "https://www.youtube.com/watch?v=fI6lFLydv0M&t=13m46s"}, },			{				desc = "The Spriters Resource", args = {"TSR", "Deathbringer", "https://www.spriters-resource.com/snes/legendofzeldaalinktothepast/sheet/39608/"}, },			{				args = {"TSR", "Random Talking Bush, SciresM", "https://www.spriters-resource.com/nintendo_switch/thelegendofzeldabreathofthewild/sheet/93828/"} }		},	} }

return p