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 60: | Line 60: | ||
local licenseMachinedata = "" | local licenseMachinedata = "" | ||
if licenseData[license] then | if licenseData[license] then | ||
licenseText = frame:preprocess(licenseData[license][1]) | if ownWork ~= "" then | ||
licenseMachinedata = '<span class="licensetpl"><span class="licensetpl_short">' .. licenseData[license][ | licenseText = "I, the copyright holder of this ".. typeOfFile .. ", hereby " .. frame:preprocess(licenseData[license][2]) .. " it's use on Tardis Wiki, hosted on servers in France by Wiki Federation," .. intent .. "." | ||
else | |||
licenseText = tentativeText .. " of this " .. typeOfFile .. " " .. intent .. " on Tardis Wiki, hosted on servers in France by Wiki Federation, " .. frame:preprocess(licenseData[license][1]) | |||
end | |||
licenseText = licenseText .. frame:preprocess(licenseData[license][3]) | |||
licenseMachinedata = '<span class="licensetpl"><span class="licensetpl_short">' .. licenseData[license][4] .. '</span><span class="licensetpl_long">' .. licenseData[license][5] .. '</span><span class="licensetpl_link">' .. frame:preprocess("<nowiki>" .. licenseData[license][6] .. "</nowiki>") .. '</span><span class="licensetpl_link_req">' .. licenseData[license][7] .. '</span><span class="licensetpl_attr_req">' .. licenseData[license][8] .. '</span><span class="licensetpl_attr">' .. copyrightHolderText .. '</span><span class="licensetpl_nonfree">' .. licenseData[license][9] .. '</span></span>' | |||
end | end | ||
Line 82: | Line 87: | ||
end | end | ||
local finalLicense = '<div id="license">' .. imageCode .. "This file is " .. typeOfFileArticle .. " '''" .. typeOfFile .. "'''" .. sourceText .. ". It's copyright is owned by " .. copyrightHolderText .. ". Other parties may have intellectual property rights over this image, as well." .. extraCopyrightText .. "<hr/> | local finalLicense = '<div id="license">' .. imageCode .. "This file is " .. typeOfFileArticle .. " '''" .. typeOfFile .. "'''" .. sourceText .. ". It's copyright is owned by " .. copyrightHolderText .. ". Other parties may have intellectual property rights over this image, as well." .. extraCopyrightText .. "<hr/>" .. licenseText .. '<span style="display:none;>" ' .. licenseMachinedata .. infoMachinedata .. "</span></div>" | ||
if ownWork ~= "" then | if ownWork ~= "" then |
Revision as of 18:07, 17 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["image size"]) or 80
local typeOfFile = args["type of file"] or "image"
local source = args["source"] or ""
local license = args["license"] or ""
local copyrightHolder = args["copyright holder"] or ""
local intent = args["intent"] or "to illustrate articles"
local tentative = args["tentative"] or ""
local ownWork = args["own work"] or ""
if tentative ~= "" then
tentativeText = "It is believed that use"
else
tentativeText = "Use"
end
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 = " from " .. source
end
local copyrightHolderData = mw.loadData("Module:File license/data/copyright holders")
local imageCode = ""
if image ~= "" then
imageCode = '<span style="margin-top:5px;float:left;margin-right:10px;">[[File:' .. image .. '|' .. tostring(imageSize) .. "px]]</span>"
elseif copyrightHolderData[copyrightHolder] then
if copyrightHolderData[copyrightHolder][2] then
imageCode = '<span style="margin-top:5px;float:left;margin-right:10px;">[[File:' .. copyrightHolderData[copyrightHolder][2] .. '|' .. tostring(imageSize) .. "px]]</span>"
end
end
local copyrightHolderText = ""
if copyrightHolder ~= "" then
if copyrightHolderData[copyrightHolder] then
if copyrightHolderData[copyrightHolder][1] then
copyrightHolderText = frame:preprocess(copyrightHolderData[copyrightHolder][1])
end
elseif copyrightHolderDisplay then
copyrightHolderText = "[[" .. copyrightHolder .. "|" .. copyrightHolderDisplay .. "]]"
else
copyrightHolderText = frame:preprocess(copyrightHolder)
end
end
local licenseData = mw.loadData("Module:File license/data/licenses")
local licenseText = ""
local licenseMachinedata = ""
if licenseData[license] then
if ownWork ~= "" then
licenseText = "I, the copyright holder of this ".. typeOfFile .. ", hereby " .. frame:preprocess(licenseData[license][2]) .. " it's use on Tardis Wiki, hosted on servers in France by Wiki Federation," .. intent .. "."
else
licenseText = tentativeText .. " of this " .. typeOfFile .. " " .. intent .. " on Tardis Wiki, hosted on servers in France by Wiki Federation, " .. frame:preprocess(licenseData[license][1])
end
licenseText = licenseText .. frame:preprocess(licenseData[license][3])
licenseMachinedata = '<span class="licensetpl"><span class="licensetpl_short">' .. licenseData[license][4] .. '</span><span class="licensetpl_long">' .. licenseData[license][5] .. '</span><span class="licensetpl_link">' .. frame:preprocess("<nowiki>" .. licenseData[license][6] .. "</nowiki>") .. '</span><span class="licensetpl_link_req">' .. licenseData[license][7] .. '</span><span class="licensetpl_attr_req">' .. licenseData[license][8] .. '</span><span class="licensetpl_attr">' .. copyrightHolderText .. '</span><span class="licensetpl_nonfree">' .. licenseData[license][9] .. '</span></span>'
end
local infoMachinedata = '<span class="fileinfotpl"><span class="fileinfotpl_desc">' .. string.sub(typeOfFileArticle, 1, 1):upper() .. string.sub(typeOfFileArticle, 2, -1) .. ' ' .. typeOfFile .. sourceText .. '.</span><span class="fileinfotpl_src">' .. source .. '</span><span class="fileinfotpl_aut">' .. copyrightHolderText .. '</span></span>'
local i = 1
local extraCopyrightText = ""
while args["extra copyright" .. tostring(i)] and args["extra copyright" .. tostring(i)] ~= "" do
extraCopyrightText = extraCopyrightText .. args["extra copyright" .. tostring(i)]
if string.find(args["extra copyright" .. tostring(i)], "and") then
extraCopyrightText = extraCopyrightText .. " are "
else
extraCopyrightText = extraCopyrightText .. " is "
end
extraCopyrightText = extraCopyrightText .. " © " .. args["extra copyright owner" .. tostring(i)] .. ". "
i = i + 1
end
if extraCopyrightText ~= "" then
extraCopyrightText = "<hr/>" .. extraCopyrightText
end
local finalLicense = '<div id="license">' .. imageCode .. "This file is " .. typeOfFileArticle .. " '''" .. typeOfFile .. "'''" .. sourceText .. ". It's copyright is owned by " .. copyrightHolderText .. ". Other parties may have intellectual property rights over this image, as well." .. extraCopyrightText .. "<hr/>" .. licenseText .. '<span style="display:none;>" ' .. licenseMachinedata .. infoMachinedata .. "</span></div>"
if ownWork ~= "" then
finalLicense = '<div style="padding:5px;" id="license">I, the copyright holder of this work, hereby publish it under the following license:' .. finalLicense .. "</div>"
end
return finalLicense
end
return p