Module:Web citation: Difference between revisions

From ProleWiki, the proletarian encyclopedia
(Sketch of template)
 
No edit summary
Line 11: Line 11:
local Date = pframe.args['date']
local Date = pframe.args['date']
local Title = pframe.args.title
local Title = pframe.args.title
local TitleURL = pframe.args['title-url']
local URL = pframe.args.url
local Newspaper = pframe.args.newspaper
local Newspaper = pframe.args.newspaper
local ArchiveURL = pframe.args['archive-url']
local ArchiveURL = pframe.args['archive-url']
Line 19: Line 19:
if is_set (Journalist) then
if is_set (Journalist) then
if is_set (Date) then
if is_set (Date) then
x1 = Journalist .. " (" .. Date .. ")" .. ". "
x1 = Journalist .. " (" .. Date .. ")."
else
else
x1 = Journalist .. "."
x1 = Journalist .. "."
Line 26: Line 26:
x1 = ""
x1 = ""
end
end
 
if is_set (Title) then
if is_set (Title) then
if is_set (TitleURL) then
if is_set (URL) then
Title = "[" .. TitleURL .. " " .. "\"" .. Title .. "\"" .. "]"
Title = "[" .. URL .. " " .. "\"" .. Title .. "\"" .. "]."
end
end
x2 = Title
x2 = Title
Line 37: Line 37:
if is_set(Newspaper) then
if is_set(Newspaper) then
x3 = "''" .. Newspaper .. "''" .. "."
x3 = "''" .. Newspaper .. "''."
else
else
x3 = ""
x3 = ""
end
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


Line 54: Line 71:
x3 = x3 .. " "
x3 = x3 .. " "
end
end
 
return x1 .. x2 .. x3 .. x4
if is_set (x4) then
x4 = x4 .. " "
end
return x1 .. x2 .. x3 .. x4 .. x5
end
end
return p
return p

Revision as of 03:12, 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
		x2 = Title
		else
			x2 = ""
	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
	
	return x1 .. x2 .. x3 .. x4 .. x5
end
return p