More languages
More actions
mNo edit summary |
mNo edit summary |
||
Line 16: | Line 16: | ||
local ArchiveDate = pframe.args['archive-date'] | local ArchiveDate = pframe.args['archive-date'] | ||
local Retrieved = pframe.args.retrieved | local Retrieved = pframe.args.retrieved | ||
if is_set (Journalist) then | if is_set (Journalist) then | ||
Line 43: | Line 39: | ||
else | else | ||
x2 = "" | x2 = "" | ||
end | |||
if not Date:match("%d%d%d%d-%d%d-%d%d") then | |||
Date = "<span class=\"error\">Wrong date format. Expected YYYY-MM-DD</span>" | |||
end | end | ||
Revision as of 17:09, 3 November 2021
local p = {}
local function is_set (var)
return not (var == nil or var == '');
end
function p.cite( frame )
local pframe = frame:getParent()
local Journalist = pframe.args.journalist
local Date = pframe.args['date']
local Title = pframe.args.title
local URL = pframe.args.url
local Newspaper = pframe.args.newspaper
local ArchiveURL = pframe.args['archive-url']
local ArchiveDate = pframe.args['archive-date']
local Retrieved = pframe.args.retrieved
if is_set (Journalist) then
if is_set (Date) then
x1 = Journalist .. " (" .. Date .. ")."
else
x1 = Journalist .. "."
end
else
x1 = ""
end
if is_set (Title) then
if is_set (URL) then
Title = "[" .. URL .. " " .. "\"" .. Title .. "\"" .. "]"
end
if not is_set (Journalist) then
Title = Title .. " (" .. Date .. ")."
else
Title = Title .. "."
end
x2 = Title
else
x2 = ""
end
if not Date:match("%d%d%d%d-%d%d-%d%d") then
Date = "<span class=\"error\">Wrong date format. Expected YYYY-MM-DD</span>"
end
if is_set(Newspaper) then
x3 = "''" .. Newspaper .. "''."
else
x3 = ""
end
if is_set(ArchiveURL) then
if is_set(ArchiveDate) then
x4 = "[" .. ArchiveURL .. " " .. "Archived" .. "]" .. " " .. "from the original on" .. " " .. ArchiveDate .. "."
else
x4 = "[" .. ArchiveURL .. " " .. "Archived" .. "]" .. "from the original."
end
else
x4 = ""
end
if is_set (Retrieved) then
x5 = "Retrieved" .. " " .. Retrieved .. "."
else
x5 = ""
end
if is_set (x1) then
x1 = x1 .. " "
end
if is_set (x2) then
x2 = x2 .. " "
end
if is_set (x3) then
x3 = x3 .. " "
end
if is_set (x4) then
x4 = x4 .. " "
end
Render = x1 .. x2 .. x3 .. x4 .. x5
return Render
end
return p