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

De Lagny-sur-Marne Wiki
Aller à la navigation Aller à la recherche
0x010D (discussion | contributions)
ISBN et ISSN : mise à jour
0x010D (discussion | contributions)
Ajout fonction lienBrise pour le modèle:Lien brisé
 
(12 versions intermédiaires par le même utilisateur non affichées)
Ligne 3 : Ligne 3 :
local Biblio = {  }
local Biblio = {  }


 
require( 'Module:No globals' )
local Outils = require( 'Module:Outils' )
local Outils = require( 'Module:Outils' )




Biblio.ouvrage = function ( frame )
Biblio.ouvrage = function ( frame )
    local args = Outils.extractArgs( frame )
local args = Outils.extractArgs( frame )
    local Ouvrage = require( 'Module:Biblio/Ouvrage' )
local Ouvrage = require( 'Module:Biblio/Ouvrage' )
    return Ouvrage.ouvrage( args )  
return Ouvrage.ouvrage( args )  
end
end




Biblio.chapitre = function ( frame )
Biblio.chapitre = function ( frame )
    local args = Outils.extractArgs( frame )
local args = Outils.extractArgs( frame )
    local Ouvrage = require( 'Module:Biblio/Ouvrage' )
local Ouvrage = require( 'Module:Biblio/Ouvrage' )
    return Ouvrage.chapitre( args )  
return Ouvrage.chapitre( args )  
end
end




Biblio.article = function ( frame )
Biblio.article = function ( frame )
    local args = Outils.extractArgs( frame )
local args = Outils.extractArgs( frame )
    local Ouvrage = require( 'Module:Biblio/Article' )
local Ouvrage = require( 'Module:Biblio/Article' )
    return Ouvrage.article( args )  
return Ouvrage.article( args )  
end
end




Biblio.lienWeb = function( frame )
Biblio.lienWeb = function( frame )
    local args = Outils.extractArgs( frame )
local args = Outils.extractArgs( frame )
    local Ouvrage = require( 'Module:Biblio/Lien web' )
local Ouvrage = require( 'Module:Biblio/Lien web' )
    return Ouvrage.lienWeb( args )  
return Ouvrage.lienWeb( args )
end
 
Biblio.lienBrise = function( frame )
local args = Outils.extractArgs( frame )
local Ouvrage = require( 'Module:Biblio/Lien web' )
return Ouvrage.lienBrise( args )
end
end




Biblio.dictionnaire = function( frame )
Biblio.dictionnaire = function( frame )
    local args = Outils.extractArgs( frame )
local args = Outils.extractArgs( frame )
    local article = Outils.validTextArg( args, 'notice', 'article', 'titre chapitre' )
local article = Outils.validTextArg( args, 'notice', 'article', 'titre chapitre' )
    local Ouvrage = require( 'Module:Biblio/Ouvrage' )
local Ouvrage = require( 'Module:Biblio/Ouvrage' )
if article then
if article then
args['titre chapitre'] = article
args['titre chapitre'] = article
Ligne 51 : Ligne 57 :
end
end


-- catégorise une page en fonction du namespace
local function categorise(args)
local namespaceCategorisation = { [0] = true, [4] = true, [10] = true, [12] = true, [14] = true, [100] = true, [104] = true }
local category = args[1]
local flag = args[2]
if type(category) == 'string'
and flag
and namespaceCategorisation[ mw.title.getCurrentTitle().namespace ]
then
return '[[Category:' .. category .. ']]'
end
return ''
end


Biblio.ISBN = function ( frame )
Biblio.ISBN = function ( frame )
    local args = Outils.extractArgs( frame )
local args = Outils.extractArgs( frame )
    local References = require( 'Module:Biblio/Références' )
if Outils.trim( args[1] ) then
    local newArgs = { categ = { isbnInvalid = false } }
local newArgs = { isbn = args[1] }
   
local i = 2
    if Outils.trim(args[1]) then
while args[i] do
    newArgs.isbn = args[1]
newArgs[ 'isbn' .. i ] = args[i]
    local i = 2
i = i + 1
    while args[i] do
end
    newArgs['isbn' .. i] = args[i]
return Biblio.identifiantsBiblio( newArgs )
    i = i + 1
else
    end
return '<small>([[International Standard Book Number|ISBN]]&nbsp;inconnu)</small>' .. categorise{ 'ISBN nécessaire', true }
    local listeISBN = References.isbn( newArgs )
end
    local categ = References.categorise{'Ouvrage avec ISBN invalide', newArgs.categ.isbnInvalid }
