<webmake>

<include file="${WebMake.PerlLib}/sitetree.wmk" />
<include file="data/test_stories.inc" />

<{perl
        # create a ${all_stories} variable containing the list
        # of all text files just loaded.
        $_ = '';
        foreach my $pg (sorted_content_matching ("score title", "*.txt"))
	{
          $pg =~ s/\.txt$//; $_ .= "$pg ";
        }
        set_content ("all_stories", $_);
        '';
}>

<{!-- ------------------------------------------------------------------- --}>

<template name=header >
  <html><head>
    <title>$[this.title]</title>
    <meta name="Abstract" value="$[this.abstract]" />
  </head>
  <body bgcolor=#ffffff>
  <h1>WebMake Sitemap Demo</h1>
  <hr />
  $[sitetree]
  <hr />
  <a href=$(mainindex)>Index</a> | 
  <a href=$(map)>Site Map</a>
  <hr />
</template>

<template name=footer >
  <hr /><p>
  <em>Sorry about the crappy formatting BTW, this is just a demo. ;)</em>
  </p>
  </body>
  </html>
</template>

<{!-- ------------------------------------------------------------------- --}>

<template name=index_list_item >
  <li>
    <a href=$(${item})>$[${item}.txt.title]</a><br />
    <p>$[${item}.txt.abstract]</p>
  </li>
</template>

<content name=index_chunk isroot=true>
  <wmmeta name=title value="WebMake Sample: a news site" />
  <wmmeta name=abstract value="some old news site" />
  <ul> <{perl make_list ('index_list_item', get_list ("all_stories")); }> </ul>
</content>

<{!-- ------------------------------------------------------------------- --}>

<for name=pg values="${all_stories}">
  <out name="${pg}" file="log/sitetree_${pg}.html">
    ${header}${${pg}.txt}${footer}
  </out>
</for>

<out name=mainindex file=log/sitetree.html>
  ${header}${index_chunk}${footer}
</out>

<{!-- ------------------------------------------------------------------- --}>

<template name=treeopen >
  <li>
    <strong>-</strong> <a href=$(url)>${title}</a>: $[${name}.abstract]<br>
    <ul>${list}</ul>
  </li>
</template>

<template name=treeclosed >
  <li>
    <strong>+</strong> <a href=$(url)>${title}</a>: $[${name}.abstract]<br>
  </li>
</template>

<template name=treenotthispage >
  <li>
    <strong>.</strong> <a href=$(url)>${title}</a>: $[${name}.abstract]<br>
  </li>
</template>

<template name=treethispage >
  <li>
    <strong>&gt;</strong> <a href=$(url)>${title}</a>: $[${name}.abstract]<br>
  </li>
</template>

<sitemap name=mainsitemap node=sitemapnode leaf=sitemapleaf>
<wmmeta name=title value="WebMake Sample: site map" />
<wmmeta name=Abstract value="Map of the site" />
</sitemap>

<sitetree name=sitetree sitemap="mainsitemap"
	opennode="treeopen" closednode="treeclosed"
	thispage="treethispage" leaf="treenotthispage" />

<{!-- ------------------------------------------------------------------- --}>

<template name=sitemapnode >
  <li>
    <p>
      <a href=$(url)>${title}</a>: $[${name}.abstract]<br>
      <em>[score: ${score}, name: ${name}, is_node: ${is_node}]</em>
      <{!-- don't forget to list the sub-items --}>
      <ul> ${list} </ul>
    </p>
  </li>
</template>

<template name=sitemapleaf >
  <li>
    <p>
      <a href=$(url)>${title}</a>: $[${name}.abstract]<br>
      <em>[score: ${score}, name: ${name}, is_node: ${is_node}]</em>
      <{!-- no sub-items here --}>
    </p>
  </li>
</template>

<out name=map file=log/sitetree_map.html>
  ${header}${mainsitemap}${footer}
</out>

</webmake>

