Module:Chapter navigation
This module provides a way to generate navigation bars to navigate between chapters of a book and a way to put a book chapter in the book category.
Usage
editThis module should not be invoked directly. The {{simple chapter navigation}} template should be used instead.
Functions
editThis module provides two functions: one to create a navigation bar and one to categorize the page automatically, assuming it is a book chapter. The former receives two optional arguments, previous and next, which should be the names of the previous and next chapters, respectively. It uses these chapter names to generate a navigation bar that is meant to be put at the bottom of the chapter page. The latter function does not have any parameter and puts the chapter page in the book category, ordering it properly. These two functions assume that the book follows the Wikibooks naming policy and are likely to work improperly if it is not followed.
return {
navigation_bar = function(frame)
local current_title = mw.title.getCurrentTitle()
local base_page_name = current_title.baseText
if frame.args.bordertopstyle == null then frame.args.bordertopstyle = '' end
if frame.args.bordertopwidth == null then frame.args.bordertopwidth = '' end
if frame.args.borderbottomstyle == null then frame.args.borderbottomstyle = '' end
if frame.args.borderbottomwidth == null then frame.args.borderbottomwidth = '' end
local bar = mw.html.create('div')
:addClass('noprint')
:css {
['border-top-style'] = frame.args.bordertopstyle;
['border-top-width'] = frame.args.bordertopwidth;
['border-bottom-style'] = frame.args.borderbottomstyle;
['border-bottom-width'] = frame.args.borderbottomwidth;
clear = 'both';
['margin-top'] = "1em";
['margin-bottom'] = "1em";
width = "100%";
height = "20px";
}
if frame.args.previous and frame.args.previous ~= '' then
bar:tag('span'):css('float', 'left'):wikitext('[[' .. base_page_name .. '/' .. frame.args.previous .. '|' .. frame.args.previous .. ']]')
end
if frame.args.next and frame.args.next ~= '' then
bar:tag('span'):css('float', 'right'):wikitext('[[' .. base_page_name .. '/' .. frame.args.next .. '|' .. frame.args.next .. ']]')
end
return tostring(bar)
end;
categorize = function(frame)
--local current_title = mw.title.getCurrentTitle()
--return "[[Category:" .. current_title.baseText .. '|' .. current_title.subpageText .. ']]'
return frame:expandTemplate{title = "BookCat"}
end
}