Module:Copied

This is an old revision of this page, as edited by Trialpears (talk | contribs) at 17:05, 2 February 2020 (test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local MessageBox = require('Module:Message box')
local p = {}

local function singleText(frame)
	local from_oldid = (frame.args["from_oldid"] or "")
	local from = (frame.args["from"] or "")
	local to_diff = (frame.args["to_diff"] or "")
	local diff = (frame.args["diff"] or "")
	local to_oldid = (frame.args["to_oldid"] or "")
	local to = (frame.args["to"] or "")
	local date = (frame.args["date"] or "")
	local afd = (frame.args["afd"] or "")
	local text = "Text and/or other creative content from " 
	if not from_oldid == "" then
		text = text .. "[{{fullurl:" .. from .. "|oldid=" .. from_oldid .. "this version] of "
	end
	text = text .. "[[" .. from .."]]" 
	text = text .. " was copied or moved into " 
	text = text .. "[[" .. to .. "]]"
	if not diff == "" then
		text = text .. " with [" .. diff .. "|this edit]"
	elseif not to_oldid == "" then
		text = text .. "with [{{fullurl:" .. to .. "|diff=" .. to_diff .. "&oldid=" .. to_oldid .. "}}|this edit]"
	end
	if not date == "" then
		text = text .. " on " .. date
	end
	if not afd == "" then
		text = text .. " after being [[Wikipedia:Articles for deletion/" .. afd "|nominated for deletion]]."
	end
	text = text .. ". The former page's " 
	text = text .. "History"
	text = text .. "now serves to [[WP:Copying within Wikipedia|provide attribution]] for that content in the latter page, and it must not be deleted so long as the latter page exists."
	return text
end

local function multiText(frame)
	local collapse = (frame.args["collapse"] or "")
	local text = "Text has been copied to or from this {{#ifeq:{{SUBJECTSPACE}}||article|page}}; see the list below. The source pages now serve to [[WP:Copying within Wikipedia|provide attribution]] for the content in the destination pages and must not be deleted so long as the copies exist. For attribution and to access older versions of the copied text, please see the history links below."
	if collapse == 'yes' then
		text = text .. '<table style="width:100%; background: transparent;" class="collapsible collapsed">\n<tr><th>Copied pages:</th></tr>\n<tr><td>'	
	end
	text = text .. "list(frame)"
	if collapse == 'yes' then
		text = text .. '</td></tr></table>'	
	end
	return text
end

local function BannerText(frame)
	local text
	local from2 = (frame.args["from2"] or "")
	if (from2 == "") then
		text = singleText(frame)
	elseif not (from2 == "") then
		text = multiText(frame)
	end
	return text
end

local function renderBanner(frame)
	return MessageBox.main('tmbox', {
		small = frame.args["small"],
		type = 'notice',
		image = '[[File:Splitsection.svg|50px]]',
		smallimage = 'none',
		text = BannerText(frame)
	})
end

function p.main(frame)
	return renderBanner(frame)
end

return p