« Module:Biblio/Références » : différence entre les versions

Contenu supprimé Contenu ajouté
indicationDeFormat : Ajout de l'alias "aud" pour les audio (cf Modèle:aud) ; suppression de quelques espaces.
Remaniement affichage des liens externe (sans afficher le n°) ; indicationDeFormat : accepte les extensions de 3 lettres suivi d'une précision (ex: pdf 6 Mo)
Ligne 7 :
local Outils = require( 'Module:Outils' )
local validTextArg = Outils.validTextArg
local TableBuilder = require( 'Module:TableBuilder' )
 
 
Ligne 133 ⟶ 134 :
 
 
local function databaseExterne( numlienExterne, lienIinternenum, lienExternelienInterne, complementtexteAffiche, texteAffichecomplement )
if Outils.notEmpty( num ) then
local adresse = '<span class="plainlinks noarchive nowrap">[http://'
lienIinterne
.. '&nbsp;<span class="plainlinks noarchive nowrap">[http://'
.. lienExterne
.. num
.. ( complement or ' ' )
.. ' ' .. ( texteAffiche or numlienInterne )
.. ']</spansup>[['
.. lienInterne
.. '|?]]</sup></span>'
return adresse
Ligne 165 ⟶ 166 :
 
function References.oclc( oclc )
return databaseExterne( 'worldcat.org/oclc/', oclc, '[[Online Computer Library Center|OCLC]]', 'worldcat.org/oclc/OCLC', '&lang=fr ' )
end
 
Ligne 173 ⟶ 174 :
local texte = bnf
local category = ''
local bnfId = bnf:upperlower():match( 'BNFbnf(%d+%w)' )
or bnf:lower():match( 'cb(%d+%w)' )
or bnf:match( '^%d+%w' )
if bnfId then
Ligne 198 ⟶ 201 :
-- dans tout les cas ou renvoir l'adresse, on catégorise juste pour vérifier ce qui ne va pas.
local lien = databaseExterne( 'catalogue.bnf.fr/ark:/12148/cb',
bnf,
'notice [[Bibliothèque nationale de France|BnF]] n<sup>o</sup>',
'Bibliothèque nationale de France',
'catalogue.bnf.fr/ark:/12148/cb',
'/PUBLICnotice FRBNFBnF',
texte '/PUBLIC'
)
Ligne 215 ⟶ 218 :
 
function References.lccn( lccn )
return databaseExterne( 'lccn.loc.gov/', lccn, '[[Numéro de contrôle de la Bibliothèque du Congrès|LCCN]]', 'lccn.loc.gov/LCCN' )
end
 
function References.dnb( dnb )
return databaseExterne( 'd-nb.info/', dnb, '[[Bibliothèque nationale allemande|DNB]]', 'd-nb.info/DNB' )
end
 
function References.jstor( jstor )
return databaseExterne( jstor, '[[JSTOR]]', 'jstor.org/stable/', jstor, 'JSTOR' )
end
 
function References.pmid( pmid )
return databaseExterne( pmid, '[[PubMed|PMID]]', 'www.ncbi.nlm.nih.gov/pubmed/', pmid, 'PubMed' )
end
 
function References.pmcid( pmcid )
return databaseExterne( pmcid, '[[PubMed Central|PMCID]]', 'www.ncbi.nlm.nih.gov/pmc/articles/', pmcid, 'PubMed Central' )
end
 
function References.doi( doi )
return databaseExterne( 'dx.doi.org/', doi, '[[Digital Object Identifier|DOI]]', 'dx.doi.org/DOI' )
end
 
function References.bibcode( bibcode )
return databaseExterne( bibcode, '[[Bibcode]]', 'adsabs.harvard.edu/abs/', bibcode, 'Bibcode' )
end
 
function References.mathreviews( mathreviews )
return databaseExterne( mathreviews, '[[Mathematical Reviews|Math Reviews]]', 'www.ams.org/mathscinet-getitem?mr=', mathreviews, 'Mathematical Reviews', 'Math Reviews' )
end
 
function References.zbl( zbl )
return databaseExterne( 'zbmath.org/?q=an:', zbl, '[[Zentralblatt MATH|zbMATH]]', 'zbmath.org/?q=an:zbMATH' )
end
 
function References.arxiv( arxiv )
return databaseExterne( arxiv, '[[arXiv]]', 'fr.arxiv.org/abs/', arxiv, 'arXiv' )
end
 
Ligne 262 ⟶ 265 :
 
-- enLigne est destiné à remplacer "lire en ligne", "écouter en ligne", "présentation en ligne"
function References.enLigne( args, validArg )
local validArg = validArg or function ( ... ) return validTextArg( args, ... ) end
local lang, esp = '', ''
Ligne 289 ⟶ 292 :
return lang .. esp .. '[' .. url .. ' ' .. texte .. ']'
end
end
 
