« Module:Version imprimable » : différence entre les versions

Contenu supprimé Contenu ajouté
MEP
Aucun résumé des modifications
Ligne 8 :
Ending1 = "GFDL"
Ending2 = ""
templateLeft = '<div style="float: left;">[[File:Go-previous-grey.svg|48px40px|link=printf]] [[printf]]</div>'
templateRight = '<div style="float: right;">[[printf]] [[File:Go-next-grey.svg|48px40px|link=printf]]</div>'
TOC = "Sommaire"
sep = "/"
Ligne 139 :
 
function p.displays_footer(frame)
if frame == nil then return ''"" end
if frame.args == nil then return ''"" end
if frame.args[1] == nil then return ''"" end
local BookName = frame.args[1]
local currentPageName = frame.args[2]
 
if (BookName ~= nil and mw.text.trim(BookName) ~= ''"") then
title = mw.title.new(BookName)
if mw.ustring.find(BookName, p._escapePattern(sep .. TOC)) ~= nil then BookName = mw.ustring.gsub(BookName, "^(.*)" .. sep .. TOC .. "$", "%1") end
Ligne 152 :
end
 
if (currentPageName ~== nil andor mw.text.trim(currentPageName) ~== '') then currentPageName = mw.title.getCurrentTitle().subpageText end
if (currentPageName ~= nil and mw.text.trim(currentPageName) ~= "") then
currentPageName = mw.text.trim(currentPageName)
else
Ligne 158 ⟶ 159 :
end
 
if (title == nil or title == ''"") then return Error end
text = title.getContent(title)
if (text == nil or text == ''"") then return Error end
 
-- Book subpages titles normalization to absolute names
local lines_ = mw.text.split(text, "\n")
local footer = {}
local previousChapter = ''""
local found = false
local chapter
Ligne 178 ⟶ 179 :
if (ChapterTitle ~= nil and ChapterTitle.exists) then
PageName = mw.ustring.gsub(chapter, "[^"..sep.."]*"..sep.."*(.*)", "%1")
if (PageName ~= nil and PageName ~= ''"") then
if found == true then
if debug then table.insert(footer, "<font color=red>Previous & next chapter insertion</font>\n") end
if previousChapter == ''"" then
theTemplateLeft, nb = mw.ustring.gsub(templateLeft, "printf", BookName .. '"|'" .. TOC)
else
theTemplateLeft, nb = mw.ustring.gsub(templateLeft, "printf", BookName .. sep .. previousChapter .. '"|'" .. previousChapter)
end
table.insert(footer, theTemplateLeft)
theTemplateRight, nb = mw.ustring.gsub(templateRight, "printf", BookName .. sep .. PageName .. '"|'" .. PageName)
table.insert(footer, theTemplateRight)
break
Ligne 193 ⟶ 194 :
found = true
if debug then table.insert(footer, "<font color=red>Page</font> '" .. currentPageName .. "' found\n\n") end
elseif mw.text.trim(v) ~= ''"" then
previousChapter = PageName
else
Ligne 207 ⟶ 208 :
if found == true and table.getn(footer) == 0 then
if debug then table.insert(footer, "<font color=red>No next chapter</font>\n") end
theTemplateLeft, nb = mw.ustring.gsub(templateLeft, "printf", BookName .. sep .. previousChapter .. '"|'" .. previousChapter)
table.insert(footer, theTemplateLeft)
theTemplateRight, nb = mw.ustring.gsub(templateRight, "printf", BookName .. '"|'" .. TOC)
table.insert(footer, theTemplateRight)
end