[%  PROCESS docset/config;
    bookname = template.book;
    pagename = template.page;
    book = docset.books.$bookname;
    page = book.pages.$pagename;
    nextpage = book.pages.${page.next};
    prevpage = book.pages.${page.prev};

    # macro for resolving links of the form L<Template::Manual::Config>
    MACRO ttlink(link, text) PROCESS link;

    # macro for resolving a link from the current page
    MACRO uplink(link) BLOCK;
	prefix = page.uplink ? "$page.uplink/" : '';
	"${prefix}$link";
    END;

    # define links from this page to main index and book index
    rootindex = uplink('index.html');
    bookindex = uplink(book.pages.index.url);

    # build list of tabs for each book
    booktabs = [ ];
    FOREACH bid = docset.booklist;
	b = docset.books.$bid;
	p = b.pagelist.size == 1 ? b.pagelist.0 : 'index';
	p = b.pages.$p;
	t = { text = b.id, link = uplink(p.url) };
	booktabs.push(t);
    END;

    # build buttons for page navigation menu
    pagemenu = [ 
        { link = rootindex, text = 'Index' }
    ];
    b = { link = bookindex, text = "$book.name" };
    pagemenu.push(b) UNLESS page.id == book.pages.index.id;
    b = { link = '#top', text = 'Top' };
    pagemenu.push(b);

    # build buttons for prev/next navigation menu
    navigate = [ ];
    navleft = 0; navright = 0;
    IF prevpage;
	b = {
	    text = prevpage.title
	    link = uplink(prevpage.url)
	};
	navleft = 1;
	navigate.push(b);
    END;
    IF nextpage;
	b = { 
	    text = nextpage.title
	    link = uplink(nextpage.url)
	};
        navright=1;
        navigate.push(b);
    END;

    tt_start_tag = "<b>[\%"
    tt_end_tag   = "%\]</b>";
    tt_homepage  = 'http://www.template-toolkit.org/';

    SET splash.style.select.col.fore  = splash_fg IF splash_fg;
    SET splash.style.default.col.fore = splash_bg IF splash_bg;
    SET splash.style.select.col.text  = splash_ft IF splash_ft;
    SET splash.style.select.col.icon  = splash_ft IF splash_ft;
    SET splash.style.default.col.text = splash_bt IF splash_bt;
    SET splash.style.default.col.icon = splash_bt IF splash_bt;
-%]
