Module:Biblio/Ouvrage

 Documentation

Ce module est destiné à être utilisé uniquement par le module:Biblio.

Utilisation

Fonctions exportables :

  • ouvrage(args) – affiche les références d'un ouvrage. Voir {{Ouvrage}}. Il faut fournir une table de paramètre simple.
  • chapitre(args) – affiche les références d'un chapitre d'un ouvrage. Voir {{Chapitre}}. Il faut fournir une table de paramètre simple.

Modules externes et autres éléments dont ce module a besoin pour fonctionner :


local Ouvrage = { }local Commun = require( 'Module:Biblio/Commun' )local References = require( 'Module:Biblio/Références' )local Nombre2texte = require( 'Module:Nombre2texte' )local TableBuilder = require( 'Module:TableBuilder' )local Langue = require( 'Module:Langue' )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 Commun.validTextArg( args, ... ) end-- titreChap est un paramètre différent de ceux du modèle ouvrage pour utiliser le même programmeargs.numChap = validArg( 'numéro chapitre' )args.titreChap = validArg( 'titre chapitre', 'chap', 'titre', 'title', 'Titel' )if args.titre == args.titreChap thenargs.titre = falseendargs.titre = validArg( 'titre ouvrage', 'ouvrage', 'titre', 'title', 'Titel') or falseargs['numéro chapitre'] = falseargs['titre chapitre'] = falseargs['traduction titre chapitre'] = validArg( 'traduction titre chapitre') or nilargs.chap = falseargs['sous-titre chapitre'] = validArg( 'sous-titre chapitre', 'sous-titre' ) or falseargs['sous-titre'] = validArg( 'sous-titre ouvrage', 'sous-titre' )if args['sous-titre chapitre'] == args['sous-titre'] thenargs['sous-titre'] = falseendargs['lien titre'] = validArg( 'lien titre ouvrage', 'lien titre' )local preface = validArg( 'préface' )local auteurOuvrage = validArg( 'auteurs ouvrage', 'auteur ouvrage' )if preface and auteurOuvrage thenargs['auteurs ouvrage'] = ( validArg( 'auteurs ouvrage', 'auteur ouvrage' ) or '' ) .. ' (préf. ' .. preface .. ')'args['préface'] = ''endreturn Ouvrage.ouvrage( args, true )endfunction 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 Commun.validTextArg( args, ... ) or false endlocal genre = ( chapitre and 'chapitre' ) or 'ouvrage'--Table servant à la catégorisationargs.categ = {}local modeNormal = not validArg( 'nocat' )-- Clarification des paramètres  nécessaires pour les COinSargs.titre = validArg( 'titre', 'title', 'Titel' )args['pages totales'] = validArg( 'pages totales', 'pages' )args.pages = ''local lienExternes = validArg( 'lire en ligne', 'url texte', 'url', 'texte', 'Online' )if args.format and not args['format électronique'] and lienExternes and string.match( args.format,"pdf" ) thenargs['format électronique'] = args.formatargs.format = falseend-- span initial (id) et libellélocal spanInitial, spanFinal = Commun.spanInitial ( args, validArg )wiki.minsert( spanInitial,  Commun.libelle( args ) )-- Indication de languelocal indicLangue, codeLangue = Commun.indicationDeLangue ( args, validArg )local dir, attributsLangue -- attention, la variable "dir" est aussi utilisée à la fin du codeif indicLangue and indicLangue ~= '' thenwiki.minsert( indicLangue, ' ' )if codeLangue thendir = Langue.directionLangue( codeLangue )if dir == 'rtl' then attributsLangue = ' lang="' .. codeLangue .. '" dir="rtl"'else dir = nilattributsLangue = ' lang="' .. codeLangue .. '"'endendend-- Liste des auteurs et de leurs responsabilités (principales et secondaires)local auteur = validArg( 'nom1', 'nom', 'auteur1', 'auteur', 'auteurs', 'auteur institutionnel', 'last1', 'last', 'author1', 'author', 'Autor' )if auteur thenif validArg( 'auteurs' ) thenwiki.minsert( args.auteurs )elsewiki.minsert( Commun.responsabilitePrincipale( args, validArg ) )endlocal coauteur = validArg( 'co-auteur', 'coauteurs', 'coauteur', 'coauthors' )if coauteur thenwiki.minsert( ', ', coauteur )endwiki.minsert( Commun.responsabiliteSecondaire( args, validArg ), ', ' )end-- Pour le modèle chapitre : affichage du chapitreif chapitre thenif args.numChap thenwiki.minsert( Commun.chap, args.numChap, ' ' )endif args.titreChap thenwiki.minsert( '<cite style="font-style:normal"', attributsLangue, '>« ', args.titreChap )if args['sous-titre chapitre'] thenwiki.minsert( ' : ', args['sous-titre chapitre'] )endwiki.minsert( ' »' )if args["traduction titre chapitre"] thenwiki.minsert(' [« ', args["traduction titre chapitre"],' »]')endwiki.minsert( '</cite>' )elseif modeNormal thenwiki.minsert( '<span class="error">[[Modèle:Chapitre|{{Chapitre}}]] : paramètre <code>titre chapitre</code> manquant</span>' )args.categ.titreChapitre = trueendwiki.minsert( ', dans ' )local auteurOuvrage = validArg( 'auteurs ouvrage', 'auteur ouvrage' )if auteurOuvrage thenwiki.minsert( auteurOuvrage, ', ' )endend-- Titreif args.titre thenlocal titre, sousTitre = args.titre, validArg( 'sous-titre' )-- retrait italique, ne doit normalement pas être mis mais l'erreur est très fréquentetitre = titre:gsub( "^''%f[^'](.+)%f[']''$", "%1" )if sousTitre then-- retrait italique, erreur moins fréquente avec les sous-titres mais autant être consistantsousTitre = sousTitre:gsub( "^''%f[^'](.+)%f[']''$", "%1" )titre =  titre .. ' : ' .. sousTitreendtitre = Commun.fusionTexteLien( titre, args['lien titre'], args.categ )local graphie = ' class="italique"'if Langue.nonLatin( titre ) thengraphie = ' style="font-style:normal"'endwiki.minsert( '<cite', graphie, attributsLangue, '>', titre, '</cite>' )elseif modeNormal thenif chapitre thenargs.categ.titreOuvrage = trueif args.categ.titreChapitre thenwiki.minsert( '<span class="error">paramètre <code>titre ouvrage</code> manquant</span>' )elsewiki.minsert( '<span class="error">[[Modèle:Chapitre|{{Chapitre}}]] : paramètre <code>titre ouvrage</code> manquant</span>' )endelseargs.categ.titre = truewiki.minsert( '<span class="error">[[Modèle:Ouvrage|{{Ouvrage}}]] : paramètre <code>titre</code> manquant</span>' )endend-- Titre original et traducteurlocal original = validArg( 'titre original', 'titre vo')local traduction_titre = validArg('traduction titre')if original and original ~= args.titre thenif validArg( 'langue originale' ) thenwiki.minsert( ' [« ', Langue.langue{ args['langue originale'], original }, ' »]' )elsewiki.minsert( ' [« ', original, ' »]' )endendif traduction_titre thenwiki.minsert( ' [« ', traduction_titre, ' »]' )endif not auteur thenlocal responsabiliteSecondaire = Commun.responsabiliteSecondaire( args, validArg )if responsabiliteSecondaire thenwiki.minsert( ' ', responsabiliteSecondaire )endend-- Volume, tomelocal volume = validArg( 'volume', 'vol', 'Band' )if volume thenwiki.minsert( ', ', Commun.vol, volume )endlocal tome = validArg( 'tome' )if tome thenwiki.minsert( ', ', Commun.tome, tome )endlocal titreVolTome = validArg( 'titre volume', 'titre tome' )if titreVolTome thenif volume or tome thenwiki.minsert( ' : ' )elsewiki.minsert( ', ' )endif codeLangue thenwiki.minsert( Langue.langue{ codeLangue, titreVolTome, class='italique' } )elsewiki.minsert( '<span class="italique">', titreVolTome,  '</span>' )endlocal tradTitreVolTome = validArg( 'traduction titre volume', 'traduction titre tome' )if tradTitreVolTome thenwiki.minsert( ' [« ', tradTitreVolTome, ' »]' )endend-- Nature du document et établissement (pour les thèses...)local nature = validArg( 'nature ouvrage' )if nature thenwiki.minsert( ' (', nature, ')')endlocal etablissement = validArg( 'établissement' )if etablissement thenwiki.minsert( ', ', etablissement )end-- Lieu et éditeurlocal lieu = validArg( 'lieu', 'location', 'Ort' )if lieu thenwiki.minsert( ', ', lieu )endlocal editeur = validArg( 'éditeur', 'édition', 'editeur', 'edition', 'publisher', 'Verlag' )if editeur thenlocal lienEditeur = validArg( 'lien éditeur' )wiki.minsert( ', ', Commun.fusionTexteLien( editeur, lienEditeur, args.categ ) )end-- Collecion et numérolocal collection = validArg( 'collection', 'series' )if collection thenwiki.minsert( ', ', Commun.coll, '« ', collection )local serie = validArg( 'série' )if serie thenwiki.minsert( ' / ', serie )endwiki.minsert( ' »' )endlocal numeroCollection = validArg( 'numéro dans collection', 'numéro dans la collection' )if numeroCollection thenwiki.minsert( ' (', Commun.numero, numeroCollection, ')' )end-- Date, réimpression et éditionslocal annee = validArg( 'année', 'date', 'year', 'Datum', 'Jahr' )if annee thenlocal lrmif Langue.nonLatin( wiki.concat() ) thenlrm = '&lrm;'endwiki.minsert( ',', lrm, ' ', 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...)endlocal publi = validArg( 'réimpression', 'publi' )if publi thenwiki.minsert( ' (', Commun.reimpr, publi, ')' )endlocal numeroEdition = validArg( "numéro d'édition", "numéro édition"  )if numeroEdition thenwiki.minsert( ', ', Nombre2texte.ordinal( numeroEdition, true ), Commun.ed )endlocal premiereEdition = validArg( 'année première édition', 'origyear' )if premiereEdition thenwiki.minsert( ' (', Commun.premiere, Commun.ed, ' ', premiereEdition, ')' )end-- Pages et formatlocal pages = validArg( 'pages totales', 'pages' )if pages thenwiki.minsert( ', ', Commun.formatePagesTotales( pages ) )endlocal format = validArg( 'format livre', 'format' )if format thenwiki.minsert( ', ', format )end-- Référenceslocal reference = validArg( 'référence' )if reference thenwiki.minsert( ' ', Commun.detailEditions( reference ) )endlocal refSimple = validArg( 'référence simplifiée', 'ref' )if refSimple thenwiki.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 ) )-- 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 thenif partie:match( '^[%dIVXLCM]+$' ) thenwiki.minsert( ', partie&nbsp;', partie )elseif partie:match( '^[ivxlcmIVXLCM]+$' ) thenwiki.minsert( ', partie&nbsp;', Commun.romain( partie ) )elsewiki.minsert( ', ', partie )endendlocal numeroChapitre = validArg( 'numéro chapitre', 'numéro' )if numeroChapitre thenwiki.minsert( ', ', Commun.chap, numeroChapitre )endlocal titreChapitre = validArg( 'titre chapitre', 'chap', 'chapitre', 'chapter' )if titreChapitre thenif numeroChapitre thentitreChapitre = ' (« ' .. titreChapitre .. ' »)'elsetitreChapitre = ', « ' .. titreChapitre .. ' »'endif codeLangue thentitreChapitre = Langue.langue{ codeLangue, titreChapitre }endwiki.minsert( titreChapitre )local tradTitreChap = validArg( 'traduction titre chapitre' )if tradTitreChap thenwiki.minsert( ' [« ', tradTitreChap, ' »]' )endendlocal passage = validArg( 'passage', 'page' )if passage thenwiki.minsert( ', ', Commun.formatePassage( passage ) )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'ouvragewiki.minsert( spanFinal )-- Plume "Ouvrage utilisé pour la rédaction de l'article"if validArg( 'plume' ) thenlocal patternPonct = '[,.;:!?]$'local ponctuation = wiki.concat():gsub( '%b<>', '' ):match( patternPonct )if not ponctuation thenwiki.minsert( '.' )endwiki.minsert( Commun.plume )end-- Citation et commentaire de cet ouvragelocal citation = validArg( 'extrait', 'citation' )if citation thenif codeLangue thencitation = Langue.lang{ codeLangue, citation }endwiki.minsert( '&nbsp;:<blockquote>«&nbsp;', citation, '&nbsp;»</blockquote>' )endwiki.minsert( Commun.commentaire( args ) )local namespaceCategorisation = { [0] = true, [4] = true, [10] = true, [12] = true, [14] = true, [100] = true, [104] = true }if namespaceCategorisation[ mw.title.getCurrentTitle().namespace ] and modeNormal thenwiki.minsert(args.categ.langue and '[[Catégorie:Page du modèle Ouvrage comportant une erreur|langue]]',args.categ.titre and '[[Catégorie:Page du modèle Ouvrage comportant une erreur|titre]]',args.categ.titreChapitre and '[[Catégorie:Page du modèle Chapitre comportant une erreur|Chapitre]]',args.categ.titreOuvrage and '[[Catégorie:Page du modèle Chapitre comportant une erreur|Ouvrage]]',args.categ.lienExterne and '[[Catégorie:Page du modèle Ouvrage comportant une erreur|Externe]]',args.categ.isbnInvalid and '[[Catégorie:Page avec ISBN invalide]]',args.categ.issnInvalid and '[[Catégorie:Page avec ISSN invalide]]',args.categ.eanInvalid and '[[Catégorie:Page avec EAN invalide]]')if dir thenwiki.minsert( '[[Catégorie:Recension temporaire pour le modèle Ouvrage|rtl]]' )endendreturn wiki.concat()endreturn Ouvrage
🔥 Top keywords: