Basculer le menu
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

« Module:Citation web » : différence entre les versions

De ProleWiki
CriticalResist (discussion | contributions)
FR translation test
CriticalResist (discussion | contributions)
test 3
 
Ligne 1 : Ligne 1 :
local p = {}
local p = {}


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


local function italics (var)
local function italiques (var)
return "''" .. var .. "''"
return "''" .. var .. "''"
end
end
Ligne 12 : Ligne 12 :
local pframe = frame:getParent()
local pframe = frame:getParent()


local Author = pframe.args.auteur
local Auteur = pframe.args.auteur
if is_set (pframe.args.journalist) then
if est_defini (pframe.args.journaliste) then
Author = pframe.args.journaliste
Auteur = pframe.args.journaliste
end
end
local Date = pframe.args['date']
local Date = pframe.args['date']
local title = pframe.args.titre
local Titre = pframe.args.titre
local URL = pframe.args.url
local URL = pframe.args.url
local Website = pframe.args.journal or pframe.args['site web']
local Site = pframe.args.journal or pframe.args.site
local ArchiveURL = pframe.args['archive-url']
local URLArchive = pframe.args['archive-url']
local ArchiveDate = pframe.args['archive-date']
local DateArchive = pframe.args['archive-date']
local Retrieved = pframe.args['retrouvé']
local Recupere = pframe.args.recupere
local Quote = pframe.args.citation
local Citation = pframe.args.citation
local Image = pframe.args.image
local Image = pframe.args.image
local ImageCaption = pframe.args['légende-image']
local LegendeImage = pframe.args['legende-image']
if is_set (Author) then
local premiere_partie = ""
if is_set (Date) then
first_part = Author .. " (" .. Date .. ")."
if est_defini (Auteur) then
else
if est_defini (Date) then
first_part = Author .. "."
premiere_partie = Auteur .. " (" .. Date .. ")."
else
premiere_partie = Auteur .. "."
end
end
else
first_part = ""
end
end
if is_set (Image) then
if est_defini (Image) then
local span = mw.html.create ( 'span' )
local span = mw.html.create ( 'span' )
span
span
:wikitext('[[File:' .. Image .. '|center|300px|frameless]]')
:wikitext('[[Fichier:' .. Image .. '|center|300px|sans_cadre]]')
local br = mw.html.create ('br', selfClosing)
local br = mw.html.create ('br', selfClosing)


if is_set(ImageCaption) then  
if est_defini(LegendeImage) then  
local caption = mw.html.create ('div')
local legende = mw.html.create ('div')
caption
legende
:attr("style", "text-align:center;font-size:85%;")
:attr("style", "text-align:center;font-size:85%;")
:wikitext(ImageCaption)
:wikitext(LegendeImage)
first_part = tostring(span) .. tostring(caption) .. first_part
premiere_partie = tostring(span) .. tostring(legende) .. premiere_partie
else
else
first_part = tostring(span) .. first_part
premiere_partie = tostring(span) .. premiere_partie
end
end
end
end
if is_set (Title) then
local deuxieme_partie = ""
if is_set (URL) then
Title = "[" .. URL .. " " .. "\"" .. Title .. "\"" .. "]"
if est_defini (Titre) then
end
if est_defini (URL) then
if not is_set (Author) then
Titre = "[" .. URL .. " " .. "\"" .. Titre .. "\"" .. "]"
if is_set (Date) then
end
Title = Title .. " (" .. Date .. ")."
if not est_defini (Auteur) then
if est_defini (Date) then
Titre = Titre .. " (" .. Date .. ")."
else
else
Title = Title .. "."
Titre = Titre .. "."
end
end
end
deuxieme_partie = Titre
end
end
second_part = Title
else
local troisieme_partie = ""
second_part = ""
if est_defini(Site) then
troisieme_partie = "''" .. Site .. "''."
end
end
local quatrieme_partie = ""
if is_set(Website) then
if est_defini(URLArchive) then
third_part = "''" .. Website .. "''."
if est_defini(DateArchive) then
else
quatrieme_partie = "[" .. URLArchive .. " " .. "Archivé" .. "]" .. " " .. "depuis l'original le" .. " " .. DateArchive .. "."
third_part = ""
else
end
quatrieme_partie = "[" .. URLArchive .. " " .. "Archivé" .. "]" .. " depuis l'original."
 
