lib/sidebar.tmpl
author kairo@kairo.at
Tue, 03 Mar 2009 20:26:16 +0000
changeset 284 bdc53bc52ebf81d86eba693cab08d29252f680af
parent 19 8377697a39a79152ca24ddf5d813578109efe349
child 504 7a3e77a15229971063980d85bb3d83b46a97055c
permissions -rw-r--r--
add 1.1.15 relnotes

[% USE site = XML::Simple( 
       'sitemap.xml'
       ForceArray = ['page']
       KeyAttr = ['' ]
   )
%]

[% INCLUDE explore node=site;
   BLOCK explore;
     # nodes is already set by breadcrumbs.tmpl
     PROCESS crumblist urllist=[] cnode=nodes.0;

     itemcount = 0;
     FOREACH page IN node.page;
       IF page.url;
         IF page.url.match("^http://") OR page.url.match("^https://");
           page.path = page.url;
         ELSE;
           page.path = (page.url == '.') ? toplink : "$toplink$page.url";
         END;
       ELSE;
         # add page id to current path to get page path
         page.path = "$toplink$path/$page.id";

         # add suffix for a section (/index.html) or page (.html)
         suffix    = page.page ? '/index.en.html' : '.en.html';
         page.url  = "${page.path}${suffix}";
       END;

       # add complete URL to sitemap lookup table
       site.url2page.${page.url} = page;

       t_url = "$toplink${template.name}"|replace('/index.html|/index.en.html','/')|replace('.html|.en.html','');
       in_list = 0;
       FOREACH url IN urllist;
         IF page.path == "$toplink$url";
           in_list = 1;
         END;
       END;

       IF !page.hide || in_list;
         IF itemcount == 0;
           node == site ?  "<ul id=\"nav\">" : "\n<ul>";
           "\n";
         END;
         itemcount = itemcount + 1;
         # print some debugging info
         # "page: $page.id\n  path: $page.path\n   url: $page.url\n" | stderr;
         "\t<li><a href=\"$page.path\">$page.title</a>";

         # process and child nodes
         INCLUDE explore node=page path=page.path
           IF page.page AND (t_url.match("^$page.path") OR in_list);

         "</li>\n";
       END;
     END;
     IF itemcount > 0;
       "</ul>\n";
     END;
   END;

   BLOCK crumblist;
     IF cnode && cnode.getName() == "page";
       urllist.push(cnode.getAttribute("url"));
       PROCESS crumblist cnode=cnode.getParentNode();
     END;
   END;
%]

[%- # vim: set expandtab tabstop=2 shiftwidth=2 textwidth=76 autoindent: -%]