Модуль:Скопировано/песочница
Перейти к навигации
Перейти к поиску
Документация
![]() |
local MessageBox = require('Модуль:Message box')
local p = {}
local function row(args, i)
local text = ""
local afd = args["к удалению" .. i]
if (afd or args["к объединению" .. i]) then
text = string.format("%s\n*Объединено",text)
else
local action = args["действие" .. i]
if not action then
action = "Скопировано"
end
action = mw.ustring.gsub(action, '^%l', mw.ustring.upper)
text = string.format("%s\n*%s:",text, action)
end
local from = args["из" .. i] or ""
text = string.format("%s [%s %s] (",text,tostring(mw.uri.fullUrl(from, {redirect = "no"} )),from)
local from_oldid = args["исходный oldid" .. i]
if (from_oldid) then
text = string.format("%s[%s %s], ",text,tostring(mw.uri.fullUrl(from, {oldid = from_oldid} )), from_oldid)
end
local to = args["в".. i] or ""
text = string.format("%s[%s история]) → [[%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["целевой oldid" .. i] or args["целевой diff".. i]) then
local to_diff = args["целевой diff".. i] or "next"
local to_oldid = args["целевой oldid" .. i] or "prev"
text = string.format("%s ([%s diff])",text,tostring(mw.uri.fullUrl(to, {diff=to_diff, oldid = to_oldid} )))
end
local date = args["дата" .. i]
if (date) then
text = string.format("%s от %s",text,date)
end
if (afd) then
if (mw.ustring.match(afd, "Википедия:", 1 )) then --If no venue is given add AfD prefix
text = string.format("%s после [[%s|номинирования на удаление]]",text,afd)
else
text = string.format("%s после [[Википедия:К удалению/%s|номинирования на удаление]]",text,afd)
end
end
if (not (args["целевой oldid" .. i] or args["целевой diff".. i])) then
text = string.format("%s[[Категория:Страницы Википедии, использующие шаблон Скопировано без oldid]]",text)
end
return text
end
local function list(args)
local text = ""
local from1 = args["из1"]
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["из" .. 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(1)) then
pageType = "статью"
else
pageType = "страницу"
end
local historyList = list(args)
if (args["collapse"] == 'yes') then
local collapsedText = '<table style="width:100%%; background: transparent;" class="mw-collapsible mw-collapsed">\n<tr><th>Страницы, в рамках которых было копирование:</th></tr>\n<tr><td> %s </td></tr></table>'
historyList = string.format(collapsedText, historyList)
end
local text = "Содержимое было скопировано/перемещено/переведено из или в текущую %s; смотрите список ниже. Исходная страница теперь служит для [[Википедия:Копирование внутри Википедии|предоставления атрибуции]] для содержимого, добавленного в целевую статью, и не должна удаляться до тех пор, пока существует целевая статья со скопированным/перемещённым/переведённым в неё содержимым. Для атрибуции и просмотра сделанных изменений смотрите ссылки на историю правок ниже. %s"
text = string.format(text, pageType, historyList)
return text
end
local function categories(args)
local nocat = args["nocat"]
if nocat then
return ''
end
local to_oldid = args["целевой oldid"] or args["целевой diff"] or args["diff"] or args["целевой oldid1"] or args["целевой diff1"] or args["diff1"]
local from_oldid = args["исходный oldid"] or args["исходный oldid1"]
local text = "[[Категория:Страницы Википедии, использующие шаблон Скопировано]]"
if (not from_oldid) or (not to_oldid) then
text = text .. "[[Категория:Страницы Википедии, использующие шаблон Скопировано без oldid]]"
end
return text
end
local function BannerText(args)
--Checks if there are multiple rows
local text
text = multiText(args) .. categories(args)
return text
end
local function renderBanner(args)
return MessageBox.main('tmbox', {
class = "copiednotice",
small = args["small"],
image = '[[File:Splitsection.svg|50px]]',
text = BannerText(args)
})
end
function p.main(frame)
local getArgs = require('Модуль:Arguments').getArgs
local args = getArgs(frame)
return renderBanner(args)
end
return p