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

De Lagny-sur-Marne Wiki
Aller à la navigation Aller à la recherche
0x010D (discussion | contributions)
0x010D (discussion | contributions)
Ajout de « numéro édition », « format livre » et « format électronique » ; Utilisation de Biblio/Références | affichageLiensExternes commun à tout les modèles Biblio
Ligne 52 : Ligne 52 :
args['pages totales'] = validArg( 'pages totales', 'pages' )
args['pages totales'] = validArg( 'pages totales', 'pages' )
args.pages = ''
args.pages = ''
if args.format and string.match(args.format,"pdf") then
args['format électronique'] = args.format
args.format = false
end
Ligne 238 : Ligne 242 :
wiki.minsert( ' (', Commun.reimpr, publi, ')' )
wiki.minsert( ' (', Commun.reimpr, publi, ')' )
end
end
local numeroEdition = validArg( "numéro d'édition" )
local numeroEdition = validArg( "numéro d'édition", "numéro édition"  )
if numeroEdition then
if numeroEdition then
wiki.minsert( ', ', Outils.ordinal( numeroEdition, true ), Commun.ed )
wiki.minsert( ', ', Outils.ordinal( numeroEdition, true ), Commun.ed )
Ligne 248 : Ligne 252 :
-- format et pages
-- format et pages
local format = validArg( 'format' )
local format = validArg( 'format livre', 'format' )
if format then
if format then
wiki.minsert( ', ', format )
wiki.minsert( ', ', format )
Ligne 267 : Ligne 271 :
end
end
-- références ISBN, oclc, lccn, bnf... et liens en ligne
 
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
-- lien vers l'ouvrage en ligne (isbn, issn, pmid, doi, lire en ligne, résumé...)
local enligne = TableBuilder.new(  )
wiki.minsert( References.affichageLiensExternes( args, validArg, true, false ) )
categIsbnInvalid = args.categIsbnInvalid
args.categIsbnInvalid = false
-- consulté le n'est plus affiché, voir [[Discussion_modèle:Ouvrage#Évolution documentation]]
enligne.minsert( References.isbn( args, validArg ), References.issn( args, validArg ) )
categIsbnInvalid = args.categIsbnInvalid
enligne.minsert(
References.oclc( args.oclc ),
References.bnf ( args.bnf ),
References.lccn( args.lccn ),
References.dnb ( args.dnb ),
References.doi( args.doi ),
References.pmid( args.pmid ),
References.jstor( args.jstor ),
References.bibcode( args.bibcode ),
References.mathreviews( args['math reviews'] ),
References.zbl( args.zbl ),
References.arxiv( args.arxiv ),
References.wikisource( args.wikisource )
)
local url = validArg( 'lire en ligne', 'url', 'url texte' )
if url then
enligne.insert( References.enLigne{
lien = url,
texte = 'lire en ligne',
} )
end
local ecouterEnLigne = validArg( 'écouter en ligne' )
if ecouterEnLigne then
enligne.insert( References.enLigne{
lien = ecouterEnLigne,
texte = 'écouter en ligne',
} )
end
local resume = validArg( 'présentation en ligne', 'résumé' )
if resume then
enligne.insert( References.enLigne{
lien = resume,
texte = 'présentation en ligne',
} )
end
--[=[ consulté le n'est plus affiché, voir [[Discussion_modèle:Ouvrage#Évolution documentation]]
local cousulteLe = validArg( 'consulté le', 'accessdate', 'consulté' )
if cousulteLe then
enligne.insert( 'consulté le ' .. Outils.nobr( cousulteLe ) )
end
]=]
wiki.minsert( ' <small>', mw.text.nowiki( '(' ), enligne.concat( ', ' ),  ')</small>' )
end
-- précision sur le passage concerné
-- précision sur le passage concerné

Version du 18 juillet 2014 à 20:17

local Ouvrage = { }


local Commun = require( 'Module:Biblio/Commun' ) local References = require( 'Module:Biblio/Références' ) local Outils = require( 'Module:Outils' ) local TableBuilder = require( 'Module:TableBuilder' ) local Langue -- = require( 'Module:Langue' ) ne sera chargé que si nécessaire.


function Ouvrage.chapitre( args ) -- validArg renvoie le premier paramètre non vide, ou nil s'ils sont tous vides. -- Seul les noms des paramètres doivent être transmis à la fonction. local validArg = function ( ... ) return Outils.validTextArg( args, ... ) end

-- titreChap est un paramètre différents de ceux du modèle ouvrage pour utilisé le même programme args.titreChap = validArg( 'titre chapitre', 'chap', 'titre' ) if args.titre == args.titreChap then args.titre = false end args.titre = validArg( 'titre ouvrage', 'ouvrage', 'titre' ) or false args['titre chapitre'] = false args.chap = false args['sous-titre chapitre'] = validArg( 'sous-titre chapitre', 'sous-titre' ) or false args['sous-titre'] = validArg( 'sous-titre ouvrage', 'sous-titre' ) if args['sous-titre chapitre'] == args['sous-titre'] then args['sous-titre'] = false end args['lien titre'] = validArg( 'lien titre ouvrage', 'lien titre' ) return Ouvrage.ouvrage( args, true ) end


