Content deleted Content added
add error for missing date (required parameter) |
per talk |
||
(9 intermediate revisions by 4 users not shown) | |||
Line 6:
local function demoCheck(args)
return yesno(args["demo"]) or yesno(args["nocat"])
end
local function showWarning(text, nocat)
mw.addWarning(text)
return nocat and "" or "[[Category:Pages with backwards copy warnings]]"
end
Line 53 ⟶ 58:
table.insert(citations, args[tostring(i)])
else
local date = (args["date" .. i] or (i == 1 and args["date"])) or
-- legacy way of providing dates
Line 62 ⟶ 68:
if mw.text.trim(date or "") == "" then
if string.match(author or "", "(%d%d%d[%d]+)") then
return showError("Provided titles must also have a respective <code>year</code> or <code>date</code> parameter.")▼
text = text .. " " .. showWarning(string.format(
"A <code>year%s</code> or <code>date%s</code> parameter was not found, but a parenthesized year was found in the " ..
"<code>author%s</code> parameter. Move the provided year to the correct parameter.",
i, i, i
), demoCheck(args))
else
text = text .. " " .. showWarning(string.format(
▲
i, i, i
))
end
end
if tonumber (display_authors) and (0 ~= tonumber (display_authors)) then -- for {{backwards copy}} only allowed number is 0 to suppress author name list
display_authors = 'etal'; -- any other number gets 'etal'; any other text will be rejected by cs1|2
end
table.insert(citations, frame:expandTemplate{ title = "Citation", args = {
ref = "none",
author =
["display-authors"] = display_authors,
▲ authors = args["authorlist" .. i] or (i == 1 and args["authorlist"]),
▲ ["display-authors"] = args["display-authors" .. i] or (i == 1 and args["display-authors"]),
date = date,
url = args["url" .. i] or (i == 1 and args["url"]),
title = (args["articlename" .. i] or (i == 1 and args["articlename"]))
or args["title" .. i] or (i == 1 and args["title"]),
publisher = (args["
or args["publisher" .. i] or (i == 1 and args["publisher"])
} })
Line 84 ⟶ 105:
text = string.format(
"%s article is substantially duplicated by a piece in an external publication. " ..
"
text
)
Line 132 ⟶ 153:
return MessageBox.main('tmbox', {
name = "backwards-copy",
small = yesno(args["small"]),
image = '[[File:Newspaper Cover.svg|50px]]',
text = bannerText(frame, args)
}) .. ((demoCheck(args)
"" or "[[Category:Wikipedia article talk pages incorporating the backwards copy template]]"
)
end
|