Toggle menu
Toggle personal menu
Δεν έχετε συνδεθεί
Your IP address will be publicly visible if you make any edits.

Module:Video citation: Διαφορά μεταξύ των αναθεωρήσεων

Από την ΠρολεΒίκι, την προλεταριακή εγκυκλοπαίδεια
(εισαγωγή προσθέτου)
 
μ (Ο Itsraining μετακίνησε τη σελίδα Module:YouTube citation στην Module:Video citation χωρίς να αφήσει ανακατεύθυνση)
(Καμία διαφορά)

Αναθεώρηση της 15:47, 23 Απριλίου 2024

Documentation for this module may be created at Module:Video citation/τεκμηρίωση

local p = {}

local function is_set (var)
	return not (var == nil or var == '');
end

local function italics (var)
	return "<i>" .. var .. "</i>"
end

function p.cite(frame)
	local parent = frame:getParent()
	
	local Title = parent.args['τίτλος'] or parent.args.title
	local Channel = parent.args['κανάλι'] or parent.args.channel
	local Date = parent.args['ημερομηνία'] or parent.args['date']
	local Quote = parent.args['απόφθεγμα'] or parent.args.quote
	local URL = parent.args.url
	local ArchiveURL = parent.args['αρχειοθετημένο-url'] or parent.args['archive-url']
	local ArchiveDate = parent.args['ημερομηνία-αρχειοθέτησης'] or parent.args['archive-date']
	local Retrieved = parent.args['ανακτήθηκε'] or parent.args.retrieved

	local first_part = ''
	local second_part = ''
	local third_part = ''
	
	local extTimestamp = ''
	if is_set(URL) then
		extTimestamp = URL:match("?t=(%d+)")
		if is_set(extTimestamp) then
			local second = extTimestamp%60
			local minute = math.floor(extTimestamp/60)
			local hour = math.floor(minute/60)
			while (minute>=60) do
				minute = minute - 60
			end
			
			extTimestamp = second
			if minute>0 then
				if minute<10 then
					minute = "0" .. minute
				end
				extTimestamp = minute .. ":" .. extTimestamp
				else
					extTimestamp = "00:" .. extTimestamp
			end
			if hour>0 then
				if hour<10 then
					hour = "0" .. hour
				end
				extTimestamp = hour .. ":" .. extTimestamp
			end
		end
	end

	if is_set (Quote) then
		Quote = string.gsub(Quote,"\n","<br>")
		Quote = "“" .. Quote .. "”"
		local div = mw.html.create ('div')
		div
		:attr("style", "width:80%; margin-left:10%;")
		:wikitext(Quote)
		local br = mw.html.create ('br', selfClosing)
		first_part = italics(tostring(div)) .. tostring(br) .. first_part
	end

	if is_set(Channel) then
		first_part = first_part .. Channel
	end
	
	if is_set(Title) then
		if is_set(URL) then
			Title = '[' .. URL .. " " .. '"' .. Title .. '"' .. ']'
		end
		second_part = second_part  .. Title
	end
	
	if is_set(extTimestamp) then
		second_part = second_part .. " (" .. extTimestamp .. ")"
		elseif is_set(Timestamp) then
			second_part = second_part .. " (" .. Timestamp .. ")"
	end
	
	if is_set(Date) then
		if is_set(Channel) then
			first_part = first_part .. ' (' .. Date .. ')'
		else
			second_part = second_part .. ' (' .. Date .. ')'
		end
	end
	
	if is_set(ArchiveURL) then
		if is_set(ArchiveDate) then
			third_part = " [" .. ArchiveURL .. " " .. "Αρχειοθετήθηκε" .. "]" .. " " .. " από το πρωτότυπο στις" .. " " .. ArchiveDate .. "."
			else
				third_part = " [" .. ArchiveURL .. " " .. "Αρχειοθετήθηκε" .. "]" .. " από το πρωτότυπο."
		end
	end
			
	if is_set (Retrieved) then
		third_part = third_part .. " Ανακτήθηκε" .. " " .. Retrieved .. "."
	end
	
return first_part .. ". " .. second_part .. ". " .. "''[[YouTube]]''." .. third_part
end
return p