-- Intégration des citations
local p = {}
local outils = require('Module:Outils')
-- Citation bloc
function p.blockQuote(frame)
local params = outils.extractArgs(frame)
local quote = outils.trim(params[1]) or outils.trim(params['citation']) or 'Citation ?'
local author = outils.trim(params[2]) or outils.trim(params['auteur'])
local reference = outils.trim(params[3]) or outils.trim(params['référence'])
local style = outils.trim(params['style']) or 'center'
local sound = outils.trim(params['son'])
local res = mw.html.create('blockquote')
res
:addClass('noexcerpt')
:attr('style', 'text-align: ' .. style)
:tag('p')
:wikitext('« ' .. quote .. ' »')
:done()
:done()
:done()
if author or reference then
local cite = ''
if author and reference then
cite = author .. ', <cite>' .. reference .. '</cite>'
elseif reference then
cite = '<cite>' .. reference .. '</cite>'
else
cite = author
end
res
:tag('small')
:wikitext('— ' .. cite)
:done()
end
if sound then
res:wikitext('[[Fichier:' .. sound .. '|alt=]]')
end
res:allDone()
return res
end
-- Citation ligne
function p.lineQuote(frame)
local params = outils.extractArgs(frame)
local quote = outils.trim(params[1]) or outils.trim(params['citation']) or 'Citation ?'
local author = outils.trim(params[2]) or outils.trim(params['auteur'])
local reference = outils.trim(params[3]) or outils.trim(params['référence'])
local style = outils.trim(params['style']) or 'center'
local sound = outils.trim(params['son'])
if author or reference then
if author and reference then
reference = ' — ' .. author .. ', <cite>' .. reference .. '</cite>'
elseif reference then
reference = ' — <cite>' .. reference .. '</cite>'
else
reference = ' — ' .. author
end
else
reference = nil
end
local res = mw.html.create('q')
res:wikitext('« ' .. quote .. ' »'):done()
if reference then
res:tag('small'):wikitext(reference):done()
end
if sound then
res
:tag('div')
:addClass('np-quote-snd-trigger')
:wikitext('[[Fichier:Icon sound trigger.png|middle|link=|alt=]]')
:tag('div')
:addClass('np-quote-snd-player')
:tag('div')
:addClass('np-quote-snd-player-img')
:wikitext('[[Fichier:Icon sound.png|x50px|link=|alt=]]')
:done()
:tag('div')
:addClass('np-quote-snd-player-title')
:tag('span')
:wikitext('Lire le fichier audio<br/>[[:Fichier:' .. sound .. '|' .. sound .. ']]')
:done()
:done()
:wikitext('[[Fichier:' .. sound .. '|noicon|300px|center]]')
:done()
:done()
end
res:allDone()
return res
end
return p