Module:Sandbox/Chapter 23

-- Build header template for main namespace --

local p = {};

p.chapter = function(frame) mw.log(frame.args.chapter) --local c = string.sub(frame.args.chapter, 8) c = frame.args.chapter c = tonumber(c) return c end

function p.list_iter(t) local i = 0 local n = table.getn(t) return function i = i + 1 if i <= n then return t[i] end end end

p.page = function(frame, chapter) -- https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#require local tdFunc = require 'Module:Sandbox/Tabular data' --local tdPath = 'Sandbox/Heyzeuss/Signswondersgodw0000wood.tab' local tdPath = frame.args[1] --Page in commons.wikimedia.org/wiki/Data: that has tabular data return tdFunc._cell{output_row=chapter, output_column='page', tdPath} end

p.from = function (frame) local chapter = tonumber(frame.args.chapter) return p.page(frame, chapter) + frame.args.pageoffset end

p.to = function (frame) local chapter = tonumber(frame.args.chapter) return p.page(frame, chapter+1) + frame.args.pageoffset - 1 end

p.chapterlink = function (frame, add) c = tonumber(frame.args.chapter)+add wikilink = [=[../Chapter chapternro/]=] wikilink = string.gsub(wikilink, 'chapternro', c)   mw.log(wikilink) return wikilink end

p.prev = function (frame) return p.chapterlink(frame, -1) end

p.next = function (frame) return p.chapterlink(frame, 1) end p.header = function (frame) local chapter = p.chapter(frame) local prev = chapter - 1 local next = chapter + 1

local output = [=[ ]=]

output = string.gsub(output, "prevchapter", prev) output = string.gsub(output, "nextchapter", next) output = string.gsub(output, "frompage", from) output = string.gsub(output, "topage", to) output = tostring(output) mw.log(output) return output end

p.pagesstring = function (frame) local chapter = tonumber(frame.args.chapter) local from = p.from(frame, chapter) local to = p.to(frame, chapter) local output = [=[  ]=]	output = string.gsub(output, "frompage", from) output = string.gsub(output, "topage", to) mw.log(output) return output end

p.pages = function(frame) local chapter = tonumber(frame.args.chapter) local from = p.from(frame, chapter) local to = p.to(frame, chapter) local pgs = mw.html.create('pages', {selfClosing=true}) return pgs :attr('index', 'Signswondersgodw0000wood.djvu') :attr('from', from) :attr('to', to) end

return p