Modulo:Biblio/Libro
Dokumentado por ĉi tiu modulo povas esti kreata ĉe Modulo:Biblio/Libro/dokumentado
local Verko = { }
local Commun = require( 'Modulo:Biblio/Commun' )
local References = require( 'Modulo:Biblio/Referencoj' )
local Outils = require( 'Modulo:Iloj' )
local TableBuilder = require( 'Modulo:TableBuilder' )
local Langue = require( 'Modulo:Lingvo' )
function Verko.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 ceŭ du modèle Verko pour utiliser le même programme
args.titreChap = validArg( 'titre chapitre', 'chap', 'titre', 'title' )
if args.titre == args.titreChap then
args.titre = false
end
args.titre = validArg( 'titre Verko', 'Verko', 'titre', 'title' ) 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( 'subtitolo', 'sous-titre Verko', 'sous-titre' )
if args['sous-titre chapitre'] == args['sous-titre'] then
args['sous-titre'] = false
end
args['lien titre'] = validArg( 'lien titre Verko', 'lien titre' )
return Verko.Verko( args, true )
end
function Verko.libro( 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 end
local genre = ( chapitre and 'chapitre' ) or 'Verko'
--Table servant à la catégorisation
args.categ = {}
local modeNormal = not validArg( 'nocat' )
-- Clarification des paramètres nécessaires pour les COinS
args.titre = validArg( 'titolo', 'titre' )
args['pages totales'] = validArg( 'pages totales', 'pages', 'paĝoj' )
args.pages = ''
local lienExternes = validArg( 'lire en ligne', 'url texte', 'url', 'texte' )
if args.format and not args['format électronique'] and lienExternes and string.match( args.format,"pdf" ) then
args['format électronique'] = args.format
args.format = false
end
-- span initial (id) et libellé
local spanInitial, spanFinal = Commun.spanInitial ( args, validArg )
wiki.minsert( spanInitial, Commun.libelle( args ) )
-- Indikado de lingvo
local indicLangue, codeLangue = Commun.indicationDeLangue ( args, validArg )
local dir, attributsLangue
if Outils.notEmpty( indicLangue ) then
wiki.minsert( indicLangue, ' ' )
if codeLangue then
dir = Langue.directionLangue( codeLangue )
if dir == 'rtl' then
attributsLangue = ' lang="' .. codeLangue .. '" dir="rtl"'
else
dir = nil
attributsLangue = ' lang="' .. codeLangue .. '"'
end
end
end
-- Listo de la verkintoj kaj de leurs responsabilités (principales et secondaires)
local verkinto = validArg( 'nom1', 'nom', 'verkinto1', 'verkinto', 'verkintoj', 'verkinto institutionnel' )
if verkinto then
if validArg( 'verkintoj' ) then
wiki.minsert( args.verkintoj )
else
wiki.minsert( Commun.responsabilitePrincipale( args, validArg ) )
end
local coverkinto = validArg( 'co-verkinto', 'coverkintoj', 'coverkinto' )
if coverkinto then
wiki.minsert( ', ', coverkinto )
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( '<cite style="font-style:normal"', attributsLangue, '>“', args.titreChap )
if args['sous-titre chapitre'] then
wiki.minsert( ' : ', args['sous-titre chapitre'] )
end
wiki.minsert( '”</cite>' )
elseif modeNormal then
wiki.minsert( Outils.erreur( ' [[Modèle:Chapitre|{{Chapitre}}]] : paramètre <code>titre chapitre</code> manquant' ) )
args.categ.titreChapitre = true
end
wiki.minsert( ', dans ' )
local verkintoVerko = validArg( 'verkintoj Verko', 'verkinto Verko' )
if verkintoVerko then
wiki.minsert( verkintoVerko, ', ' )
end
end
-- Titre
if args.titre then
local titre, sousTitre = args.titre, validArg('subtitolo', 'sous-titre' )
if sousTitre then
titre = titre .. ' : ' .. sousTitre
end
titre = Commun.fusionTexteLien( titre, args['lien titre'], args.categ )
local graphie = ' class="italique"'
if Langue.nonLatin( titre ) then
graphie = ' style="font-style:normal"'
end
wiki.minsert( '<cite', graphie, attributsLangue, '>', titre, '</cite>' )
elseif modeNormal then
if chapitre then
args.categ.titreVerko = true
if args.categ.titreChapitre then
wiki.minsert( Outils.erreur( 'paramètre <code>titre Verko</code> manquant' ) )
else
wiki.minsert( Outils.erreur( '[[Modèle:Chapitre|{{Chapitre}}]] : paramètre <code>titre Verko</code> manquant' ) )
end
else
args.categ.titre = true
wiki.minsert( Outils.erreur( '[[Modèle:Verko|{{Verko}}]] : paramètre <code>titre</code> manquant' ) )
end
end
-- origina titolo kaj traducteur
local original = validArg('origina titolo', 'titre original', 'titre vo', 'traduction titre', 'traduktado titolo' )
if original and original ~= args.titre then
if validArg( 'langue originale' ) then
wiki.minsert( ' [“', Langue.langue{ args['langue originale'], original }, '”]' )
else
wiki.minsert( ' [“', original, '”]' )
end
end
if not verkinto 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', 'tomo' )
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
wiki.minsert( Langue.langue{ codeLangue, titreVolTome }, [['']] )
else
wiki.minsert( titreVolTome, [['']] )
end
local tradTitreVolTome = validArg( 'traduction titre volume', 'traduction titre tome' )
if tradTitreVolTome then
wiki.minsert( ' [“', tradTitreVolTome, '”]' )
end
end
-- Lieu et éditeur
local lieu = validArg('loko', 'lieu', 'location' )
if lieu then
wiki.minsert( ', ', lieu )
end
local editeur = validArg( 'eldonejo', 'éditeur', 'édition', 'editeur', 'edition', 'publisher' )
if editeur then
local lienEditeur = validArg( 'lien éditeur' )
wiki.minsert( ', ', Commun.fusionTexteLien( editeur, lienEditeur, args.categ ) )
end
-- Nature du document
local nature = validArg( 'nature Verko' )
if nature then
wiki.minsert( ' (', nature, ')')
end
-- Collecion et numéro
local collection = validArg( 'collection', 'series' )
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('jaro', '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ébreŭ...)
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
-- Pages et format
local pages = validArg( 'pages totales', 'pages' )
if pages then
wiki.minsert( ', ', pages, Commun.nbp )
end
local format = validArg( 'format livre', 'format' )
if format then
wiki.minsert( ', ', format )
end
local eldonkvanto = validArg('eldonkvanto')
if eldonkvanto then
wiki.minsert('. ', eldonkvanto, ' kopioj. ')
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
-- Ligolo verken reta (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:Verko#É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
titreChapitre = Langue.langue{ codeLangue, titreChapitre }
end
wiki.minsert( titreChapitre )
local tradTitreChap = validArg( 'traduction titre chapitre' )
if tradTitreChap then
wiki.minsert( ' [“', tradTitreChap, '”]' )
end
end
local passage = validArg( 'paĝo', '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'Verko
wiki.minsert( spanFinal )
-- Citation et commentaire de cet Verko
local citation = validArg( 'extrait', 'citation' )
if citation then
wiki.minsert( ' :<blockquote>', citation, '</blockquote>' )
end
if validArg( 'plume' ) then
wiki.minsert( Commun.plume )
end
wiki.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 then
wiki.minsert(
args.categ.langue and '[[Catégorie:Page du modèle Verko comportant une erreur|langue]]',
args.categ.titre and '[[Catégorie:Page du modèle Verko comportant une erreur|titre]]',
args.categ.titreChapitre and '[[Catégorie:Page du modèle Chapitre comportant une erreur|Chapitre]]',
args.categ.titreVerko and '[[Catégorie:Page du modèle Chapitre comportant une erreur|Verko]]',
args.categ.lienExterne and '[[Catégorie:Page du modèle Verko comportant une erreur|Externe]]',
args.categ.isbnInvalid and '[[Kategorio:Verko kun ISBN ne valida]]',
args.categ.issnInvalid and '[[Catégorie:Page avec ISSN invalide]]',
args.categ.eanInvalid and '[[Catégorie:Page avec EAN invalide]]'
)
if dir then
wiki.minsert( '[[Catégorie:Recension temporaire pour le modèle Verko|rtl]]' )
end
end
return wiki.concat()
end
return Verko