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.VGR(domain, site) return function(authors, url) local authorLinks = {} for i, author in ipairs(authors) do			local submitterUrl = string.format("https://www.%s/submitter/%s", domain, mw.uri.encode(author)) authorLinks[i] = utilsMarkup.link(submitterUrl, author) end local result = utilsMarkup.link(url, site) if authors[1] ~= "" then result = result .. " | " .. mw.text.listToText(authorLinks) end return result end end h.TSR = h.VGR("spriters-resource.com", "The Spriters Resource") h.TMR = h.VGR("models-resource.com", "The Models Resource") h.TTR = h.VGR("textures-resource.com", "The Textures Resource")

p.Templates = { Source = { purpose = "Citing file sources in Template:FileInfo.", format = "inline", params = { [1] = {				name = "sourceType", type = "string", required = true, enum = {"Original", "YT", "TSR", "TMR", "TTR"}, desc = "" },			[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, Htwretched"}, },			{				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, The Models Resource, The Textures 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/"} },			{				args = {"TMR", "Trikeboy", "https://www.models-resource.com/wii_u/thelegendofzeldabreathofthewild/model/20383/"} },			{				args = {"TTR", "AleX_XelA", "https://www.textures-resource.com/gamecube/legendofzeldawindwaker/texture/427/"} },		},	} }

return p