Module:Split article
Appearance
Implements {{split article}}
local MessageBox = require('Module:Message box')
local yesno = require("Module:Yesno")
local p = {}
local function singleText(args)
-- from1 also included in case someone filed the template improperly
local from = args["from"] or args["from1"] or mw.title.getCurrentTitle().subjectPageTitle()
if args["from1"] then
mw.addWarning("<code>from</code> is not a row-based parameter. Use <code>from</code> instead of <code>from1</code>.")
end
local from_oldid = args["from_oldid"] or args["from_oldid1"]
if args["from_oldid1"] then
mw.addWarning("<code>from_oldid</code> is not a row-based parameter. Use <code>from_oldid</code> instead of <code>from_oldid1</code>.")
end
-- Row-based parameters
local to = args["to"] or args["to1"]
if to == nil then
return mw.getCurrentFrame():expandTemplate{ title = "error", args = {
"Target page was not specified with <code>to</code>."
} }
end
local toTalk = mw.title.new(to).subjectPageTitle()
local diff = args["diff"] or args["diff1"] or ""
local date = args["date"] or args["date1"]
local text = string.format("Material from [[%s]] was split to [[%s]]", from, to, date)
if date then
text = string.format("%s on %s", text, date)
end
if from_oldid then
local oldidLink = ""
if from_oldid:match("^%d+$") then
oldidLink = string.format("[[Special:Diff/%s|this version]]", from_oldid)
else
oldidLink = string.format("[%s this version]", from_oldid)
end
text = string.format("%s from %s", oldidLink)
end
text = string.format(
"%s. The former page's [[Special:PageHistory/%s|history]] now serves to "..
"[[Wikipedia: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. Please leave this template in place to link the article histories "..
"and preserve this attribution. The former page's talk page can be accessed at [[%s]]",
text, from, toTalk
)
return text
end
local function bannerText(args)
-- Checks if there are multiple rows
local text
local from2 = args["from2"]
if (from2) then
text = multiText(args) --.. categories(args,true)
else
text = singleText(args) --.. categories(args,false)
end
return text
end
function p.renderBanner(args)
return MessageBox.main('tmbox', {
name = "split-article",
small = args["small"],
image = '[[File:Split-arrows.svg|50px]]',
text = bannerText(args)
})
end
function p.main(frame)
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame, {
trim = true,
removeBlanks = true
})
return p.renderBanner(args)
end
return p