« Module:Header template » : différence entre les versions

Contenu supprimé Contenu ajouté
mAucun résumé des modifications
usage des données de Wikidata quand un item est indiqué dans la page d'index
Ligne 133 :
function headerTemplate( frame )
local parentFrame = frame:getParent()
local data = (require 'Module:Index_data').indexDataWithWikidata(parentFrame)
local args = parentFramedata.args
local page = mw.title.getCurrentTitle()
local item = mw.wikibase.getEntity()
local headerType = args.value
if args.header_type and args.header_type ~= '' then
headerType = args.header_type
end
Ligne 146 ⟶ 147 :
--Custom page numbers
local from = ''
if args.displayed_from and args.displayed_from ~= '' then
from = args.displayed_from
elseif args.from then
Ligne 153 ⟶ 154 :
 
local to = ''
if args.displayed_to and args.displayed_to ~= '' then
to = args.displayed_to
elseif args.to then
Ligne 218 ⟶ 219 :
 
--Auteur
if args.auteur and args.auteur ~= '' then
headertemplate:tag('div')
:addClass('headertemplate-author')
Ligne 227 ⟶ 228 :
local titre = formatString( page.baseText, 'name' )
if args.type == 'collection' then
if args.recueil and args.recueil ~= '' then
-- Commenté pour tester avec uniquement le nom du recueil, le titre lui est déjà
-- dans le navigateur et fréquemment en début de la page.
Ligne 242 ⟶ 243 :
end
 
if args.publication and args.publication ~= '' then
titre = titre .. ' <span style="font-size:90%;">(' .. args.publication .. ')</span>'
end
Ligne 262 ⟶ 263 :
titre = parseTitleWikitext(titre, 'isPartOf')
end
if args.publication and args.publication ~= '' then
titre = titre .. ' <span style="font-size:90%;">(' .. args.publication .. ')</span>'
end
end
if estSommaire and args['.sous_titre'] and args['sous_titre'] ~= '' then
titre = titre .. ' <br/><small>' .. args['sous_titre'] .. '</small>'
end
Ligne 276 ⟶ 277 :
local references = headertemplate:tag('div')
:addClass('headertemplate-reference')
if args.traducteur and args.traducteur ~= '' then
references:wikitext('Traduction par ' .. parseLinkWikitext(args.traducteur, 'translator') .. '.')
:tag('br')
end
if estSommaire and args.illustrateur and args.illustrateur ~= '' then
references:wikitext('Illustrations par ' .. parseLinkWikitext(args.illustrateur, 'illustrator') .. '.')
:tag('br')
end
 
if estSommaire and args.volume and args.volume ~= '' then
references:wikitext( formatString( args.volume, 'volumeNumber' ) )
:tag('br')
Ligne 292 ⟶ 293 :
local infos = {} --Liste des données à afficher séparés par une virgule
if args.type == 'collection' then
if args.titre and args.titre ~= '' then
table.insert( infos, '<i>' .. parseTitleWikitext(args.titre, 'isPartOf') .. '</i>' )
end
if args.editeur_scientifique and args.editeur_scientifique ~= '' then
table.insert( infos, 'Texte établi par ' .. parseLinkWikitext( args.editeur_scientifique, 'editor' ) )
end
if args.editeur and args.editeur ~= '' then
table.insert( infos, formatPublisherWithName( args.editeur ) )
end
if args.annee and args.annee ~= '' then
table.insert( infos, formatYear( args.annee, 'datePublished' ) )
end
if not estSommaire then
if args.volume and args.volume ~= '' then
table.insert( infos, formatString( args.volume, 'volumeNumber' ) )
end
Ligne 312 ⟶ 313 :
if not estSommaire then
table.insert( infos, '<i>' .. parseTitleWikitext( args.titre, 'isPartOf' ) .. '</i>' )
if args.volume and args.volume ~= '' then
table.insert( infos, formatString( args.volume, 'volumeNumber' ) )
end
end
if args.annee and args.annee ~= '' then
table.insert( infos, formatYear( args.annee, 'datePublished' ) )
end
else
if args.editeur_scientifique and args.editeur_scientifique ~= '' then
table.insert( infos, 'Texte établi par ' .. parseLinkWikitext( args.editeur_scientifique, 'editor' ) )
end
if args.editeur and args.editeur ~= '' then
table.insert( infos, formatPublisherWithName( args.editeur ) )
end
if args.annee and args.annee ~= '' then
table.insert( infos, formatYear( args.annee, 'datePublished' ) )
end
Ligne 338 ⟶ 339 :
if not estSommaire and from ~= '' then
local temp = ''
if args.volume and args.volume ~= '' and args.type ~= 'collection' and args.type ~= 'journal' then
temp = formatString( args.volume, 'volumeNumber' ) .. ',&nbsp;'
end
Ligne 367 ⟶ 368 :
end
 
