Module:Do not move to Commons

--[=[ Implements Template:Do not move to Commons ]=] require('strict')

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local messageBox = require('Module:Message box').main

function p._do_not_move_to_commons(args) local localyear = tonumber(os.date("%Y")) local namespace = mw.title.getCurrentTitle.nsText local expiry = args.expiry or args.expire or args.expires or args['until'] -- hacky, needs to handle non-math input into expr better if expiry and tonumber(string.sub(expiry, 1, 1)) then expiry = tonumber(mw.ext.ParserFunctions.expr(tostring(expiry))) else expiry = nil end local has_expired = expiry and expiry < localyear local why = args.why or args.reason local test = yesno(args.test or 'no') local text = " Do not copy this file to Wikimedia Commons. " if test then text = text .. " " .. (why or "This is a temporary or test file, or otherwise only relevant to English Wikisource, and therefore out of scope for Wikimedia Commons.") .. " "	else text = text .. " This file is in the public domain in the United States but " .. (why or " not in its country of origin ") .. ". Wikimedia Commons only accepts files that are in the public domain (or otherwise freely licensed) in both the country of origin and the United States. For more details, see Commons:Licensing, Public domain, Copyrights and talk for the PD-US license template. " end if expiry then text = text .. "This message expires at the end of " .. expiry .. ". "	end local category local nocat = yesno(args.parent) or yesno(args.nocat) or yesno(args.demo) or (namespace ~= "File" and namespace ~= "Category") if nocat then category = "" elseif has_expired then category = "" elseif expiry then category = "" elseif test then category = "" else category = "" end -- check if invocation uses numbered parameters, since those aren't supported local has_unnamed_parameters = false for k, v in pairs(args) do		if tonumber(k) then has_unnamed_parameters = true end end if has_unnamed_parameters then category = category .. ""	end if has_expired then return category else return messageBox(			"imbox",			{				['type'] = "style",				['imageright'] = '   ',				['text'] = text .. category			}		) end end

function p.do_not_move_to_commons(frame) local args = getArgs(frame) return p._do_not_move_to_commons(args) end

return p