function References.affichageLiensExternes(args, validArg, lireEnLigne, consulteLe)
local validArg = validArg or function ( ... ) return validTextArg( args, ... ) end
-- if validArg( 'consulté le', 'accessdate', 'Consulté le', 'consulté', 'isbn', 'ISBN', 'isbn erroné', 'issn', 'consultée le', 'oclc', 'pmid', 'pmcid', 'pmc', 'doi', 'jstor', 'bibcode', 'math reviews', 'zbl', 'arxiv' ) then
-- if validArg( 'url texte', 'url', 'issn', 'doi', 'pmid', 'résumé', 'ISSN', 'lire en ligne', 'isbn', 'texte', 'présentation en ligne', 'issn1', 'ISBN', 'oclc', 'PMID', 'pmcid', 'pmc', 'DOI', 'jstor', 'bibcode', 'math reviews', 'zbl', 'arxiv' ) then
-- if validArg( 'isbn', 'lire en ligne', 'présentation en ligne', 'oclc', 'url', 'lccn', 'issn', 'bnf', 'ISBN', 'isbn1', 'isbn erroné', 'ISSN', 'wikisource', 'dnb', 'doi', 'pmid', 'jstor', 'bibcode', 'math reviews', 'zbl', 'arxiv', 'url texte', 'résumé' ) then
local liensExternes = TableBuilder.new( )
local separateur = ', '
-- isbn et issn
liensExternes.minsert( References.isbn( args, validArg ), References.issn( args, validArg ) )
if validArg( 'isbn3', 'issn3', 'ISBN3', 'ISSN3' ) then
separateur = ' ; '
end
local liens = TableBuilder.new( )
liens.minsert(
References.oclc( args.oclc ),
References.bnf ( args.bnf ),
References.lccn( args.lccn ),
References.dnb ( args.dnb ),
References.pmid( args.pmid ),
References.pmcid ( validArg( 'pmcid', 'pmc' ) ),
References.doi( args.doi ),
References.jstor( args.jstor ),
References.bibcode( args.bibcode ),
References.mathreviews( args['math reviews'] ),
References.zbl( validArg( 'zbl', 'zbmath' ) ),
References.arxiv( args.arxiv ),
References.wikisource( args.wikisource )
)
if #liens == 1 then
liensExternes.minsert( 'lien ' .. liens[1] )
elseif #liens > 1 then
liensExternes.minsert( 'liens ' .. mw.text.listToText( liens ) )
if #liens > 2 then
separateur = ' ; '
end
end
if lireEnLigne then
local resume = validArg( 'résumé', 'présentation en ligne' )
if resume then
liensExternes.insert( References.enLigne{
lien = resume,
texte = 'résumé',
} )
end
local url = validArg( 'lire en ligne', 'url texte', 'url', 'texte' )
if url then
liensExternes.insert(
References.enLigne{
lien = url,
texte = 'lire en ligne',
} .. ( References.indicationDeFormat( args['format électronique'] ) or '' )
)
end
local ecouterEnLigne = validArg( 'écouter en ligne' )
if ecouterEnLigne then
liensExternes.insert( References.enLigne{
lien = ecouterEnLigne,
texte = 'écouter en ligne',
} )
end
end
-- consulté le
if consulteLe then
local consult = validArg( 'consulté le', 'accessdate', 'Consulté le', 'consulté', 'consultée le' )
local consulteLe = ''
if consult then
if string.sub( consult, -1,-1) == '.' then
consult = string.sub( consult, 1, -2)
end
if (string.match(consult, '^.*[ /-].*[ /-].*')) then
consulteLe = 'consulté le '
else
consulteLe = 'consulté en '
end
liensExternes.minsert( consulteLe .. Outils.nobr( consult ) )
end
end
if #liensExternes > 0 then
return ' <small style="line-height:1em;">(' .. liensExternes.concat( separateur ), ')</small>'
end
-- end
end
 
Ligne 331 ⟶ 424 :
listeFormat['vidéo'] = listeFormat.video
listeFormat.vid = listeFormat.video
listeFormat.htm = listeFormat.html
listeFormat.excel = listeFormat.xls
listeFormat.powerpoint = listeFormat.ppt
listeFormat.word = listeFormat.doc
listeFormat.aud = listeFormat.audio
local tabFormat = listeFormat[ string.lower( format ) ]
if tabFormat then
Ligne 342 ⟶ 435 :
.. '">' .. mw.text.nowiki( '[' .. tabFormat[1] .. ']' ) .. '</abbr>' )
else
-- teste si l'extention est suivi d'une précision (ex : pdf 6 Mo)
return mw.text.nowiki( ' [' ) .. format .. mw.text.nowiki( ']' )
local ext, texte = string.match( format, "^(...) (.*)$")
if ext and listeFormat[ string.lower( ext ) ] then
return References.indicationDeFormat( ext ) .. ' ' .. texte
else
return ' ' .. mw.text.nowiki( '[' ) .. format .. mw.text.nowiki( ']' )
end
end