if (not estSommaire or (args.header_type and args.header_type =='toc')) and ((args.prev and args.prev ~= '') or (args.next and args.next ~= '')) then
local maxwidth = 50
if args.type ~= 'collection' and args.current and args.current ~= '' then
maxwidth = 33
end
Ligne 380 ⟶ 381 :
:css('padding-right', '0px')
:css('background-color', 'transparent')
if args.prev and args.prev ~= '' then
nav:tag('div')
:css('text-align', 'left')
Ligne 393 ⟶ 394 :
:wikitext(parseLinkWikitext(args.prev, 'previousItem'))
end
if args.next and args.next ~= '' then
nav:tag('div')
:css('text-align', 'right')
Ligne 405 ⟶ 406 :
:wikitext('&nbsp;&nbsp;&#x25BA;')
end
if args.type ~= 'collection' and args.current and args.current ~= '' then
nav:tag('div')
:attr('itemprop', 'name')
Ligne 425 ⟶ 426 :
-- Inclusion de l'épigraphe et du sommaire
if headerType == 'toc' then
if args.epigraphe and args.epigraphe ~= '' then
container:wikitext(args.epigraphe)
:newline()
Ligne 444 ⟶ 445 :
:attr('itemprop', 'inLanguage')
:attr('content', 'fr') --TODO: que faire pour l'ancien français...
if args.lieu and args.lieu ~= '' then
container:tag('meta')
:attr('itemprop', 'http://purl.org/library/placeOfPublication')
:attr('content', args.lieu) --TODO: is it the best property URI and the best value format?
end
if args.index and args.index ~= '' then
local indexFile = mw.title.makeTitle('File', args.index)
if indexFile ~= nil and indexFile.file.exists then
Ligne 517 ⟶ 518 :
end
datahtml:node( outputMicroformatRow( 'title', titre ) )
if args.auteur and args.auteur ~= '' then
datahtml:node( outputMicroformatRow( 'author', args.auteur ) )
coins['rft.au'] = cleanCoinsParameter( args.auteur )
end
if args.traducteur and args.traducteur ~= '' then
datahtml:node( outputMicroformatRow( 'translator', args.traducteur ) )
end
if args.illustrateur and args.illustrateur ~= '' then
datahtml:node( outputMicroformatRow( 'illustrator', args.illustrateur ) )
end
if args.school and args.school ~= '' then
datahtml:node( outputMicroformatRow( 'school', args.school ) )
end
if args.editeur and args.editeur ~= '' then
datahtml:node( outputMicroformatRow( 'publisher', args.editeur ) )
coins['rft.pub'] = cleanCoinsParameter( args.editeur )
end
if args.annee and args.annee ~= '' then
datahtml:node( outputMicroformatRow( 'year', args.annee ) )
coins['rft.date'] = args.annee
end
if args.lieu and args.lieu ~= '' then
datahtml:node( outputMicroformatRow( 'place', args.lieu ) )
coins['rft.place'] = args.lieu
end
if args.avancement and args.avancement ~= '' then
datahtml:node( outputMicroformatRow( 'progress', args.avancement ) )
end
if args.volume and args.volume ~= '' then
datahtml:node( outputMicroformatRow( 'volume', args.volume ) )
end
if args.current and args.current ~= '' then
datahtml:node( outputMicroformatRow( 'chapter', args.current ) )
end