<webmake>
<!--

  This is the source .wmk file for the WebMake documentation.  If you are
  looking at this for some simple WebMake usage examples, be warned; this is
  quite a complicated WebMake file.  As well as the simple templating and
  metadata stuff, it also dynamically incorporates the POD documentation
  straight from the source code, and includes a sitemap, navigation links, and
  a dynamically-generated index page.

  Some of the other samples on the WebMake site (http://webmake.taint.org/)
  would be easier for beginners to understand.

  Anyway, just thought I should mention it.  Consider yourself warned! ;)

-->

<!-- include some library .wmk's -->
<use plugin="safe_tag" />

<!-- include the source EtText files -->
<contents src="" name="*.txt" format="text/et" listname=all_files />

<!-- stylesheets -->
<contents src="" name="*.css" map="false" />

<!-- the names and titles of all the sections -->
<contents src="svfile:sections.tsv" name="*" format="text/html"
	namefield=1 valuefield=2 delimiter="|"
	listname=all_sections map=false
/>

<!-- ------------------------------------------------------------------------ -->

<!-- include the POD documentation directly from the source files -->

<attrdefault name="listname"	value="all_pods">
<attrdefault name="format"	value="text/pod">
<attrdefault name="asis"	value="true">
<attrdefault name="map"		value="true">
<metadefault name="score"	value="50">

<metadefault name="section"	value="08-pod">
<contents src="../lib/HTML/WebMake" name="PerlCodeLibrary.pm" />
<contents src="../lib/HTML/WebMake" name="Content.pm" />
<contents src="../lib/HTML/WebMake" name="Main.pm" />
</metadefault>

<metadefault name="section"	value="09-man">
<contents src=".." name="webmake" />
</metadefault>

<metadefault name="section"	value="10-perllib">
<contents src="../lib/HTML/WebMake/PerlLib" name="*.wmk" />
</metadefault>

<!-- and now define the metadata for those PODs quickly using a metatable -->

</metadefault>
</attrdefault>
</attrdefault>
</attrdefault>
</attrdefault>

<metatable delimiter="|">
.|title|abstract

Main.pm|HTML::WebMake::Main|module documentation
PerlCodeLibrary.pm|HTML::WebMake::PerlCodeLibrary|module documentation
Content.pm|HTML::WebMake::Content|module documentation
webmake|webmake(1)|manual page
dump_vars.wmk|dump_vars.wmk|dump all WebMake variables and content items
sitetree.wmk|sitetree.wmk|WebMake tag to generate a per-page sitemap
safe_tag.wmk|safe_tag.wmk|Tag to ''make safe'' WebMake, EtText or HTML data
download_tag.wmk|download_tag.wmk|Tag for quick download links to files
csvtable_tag.wmk|csvtable_tag.wmk|define a HTML table using comma-separated values
</metatable>

<!-- ------------------------------------------------------------------------ -->

<attrdefault name=map value=false />

<!-- Some static bits of HTML for headers and footers... -->

<content name=header>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
      <title>WebMake: Documentation: $[this.title]</title>
      <meta name="generator" content="${WebMake.GeneratorString}">
      <style>${documentation.css}</style>
  </head>
  <body bgcolor="#ffffff" text="#000000" link="#3300cc" vlink="#660066">
  <font face="lucida,verdana,sans-serif">

  <div align=center> <img src=$(TOP/)images/WebMakeTitle.png ${IMGSIZE}></div>
  ${navbar}

  <!-- yes, it's that Mozilla black-border code again ;) -->
  <!-- stolen from www.mozilla.org via rc3.org -->
  <table border=0 cellpadding=0 cellspacing=0 width="100%">
  <tr><td BGCOLOR="#aaaaaa">
  <table border=0 cellspacing=4 cellpadding=4 width="100%">
  <tr><td BGCOLOR="#ffffff">
  <table border=0 cellspacing=4 cellpadding=4 width="100%">
  <tr><td>

  <h1>$[this.title]</h1>
</content>

<!-- ------------------------------------------------------------------------ -->

<content name=navbar>
  <table width=100%><tr><td valign=top>
  <strong><a href=http://webmake.taint.org/>WebMake</a>
  Documentation</strong> (version ${WebMake.Version})
  </td><td valign=top>
  <div align=right>
  	[ $[navlinks] | <a href=$(index)>Index</a>
	| <a href=$(allinone)>All&nbsp;In&nbsp;One</a> ]
  </div>
  </td></tr></table>
</content>

<!-- ------------------------------------------------------------------------ -->

