Module:Backwards copy: Difference between revisions

Content deleted Content added
org not title in publisher
downgrade missing date to warning if year provided in author
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 author = args["author" .. i] or (i == 1 and args["author"])
local authors = args["authorlist" .. i] or (i == 1 and args["authorlist"])
local date = (args["date" .. i] or (i == 1 and args["date"])) or
-- legacy way of providing dates
Line 62 ⟶ 69:
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))
elseif string.match(authors or "", "(%d%d%d[%d]*)") then
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>authorlist%s</code> parameter. Move the provided year to the correct parameter.",
i, i, i
), demoCheck(args))
else
return showError(string.format(
return showError( "Provided titles<code>title%s</code> must also have a respective <code>year%s</code> or <code>date%s</code> parameter."),
i, i, i
))
end
end
table.insert(citations, frame:expandTemplate{ title = "Citation", args = {
ref = "none",
author = args["author" .. i] or (i == 1 and args["author"]),
authors = args["authorlist" .. i] or (i == 1 and args["authorlist"])authors,
["display-authors"] = args["display-authors" .. i] or (i == 1 and args["display-authors"]),
date = date,