Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Web citation: Difference between revisions

From ProleWiki, the proletarian encyclopedia
m (Testing)
mNo edit summary
Line 29: Line 29:
if is_set (Title) then
if is_set (Title) then
if is_set (URL) then
if is_set (URL) then
Title = "[" .. URL .. " " .. "\"" .. Title .. "\"" .. "]."
Title = "[" .. URL .. " " .. "\"" .. Title .. "\"" .. "]"
end
end
if not is_set (Journalist) then
Title = Title .. " (" .. Date .. ")."
else
Title = Title .. "."
end
x2 = Title
x2 = Title
else
else
x2 = ""
x2 = ""
end
if not is_set (Journalist) then
x2 = x2 .. " (" .. Date .. ")."
end
end

Revision as of 15:36, 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 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