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, args) end

function h.Original(authors) local authorLinks = {} for i, author in ipairs(authors) do		authorLinks[i] = utilsMarkup.link(string.format("UserProfile:%s", author), author) 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, id, options) local time = options.time local url = "https://www.youtube.com/watch?v=" .. id	if time then url = url .. "&t=" .. time end local result = utilsMarkup.link(url, "YouTube") if author[1] ~= "" then local channelUrl = "https://www.youtube.com/channel/" .. author[2] result = result .. " | " .. utilsMarkup.link(channelUrl, 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", paramOrder = {1, 2, 3, "time"}, 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. For YouTube videos, use only the ID of the video, not the whole URL.", --YouTube URLs have = in them which causes problems },			time = { type = "string", canOmit = true, desc = "Use this field to link to a specific time in a YouTube video.", nilIfEmpty = true, },		},		examples = { {				desc = "Zelda Wiki", args = {"Original", "Dany36"}, },			{				args = {"Original", "Dany36, Abdullah, Htwretched"}, },			{				desc = "YouTube", args = {"YT", "Desilent49, UC5uT3OL7x_lrrch77m4y0uw", "fVEgS3Skids"}, },			{				args = {"YT", "", "fI6lFLydv0M", time = "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