Module:File license: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
(Created page with "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 = 80 local typeOfFile = "" or "image" local source = "" local license = args["license"] or "" local copyrightHolder = "" local typeOfFileArticle = "a" local vowels = {["a"] = true, ["e"] = true, ["i"] = true, ["o"] = true, ["u"] = true} if vowels[string.sub(typeOfFile, 1,...")
 
No edit summary
Line 16: Line 16:
if vowels[string.sub(typeOfFile, 1, 1)] then
if vowels[string.sub(typeOfFile, 1, 1)] then
typeOfFileArticle = "an"
typeOfFileArticle = "an"
end
local sourceText = ""
if source ~= "" then
sourceText = " of " .. source
end
end
Line 26: Line 31:
local licenseText = ""
local licenseText = ""
local finalLicense = '<div id="license">' .. imageCode .. "This file is " .. typeOfFileArticle .. " '''" .. typeOfFile .. "''' of " .. source .. ". 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>"
return finalLicense
return finalLicense
end
end


return p
return p

Revision as of 20:37, 2 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 = 80
	local typeOfFile = "" or "image"
	local source = ""
	local license = args["license"] or ""
	local copyrightHolder = ""
	
	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>"
	end
	
	local licenseData = mw.loadData("Module:File license/data/licenses")
	local licenseText = ""
	
	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