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

Contenu supprimé Contenu ajouté
couverture : permet de mettre un numéro de page après un nom de fichier
Ligne 45 :
:tag('td'):wikitext(value)
end
end
 
function splitFileNameInFileAndPage(title)
local slashPosition = string.find(title.text, "/")
if tonumber(args.image)slashPosition == nil then
return title.text,nil
else
return string.sub(title.text, 1, slashPosition - 1), string.sub(title.text, slashPosition + 1)
end
end
 
Ligne 68 ⟶ 77 :
--Image
if args.image then
local imageContainer = left:tag('div')
:css({
float = 'left',
overflow = 'hidden',
border = 'thin grey solid'
})
local imageTitle = nil
if tonumber(args.image) == nil then
local imageTitle = mw.title.new if tonumber(args.image, "Media") ~= nil then
-- this is a page number
if imageTitle ~= nil and imageTitle.exists then
imageTitle = mw.title.getCurrentTitle().subPageTitle(args.image)
imageContainer:wikitext('[[File:' .. args.image .. '|160px]]')
else
-- TODO mettre une catégorie ici pour les livres ayant une couverture qui ne provient pas du DJVU/PDF
-- this is an other file
else
imageContainer:wikitext imageTitle = mw.title.new(args.image, "Media")
-- TODO mettre une catégorie depour maintenanceles icilivres lorsqueayant laune couverture estqui ne provient pas du manquanteDJVU/PDF
end
if imageTitle ~== nil and imageTitle.exists then
else
imageContainer:wikitext(args.image)
imageContainer:wikitext('[[File:' .. mw.title.getCurrentTitle().text .. '|page=' .. args.image .. '|160px]]')
-- TODO mettre une catégorie icide pourmaintenance lesici livreslorsque ayant unela couverture qui ne provient pas duest DJVU/PDFmanquante
end
else
local imageName, imagePage = splitFileNameInFileAndPage(imageTitle)
if imagePage ~= nil then
imageContainer:wikitext('[[File:' .. mw.title.getCurrentTitle().textimageName .. '|page=' .. args.imageimagePage .. '|160px]]')
else
imageContainer:wikitext('[[File:' .. args.imageimageName .. '|160px]]')
end
end
end
--Metadata