head	1.4;
access;
symbols
	start:1.1.1.1 swish-e:1.1.1;
locks; strict;
comment	@# @;


1.4
date	2005.02.10.00.39.30;	author whmoseley;	state Exp;
branches;
next	1.3;

1.3
date	2005.02.09.23.29.29;	author whmoseley;	state Exp;
branches;
next	1.2;

1.2
date	2005.02.09.19.11.54;	author whmoseley;	state Exp;
branches;
next	1.1;

1.1
date	2005.01.18.20.32.49;	author whmoseley;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2005.01.18.20.32.49;	author whmoseley;	state Exp;
branches;
next	;


desc
@@


1.4
log
@
I blame this all on my quick fingers and vim.
@
text
@[%  # From chapter 11 of Badger book.

# page.trail tracks path to the current page.
DEFAULT page.trail = [ ];
DEFAULT navigation = {};

this_level = 0;
first_item = 0;

# List of menu items we're constructing.
map.items = [ ];


# Walk through item names in map.menu.
FOREACH id IN map.menu;

    # Allow for there to be a missing page entry (setting the name to the menu id)
    SET map.page = {} UNLESS map.page;
    SET map.page.$id = { name = id } UNLESS map.page.$id;
    SET map.page.$id.name = id UNLESS map.page.$id.name;
    item = map.page.$id;



    # Add location data.
    item.id   = id;

    # Check for external link
    IF item.external;
        item.url = item.external;

    ELSE;
        item.path = path ? "$path/$id" : id;

        item.extension = item.defined('extension') ? item.extension : '.html';
        item.indexname = item.defined('indexname') ? item.indexname : 'index.html';

        UNLESS item.file;
            item.file = item.menu
                      ? "${item.path}/${item.indexname}"
                      : "${item.path}${item.extension}";
        END;



        # Here's a hack to deal with geneating just HTML docs (abslinks is the flag)
        # Want all links to go to http://swish-e.org.  That's set in site.url.root
        # The exception is when geneating links for the docs pages, which then
        # the links are relative to the current directory.

        IF this.abslinks && item.path.match("^docs");
            item.url = item.file.replace('^docs/','./');

            # Adjust the name of the current page for item.hot check below
            SET page.file = "docs/$page.file" UNLESS page.file.match('^docs/');

        ELSE;
            SET item.hidden = 1 IF this.abslinks;  # This removes the non-doc items from the menu
            item.url = "$site.url.root/$item.file";

        END;


        # When buidling pod-only then the docs/ section is moved up to root, which
        # will clash with the real root.  So need to excluded this checking with 
        # generating pods.

        IF !this.abslinks || item.path.match("^docs");

            # Is this item on the path to the current page?
            item.hot  = page.file.match("^(../)?$item.path");
            item.subs = item.hot and item.menu.size;
            item.here = (item.file == page.file);
        END;


    END;


    # Now build navigation and add this item to its parent's list of items
    # How navigation works depends on how you define next/prev and things like that
    # Here we just take'em as them come
    # Some of this would be easier if the list was flat.

    UNLESS item.hidden;


        # Very first link ("Top" for Mozilla)
        SET navigation.Start = item UNLESS navigation.Start;

        # Should these be limited to the current level  Currently: yes
        # Happens because recursion is locallizing last_item.

        SET navigation.Prev  = last_item IF last_item && item.here;
        SET navigation.Next  = item IF last_item && last_item.here;
        SET last_item = item;  # save for next time

        SET navigation.Up    = page.trail.last IF page.trail.last && item.here;

        page.trail.push( item ) IF item.hot;

        # First and Last are a bit more complex
        SET this_level = item IF item.here;
        SET first_item = item UNLESS first_item;


        # Add this item to it's parent's list (recursive menu)
        map.items.push(item);
    END;


    # Recursively process any sub menus

    IF item.menu;
        INCLUDE config/expand
            map  = item
            path = item.path;
    END;


END;  # Foreach


IF this_level && !( navigation.First || navigation.Last );
#IF this_level;
    SET navigation.First = first_item IF first_item && !first_item.here;
    SET navigation.Last  = last_item UNLESS last_item.here;
END;



-%]
@


1.3
log
@
Add a little navigation that smart browsers can use
@
text
@d7 3
d123 1
d125 1
@


1.2
log
@
Limit menu to just docs when buiding docs for distribution.
Also, instead of removing search box the searh button now says:

  "search swish-e.org"

Or should that be "search Swish-e.org"?
@
text
@a2 1

d5 1
a9 1
USE Dumper;
d20 2
d55 1
a55 1
            item.hidden = 1 IF this.abslinks;  # This removes the non-doc items from the menu
d77 29
a105 6
    # Set next/last if this is the actual page.
    # These don't work if there are "hidden" menu items.
    # To fix need to set a previous item to look at next time through loop.
    IF item.here;
        page.prev = map.page.${loop.last};
        page.next = map.page.${loop.next};
a107 2
    # Add item to map items list.
    map.items.push(item) UNLESS item.hidden;
d109 1
a109 7
    # Also to the trail if the page is hot.
    page.trail.push(item) IF item.hot;

    # Expand any submenu for this item.
    # Note, used to only expand IF item.subs, but then would not expand 
    # all items (i.e. set the page has for each one)  Need to exapnd all so can
    # use the link_to_page() MACRO.
d116 7
d125 2
@


1.1
log
@Initial revision
@
text
@d54 1
@


1.1.1.1
log
@Initial import
@
text
@@
