« Module:Biblio » : différence entre les versions

Contenu supprimé Contenu ajouté
indicationDeLangue : simplification, responsabilitePrincipale : correction boucle infinie
Ajout des function ISBN, ISSN, responsabiliteSecondaire, descriptionPhysique et COinS
Ligne 2 :
 
local Langue = require ( 'Module:Langue' )
local Date = require ( 'Module:Date' )
 
-- cette simple fonction permet de récupérer les arguement du modèle,
Ligne 31 ⟶ 32 :
end
 
-- voir Modèle:ISBN
function Biblio.ISBN ( frame )
local args = extractArgs ( frame )
local liste = { }
local i = 1
local isbn = mw.text.trim ( args [1] or '' )
if isbn == '' then
liste = { 'ISBN inconnu[[Catégorie:ISBN nécessaire]]' }
else
local texteIsbn = 'ISBN ' .. isbn
repeat
local lien = '[[Spécial:Ouvrages de référence/' .. isbn
.. '|<span class="nowrap">' .. texteIsbn .. '</span>]]'
table.insert ( liste, lien )
 
i = i + 1
isbn = mw.text.trim ( args [i] or '' )
texteIsbn = isbn
until ibsn == ''
end
return '<small>(' .. mw.text.listToText ( liste ) .. ')</small>'
end
 
-- voir Modèle:ISSN
function Biblio.ISSN ( frame )
local args = extractArgs ( frame )
local liste = { }
local i = 1
local issn = mw.text.trim ( args [1] or '' )
if issn == '' then
liste = { 'inconnu[[Catégorie:ISSN nécessaire]]' }
else
repeat
local lien = '<span class="plainlinks noarchive">[http://worldcat.org/issn/'
.. mw.uri.encode( issn ) .. '&lang=fr ' .. issn.. ']</span>]]'
table.insert ( liste, lien )
 
i = i + 1
issn = mw.text.trim ( args [i] or '' )
texteIsbn = issn
until ibsn == ''
end
return '<small>([[International Standard Serial Number|ISSN]]&nbsp;' .. mw.text.listToText ( liste ) .. ')</small>'
end
 
-- voir Modèle:Module biblio/span initial
function Biblio.spanInitial ( frame )
local args = extractArgs ( frame ) -- préparation pour appel par modèle ou direct.
Ligne 40 ⟶ 89 :
end
 
-- voir Modèle:Module biblio/libellé
function Biblio.libelle ( frame )
local args = extractArgs ( frame )
Ligne 49 ⟶ 99 :
end
 
-- voir Modèle:Module biblio/indication de langue
function Biblio.indicationDeLangue ( frame )
local args = extractArgs ( frame )
Ligne 59 ⟶ 110 :
end
 
-- voir Modèle:Module biblio/responsabilité principale
function Biblio.responsabilitePrincipale ( frame )
local args = extractArgs ( frame )
Ligne 67 ⟶ 119 :
end
local listeRresponsables = { } -- contiendra un élément pour chaque nom
local directeur = Biblio.abr { 'dir.', 'directeur de publication', abrd = true }
local responsable, prenom, lien , precision, resp
local i = 1
repeat
repeat -- boucle sur chaque nom, assemble toutes les caractéristique et ajoute l'ensemble à la liste.
prenom = args [ 'prénom' .. i ] or ''
if prenom ~= '' then prenom = prenom .. ' '
Ligne 106 ⟶ 159 :
if args [ 'et al.' ] == 'oui' then
local et_al = " ''" .. Biblio.abr { "et al.", "et alii (et d’autres)", abrd = true } .. "''"
return table.concat ( listeRresponsables, ', ' ) .. et_al
else
return mw.text.listToText ( listeRresponsables )
Ligne 112 ⟶ 165 :
end
 
-- voir Modèle:Module biblio/responsabilité secondaire
function Biblio.responsabiliteSecondaire ( frame )
local args = extractArgs ( frame )
local traducteur = args.traducteur or ''
local preface = args [ 'péface' ] or ''
local illustrateur = args.illustrateur or ''
local photographe = args.photographe or ''
local libre = args [ 'champ libre' ] or ''
local liste = { }
if traducteur ~= '' then
table.insert ( liste, Biblio.abr { 'trad.', 'traduction', abrd = true } .. '&nbsp;' .. traducteur )
end
if preface ~= '' then
table.insert ( liste, Biblio.abr { 'préf.', 'préface', abrd = true } .. '&nbsp;' .. preface )
end
if illustrateur ~= '' then
table.insert ( liste, Biblio.abr { 'ill.', 'illustrations', abrd = true } .. '&nbsp;' .. illustrateur )
end
if photographe ~= '' then
table.insert ( liste, Biblio.abr { 'photogr.', 'photographies', abrd = true } .. '&nbsp;' .. photographe )
end
if libre ~= '' then
table.insert ( liste, libre )
end
local texte = table.concat ( liste , ', ')
if texte ~= '' then
return '(' .. texte .. ')'
else
return ''
end
end
 
