« Module:Biblio/Références » : différence entre les versions
mAucun résumé des modifications |
Ajout Math reviews |
||
Ligne 118 : | Ligne 118 : | ||
end | end | ||
function References.mathreviews( mathreviews ) | |||
return databaseExterne( mathreviews, '[[Mathematical Reviews|Math Reviews]]', 'www.ams.org/mathscinet-getitem?mr=' ) | |||
end | |||
-- enLigne est destiné à remplacer "lire en ligne", "écouter en ligne", "présentation en ligne" | -- enLigne est destiné à remplacer "lire en ligne", "écouter en ligne", "présentation en ligne" |
Version du 25 septembre 2013 à 22:38
-- Les fonctions de ce module sont destinées à être utilisée par un autre module. -- Leur paramètre d'entrée est une table simple (args), voir une chaine (oclc, bnf...)
local References = { }
local Outils = require( 'Module:Outils' )
local validTextArg = Outils.validTextArg
-- voir Modèle:ISBN
-- renvoie une liste de chaine formant le résultat du modèle une fois concaténé
function References.isbn( args, validArg )
local validArg = validArg or function ( ... ) return validTextArg( args, ... ) end
local liste = { } local i = 1
local isbn = validArg( 'isbn', 'ISBN', 'isbn1', 'ISBN1' ) if isbn then -- on réduit la chaine au caractères qui peubent être dans un code isbn (pad de test de longueur) local isbnValid = string.match( isbn, '[%dXx -]*' )
-- boucle sur les isbn2, 3... while isbnValid do local lien = '[[Spécial:Ouvrages de référence/' .. isbnValid .. '|' .. isbn .. ']]' table.insert( liste, lien )
i = i + 1 isbn = validArg( 'isbn' .. i, 'ISBN' .. i ) isbnValid = isbn and string.match( isbn, '[%dXx -]*' ) end
return 'ISBN ' .. mw.text.listToText( liste ) end end
-- voir Modèle:ISSN
-- renvoie une liste de chaine formant le résultat du modèle une fois concaténé
function References.issn( args, validArg )
local validArg = validArg or function ( ... ) return validTextArg( args, ... ) end
local liste = { } local i = 1
local issn = validArg( 'issn', 'ISSN', 'issn1', 'ISSN1' ) if issn then -- on réduit la chaine au caractères qui peubent être dans un code isbn (pad de test de longueur) local issnValid = string.match( string.gsub( issn, ' ', ), '[%dXx -]*' )
while issnValid do local lien = '[http://worldcat.org/issn/' .. mw.uri.encode( issn ) .. '&lang=fr ' .. issn.. ']' table.insert( liste, lien )
i = i + 1 issn = validArg( 'issn' .. i, 'ISSN' .. i ) issnValid = issn and string.match( string.gsub( issn, ' ', ), '[%dXx -]*' ) end
return 'ISSN ' .. mw.text.listToText( liste ) end end
local function databaseExterne( num, interne, externe, complement )
if Outils.notEmpty( num ) then
local adresse =
interne
.. ' [http://'
.. externe
.. mw.uri.encode( num )
.. ( complement or ' ' )
.. num
.. ']'
return adresse end end
function References.oclc( oclc ) return databaseExterne( oclc, 'OCLC', 'worldcat.org/oclc/', '&lang=fr ' ) end
function References.bnf( bnf ) return databaseExterne( bnf, 'notice BnF no', 'catalogue.bnf.fr/ark:/12148/cb', '/PUBLIC FRBNF' ) end
function References.lccn( lccn ) return databaseExterne( lccn, 'LCCN', 'lccn.loc.gov/' ) end
function References.dnb( dnb ) return databaseExterne( dnb, 'DNB', 'd-nb.info/' ) end
function References.jstor( jstor ) return databaseExterne( jstor, 'JSTOR', 'jstor.org/stable/' ) end
function References.pmid( pmid ) return databaseExterne( pmid, 'PMID', 'www.ncbi.nlm.nih.gov/pubmed/' ) end
function References.pmcid( pmcid ) return databaseExterne( pmcid, 'PMCID', 'www.ncbi.nlm.nih.gov/pmc/articles/' ) end
function References.doi( doi ) return databaseExterne( doi, 'DOI', 'dx.doi.org/' ) end
function References.bibcode( bibcode ) return databaseExterne( bibcode, 'Bibcode', 'adsabs.harvard.edu/abs/' ) end
function References.mathreviews( mathreviews ) return databaseExterne( mathreviews, 'Math Reviews', 'www.ams.org/mathscinet-getitem?mr=' ) end
-- enLigne est destiné à remplacer "lire en ligne", "écouter en ligne", "présentation en ligne" function References.enLigne( args ) local validArg = validArg or function ( ... ) return validTextArg( args, ... ) end local lang, esp = , if args.langue then local Langue = require( 'Module:Langue' ) lang = Langue.indicationMultilingue{ args.langue, args.langue2, args.langue3 } esp = ' ' end
local url = validArg( 'lien', 'url' ) if url == nil then if validArg( 'doi' ) then url = 'http://dx.doi.org/' .. mw.uri.encode( args.doi ) else return end end url = string.gsub ( string.gsub ( url, '%[', '%%5B' ), '%]', '%%5D' )
local texte = validArg( 'texte' ) or 'en ligne' local date = validArg( 'date', 'consulté le' )
if date then return lang .. esp .. '[' .. url .. ' ' .. texte .. '] (consultée le' .. date .. ')' else return lang .. esp .. '[' .. url .. ' ' .. texte .. ']' end end
function References.indicationDeFormat( format ) if not Outils.trim( format ) then return end local listeFormat = { audio = { "audio", "Fichiers audio au format mp3, ogg..." }, bat = { "bat", "Script de traitement par lot (batch)" }, djvu = { "DjVu", "Document au format DjVu" }, doc = { "doc", "Document Microsoft Word" }, epub = { "EPUB", "Document au format Epub" }, flash = { "flash", "Animation vectorielle au format Macromedia Flash" }, hlp = { "hlp", "Fichier HeLP (aide) datant de Microsoft Windows 3.1" }, html = { "html", "Fichier au format Hypertext Markup Language (HTML)" }, image = { "image", "Image au format JPEG, PNG, GIF..." }, java = { "java", "Applet Java" }, mov = { "mov", "Vidéo au format Apple QuickTime" }, mp3 = { "MP3", "Son au format MP3 (MPEG-1/2 Audio Layer 3)" }, odt = { "odt", "Document au format OpenDocument" }, ogg = { "ogg", "Fichier au format conteneur Ogg" }, pdf = { "PDF", "Document au format Portable Document Format (PDF) d'Adobe" }, php = { "php", "Script PHP" }, pl = { "pl", "Script Practical Extraction and Report Language (Perl)" }, ppt = { "ppt", "Présentation Microsoft Powerpoint" }, ps = { "ps", "Fichier de description vectorielle au format PostScript" }, radio = { "radio", "Radio au format mpg, avi..." }, rm = { "rm", "Vidéo au format RealMedia, RealAudio..." }, rtf = { "RTF", "Document texte au format Rich Text Format (RTF)" }, svg = { "SVG", "Image vectorielle au format Scalable Vector Graphics (SVG)" }, sxi = { "sxi", "Présentation OpenOffice.org Impress" }, sxw = { "sxw", "Document OpenOffice.org Writer" }, tex = { "TeX", "Document TeX" }, txt = { "txt", "Fichier au format texte brut" }, video = { "vidéo", "Vidéo au format mpg, avi..." }, xls = { "xls", "Classeur Microsoft Excel" }, xml = { "XML", "Document au format Extensible Markup Language (XML)" }, zip = { "zip", "Archive au format Zip" }, } listeFormat['vidéo'] = listeFormat.video
local tabFormat = listeFormat[ string.lower( format ) ] if tabFormat then return ( ' ' .. mw.text.nowiki( '[' .. tabFormat[1] .. ']' ) .. '' ) else return mw.text.nowiki( ' [' ) .. format .. mw.text.nowiki( ']' ) end
end
return References