end
    return '<small>(' .. listeISBN .. ')</small>' .. categ
 
Biblio.rechercheIsbn = function( frame )
local args = Outils.extractArgs( frame )
local References = require( 'Module:Biblio/Références' )
local newArgs = { isbn = args[1], sansLabel = true, categ = {} }
local isbn = References.isbn( newArgs ) or ''
local categ = categorise{ 'Page avec ISBN invalide', newArgs.categ.isbnInvalid }
return isbn .. categ
end
 
 
Biblio.EAN = function ( frame )
local args = Outils.extractArgs( frame )
if Outils.trim( args[1] ) then
local newArgs = { ean = args[1], categ = {} }
local i = 2
while args[i] do
newArgs[ 'ean' .. i ] = args[i]
i = i + 1
end
return Biblio.identifiantsBiblio( newArgs )
else  
else  
return '<small>([[International Standard Book Number|ISBN]]&nbsp;inconnu)</small>' .. References.categorise{'ISBN nécessaire'}
return '<small>([[EAN 13|EAN]]&nbsp;inconnu)</small>[[Catégorie:EAN nécessaire]]'
end
end
end
end
Ligne 74 : Ligne 113 :


Biblio.ISSN = function ( frame )
Biblio.ISSN = function ( frame )
    local args = Outils.extractArgs( frame )
local args = Outils.extractArgs( frame )
    local References = require( 'Module:Biblio/Références' )
if Outils.trim( args[1] ) then
    local newArgs = { categ = { issnInvalid = false } }
local newArgs = { issn = args[1], categ = {} }
   
local i = 2
    if Outils.trim(args[1]) then
while args[i] do
    newArgs.issn = args[1]
newArgs[ 'issn' .. i ] = args[i]
    local i = 2
i = i + 1
    while args[i] do
end
    newArgs['issn' .. i] = args[i]
return Biblio.identifiantsBiblio( newArgs )
    i = i + 1
    end
    local listeISSN = References.issn( newArgs )
    local categ = References.categorise{'Page avec ISSN invalide', newArgs.categ.issnInvalid }
    return '<small>(' .. listeISSN .. ')</small>' .. categ
else  
else  
return '<small>(inconnu)</small>' .. References.categorise{'ISSN nécessaire'}
return '<small>([[International Standard Serial Number|ISSN]]&nbsp;inconnu)</small>' .. categorise{ 'ISSN nécessaire', true }
end
end
end
end


Biblio.rechercheIssn = function( frame )
local args = Outils.extractArgs( frame )
local References = require( 'Module:Biblio/Références' )
local newArgs = { issn = args[1], sansLabel = true, categ = {} }
local issn = References.issn( newArgs ) or ''
local categ = categorise{ 'Page avec ISSN invalide', newArgs.categ.issnInvalid }
return issn .. categ
end
Biblio.BNF = function ( frame )
local References = require( 'Module:Biblio/Références' )
return References.bnf( Outils.extractArgs( frame )[1] )
end


Biblio.enLigne = function ( frame )
Biblio.enLigne = function ( frame )
    local args = Outils.extractArgs( frame )
local args = Outils.extractArgs( frame )
    local References = require( 'Module:Biblio/Références' )
local References = require( 'Module:Biblio/Références' )
    return '<small>[' .. References.enLigne( args )  .. ']</small>'
return '<small>[' .. References.enLigne( args )  .. ']</small>'
end
end


Biblio.identifiantsBiblio = function( frame )
local args = Outils.extractArgs( frame )
args.categ = {}
local References = require( 'Module:Biblio/Références' )
return References.affichageLiensExternes( args, nil, true, true )
.. categorise{ 'Page avec ISBN invalide', args.categ.isbnInvalid }
.. categorise{ 'Page avec ISSN invalide', args.categ.issnInvalid }
.. categorise{ 'Page avec EAN invalide', args.categ.eanInvalid }
end


return Biblio
return Biblio

Dernière version du 27 avril 2017 à 17:18

-- Le module biblio centralise les différentes fonctions utiles pour les bibliographie et références.

local Biblio = { }

require( 'Module:No globals' ) local Outils = require( 'Module:Outils' )


Biblio.ouvrage = function ( frame ) local args = Outils.extractArgs( frame ) local Ouvrage = require( 'Module:Biblio/Ouvrage' ) return Ouvrage.ouvrage( args ) end