if is_set(ArchiveURL) then
if is_set(ArchiveDate) then
fourth_part = "[" .. ArchiveURL .. " " .. "Archive" .. "]" .. " " .. " de l'original le" .. " " .. ArchiveDate .. "."
else
fourth_part = "[" .. ArchiveURL .. " " .. "Archive" .. "]" .. " de l'original."
end
end
else
fourth_part = ""
end
end
if is_set (Retrieved) then
local cinquieme_partie = ""
fifth_part = "Récupéré" .. " " .. Retrieved .. "."
else
if est_defini (Recupere) then
fifth_part = ""
cinquieme_partie = "Récupéré le" .. " " .. Recupere .. "."
end
end
if is_set (Quote) then
if est_defini (Citation) then
Quote = string.gsub(Quote,"\n","<br>")
Citation = string.gsub(Citation,"\n","<br>")
Quote = "“" .. Quote .. "”"
Citation = "« " .. Citation .. " »"
local div = mw.html.create ('div')
local div = mw.html.create ('div')
div
div
:attr("style", "width:80%; margin-left:10%;")
:attr("style", "width:80%; margin-left:10%;")
:wikitext(Quote)
:wikitext(Citation)
local br = mw.html.create ('br', selfClosing)
local br = mw.html.create ('br', selfClosing)
first_part = italics(tostring(div)) .. tostring(br) .. first_part
premiere_partie = italiques(tostring(div)) .. tostring(br) .. premiere_partie
end
end


 
if est_defini (premiere_partie) then
if is_set (first_part) then
premiere_partie = premiere_partie .. " "
first_part = first_part .. " "
end
end
if is_set (second_part) then
if est_defini (deuxieme_partie) then
second_part = second_part .. " "
deuxieme_partie = deuxieme_partie .. " "
end
end
if is_set (third_part) then
if est_defini (troisieme_partie) then
third_part = third_part .. " "
troisieme_partie = troisieme_partie .. " "
end
end
if is_set (fourth_part) then
if est_defini (quatrieme_partie) then
fourth_part = fourth_part .. " "
quatrieme_partie = quatrieme_partie .. " "
end
end
Render = first_part .. second_part .. third_part .. fourth_part .. fifth_part
local Rendu = premiere_partie .. deuxieme_partie .. troisieme_partie .. quatrieme_partie .. cinquieme_partie
return Render
return Rendu
end
end
return p
return p

Dernière version du 15 novembre 2025 à 20:07

local p = {}

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

local function italiques (var)
	return "''" .. var .. "''"
end

function p.cite( frame )
	local pframe = frame:getParent()

	local Auteur = pframe.args.auteur
	if est_defini (pframe.args.journaliste) then
		Auteur = pframe.args.journaliste
	end
	local Date = pframe.args['date']
	local Titre = pframe.args.titre
	local URL = pframe.args.url
	local Site = pframe.args.journal or pframe.args.site
	local URLArchive = pframe.args['archive-url']
	local DateArchive = pframe.args['archive-date']
	local Recupere = pframe.args.recupere
	local Citation = pframe.args.citation
	local Image = pframe.args.image
	local LegendeImage = pframe.args['legende-image']
	
	local premiere_partie = ""
	
	if est_defini (Auteur) then
		if est_defini (Date) then
			premiere_partie = Auteur .. " (" .. Date .. ")."
		else
			premiere_partie = Auteur .. "."
		end
	end
	
	if est_defini (Image) then
		local span = mw.html.create ( 'span' )
		span
		:wikitext('[[Fichier:' .. Image .. '|center|300px|sans_cadre]]')
		local br = mw.html.create ('br', selfClosing)

		if est_defini(LegendeImage) then 
			local legende = mw.html.create ('div')
			legende
			:attr("style", "text-align:center;font-size:85%;")
			:wikitext(LegendeImage)
			premiere_partie = tostring(span) .. tostring(legende) .. premiere_partie
		else
			premiere_partie = tostring(span) .. premiere_partie
		end
	end
	
	local deuxieme_partie = ""
	
	if est_defini (Titre) then
		if est_defini (URL) then
			Titre = "[" .. URL .. " " .. "\"" .. Titre .. "\"" .. "]"
		end
		if not est_defini (Auteur) then
			if est_defini (Date) then
				Titre = Titre .. " (" .. Date .. ")."
			else
				Titre = Titre .. "."
			end
		end
		deuxieme_partie = Titre
	end
	
	local troisieme_partie = ""
	
	if est_defini(Site) then
		troisieme_partie = "''" .. Site .. "''."
	end
		
	local quatrieme_partie = ""
	
	if est_defini(URLArchive) then
		if est_defini(DateArchive) then
			quatrieme_partie = "[" .. URLArchive .. " " .. "Archivé" .. "]" .. " " .. "depuis l'original le" .. " " .. DateArchive .. "."
		else
			quatrieme_partie = "[" .. URLArchive .. " " .. "Archivé" .. "]" .. " depuis l'original."
		end
	end
			
	local cinquieme_partie = ""
	
	if est_defini (Recupere) then
		cinquieme_partie = "Récupéré le" .. " " .. Recupere .. "."
	end
		
	if est_defini (Citation) then
		Citation = string.gsub(Citation,"\n","<br>")
		Citation = "« " .. Citation .. " »"
		local div = mw.html.create ('div')
		div
		:attr("style", "width:80%; margin-left:10%;")
		:wikitext(Citation)
		local br = mw.html.create ('br', selfClosing)
		premiere_partie = italiques(tostring(div)) .. tostring(br) .. premiere_partie
	end

	if est_defini (premiere_partie) then
		premiere_partie = premiere_partie .. " "
	end
	
	if est_defini (deuxieme_partie) then
		deuxieme_partie = deuxieme_partie .. " "
	end
	
	if est_defini (troisieme_partie) then
		troisieme_partie = troisieme_partie .. " "
	end
	
	if est_defini (quatrieme_partie) then
		quatrieme_partie = quatrieme_partie .. " "
	end
	
	local Rendu = premiere_partie .. deuxieme_partie .. troisieme_partie .. quatrieme_partie .. cinquieme_partie
	
	return Rendu
end

return p