Module:Old moves
Appearance
| This Lua module is used on approximately 28,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. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected. |
| This module is currently protected from editing. See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected. |
| 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(1)) 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 result = args["result"] or args["result1"] or ""
local link = args["link"] or args["link1"] or ""
local text = ""
if not (date == "") then
text = string.format("On %s, it was proposed that this %s be [[Wikipedia:Requested moves|moved]]",date,pageType)
else
text = string.format("It has previously been proposed that this %s be moved",pageType)
end
if not (from == "") then
text = string.format("%s from [[%s]]",text,from)
end
if not (to == "") then
text = string.format("%s to [[%s]]",text,to)
end
text = string.format("%s.",text)
if not (result == "") then
text = string.format("%s The result of the proposal was '''%s'''.",text,result)
end
if not (link == "") then
link = string.format("%s (See [[%s|discussion]].)", text, link)
end
return text
end
local function row(args, i)
local text = ""
return text
end
local function list(args)
local text = ""
local to1 = args["to1"]
if (to1) then --Support to1 and to 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["to" .. i]) then
text = string.format("%s%s",text,row(args, i))
i = i + 1 --Check if to(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)
local text = string.format("This %s has previously been nominated to be moved. %s", pageType)
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',
text = BannerText(args)
})
end
function p.main(frame)
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)
return renderBanner(args)
end
return p