Module:Old moves
Appearance
![]() | This Lua module is used on approximately 23,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This module depends on the following other modules: |
This module implements Template:Old move.
Test cases: Template:Old move/testcases
local MessageBox = require('Module:Message box')
local p = {}
local function singleText(args)
local pageType
if (mw.title.getCurrentTitle():inNamespace(0)) then
pageType = "article"
else
pageType = "page"
end
local date = args["date"] or args["date1"] or ""
local from = args["from"] or args["from1"] or ""
local to = args["destination"] or args["destination1"] or ""
local afd = args["result"] or args["result1"] or ""
local merge = args["link"] or args["link1"] or ""
if date then
local text = string.format("On %s, it was proposed that this %s be moved",date,pageType)
else
local text = string.format("It has previously been proposed that this %s be moved",pageType)
end
if from then
text = string.format("%s from %s",text,from)
end
if to then
text = string.format("%s to %s",text,to)
end
text = string.format("%s.",text)
if result then
text = string.format("%s The result of the proposal was %s.",text,result)
end
if result then
text = string.format("%s The result of the proposal was %s.",text,result)
end
if link then
link = string.format("%s (See [[%s|discussion]].)", text, link)
end
return text
end
local function row(args, i)
local text = ""
local afd = args["afd" .. i]
if (afd or args["merge" .. i]) then
text = string.format("%s\n*Merged",text)
else
text = string.format("%s\n*Copied",text)
end
local from = args["from" .. i] or ""
text = string.format("%s [%s %s] (",text,tostring(mw.uri.fullUrl(from, {redirect = "no"} )),from)
local from_oldid = args["from_oldid" .. i]
if (from_oldid) then
text = string.format("%s[%s oldid], ",text,tostring(mw.uri.fullUrl(from, {oldid = from_oldid} )))
end
local to = args["to".. i] or ""
text = string.format("%s[%s history]) → [[%s]]",text,tostring(mw.uri.fullUrl(from, {action = "history"} )), to)
local diff = args["diff" .. i]
if (diff) then
text = string.format("%s ([%s diff])",text,diff)
elseif (args["to_oldid" .. i] or args["to_diff".. i]) then
local to_diff = args["to_diff".. i] or "prev"
local to_oldid = args["to_oldid" .. i] or ""
text = string.format("%s ([%s diff])",text,tostring(mw.uri.fullUrl(to, {diff=to_diff, oldid = to_oldid} )))
end
local date = args["date" .. i]
if (date) then
text = string.format("%s on %s",text,date)
end
if (afd) then
if (mw.ustring.match(afd, "Wikipedia:", 1 )) then --If no venue is given add AfD prefix
text = string.format("%s after being [[%s|nominated for deletion]]",text,afd)
else
text = string.format("%s after being [[Wikipedia:Articles for deletion/%s|nominated for deletion]]",text,afd)
end
end
if (not (args["to_oldid" .. i] or args["to_diff".. i])) then
text = string.format("%s[[Category:Wikipedia pages using copied template without oldid]]",text)
end
return text
end
local function list(args)
local text = ""
local from1 = args["from1"]
if (from1) then --Support from1 and from in case of multiple rows
text = string.format("%s%s",text,row(args, 1))
else
text = string.format("%s%s",text,row(args, ""))
end
local i = 2
while i > 0 do
if (args["from" .. i]) then
text = string.format("%s%s",text,row(args, i))
i = i + 1 --Check if from(i+1) exist
else
i = - 1 --Break if fromi doesn't exist
end
end
return text
end
local function multiText(args)
local pageType
if (mw.title.getCurrentTitle():inNamespace(0)) then
pageType = "article"
else
pageType = "page"
end
local historyList = list(args)
if (args["collapse"] == 'yes') then
local collapsedText = '<table style="width:100%%; background: transparent;" class="collapsible collapsed">\n<tr><th>Copied pages:</th></tr>\n<tr><td> %s </td></tr></table>'
historyList = string.format(collapsedText, historyList)
end
local text = "Text has been copied to or from this %s; 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. %s"
text = string.format(text, pageType, historyList)
return text
end
local function BannerText(args)
--Checks if there are multiple rows
local text
local to2 = args["to2"]
if (to2) then
text = multiText(args)
else
text = singleText(args)
end
return text
end
local function renderBanner(args)
return MessageBox.main('tmbox', {
small = args["small"],
type = 'move',
image = '[[File:Splitsection.svg|50px]]',
text = BannerText(args)
})
end
function p.main(frame)
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)
return renderBanner(args)
end
return p