Biblio.chapitre = function ( frame ) local args = Outils.extractArgs( frame ) local Ouvrage = require( 'Module:Biblio/Ouvrage' ) return Ouvrage.chapitre( args ) end


Biblio.article = function ( frame ) local args = Outils.extractArgs( frame ) local Ouvrage = require( 'Module:Biblio/Article' ) return Ouvrage.article( args ) end


Biblio.lienWeb = function( frame ) local args = Outils.extractArgs( frame ) local Ouvrage = require( 'Module:Biblio/Lien web' ) return Ouvrage.lienWeb( args ) end

Biblio.lienBrise = function( frame ) local args = Outils.extractArgs( frame ) local Ouvrage = require( 'Module:Biblio/Lien web' ) return Ouvrage.lienBrise( args ) end


Biblio.dictionnaire = function( frame ) local args = Outils.extractArgs( frame ) local article = Outils.validTextArg( args, 'notice', 'article', 'titre chapitre' ) local Ouvrage = require( 'Module:Biblio/Ouvrage' ) if article then args['titre chapitre'] = article return Ouvrage.chapitre( args ) else args.titre = args['titre ouvrage'] args['sous-titre'] = args['sous-titre ouvrage'] args.auteur1 = args['auteur ouvrage'] args.auteurs = args['auteurs ouvrage'] return Ouvrage.ouvrage( args ) end end

-- catégorise une page en fonction du namespace local function categorise(args) local namespaceCategorisation = { [0] = true, [4] = true, [10] = true, [12] = true, [14] = true, [100] = true, [104] = true } local category = args[1] local flag = args[2] if type(category) == 'string' and flag and namespaceCategorisation[ mw.title.getCurrentTitle().namespace ] then return end return end

Biblio.ISBN = function ( frame ) local args = Outils.extractArgs( frame ) if Outils.trim( args[1] ) then local newArgs = { isbn = args[1] } local i = 2 while args[i] do newArgs[ 'isbn' .. i ] = args[i] i = i + 1 end return Biblio.identifiantsBiblio( newArgs ) else return '(ISBN inconnu)' .. categorise{ 'ISBN nécessaire', true } end end

Biblio.rechercheIsbn = function( frame ) local args = Outils.extractArgs( frame ) local References = require( 'Module:Biblio/Références' ) local newArgs = { isbn = args[1], sansLabel = true, categ = {} } local isbn = References.isbn( newArgs ) or local categ = categorise{ 'Page avec ISBN invalide', newArgs.categ.isbnInvalid } return isbn .. categ end


Biblio.EAN = function ( frame ) local args = Outils.extractArgs( frame ) if Outils.trim( args[1] ) then local newArgs = { ean = args[1], categ = {} } local i = 2 while args[i] do newArgs[ 'ean' .. i ] = args[i] i = i + 1 end return Biblio.identifiantsBiblio( newArgs ) else return '(EAN inconnu)' end end


Biblio.ISSN = function ( frame ) local args = Outils.extractArgs( frame ) if Outils.trim( args[1] ) then local newArgs = { issn = args[1], categ = {} } local i = 2 while args[i] do newArgs[ 'issn' .. i ] = args[i] i = i + 1 end return Biblio.identifiantsBiblio( newArgs ) else return '(ISSN inconnu)' .. categorise{ 'ISSN nécessaire', true } end end

Biblio.rechercheIssn = function( frame ) local args = Outils.extractArgs( frame ) local References = require( 'Module:Biblio/Références' ) local newArgs = { issn = args[1], sansLabel = true, categ = {} } local issn = References.issn( newArgs ) or local categ = categorise{ 'Page avec ISSN invalide', newArgs.categ.issnInvalid } return issn .. categ end

Biblio.BNF = function ( frame ) local References = require( 'Module:Biblio/Références' ) return References.bnf( Outils.extractArgs( frame )[1] ) end

Biblio.enLigne = function ( frame ) local args = Outils.extractArgs( frame ) local References = require( 'Module:Biblio/Références' ) return '[' .. References.enLigne( args ) .. ']' end

Biblio.identifiantsBiblio = function( frame ) local args = Outils.extractArgs( frame ) args.categ = {} local References = require( 'Module:Biblio/Références' ) return References.affichageLiensExternes( args, nil, true, true ) .. categorise{ 'Page avec ISBN invalide', args.categ.isbnInvalid } .. categorise{ 'Page avec ISSN invalide', args.categ.issnInvalid } .. categorise{ 'Page avec EAN invalide', args.categ.eanInvalid } end

return Biblio