Autres langues
Autres actions
Page créée avec « local p = {} local function is_set(var) return not (var == nil or var == ''); end local function italics(var) return "<i>" .. var .. "</i>" end local function parenthesis(var) return "(" .. var .. ")" end function p.cite(frame) local pframe = frame:getParent() local Auteur = pframe.args.author local Annee = pframe.args.year or pframe.args['date'] local Chapitre = pframe.args.chapter local URLChapitre = pframe.args['chapter-url'] local Section = pfram... » |
test 3 |
||
| Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
local function | local function est_defini(var) | ||
return not (var == nil or var == '') | return not (var == nil or var == '') | ||
end | end | ||
local function | local function italiques(var) | ||
return "<i>" .. var .. "</i>" | return "<i>" .. var .. "</i>" | ||
end | end | ||
local function | local function parentheses(var) | ||
return "(" .. var .. ")" | return "(" .. var .. ")" | ||
end | end | ||
| Ligne 15 : | Ligne 15 : | ||
function p.cite(frame) | function p.cite(frame) | ||
local pframe = frame:getParent() | local pframe = frame:getParent() | ||
local Auteur = pframe.args. | local Auteur = pframe.args.auteur | ||
local Annee = pframe.args | local Annee = pframe.args['année'] or pframe.args['date'] | ||
local Chapitre = pframe.args. | local Chapitre = pframe.args.chapitre | ||
local URLChapitre = pframe.args[' | local URLChapitre = pframe.args['url-chapitre'] | ||
local Section = pframe.args.section | local Section = pframe.args.section | ||
local Titre = pframe.args. | local Titre = pframe.args.titre | ||
local URLTitre = pframe.args[' | local URLTitre = pframe.args['url-titre'] | ||
local TitreBibliotheque = pframe.args[' | local TitreBibliotheque = pframe.args['titre-bibliotheque'] | ||
local Volume = pframe.args.volume | local Volume = pframe.args.volume | ||
local Serie = pframe.args | local Serie = pframe.args['série'] or pframe.args.journal | ||
local Traduction = pframe.args[' | local Traduction = pframe.args['titre-traduction'] | ||
local LangueTrad = pframe.args[' | local LangueTrad = pframe.args['langue-traduction'] | ||
local Page = pframe.args.page or pframe.args.pages | local Page = pframe.args.page or pframe.args.pages | ||
local PDF = pframe.args.pdf | local PDF = pframe.args.pdf | ||
local Ville = pframe.args. | local Ville = pframe.args.ville | ||
local Editeur = pframe.args | local Editeur = pframe.args['éditeur'] or pframe.args.via | ||
local ISBN = pframe.args.isbn or pframe.args.issn | local ISBN = pframe.args.isbn or pframe.args.issn | ||
local ISSN = false | local ISSN = false | ||
if | if est_defini(pframe.args.issn) then | ||
ISSN = true | ISSN = true | ||
end | end | ||
| Ligne 39 : | Ligne 39 : | ||
local LG = pframe.args.lg | local LG = pframe.args.lg | ||
local MIA = pframe.args.mia | local MIA = pframe.args.mia | ||
local Citation = pframe.args. | local Citation = pframe.args.citation | ||
local Image = pframe.args.image | local Image = pframe.args.image | ||
local LegendeImage = pframe.args['image | local LegendeImage = pframe.args['legende-image'] | ||
local SansPointFinal = pframe.args. | local SansPointFinal = pframe.args.sans_point_final | ||
local premiere_partie = '' | |||
if | if est_defini(Auteur) then | ||
if | if est_defini(Annee) then | ||
premiere_partie = Auteur .. " " .. parentheses(Annee) .. "." | |||
else | else | ||
premiere_partie = Auteur .. "." | |||
end | end | ||
end | end | ||
if | if est_defini(Citation) then | ||
Citation = string.gsub(Citation, "\n", "<br>") | Citation = string.gsub(Citation, "\n", "<br>") | ||
Citation = " | Citation = "« " .. Citation .. " »" | ||
local div = mw.html.create('div') | local div = mw.html.create('div') | ||
div | div | ||
| Ligne 63 : | Ligne 62 : | ||
:wikitext(Citation) | :wikitext(Citation) | ||
local br = mw.html.create('br', selfClosing) | local br = mw.html.create('br', selfClosing) | ||
premiere_partie = italiques(tostring(div)) .. tostring(br) .. premiere_partie | |||
end | end | ||
if | if est_defini(Image) then | ||
local span = mw.html.create('span') | local span = mw.html.create('span') | ||
span | span | ||
:wikitext('[[ | :wikitext('[[Fichier:' .. Image .. '|center|300px|sans_cadre]]') | ||
if | if est_defini(LegendeImage) then | ||
local | local legende = mw.html.create('div') | ||
legende | |||
:attr("style", "text-align:center;font-size:85%;") | :attr("style", "text-align:center;font-size:85%;") | ||
:wikitext(LegendeImage) | :wikitext(LegendeImage) | ||
premiere_partie = tostring(span) .. tostring(legende) .. premiere_partie | |||
else | else | ||
premiere_partie = tostring(span) .. premiere_partie | |||
end | end | ||
end | end | ||
-- | -- deuxième partie: Titre(URL), Série, Volume, URLChapitre, Année, Page, Traduction(Langue), PDF | ||
local deuxieme_partie = '' | local deuxieme_partie = '' | ||
if | if est_defini(Titre) then | ||
if | if est_defini(URLTitre) then | ||
Titre = "[" .. URLTitre .. " " .. Titre .. "]" | Titre = "[" .. URLTitre .. " " .. Titre .. "]" | ||
else | else | ||
if | if est_defini(TitreBibliotheque) then | ||
Titre = "[[ | Titre = "[[Bibliothèque:" .. TitreBibliotheque .. "|" .. Titre .. "]]" | ||
end | end | ||
end | end | ||
Titre = | Titre = italiques(Titre) | ||
if not | if not est_defini(Serie) then | ||
if | if est_defini(Volume) then | ||
Titre = Titre .. ", vol. " .. Volume | Titre = Titre .. ", vol. " .. Volume | ||
end | end | ||
end | end | ||
deuxieme_partie = Titre | deuxieme_partie = Titre | ||
if | if est_defini(Chapitre) then | ||
if | if est_defini(URLChapitre) then | ||
Chapitre = "[" .. URLChapitre .. " " .. Chapitre .. "]" | Chapitre = "[" .. URLChapitre .. " " .. Chapitre .. "]" | ||
end | end | ||
if | if est_defini(Section) then | ||
Chapitre = Chapitre .. "; " .. Section | Chapitre = Chapitre .. "; " .. Section | ||
end | end | ||
| Ligne 111 : | Ligne 109 : | ||
end | end | ||
if not | if not est_defini(Auteur) then | ||
if | if est_defini(Annee) then | ||
deuxieme_partie = deuxieme_partie .. " " .. | deuxieme_partie = deuxieme_partie .. " " .. parentheses(Annee) | ||
end | end | ||
end | end | ||
if | if est_defini(Traduction) then | ||
if | if est_defini(LangueTrad) then | ||
deuxieme_partie = deuxieme_partie .. " " .. "(" .. LangueTrad .. ": " .. Traduction .. ")" | deuxieme_partie = deuxieme_partie .. " " .. "(" .. LangueTrad .. ": " .. Traduction .. ")" | ||
else | else | ||
deuxieme_partie = deuxieme_partie .. " " .. | deuxieme_partie = deuxieme_partie .. " " .. parentheses(Traduction) | ||
end | end | ||
end | end | ||
if | if est_defini(Page) and not est_defini(Volume) then | ||
if tonumber(Page) ~= nil then | if tonumber(Page) ~= nil then | ||
Page = "p." .. " " .. Page | Page = "p." .. " " .. Page | ||
| Ligne 130 : | Ligne 128 : | ||
Page = "pp." .. " " .. Page | Page = "pp." .. " " .. Page | ||
end | end | ||
deuxieme_partie = deuxieme_partie .. " " .. | deuxieme_partie = deuxieme_partie .. " " .. parentheses(Page) .. "." | ||
else | else | ||
deuxieme_partie = deuxieme_partie .. "." | deuxieme_partie = deuxieme_partie .. "." | ||
| Ligne 136 : | Ligne 134 : | ||
end | end | ||
if | if est_defini(Serie) then | ||
if | if est_defini(Volume) then | ||
Serie = Serie .. ", vol." .. Volume | Serie = Serie .. ", vol." .. Volume | ||
end | end | ||
if | if est_defini(Page) and est_defini(Volume) and est_defini(Serie) then | ||
if tonumber(Page) ~= nil then | if tonumber(Page) ~= nil then | ||
Page = "p." .. " " .. Page | Page = "p." .. " " .. Page | ||
| Ligne 147 : | Ligne 145 : | ||
Page = "pp." .. " " .. Page | Page = "pp." .. " " .. Page | ||
end | end | ||
deuxieme_partie = deuxieme_partie .. " " .. Serie .. " " .. | deuxieme_partie = deuxieme_partie .. " " .. Serie .. " " .. parentheses(Page) .. "." | ||
else | else | ||
deuxieme_partie = deuxieme_partie .. " " .. Serie .. "." | deuxieme_partie = deuxieme_partie .. " " .. Serie .. "." | ||
| Ligne 153 : | Ligne 151 : | ||
end | end | ||
if | if est_defini(PDF) then | ||
local span = mw.html.create('span') | local span = mw.html.create('span') | ||
span | span | ||
:attr('title', ' | :attr('title', 'Télécharger en PDF') | ||
:addClass('plainlinks') | :addClass('plainlinks') | ||
:tag('small') | :tag('small') | ||
| Ligne 163 : | Ligne 161 : | ||
end | end | ||
-- | -- troisième partie: Ville, Éditeur | ||
local troisieme_partie = '' | local troisieme_partie = '' | ||
if | if est_defini(Ville) then | ||
if | if est_defini(Editeur) then | ||
troisieme_partie = Ville .. ": " .. Editeur .. "." | troisieme_partie = Ville .. ": " .. Editeur .. "." | ||
else | else | ||
| Ligne 175 : | Ligne 172 : | ||
end | end | ||
if not | if not est_defini(Ville) then | ||
if | if est_defini(Editeur) then | ||
troisieme_partie = Editeur .. "." | troisieme_partie = Editeur .. "." | ||
else | else | ||
| Ligne 183 : | Ligne 180 : | ||
end | end | ||
-- | -- quatrième partie: ISBN, DOI, Library Genesis, Marxists Internet Archive | ||
local quatrieme_partie = '' | local quatrieme_partie = '' | ||
if | if est_defini(ISBN) then | ||
local span = mw.html.create('span') | local span = mw.html.create('span') | ||
span | span | ||
| Ligne 205 : | Ligne 201 : | ||
end | end | ||
if | if est_defini(DOI) then | ||
local doispan = mw.html.create('span') | local doispan = mw.html.create('span') | ||
doispan | doispan | ||
| Ligne 220 : | Ligne 216 : | ||
end | end | ||
if | if est_defini(LG) then | ||
local span = mw.html.create('span') | local span = mw.html.create('span') | ||
span | span | ||
| Ligne 230 : | Ligne 226 : | ||
end | end | ||
if | if est_defini(MIA) then | ||
local span = mw.html.create('span') | local span = mw.html.create('span') | ||
span | span | ||
| Ligne 240 : | Ligne 236 : | ||
end | end | ||
if est_defini(deuxieme_partie) then | |||
if | |||
deuxieme_partie = " " .. deuxieme_partie | deuxieme_partie = " " .. deuxieme_partie | ||
end | end | ||
if | if est_defini(troisieme_partie) then | ||
troisieme_partie = " " .. troisieme_partie | troisieme_partie = " " .. troisieme_partie | ||
end | end | ||
if | if est_defini(quatrieme_partie) then | ||
quatrieme_partie = " " .. quatrieme_partie | quatrieme_partie = " " .. quatrieme_partie | ||
end | end | ||
local rendu = | local rendu = premiere_partie .. deuxieme_partie .. troisieme_partie .. quatrieme_partie | ||
-- supprimer les espaces au | -- supprimer les espaces au début et à la fin | ||
rendu = string.gsub(rendu, "^%s*(.-)%s*$", "%1") | rendu = string.gsub(rendu, "^%s*(.-)%s*$", "%1") | ||
| Ligne 264 : | Ligne 259 : | ||
return rendu | return rendu | ||
end | end | ||
return p | return p | ||
Dernière version du 15 novembre 2025 à 20:15
local p = {}
local function est_defini(var)
return not (var == nil or var == '')
end
local function italiques(var)
return "<i>" .. var .. "</i>"
end
local function parentheses(var)
return "(" .. var .. ")"
end
function p.cite(frame)
local pframe = frame:getParent()
local Auteur = pframe.args.auteur
local Annee = pframe.args['année'] or pframe.args['date']
local Chapitre = pframe.args.chapitre
local URLChapitre = pframe.args['url-chapitre']
local Section = pframe.args.section
local Titre = pframe.args.titre
local URLTitre = pframe.args['url-titre']
local TitreBibliotheque = pframe.args['titre-bibliotheque']
local Volume = pframe.args.volume
local Serie = pframe.args['série'] or pframe.args.journal
local Traduction = pframe.args['titre-traduction']
local LangueTrad = pframe.args['langue-traduction']
local Page = pframe.args.page or pframe.args.pages
local PDF = pframe.args.pdf
local Ville = pframe.args.ville
local Editeur = pframe.args['éditeur'] or pframe.args.via
local ISBN = pframe.args.isbn or pframe.args.issn
local ISSN = false
if est_defini(pframe.args.issn) then
ISSN = true
end
local DOI = pframe.args.doi
local LG = pframe.args.lg
local MIA = pframe.args.mia
local Citation = pframe.args.citation
local Image = pframe.args.image
local LegendeImage = pframe.args['legende-image']
local SansPointFinal = pframe.args.sans_point_final
local premiere_partie = ''
if est_defini(Auteur) then
if est_defini(Annee) then
premiere_partie = Auteur .. " " .. parentheses(Annee) .. "."
else
premiere_partie = Auteur .. "."
end
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(Image) then
local span = mw.html.create('span')
span
:wikitext('[[Fichier:' .. Image .. '|center|300px|sans_cadre]]')
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
-- deuxième partie: Titre(URL), Série, Volume, URLChapitre, Année, Page, Traduction(Langue), PDF
local deuxieme_partie = ''
if est_defini(Titre) then
if est_defini(URLTitre) then
Titre = "[" .. URLTitre .. " " .. Titre .. "]"
else
if est_defini(TitreBibliotheque) then
Titre = "[[Bibliothèque:" .. TitreBibliotheque .. "|" .. Titre .. "]]"
end
end
Titre = italiques(Titre)
if not est_defini(Serie) then
if est_defini(Volume) then
Titre = Titre .. ", vol. " .. Volume
end
end
deuxieme_partie = Titre
if est_defini(Chapitre) then
if est_defini(URLChapitre) then
Chapitre = "[" .. URLChapitre .. " " .. Chapitre .. "]"
end
if est_defini(Section) then
Chapitre = Chapitre .. "; " .. Section
end
deuxieme_partie = deuxieme_partie .. ": " .. "'" .. Chapitre .. "'"
end
if not est_defini(Auteur) then
if est_defini(Annee) then
deuxieme_partie = deuxieme_partie .. " " .. parentheses(Annee)
end
end
if est_defini(Traduction) then
if est_defini(LangueTrad) then
deuxieme_partie = deuxieme_partie .. " " .. "(" .. LangueTrad .. ": " .. Traduction .. ")"
else
deuxieme_partie = deuxieme_partie .. " " .. parentheses(Traduction)
end
end
if est_defini(Page) and not est_defini(Volume) then
if tonumber(Page) ~= nil then
Page = "p." .. " " .. Page
else
Page = "pp." .. " " .. Page
end
deuxieme_partie = deuxieme_partie .. " " .. parentheses(Page) .. "."
else
deuxieme_partie = deuxieme_partie .. "."
end
end
if est_defini(Serie) then
if est_defini(Volume) then
Serie = Serie .. ", vol." .. Volume
end
if est_defini(Page) and est_defini(Volume) and est_defini(Serie) then
if tonumber(Page) ~= nil then
Page = "p." .. " " .. Page
else
Page = "pp." .. " " .. Page
end
deuxieme_partie = deuxieme_partie .. " " .. Serie .. " " .. parentheses(Page) .. "."
else
deuxieme_partie = deuxieme_partie .. " " .. Serie .. "."
end
end
if est_defini(PDF) then
local span = mw.html.create('span')
span
:attr('title', 'Télécharger en PDF')
:addClass('plainlinks')
:tag('small')
:wikitext('[' .. PDF .. " " .. mw.text.nowiki('[PDF]') .. ']')
deuxieme_partie = deuxieme_partie .. " " .. tostring(span)
end
-- troisième partie: Ville, Éditeur
local troisieme_partie = ''
if est_defini(Ville) then
if est_defini(Editeur) then
troisieme_partie = Ville .. ": " .. Editeur .. "."
else
troisieme_partie = Ville .. "."
end
end
if not est_defini(Ville) then
if est_defini(Editeur) then
troisieme_partie = Editeur .. "."
else
troisieme_partie = ''
end
end
-- quatrième partie: ISBN, DOI, Library Genesis, Marxists Internet Archive
local quatrieme_partie = ''
if est_defini(ISBN) then
local span = mw.html.create('span')
span
:addClass('plainlinks')
if (ISSN) then
span
:tag('small')
:attr('title', 'Portail ISSN')
:wikitext('[' .. "https://portal.issn.org/resource/ISSN/" .. ISBN .. " " .. "ISSN " .. ISBN .. ']')
else
span
:tag('small')
:attr('title', 'WorldCat')
:wikitext('[' .. "https://www.worldcat.org/search?qt=worldcat_org_all&q=" .. ISBN .. " " .. "ISBN " .. ISBN .. ']')
end
quatrieme_partie = quatrieme_partie .. tostring(span)
end
if est_defini(DOI) then
local doispan = mw.html.create('span')
doispan
:tag('small')
:wikitext("doi: " .. DOI)
quatrieme_partie = quatrieme_partie .. " " .. tostring(doispan)
local span = mw.html.create('span')
span
:attr('title', 'Lien Sci-Hub')
:addClass('plainlinks')
:tag('small')
:wikitext('[' .. "https://sci-hub.se/" .. DOI .. " " .. mw.text.nowiki('[HUB]') .. ']')
quatrieme_partie = quatrieme_partie .. " " .. tostring(span)
end
if est_defini(LG) then
local span = mw.html.create('span')
span
:attr('title', 'Lien Library Genesis')
:addClass('plainlinks')
:tag('small')
:wikitext('[' .. LG .. " " .. mw.text.nowiki('[LG]') .. ']')
quatrieme_partie = quatrieme_partie .. " " .. tostring(span)
end
if est_defini(MIA) then
local span = mw.html.create('span')
span
:attr('title', 'Lien Marxists Internet Archive')
:addClass('plainlinks')
:tag('small')
:wikitext('[' .. MIA .. " " .. mw.text.nowiki('[MIA]') .. ']')
quatrieme_partie = quatrieme_partie .. " " .. tostring(span)
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
-- supprimer les espaces au début et à la fin
rendu = string.gsub(rendu, "^%s*(.-)%s*$", "%1")
if SansPointFinal then
rendu = rendu:sub(1, -2)
end
return rendu
end
return p