Module:File license: Difference between revisions
From Tardis Wiki, the free Doctor Who reference
Bongolium500 (talk | contribs) No edit summary |
Bongolium500 (talk | contribs) No edit summary |
||
Line 27: | Line 27: | ||
if image ~= "" then | if image ~= "" then | ||
imageCode = '<span style="margin-top:5px;float:left;margin-right:10px;">[[File:' .. image .. '|' .. tostring(imageSize) .. "px]]</span>" | imageCode = '<span style="margin-top:5px;float:left;margin-right:10px;">[[File:' .. image .. '|' .. tostring(imageSize) .. "px]]</span>" | ||
else | |||
local imageData = mw.loadData("Module:File license/data/images") | |||
if imageData[copyrightHolder] then | |||
imageCode = '<span style="margin-top:5px;float:left;margin-right:10px;">[[File:' .. imageData[copyrightHolder] .. '|' .. tostring(imageSize) .. "px]]</span>" | |||
end | |||
end | end | ||
local licenseData = mw.loadData("Module:File license/data/licenses") | local licenseData = mw.loadData("Module:File license/data/licenses") | ||
local licenseText = "" | local licenseText = "" | ||
if licenseData[license] then | |||
licenseText = licenseData[license] | |||
end | |||
local finalLicense = '<div id="license">' .. imageCode .. "This file is " .. typeOfFileArticle .. " '''" .. typeOfFile .. "'''" .. sourceText .. ". It's copyright is owned by " .. copyrightHolder .. ".<br/>" .. licenseText .. "</div>" | local finalLicense = '<div id="license">' .. imageCode .. "This file is " .. typeOfFileArticle .. " '''" .. typeOfFile .. "'''" .. sourceText .. ". It's copyright is owned by " .. copyrightHolder .. ".<br/>" .. licenseText .. "</div>" |
Revision as of 20:39, 3 March 2024
Documentation for this module may be created at Module:File license/doc
local p = {} --p stands for package
local h = {} --h stands for helper
function p.makeLicense(frame)
local args = frame:getParent().args
local image = args["image"] or ""
local imageSize = tonumber(args["imageSize"]) or ""
local typeOfFile = args["typeOfFile"] or "image"
local source = args["source"] or ""
local license = args["license"] or ""
local copyrightHolder = args["copyrightHolder"] or ""
local intent = args["intent"] or "to illustrate articles on Tardis Wiki"
local typeOfFileArticle = "a"
local vowels = {["a"] = true, ["e"] = true, ["i"] = true, ["o"] = true, ["u"] = true}
if vowels[string.sub(typeOfFile, 1, 1)] then
typeOfFileArticle = "an"
end
local sourceText = ""
if source ~= "" then
sourceText = " of " .. source
end
local imageCode = ""
if image ~= "" then
imageCode = '<span style="margin-top:5px;float:left;margin-right:10px;">[[File:' .. image .. '|' .. tostring(imageSize) .. "px]]</span>"
else
local imageData = mw.loadData("Module:File license/data/images")
if imageData[copyrightHolder] then
imageCode = '<span style="margin-top:5px;float:left;margin-right:10px;">[[File:' .. imageData[copyrightHolder] .. '|' .. tostring(imageSize) .. "px]]</span>"
end
end
local licenseData = mw.loadData("Module:File license/data/licenses")
local licenseText = ""
if licenseData[license] then
licenseText = licenseData[license]
end
local finalLicense = '<div id="license">' .. imageCode .. "This file is " .. typeOfFileArticle .. " '''" .. typeOfFile .. "'''" .. sourceText .. ". It's copyright is owned by " .. copyrightHolder .. ".<br/>" .. licenseText .. "</div>"
return finalLicense
end
return p