« Module:Biblio/Ouvrage » : différence entre les versions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 54 : | Ligne 54 : | ||
wiki.minsert( Commun.COinS( args, validArg, genre ) ) | wiki.minsert( Commun.COinS( args, validArg, genre ) ) | ||
wiki.minsert( Commun.spanInitial ( args, validArg ) ) | wiki.minsert( Commun.spanInitial ( args, validArg ) ) | ||
local libelle = validArg( 'libellé' ) | |||
wiki.minsert( '<small>[', | if libelle then | ||
wiki.minsert( '<small>[', libelle, ']</small> ' ) | |||
end | end | ||
| Ligne 69 : | Ligne 70 : | ||
wiki.minsert( Commun.responsabilitePrincipale( args, validArg, true ) ) | wiki.minsert( Commun.responsabilitePrincipale( args, validArg, true ) ) | ||
end | end | ||
local coauteur = validArg( 'co-auteur', 'coauteurs' ) | |||
wiki.minsert( ', ', | if coauteur then | ||
wiki.minsert( ', ', coauteur ) | |||
end | end | ||
wiki.minsert( Commun.responsabiliteSecondaire( args, validArg ), ', ' ) | wiki.minsert( Commun.responsabiliteSecondaire( args, validArg ), ', ' ) | ||
| Ligne 92 : | Ligne 94 : | ||
end | end | ||
local auteurOuvrage = validArg( 'auteurs ouvrage' ) | |||
if auteurOuvrage or agrs.titre then | |||
wiki.minsert( ', dans ' ) | wiki.minsert( ', dans ' ) | ||
if | if auteurOuvrage then | ||
wiki.minsert( | wiki.minsert( auteurOuvrage, ', ' ) | ||
end | end | ||
else | else | ||
| Ligne 115 : | Ligne 118 : | ||
wiki.minsert( '<cite>') | wiki.minsert( '<cite>') | ||
end | end | ||
local lienTitre = validArg( 'lien titre' ) | |||
wiki.minsert( '[[', | if lienTitre then | ||
wiki.minsert( '[[', lienTitre, '|' ) | |||
end | end | ||
wiki.minsert( args.titre ) | wiki.minsert( args.titre ) | ||
local sousTitre = validArg( 'sous-titre' ) | |||
wiki.minsert( ( codeLangue and ': ' ) or ' : ', | if sousTitre then | ||
wiki.minsert( ( codeLangue and ': ' ) or ' : ', sousTitre ) | |||
end | end | ||
if | if lienTitre then | ||
wiki.minsert( ']]' ) | wiki.minsert( ']]' ) | ||
end | end | ||
| Ligne 143 : | Ligne 148 : | ||
end | end | ||
-- volume, tome | -- volume, tome | ||
local volume = validArg( 'volume', 'vol' ) | |||
wiki.minsert( ', ', Commun.vol, | if volume then | ||
wiki.minsert( ', ', Commun.vol, volume ) | |||
end | end | ||
local tome = validArg( 'tome' ) | |||
wiki.minsert( ', ', Commun.tome, | if tome then | ||
wiki.minsert( ', ', Commun.tome, tome ) | |||
end | end | ||
local titreVolTome = validArg( 'titre volume', 'titre tome' ) | |||
if | if titreVolTome then | ||
if volume or tome then | |||
wiki.minsert( [[ : '']] ) | wiki.minsert( [[ : '']] ) | ||
else | else | ||
| Ligne 157 : | Ligne 165 : | ||
if codeLangue then | if codeLangue then | ||
Langue = Langue or require( 'Module:Langue' ) | Langue = Langue or require( 'Module:Langue' ) | ||
wiki.minsert( Langue.lang{ codeLangue, | wiki.minsert( Langue.lang{ codeLangue, titreVolTome }, [['']] ) | ||
else | else | ||
wiki.minsert( | wiki.minsert( titreVolTome, [['']] ) | ||
end | end | ||
end | end | ||
-- références | -- références | ||
local reference = validArg( 'référence' ) | |||
wiki.minsert( ' ', Commun.detailEditions( | if reference then | ||
wiki.minsert( ' ', Commun.detailEditions( reference ) ) | |||
else | else | ||
local lieu = validArg( 'lieu' ) | |||
wiki.minsert( ', ', | if lieu then | ||
wiki.minsert( ', ', lieu ) | |||
end | end | ||
local | local editeur = validArg( 'éditeur', 'édition' ) | ||
if | if editeur then | ||
local lienEditeur = validArg( 'lien éditeur' ) | |||
wiki.minsert( ', [[', | if lienEditeur then | ||
wiki.minsert( ', [[', lienEditeur, '|', editeur, ']]' ) | |||
else | else | ||
wiki.minsert( ', ', | wiki.minsert( ', ', editeur ) | ||
end | end | ||
end | end | ||
local refSimple = validArg( 'référence simplifiée', 'ref' ) | |||
local annee = validArg( 'année', 'date' ) | |||
wiki.minsert( ', ', | if refSimple then | ||
if annee then | |||
wiki.minsert( ', ', annee ) | |||
end | end | ||
wiki.minsert( ' ', Commun.detailEdition( | wiki.minsert( ' ', Commun.detailEdition( refSimple ) ) | ||
else | else | ||
local collection = validArg( 'collection' ) | |||
wiki.minsert( ', ', Commun.coll, '« ', | if collection then | ||
wiki.minsert( ', ', Commun.coll, '« ', collection ) | |||
wiki.minsert( ' / ', | local serie = validArg( 'série' ) | ||
if serie then | |||
wiki.minsert( ' / ', serie ) | |||
end | end | ||
wiki.minsert( ' »' ) | wiki.minsert( ' »' ) | ||
end | end | ||
local numeroCollection = validArg( 'numéro dans collection' ) | |||
wiki.minsert( ' (', Commun.numero, | if numeroCollection then | ||
wiki.minsert( ' (', Commun.numero, numeroCollection, ')' ) | |||
end | end | ||
if | if annee then | ||
wiki.minsert( ', ', Commun.inscriptionDate( args ) ) | wiki.minsert( ', ', Commun.inscriptionDate( args ) ) | ||
end | end | ||
local publi = validArg( 'réimpression', 'publi' ) | |||
wiki.minsert( ' ', Commun.reimpr, | if publi then | ||
wiki.minsert( ' ', Commun.reimpr, publi ) | |||
end | end | ||
local numeroEdition = validArg( "numéro d'édition" ) | |||
wiki.minsert( ', ', Outils.ordinal( | if numeroEdition then | ||
wiki.minsert( ', ', Outils.ordinal( numeroEdition, true ), Commun.ed ) | |||
end | end | ||
local premiereEdition = validArg( 'année première édition', 'origyear' ) | |||
wiki.minsert( ' (', Commun.premiere, Commun.ed, | if premiereEdition then | ||
wiki.minsert( ' (', Commun.premiere, Commun.ed, premiereEdition ) | |||
end | end | ||
local format = validArg( 'format' ) | |||
wiki.minsert( ', ', | if format then | ||
wiki.minsert( ', ', format ) | |||
end | end | ||
local pages = validArg( 'pages totales', 'pages' ) | |||
wiki.minsert( ', ', | if pages then | ||
wiki.minsert( ', ', pages, Commun.nbp ) | |||
end | end | ||
| Ligne 232 : | Ligne 253 : | ||
References.jstor( validArg( 'jstor' ) ) | References.jstor( validArg( 'jstor' ) ) | ||
) | ) | ||
local url = validArg( 'lire en ligne', 'url', 'url texte' ) | |||
if url then | |||
enligne.insert( References.enLigne{ | enligne.insert( References.enLigne{ | ||
lien = | lien = url, | ||
texte = 'lire en ligne', | texte = 'lire en ligne', | ||
} ) | } ) | ||
end | end | ||
local ecouterEnLigne = validArg( 'écouter en ligne' ) | |||
if ecouterEnLigne then | |||
enligne.insert( References.enLigne{ | enligne.insert( References.enLigne{ | ||
lien = | lien = ecouterEnLigne, | ||
texte = 'écouter en ligne', | texte = 'écouter en ligne', | ||
} ) | } ) | ||
end | end | ||
local resume = validArg( 'présentation en ligne', 'résumé' ) | |||
if resume then | |||
enligne.insert( References.enLigne{ | enligne.insert( References.enLigne{ | ||
lien = | lien = resume, | ||
texte = 'présentation en ligne', | texte = 'présentation en ligne', | ||
} ) | } ) | ||
end | end | ||
local cousulteLe = validArg( 'consulté le', 'accessdate', 'consulté' ) | |||
enligne.insert( 'consulté le ' .. Outils.nobr( | if cousulteLe then | ||
enligne.insert( 'consulté le ' .. Outils.nobr( cousulteLe ) ) | |||
end | end | ||
| Ligne 261 : | Ligne 285 : | ||
-- précision sue le passage concerné | -- précision sue le passage concerné | ||
local | local numChapitrePartie | ||
local partie = validArg( 'partie' ) | |||
wiki.minsert( ', partie ', Commun.romain( | if partie then | ||
wiki.minsert( ', partie ', Commun.romain( partie ) ) | |||
numChapitrePartie = true | |||
end | end | ||
local numeroChapitre = validArg( 'numéro chapitre', 'numéro' ) | |||
wiki.minsert( ', ', Commun.chap, | if numeroChapitre then | ||
wiki.minsert( ', ', Commun.chap, numeroChapitre ) | |||
numChapitrePartie = true | |||
end | end | ||
local titreChapitre = validArg( 'titre chapitre', 'chap' ) | |||
if | if titreChapitre then | ||
wiki.minsert( ' (« ', | if numChapitrePartie then | ||
wiki.minsert( ' (« ', titreChapitre, ' »)' ) | |||
else | else | ||
wiki.minsert( ', « ', | wiki.minsert( ', « ', titreChapitre, ' »' ) | ||
end | end | ||
end | end | ||
local passage = validArg( 'passage', 'page' ) | |||
wiki.minsert( ', ', Commun.page, | if passage then | ||
wiki.minsert( ', ', Commun.page, passage ) | |||
end | end | ||
| Ligne 285 : | Ligne 313 : | ||
-- citation et commentaire de cet ouvrage | -- citation et commentaire de cet ouvrage | ||
local citation = validArg( 'extrait', 'citation' ) | |||
wiki.minsert( ' :<blockquote>', | if citation then | ||
wiki.minsert( ' :<blockquote>', citation, '</blockquote>' ) | |||
end | end | ||
if validArg( 'plume' ) then | if validArg( 'plume' ) then | ||
Version du 19 septembre 2013 à 12:42
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 renvoi 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' ) args.titre = validArg( 'titre ouvrage', 'titre' ) if args.titre == args.titreChap then args.titre = nil end args['titre chapitre'] = nil args.chap = nil args['sous-titre chapitre'] = validArg( 'sous-titre chapitre', 'sous-titre' ) args['sous-titre'] = validArg( 'sous-titre ouvrage', 'sous-titre' ) if args['sous-titre chapitre'] == args['sous-titre'] then args['sous-titre'] = nil end args['lien titre'] = validArg( 'lien titre ouvrage', 'lien titre' ) return require( 'Module:Biblio/Ouvrage' ).ouvrage( args, true ) end
function Ouvrage.ouvrage( args, chapitre )
-- La table wiki va recevoir tout les petits bouts de texte, et sera concaténtée à la fin.
-- Elle utilise la metat-table de TableBuilder, permettant d'utiliser les fonctions de la
-- librairy table comme des mèthodes. minsert permet d'insérer plusieurs élément en une
-- seule fois en, ignorant les paramètre nil.
local wiki = TableBuilder.new()
-- validArg renvoi 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 local genre = ( chapitre and 'chapitre' ) or 'ouvrage'
--Variables servant à la catégorisation local categTitre, categTitreChapitre, categTitreOuvrage, categLangue
-- clarification paramètre nécéssaire pour les coins args.titre = validArg( 'titre', 'title' )
-- COinS, id et libelé
wiki.minsert( Commun.COinS( args, validArg, genre ) )
wiki.minsert( Commun.spanInitial ( args, validArg ) )
local libelle = validArg( 'libellé' )
if libelle then
wiki.minsert( '[', libelle, '] ' )
end
-- indication de langue local incdicLangue, codeLangue, categLangue = Commun.indicationDeLangue ( args, validArg ) wiki.minsert( incdicLangue, ' ' )
-- Liste des auteurs et de leur responsabilités (principale et secondaire) if validArg( 'nom1', 'nom', 'auteur', 'auteurs', 'last1', 'last', 'author1', 'author' ) then if validArg( 'auteurs' ) then wiki.minsert( args.auteurs ) else wiki.minsert( Commun.responsabilitePrincipale( args, validArg, true ) ) end local coauteur = validArg( 'co-auteur', 'coauteurs' ) 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
wiki.minsert( '« ', args.titreChap )
if args['sous-titre chapitre'] then
wiki.minsert( ( codeLangue and ': ' ) or ' : ', args['sous-titre chapitre'] )
end
wiki.minsert( ' »' )
else
wiki.minsert( Outils.erreur( 'paramètre « titre chapitre » manquant' ) )
categTitreChapitre = true
end
local auteurOuvrage = validArg( 'auteurs ouvrage' ) if auteurOuvrage or agrs.titre then wiki.minsert( ', dans ' ) if auteurOuvrage then wiki.minsert( auteurOuvrage, ', ' ) end else wiki.minsert( ' ' ) end end
-- titre if args.titre then if codeLangue then Langue = Langue or require( 'Module:Langue' ) local dir = Langue.directionLangue( codeLangue ) if dir == 'rtl' then dir = '" dir="rtl' else dir = nil end
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( ( codeLangue and ': ' ) or ' : ', sousTitre ) end if lienTitre then wiki.minsert( '' ) end wiki.minsert( '' )
local original = validArg( 'titre original', 'titre vo' )
if original and original ~= args.titre then
wiki.minsert( ' [« ', original, ' »]' )
end
else
if chapitre then
wiki.minsert( Outils.erreur( 'paramètre « titre ouvrage » manquant' ) )
categTitreOuvrage = true
else
wiki.minsert( Outils.erreur( 'paramètre « titre » manquant' ) )
categTitre = true
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
-- références local reference = validArg( 'référence' ) if reference then wiki.minsert( ' ', Commun.detailEditions( reference ) ) else local lieu = validArg( 'lieu' ) if lieu then wiki.minsert( ', ', lieu ) end local editeur = validArg( 'éditeur', 'édition' ) if editeur then local lienEditeur = validArg( 'lien éditeur' ) if lienEditeur then wiki.minsert( ', ', editeur, '' ) else wiki.minsert( ', ', editeur ) end end local refSimple = validArg( 'référence simplifiée', 'ref' ) local annee = validArg( 'année', 'date' ) if refSimple then if annee then wiki.minsert( ', ', annee ) end wiki.minsert( ' ', Commun.detailEdition( refSimple ) ) else 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' ) if numeroCollection then wiki.minsert( ' (', Commun.numero, numeroCollection, ')' ) end if annee then wiki.minsert( ', ', Commun.inscriptionDate( args ) ) end local publi = validArg( 'réimpression', 'publi' ) if publi then wiki.minsert( ' ', Commun.reimpr, publi ) end local numeroEdition = validArg( "numéro d'é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 local format = validArg( 'format' ) if format then wiki.minsert( ', ', format ) end local pages = validArg( 'pages totales', 'pages' ) if pages then wiki.minsert( ', ', pages, Commun.nbp ) end
end
end
-- références ISBN, oclc, lccn, bnf... if validArg( 'isbn', 'lire en ligne', 'présentation en ligne', 'oclc', 'url', 'lccn', 'issn', 'bnf', 'ISBN', 'isbn1', 'ISSN', 'dnb', 'doi', 'jstor', 'url texte', 'pmid', 'résumé' ) then local enligne = TableBuilder.new( )
enligne.minsert( References.isbn( args, validArg ), References.issn( args, validArg ) )
enligne.minsert( References.oclc( validArg( 'oclc' ) ), References.bnf ( validArg( 'bnf' ) ), References.lccn( validArg( 'lccn' ) ), References.dnb ( validArg( 'dnb' ) ), References.doi( validArg( 'doi' ) ), References.pmid( validArg( 'pmid' ) ), References.jstor( validArg( 'jstor' ) ) )
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
local cousulteLe = validArg( 'consulté le', 'accessdate', 'consulté' ) if cousulteLe then enligne.insert( 'consulté le ' .. Outils.nobr( cousulteLe ) ) end
wiki.minsert( ' ', mw.text.nowiki( '[' ), enligne.concat( ', ' ), ']' ) end
-- précision sue le passage concerné local numChapitrePartie local partie = validArg( 'partie' ) if partie then wiki.minsert( ', partie ', Commun.romain( partie ) ) numChapitrePartie = true end local numeroChapitre = validArg( 'numéro chapitre', 'numéro' ) if numeroChapitre then wiki.minsert( ', ', Commun.chap, numeroChapitre ) numChapitrePartie = true end local titreChapitre = validArg( 'titre chapitre', 'chap' ) if titreChapitre then if numChapitrePartie then wiki.minsert( ' (« ', titreChapitre, ' »)' ) else wiki.minsert( ', « ', titreChapitre, ' »' ) end end local passage = validArg( 'passage', 'page' ) if passage then wiki.minsert( ', ', Commun.page, passage ) end
-- fin des span (COinS et 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 then
wiki.minsert(
categLangue and ,
categTitre and ,
categTitreChapitre and ,
categTitreOuvrage and
)
end
return wiki.concat()
end
return Ouvrage