function Ouvrage.ouvrage( args, chapitre ) -- La table wiki va recevoir tout les petits bouts de texte, et sera concaténée à la fin. -- Elle utilise la meta-table de TableBuilder, permettant d'utiliser les fonctions de la -- librairie table comme des méthodes. minsert permet d'insérer plusieurs éléments en une -- seule fois en, ignorant les paramètres nil. local wiki = TableBuilder.new()

-- validArg renvoie le premier paramètre non vide, ou nil s'ils sont tous vides. -- Seul les noms des paramètres doivent être transmis à la fonction. local validArg = function ( ... ) return Outils.validTextArg( args, ... ) or false end local genre = ( chapitre and 'chapitre' ) or 'ouvrage'

--Variables servant à la catégorisation local categTitre, categTitreChapitre, categTitreOuvrage, categIsbnInvalid --, categLangue (déclaré lors de l'indication de langue) local modeNormal = not validArg( 'nocat' )

-- clarification des paramètres nécessaires pour les coins args.titre = validArg( 'titre', 'title' ) args['pages totales'] = validArg( 'pages totales', 'pages' ) args.pages = if args.format and string.match(args.format,"pdf") then args['format électronique'] = args.format args.format = false end


-- span initial (id) et libelé wiki.minsert( Commun.spanInitial ( args, validArg ) ) local libelle = validArg( 'libellé' ) if libelle then wiki.minsert( '[', libelle, '] ' ) end

-- indication de langue local indicLangue, codeLangue, categLangue = Commun.indicationDeLangue ( args, validArg ) local dir if Outils.notEmpty( indicLangue ) then wiki.minsert( indicLangue, ' ' ) if codeLangue then Langue = Langue or require( 'Module:Langue' ) dir = Langue.directionLangue( codeLangue ) if dir == 'rtl' then dir = '" dir="rtl' else dir = nil end end end

-- Liste des auteurs et de leurs responsabilités (principales et secondaires) local auteur = validArg( 'nom1', 'nom', 'auteur1', 'auteur', 'auteurs', 'last1', 'last', 'author1', 'author' ) if auteur then if validArg( 'auteurs' ) then wiki.minsert( args.auteurs ) else wiki.minsert( Commun.responsabilitePrincipale( args, validArg, true ) ) end local coauteur = validArg( 'co-auteur', 'coauteurs', 'coauteur', 'coauthors' ) if coauteur then wiki.minsert( ', ', coauteur ) end wiki.minsert( Commun.responsabiliteSecondaire( args, validArg ), ', ' ) end

-- Pour le modèle chapitre : affichage du chapitre if chapitre then if args.titreChap then if codeLangue then wiki.minsert( '' ) end wiki.minsert( '« ', args.titreChap ) if args['sous-titre chapitre'] then wiki.minsert( ' : ', args['sous-titre chapitre'] ) end wiki.minsert( ' »' ) if codeLangue then wiki.minsert( '' ) end elseif modeNormal then wiki.minsert( Outils.erreur( ' [[Modèle:Chapitre|Modèle:Chapitre]] : paramètre « titre chapitre » manquant' ) ) categTitreChapitre = true end

wiki.minsert( ', dans ' )

local auteurOuvrage = validArg( 'auteurs ouvrage', 'auteur ouvrage' ) if auteurOuvrage then wiki.minsert( auteurOuvrage, ', ' ) end end

-- titre if args.titre then if codeLangue then wiki.minsert( '') else wiki.minsert( '') end local lienTitre = validArg( 'lien titre' ) if lienTitre then wiki.minsert( '' ) end wiki.minsert( args.titre ) local sousTitre = validArg( 'sous-titre' ) if sousTitre then wiki.minsert( ' : ', sousTitre ) end if lienTitre then wiki.minsert( '' ) end wiki.minsert( '' )

elseif modeNormal then if chapitre then categTitreOuvrage = true if categTitreChapitre then wiki.minsert( Outils.erreur( 'paramètre « titre ouvrage » manquant' ) ) else wiki.minsert( Outils.erreur( '[[Modèle:Chapitre|Modèle:Chapitre]] : paramètre « titre ouvrage » manquant' ) ) end else categTitre = true wiki.minsert( Outils.erreur( '[[Modèle:Ouvrage|{{Ouvrage}} : paramètre « titre » manquant]] : paramètre « titre » manquant' ) ) end end

-- titre original et traducteur local original = validArg( 'titre original', 'titre vo', 'traduction titre' ) if original and original ~= args.titre then wiki.minsert( ' [« ', original, ' »]' ) end if not auteur then local responsabiliteSecondaire = Commun.responsabiliteSecondaire( args, validArg ) if responsabiliteSecondaire then wiki.minsert( ' ', responsabiliteSecondaire ) end end

-- volume, tome local volume = validArg( 'volume', 'vol' ) if volume then wiki.minsert( ', ', Commun.vol, volume ) end local tome = validArg( 'tome' ) if tome then wiki.minsert( ', ', Commun.tome, tome ) end local titreVolTome = validArg( 'titre volume', 'titre tome' ) if titreVolTome then if volume or tome then wiki.minsert( '' ) else wiki.minsert( , '' ) end if codeLangue then Langue = Langue or require( 'Module:Langue' ) wiki.minsert( Langue.lang{ codeLangue, titreVolTome }, '' ) else wiki.minsert( titreVolTome, '' ) end end

-- lieu et éditeur local lieu = validArg( 'lieu', 'location' ) if lieu then wiki.minsert( ', ', lieu ) end local editeur = validArg( 'éditeur', 'édition', 'editeur', 'edition', 'publisher' ) if editeur then local lienEditeur = validArg( 'lien éditeur' ) if lienEditeur then wiki.minsert( ', ', editeur, '' ) else wiki.minsert( ', ', editeur ) end end

-- nature du document local nature = validArg( 'nature ouvrage' ) if nature then wiki.minsert( ' (', nature, ')') end

-- collecion et numéro local collection = validArg( 'collection' ) if collection then wiki.minsert( ', ', Commun.coll, '« ', collection ) local serie = validArg( 'série' ) if serie then wiki.minsert( ' / ', serie ) end wiki.minsert( ' »' ) end local numeroCollection = validArg( 'numéro dans collection', 'numéro dans la collection' ) if numeroCollection then wiki.minsert( ' (', Commun.numero, numeroCollection, ')' ) end

-- date, réimpression et éditions local annee = validArg( 'année', 'date', 'year' ) if annee then wiki.minsert( ',‎ ', Commun.inscriptionDate( args ) ) -- le &lrm est une marque de texte gauche à droite, utile si le texte qui précède est en droite à gauche (arabe, hébreux...) end local publi = validArg( 'réimpression', 'publi' ) if publi then wiki.minsert( ' (', Commun.reimpr, publi, ')' ) end local numeroEdition = validArg( "numéro d'édition", "numéro édition" ) if numeroEdition then wiki.minsert( ', ', Outils.ordinal( numeroEdition, true ), Commun.ed ) end local premiereEdition = validArg( 'année première édition', 'origyear' ) if premiereEdition then wiki.minsert( ' (', Commun.premiere, Commun.ed, ' ', premiereEdition, ')' ) end

-- format et pages local format = validArg( 'format livre', 'format' ) if format then wiki.minsert( ', ', format ) end local pages = validArg( 'pages totales', 'pages' ) if pages then wiki.minsert( ', ', pages, Commun.nbp ) end

-- références local reference = validArg( 'référence' ) if reference then wiki.minsert( ' ', Commun.detailEditions( reference ) ) end local refSimple = validArg( 'référence simplifiée', 'ref' ) if refSimple then wiki.minsert( ' ', Commun.detailEdition( refSimple ) ) end


-- lien vers l'ouvrage en ligne (isbn, issn, pmid, doi, lire en ligne, résumé...) wiki.minsert( References.affichageLiensExternes( args, validArg, true, false ) ) categIsbnInvalid = args.categIsbnInvalid -- consulté le n'est plus affiché, voir Discussion_modèle:Ouvrage#Évolution documentation

-- précision sur le passage concerné local partie = validArg( 'partie' ) if partie then if string.match ( partie, '^[%dIVXLCM]+$' ) then wiki.minsert( ', partie ', partie ) elseif string.match ( partie, '^[ivxlcmIVXLCM]+$' ) then wiki.minsert( ', partie ', Commun.romain( partie ) ) else wiki.minsert( ', ', partie ) end end local numeroChapitre = validArg( 'numéro chapitre', 'numéro' ) if numeroChapitre then wiki.minsert( ', ', Commun.chap, numeroChapitre ) end local titreChapitre = validArg( 'titre chapitre', 'chap', 'chapitre', 'chapter' ) if titreChapitre then if numeroChapitre then titreChapitre = ' (« ' .. titreChapitre .. ' »)' else titreChapitre = ', « ' .. titreChapitre .. ' »' end if codeLangue then Langue = Langue or require( 'Module:Langue' ) titreChapitre = Langue.lang{ codeLangue, titreChapitre } end wiki.minsert( titreChapitre ) end local passage = validArg( 'passage', 'page' ) if passage then if string.match ( passage, '^[%dIVXLCM]' ) then wiki.minsert( ', ', Commun.page, passage ) else wiki.minsert( ', ', passage ) end end

-- ajout des méthadonnées COinS (ContextObjects in Spans) wiki.minsert( Commun.COinS( args, validArg, genre ) )

-- fin du span (id) et de la description de l'ouvrage wiki.minsert( '' )

-- citation et commentaire de cet ouvrage local citation = validArg( 'extrait', 'citation' ) if citation then

wiki.minsert( ' :

« ', citation, ' »

' )

end if validArg( 'plume' ) then wiki.minsert( Commun.plume ) end wiki.minsert( Commun.commentaire( args ) )


if mw.title.getCurrentTitle().namespace == 0 and modeNormal then wiki.minsert( categLangue and , categTitre and , categTitreChapitre and , categTitreOuvrage and , categIsbnInvalid and ) if dir then wiki.minsert( ) end end


return wiki.concat() end


return Ouvrage