<content name=footer>
  </td></tr></table>
  </td></tr></table>
  </td></tr></table>
  ${navbar}
  <div align=right>
  <a href=http://webmake.taint.org/>
  <img src=$(TOP/)images/BuiltWithWebMake.png ${IMGSIZE} border=0></a>
  </div>
  </font></body></html>
</content>

<!-- ------------------------------------------------------------------------ -->

<!-- Take all the files and all the sections, and come up with
     a list, for each section, of the files that should be in it,
     in sorted order.
  -->
<{perl

  my @all_files = get_list("all_files");
  my @all_pods = get_list("all_pods");
  my @all_sects = get_list("all_sections");

  foreach my $sectname (@all_sects) {
    my @files_in_sect = ();

    foreach my $pg (@all_files, @all_pods) {
      next unless (get_content ("$pg.section") eq $sectname);
      push (@files_in_sect, $pg);
    }

    @files_in_sect = content_names_to_objects (@files_in_sect);
    @files_in_sect = sort_content_objects ('score title', @files_in_sect);
    @files_in_sect = content_objects_to_names (@files_in_sect);
    set_list ("$sectname.files", @files_in_sect);
  }
  '';
  
}>

<!-- ------------------------------------------------------------------------ -->

<!-- Generate the index.html file dynamically. -->

<content name=index_section_item>
<li>
  <h2>${section_title}</h2>
  <ul>
  ${section_list}
  </ul>
</li>
</content>

<content name=index_item>
<li>
  <p><a href=$[${item}.url]>$[${item}.title]</a> - $[${item}.abstract]</p>
</li>
</content>

<content name=index isroot=true map=true>
<wmmeta name="title" value="Contents" />
<wmmeta name="abstract" value="What's in this documentation" />

  <ul>
  <{perl
      my @all_sects = get_list("all_sections");

      foreach my $sectname (@all_sects) {
	my @section_list = ();

	foreach my $pg (get_list ("$sectname.files")) {
	  set_content ("item", $pg);
	  push (@section_list, get_content ("index_item"));
	}

	set_content ("section", $sectname);
	set_content ("section_title", get_content ($sectname));
	set_list ("section_list", @section_list);
	$_ .= get_content ("index_section_item");
      }
      $_;
  }>
  </ul>

</content>

<!-- ------------------------------------------------------------------------ -->
<!-- sitemap for navigation -->

<content name=sitemapnode>
  <li>
    <p>
      <a href=$(url)>${title}</a> - $[${name}.abstract]<br>
      <ul> ${list} </ul>
    </p>
  </li>
</content>

<content name=sitemapleaf>
  <li><p><a href=$(url)>${title}</a> - $[${name}.abstract]<br></p></li>
</content>

<out name=docmap file=docmap.html>
  ${header}${mainsitemap}${footer}
</out>

<sitemap name=mainsitemap node=sitemapnode leaf=sitemapleaf
			sortorder="section score title" map=true>
  <wmmeta name=title value="Documentation map" />
  <wmmeta name=Abstract value="Map of this documentation" />
  <wmmeta name=Section value="99-sitemap" />
</sitemap>

<content name=up></content>
<content name=next><a href=${url}>Forward</a></content>
<content name=prev><a href=${url}>Back</a></content>
<content name=nonext>(Last Page)</content>
<content name=noprev>(First Page)</content>

<navlinks name=navlinks map=mainsitemap up=up next=next prev=prev
	nonext=nonext noprev=noprev>
${prevtext} | ${nexttext}
</navlinks>

<!-- ------------------------------------------------------------------------ -->

<for name=pg values="${all_pods}">
  <out name="${pg}.html" file="${pg}.html">
  ${header}${${pg}}${footer}
  </out>
</for>

<for name=pg namesubst="s/.txt//" values="${all_files}">
  <out name="${pg}" file="${pg}.html">
  ${header}${${pg}.txt}${footer}
  </out>
</for>

<out name=index file=index.html>
  ${header}${index}${footer}
</out>

<!-- ------------------------------------------------------------------------ -->

<!-- An all-in-one page, for printing. -->

<out name=allinone file=allinone.html ismainurl=false>
  <wmmeta name="title" value="All-In-One Documentation" />
  ${header}

  <h1>$[index.title]</h1>
  ${index}<hr>

  <{perl
	foreach my $sectname (get_list ("all_sections")) {
	  foreach my $pg (get_list ("$sectname.files")) {
	    my $shortpg = $pg; $shortpg =~ s/\.txt$//;
	    $_ .= "<h1>".get_content("$pg.title")."</h1>".
		  get_content ("$pg") . "<hr>";
	  }
	}
	$_;
  }>

  ${footer}
</out>
</webmake>