-- voir Modèle:Module biblio/description physique
function Biblio.descriptionPhysique ( frame )
local args = extractArgs ( frame )
local form = args.format or ''
local numeros = args [ 'nombre numéros' ] or ''
local volumes = args [ 'nombre volumes' ] or ''
local tomes = args [ 'nombre tomes' ] or ''
local pages = args [ 'nombre pages' ] or ''
local liste = { }
if form ~= '' then
table.insert ( liste, ', ' .. form )
end
if numeros ~= '' then
table.insert ( liste, ', ' .. numeros .. '&nbsp;numéros' )
end
if volumes ~= '' then
table.insert ( liste, ', ' .. volumes .. '&nbsp;' .. Biblio.abr { 'vol.', 'volumes', abrd = true } )
end
if tomes ~= '' then
table.insert ( liste, ', ' .. tomes .. '&nbsp;' .. Biblio.abr { 't.', 'tomes', abrd = true } )
end
if pages ~= '' then
table.insert ( liste, ', ' .. pages .. '&nbsp;' .. Biblio.abr { 'p.', 'pages', abrd = true } )
end
return table.concat ( liste )
end
 
function Biblio.COinS ( frame )
local args = extractArgs ( frame )
local fields = {
chapitre = { 'book', { '.genre=', 'bookitem' }, { 'btitle', 'titre'}, { 'atitle', 'titre section' } },
article = { 'journal', { 'genre', 'article' }, { 'atitle', 'titre'}, { 'jtitle', 'périodique' } },
ouvrage = { 'book', { 'genre', 'bookitem' }, { 'btitle', 'titre'}, { 'atitle', 'titre section' } },
soustitre = { '.stitle=', 'sous-titre' },
{ '.volume=', 'volume' },
{ '.issue=', 'numéro' },
{ '.pages=' , 'pages' },
{ '.spage=', 'page début' },
{ '.tpages=', 'pages totales' },
{ '.place=', 'lieu' },
{ '.pub=', 'éditeur' },
{ '.edition=' , 'édition' },
{ '.isbn=', 'isbn' },
{ '.issn=', 'issn' },
{ '_id=info:doi/', 'doi' },
{ '_id=info:pmid/', 'pmid' },
{ '_id=info:oclcnum/' , 'oclc' },
{ '_id=', 'url' },
wikipedia = { '_id=info:sid/fr.wikipedia.org:', mw.title.getCurrentTitle().fullText }
}
local liste = { }
local wikiText = '<span class="Z3988" title="ctx_ver=Z39.88-2004&rft_val_fmt=' .. mw.uri.encode ( 'info:ofi/fmt:kev:mtx:' )
local function insertList ( tab, istexte )
local param
if istexte then
param = tab[2]
else
param = args [ tab[2] ] or ''
end
if param ~= '' then
table.insert ( liste, tab[1] .. mw.uri.encode ( param ) )
return true
end
end
-- genre, titre et sous-titre
local genre = fields [ args.genre ]
table.insert ( liste, genre [1] )
insertList ( genre [2], true)
insertList ( genre [3] )
insertList ( genre [4] )
isertList ( fields.soustitre )
-- liste des noms - prénoms
for i = 1, 10 do
if insertList ( { 'aulast', 'nom' .. i } ) then
insertList ( { 'aufirst', 'prénom' .. i } )
end
end
-- date
local datePub = { 'date', 'date' }
if args [ 'année' ] and args [ 'année' ] ~= '' then
local mois, jour = '', ''
if args.mois and args.mois ~= '' then
mois = '-' .. Date.prepend ( args.mois, '0', 2)
end
if args.jour and args.jour ~= '' then
jour = '-' .. Date.prepend ( args.jour, '0', 2)
end
datePub = { 'date', args [ 'année' ] .. mois .. jour }
end
insertList ( datePub )
-- autres renseignements
for i = 1, #fields do
insertList ( fields [i] )
end
-- page Wikipedia
insertList ( fields.wikipedia, true)
wikiText = wikiText .. table.concat ( liste, '&rft') .. '"><span style="display: none;">&nbsp;</span></span>'
return wikiText
end
return Biblio