Content deleted Content added
basic args logic |
per talk |
||
(15 intermediate revisions by 4 users not shown) | |||
Line 17:
return nil
end
return string.gsub(string.gsub(require("Module:Delink")._delink{text}, "%[%[", ""), "%]%]", "")
end
Line 39 ⟶ 38:
end
local function bannerText(frame, args)
local text = ""
local id = args["id"] or args["revid"]
if id ~= nil then
text = string.format("Revisions succeeding [[Special:Diff/%s|this version]] of this", id)
else
text = "This"
Line 51 ⟶ 50:
local citations = {}
local i = 1
while (
while args[tostring(i)] or args["articlename" .. i] or args["title" .. i] or (i == 1 and (args["articlename"] or args["title"])) do▼
args[tostring(i)] or
▲
) do
if args[tostring(i)] then
else
local date = (args["date" .. i] or (i == 1 and args["date"])) or
-- legacy way of providing dates
string.format(
"%s %s",
args["monthday" .. i] or (i == 1 and args["monthday"]) or "",
args["year" .. i] or (i == 1 and args["year"]) or ""
)
if mw.text.trim(date or "") == "" then
if string.match(author 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>author%s</code> parameter. Move the provided year to the correct parameter.",
i, i, i
), demoCheck(args))
else
text = text .. " " .. showWarning(string.format(
"Provided <code>title%s</code> must also have a respective <code>year%s</code> or <code>date%s</code> parameter.",
i, i, i
))
end
end
local display_authors = args["display-authors" .. i] or (i == 1 and args["display-authors"]); -- get |display-authors= parameter value for this reference
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
ref = "none",
author =
["display-authors"] = display_authors,
▲ authorlist = 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 82 ⟶ 105:
text = string.format(
"%s article is substantially duplicated by a piece in an external publication. " ..
"
text
)
local citationCount = #citations
if citationCount == 0 then
return showError(
"No citations were provided. Provide at least one citation using <code>title</code>.",
demoCheck(args)
)
elseif
text = string.format("%ss:", text)
else
Line 101 ⟶ 125:
end
text =
"%s %s %s",
text,
tostring(ul),
args["comments"] and tostring(
mw.html.create("table")
:attr("class", "mw-collapsible mw-collapsed")
:attr("style", "width:100%; background-color: #f8eaba;")
:node(mw.html.create("tr")
:node(mw.html.create("th")
:wikitext("Additional comments")
)
)
:node(mw.html.create("tr"):node(mw.html.create("td")
:attr("style", "background-color: white; border: 1px solid #c0c090; padding: 0.25em 0.5em;")
:wikitext(
args["comments"]
)
))
) or ""
)
return text
end
function p.renderBanner(frame, args)
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
Line 121 ⟶ 167:
removeBlanks = true
})
return p.renderBanner(frame, args)
end
|