« Module:Biblio/Références » : différence entre les versions
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 : | Ligne 7 : | ||
local Outils = require( 'Module:Outils' ) | local Outils = require( 'Module:Outils' ) | ||
local validTextArg = Outils.validTextArg | local validTextArg = Outils.validTextArg | ||
local TableBuilder = require( 'Module:TableBuilder' ) | |||
Ligne 133 : | Ligne 134 : | ||
local function databaseExterne( num, | local function databaseExterne( lienExterne, num, lienInterne, texteAffiche, complement ) | ||
if Outils.notEmpty( num ) then | if Outils.notEmpty( num ) then | ||
local adresse = | local adresse = '<span class="plainlinks noarchive nowrap">[http://' | ||
.. lienExterne | .. lienExterne | ||
.. num | .. num | ||
.. ( complement or ' ' ) | .. ( complement or '' ) | ||
.. ( texteAffiche or | .. ' ' .. ( texteAffiche or lienInterne ) | ||
.. ']</span>' | ..']<sup>[[' | ||
.. lienInterne | |||
.. '|?]]</sup></span>' | |||
return adresse | return adresse | ||
Ligne 165 : | Ligne 166 : | ||
function References.oclc( oclc ) | function References.oclc( oclc ) | ||
return databaseExterne( oclc, ' | return databaseExterne( 'worldcat.org/oclc/', oclc, 'Online Computer Library Center', 'OCLC', '&lang=fr ' ) | ||
end | end | ||
Ligne 173 : | Ligne 174 : | ||
local texte = bnf | local texte = bnf | ||
local category = '' | local category = '' | ||
local bnfId = bnf: | local bnfId = bnf:lower():match( 'bnf(%d+%w)' ) | ||
or bnf:lower():match( 'cb(%d+%w)' ) | |||
or bnf:match( '^%d+%w' ) | |||
if bnfId then | if bnfId then | ||
Ligne 198 : | Ligne 201 : | ||
-- dans tout les cas ou renvoir l'adresse, on catégorise juste pour vérifier ce qui ne va pas. | -- dans tout les cas ou renvoir l'adresse, on catégorise juste pour vérifier ce qui ne va pas. | ||
local lien = databaseExterne( bnf, | local lien = databaseExterne( 'catalogue.bnf.fr/ark:/12148/cb', | ||
' | bnf, | ||
' | 'Bibliothèque nationale de France', | ||
'/PUBLIC | 'notice BnF', | ||
'/PUBLIC' | |||
) | ) | ||
Ligne 215 : | Ligne 218 : | ||
function References.lccn( lccn ) | function References.lccn( lccn ) | ||
return databaseExterne( lccn, ' | return databaseExterne( 'lccn.loc.gov/', lccn, 'Numéro de contrôle de la Bibliothèque du Congrès', 'LCCN' ) | ||
end | end | ||
function References.dnb( dnb ) | function References.dnb( dnb ) | ||
return databaseExterne( dnb, ' | return databaseExterne( 'd-nb.info/', dnb, 'Bibliothèque nationale allemande', 'DNB' ) | ||
end | end | ||
function References.jstor( jstor ) | function References.jstor( jstor ) | ||
return databaseExterne( | return databaseExterne( 'jstor.org/stable/', jstor, 'JSTOR' ) | ||
end | end | ||
function References.pmid( pmid ) | function References.pmid( pmid ) | ||
return databaseExterne( | return databaseExterne( 'www.ncbi.nlm.nih.gov/pubmed/', pmid, 'PubMed' ) | ||
end | end | ||
function References.pmcid( pmcid ) | function References.pmcid( pmcid ) | ||
return databaseExterne( | return databaseExterne( 'www.ncbi.nlm.nih.gov/pmc/articles/', pmcid, 'PubMed Central' ) | ||
end | end | ||
function References.doi( doi ) | function References.doi( doi ) | ||
return databaseExterne( doi, ' | return databaseExterne( 'dx.doi.org/', doi, 'Digital Object Identifier', 'DOI' ) | ||
end | end | ||
function References.bibcode( bibcode ) | function References.bibcode( bibcode ) | ||
return databaseExterne( | return databaseExterne( 'adsabs.harvard.edu/abs/', bibcode, 'Bibcode' ) | ||
end | end | ||
function References.mathreviews( mathreviews ) | function References.mathreviews( mathreviews ) | ||
return databaseExterne( | return databaseExterne( 'www.ams.org/mathscinet-getitem?mr=', mathreviews, 'Mathematical Reviews', 'Math Reviews' ) | ||
end | end | ||
function References.zbl( zbl ) | function References.zbl( zbl ) | ||
return databaseExterne( | return databaseExterne( 'zbmath.org/?q=an:', zbl, 'Zentralblatt MATH', 'zbMATH' ) | ||
end | end | ||
function References.arxiv( arxiv ) | function References.arxiv( arxiv ) | ||
return databaseExterne( | return databaseExterne( 'fr.arxiv.org/abs/', arxiv, 'arXiv' ) | ||
end | end | ||
Ligne 262 : | Ligne 265 : | ||
-- 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" | ||
function References.enLigne( args ) | function References.enLigne( args, validArg ) | ||
local validArg = validArg or function ( ... ) return validTextArg( args, ... ) end | local validArg = validArg or function ( ... ) return validTextArg( args, ... ) end | ||
local lang, esp = '', '' | local lang, esp = '', '' | ||
Ligne 289 : | Ligne 292 : | ||
return lang .. esp .. '[' .. url .. ' ' .. texte .. ']' | return lang .. esp .. '[' .. url .. ' ' .. texte .. ']' | ||
end | 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 | end | ||
Ligne 331 : | Ligne 424 : | ||
listeFormat['vidéo'] = listeFormat.video | listeFormat['vidéo'] = listeFormat.video | ||
listeFormat.vid = listeFormat.video | listeFormat.vid = listeFormat.video | ||
listeFormat.htm = listeFormat.html | |||
listeFormat.excel = listeFormat.xls | listeFormat.excel = listeFormat.xls | ||
listeFormat.powerpoint = listeFormat.ppt | listeFormat.powerpoint = listeFormat.ppt | ||
listeFormat.word = listeFormat.doc | listeFormat.word = listeFormat.doc | ||
listeFormat.aud = listeFormat.audio | listeFormat.aud = listeFormat.audio | ||
local tabFormat = listeFormat[ string.lower( format ) ] | local tabFormat = listeFormat[ string.lower( format ) ] | ||
if tabFormat then | if tabFormat then | ||
Ligne 342 : | Ligne 435 : | ||
.. '">' .. mw.text.nowiki( '[' .. tabFormat[1] .. ']' ) .. '</abbr>' ) | .. '">' .. mw.text.nowiki( '[' .. tabFormat[1] .. ']' ) .. '</abbr>' ) | ||
else | else | ||
return mw.text.nowiki( ' [' ) .. format .. mw.text.nowiki( ']' ) | -- teste si l'extention est suivi d'une précision (ex : pdf 6 Mo) | ||
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 | end | ||
Version du 18 juillet 2014 à 20:17
-- Les fonctions de ce module sont destinées à être utilisées par un autre module. -- Leur paramètre d'entrée est une table simple (args), voire une chaine (oclc, bnf...)
local References = { }
local Outils = require( 'Module:Outils' )
local validTextArg = Outils.validTextArg
local TableBuilder = require( 'Module:TableBuilder' )
--[[ ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn(). If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes, spaces and other non-isxn characters. ]] function References.is_valid_isxn( isxn_str, len ) local temp = 0 isxn_str = { isxn_str:byte(1, len) } -- make a table of bytes len = len+1 -- adjust to be a loop counter for i, v in ipairs( isxn_str ) do -- loop through all of the bytes and calculate the checksum if v == string.byte( 'X' ) then -- if checkdigit is X temp = temp + 10 * ( len - i ) -- it represents 10 decimal else temp = temp + tonumber( string.char( v ) ) * ( len - i ) end end return temp % 11 == 0 -- returns true if calculation result is zero end
-- Determines whether an ISBN string is valid function References.checkisbn( isbn_str ) if isbn_str:find( '[^0-9Xx%s-]' ) then -- fail if isbn_str contains anything but digits, hyphens, or X return false end isbn_str = isbn_str:gsub( '[-%s]', ):gsub( 'x', 'X' ) -- remove hyphens and spaces local len = isbn_str:len()
if len == 10 then if isbn_str:match( '^%d*X?$' ) == nil then return false end return References.is_valid_isxn( isbn_str, 10 ) elseif len == 13 then local temp = 0 if isbn_str:match( '^%d*$' ) == nil then -- isbn13 or EAN13 contains only numbers return false end isbn_str = { isbn_str:byte( 1, len ) } for i, v in ipairs( isbn_str ) do temp = temp + ( 3 - 2 * ( i % 2 ) ) * tonumber( string.char( v ) ) end return temp % 10 == 0 else return false end end
-- voir Modèle:ISBN
-- renvoie une liste de chaines formant le résultat du modèle une fois concaténées
function References.isbn( args, validArg )
local validArg = validArg or function ( ... ) return validTextArg( args, ... ) end
local liste = { } local i = 1 local avertissementInvalid = '[à vérifier : isbn invalide]'
local isbnErr = validArg( 'isbn erroné' ) local isbn = validArg( 'isbn', 'ISBN', 'isbn1', 'ISBN1' ) if isbnErr or isbn then if isbnErr and isbnErr:find( '[%dXx -]' ) then local lien if isbnErr:find( '[%[\127]' ) then lien = isbnErr .. ' (édité erroné)' else lien = '[[Spécial:Ouvrages de référence/' .. isbnErr:match( '[%dXx -]*' ) .. '|' .. isbnErr .. ']] (édité erroné)' end table.insert( liste, lien ) end
-- boucle sur les isbn2, 3... while isbn do -- vérifivation de la validité de l'ISBN local isbnValid = References.checkisbn(isbn)
-- préparation du texte à afficher if isbnValid then local lien = '[[Spécial:Ouvrages de référence/' .. isbn .. '|' .. isbn .. ']]' table.insert( liste, lien ) else table.insert( liste, isbn .. avertissementInvalid ) args.categIsbnInvalid = true end
i = i + 1 isbn = validArg( 'isbn' .. i, 'ISBN' .. i ) end
return 'ISBN ' .. mw.text.listToText( liste ) end end
-- voir Modèle:ISSN
-- renvoie une liste de chaines formant le résultat du modèle une fois concaténées
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 aux caractères qui peuvent être dans un code issn (pas 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( lienExterne, num, lienInterne, texteAffiche, complement )
if Outils.notEmpty( num ) then
local adresse = '[http://'
.. lienExterne
.. num
.. ( complement or )
.. ' ' .. ( texteAffiche or lienInterne )
..'][['
.. lienInterne
.. '|?]]'
return adresse end end
function References.arkId( base ) -- Nice Opaque Identifiern utilisé par les formats Ark pour générer une clé base = tostring( base ) if base then local xdigits = '0123456789bcdfghjkmnpqrstvwxz' local sum = 0 local position for i = 1, base:len() do position = xdigits:find( base:sub( i, i ), 1, true ) or 1 sum = sum + i * ( position - 1 ) end local index = sum % 29 + 1 return xdigits:sub( index, index ) end end
function References.oclc( oclc ) return databaseExterne( 'worldcat.org/oclc/', oclc, 'Online Computer Library Center', 'OCLC', '&lang=fr ' ) end
function References.bnf( bnf ) bnf = Outils.trim( bnf ) if bnf then local texte = bnf local category = local bnfId = bnf:lower():match( 'bnf(%d+%w)' ) or bnf:lower():match( 'cb(%d+%w)' ) or bnf:match( '^%d+%w' )
if bnfId then -- bnf contient une suite de chiffre qui peut être un ark valide local base = bnfId:sub( 1, 8 ) if bnfId:len() == 8 then -- il manque la clè, on l'ajoute bnf = base .. References.arkId( 'cb' .. base ) texte = base elseif bnfId:len() > 8 and bnfId:sub( 9, 9 ) == References.arkId( 'cb' .. base ) then -- ark valide bnf = bnfId:sub( 1, 9 ) texte = base else -- ark qui semble non valide. bnf = bnfId texte = bnfId category = end else -- le paramètre de semble pas un ark valide category = end
-- 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, 'Bibliothèque nationale de France', 'notice BnF', '/PUBLIC' )
return lien .. category end end
-- à transférer dans Biblio function References.BNF( frame ) return References.bnf( Outils.extractArgs( frame )[1] ) end
function References.lccn( lccn ) return databaseExterne( 'lccn.loc.gov/', lccn, 'Numéro de contrôle de la Bibliothèque du Congrès', 'LCCN' ) end
function References.dnb( dnb ) return databaseExterne( 'd-nb.info/', dnb, 'Bibliothèque nationale allemande', 'DNB' ) end
function References.jstor( jstor ) return databaseExterne( 'jstor.org/stable/', jstor, 'JSTOR' ) end
function References.pmid( pmid ) return databaseExterne( 'www.ncbi.nlm.nih.gov/pubmed/', pmid, 'PubMed' ) end
function References.pmcid( pmcid ) return databaseExterne( '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' ) end
function References.bibcode( bibcode ) return databaseExterne( 'adsabs.harvard.edu/abs/', bibcode, 'Bibcode' ) end
function References.mathreviews( mathreviews ) return databaseExterne( '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' ) end
function References.arxiv( arxiv ) return databaseExterne( 'fr.arxiv.org/abs/', arxiv, 'arXiv' ) end
function References.wikisource( wikisource ) if Outils.notEmpty( wikisource ) then return 'lire sur Wikisource' end end
-- 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 = ,
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.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 ' (' .. liensExternes.concat( separateur ), ')' end -- 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..." }, rar = { "rar", "Document compressé au format rar" }, 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 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 return ( ' ' .. mw.text.nowiki( '[' .. tabFormat[1] .. ']' ) .. '' ) else -- teste si l'extention est suivi d'une précision (ex : pdf 6 Mo) 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
end
-- catégorise une page en fonction du namespace function References.categorise(args)
local category = args[1] or args.category local flag = ( args[2] ~= false and args.categorise ~= false )
if type(category) == 'string' and flag and mw.title.getCurrentTitle().namespace == 0 then local sort = if type( args.display or args.tri ) == 'string' then sort = '|' .. (args.display or args.tri) end return end return end
return References