--- complex/H-W-NM-complex.pl 2005-04-27 12:32:01.505752240 +0300 +++ with-embellishments/H-W-NM-embellish.pl 2005-05-06 10:31:51.359923568 +0300 @@ -5,6 +5,7 @@ use HTML::Widgets::NavMenu; use File::Path; +use Template; my $css_style = <<"EOF"; a:hover { background-color : palegreen; } @@ -14,7 +15,7 @@ padding-bottom : 1em; padding-top : 0em; margin-left : 1em; - background-color : white + background-color : white; } .navbar { @@ -33,6 +34,49 @@ margin-left : 0.3em; padding-left : 1em; } +.navlinks +{ + background-color: +#30C020; + margin-bottom : 0.2em; + padding-left: 0.5em; + padding-bottom: 0.2em; + border-style: solid; + border-width: thin; + border-color: black; +} +.breadcrumb +{ + background-color: #4190e1; + padding-bottom: 0.3em; + padding-left: 0.5em; + padding-top: 0.3em; + margin-bottom: 0.2em; + border-style: solid; + border-width: thin; + border-color: #FF8080; + font-size: 80%; +} + +.breadcrumb :link +{ + color: #FFFF00 ; +} + +.breadcrumb :link:hover +{ + color: red; +} + +.breadcrumb :visited +{ + color: #F5F5DC; +} + +.breadcrumb :visited:hover +{ + color: #800000; +} EOF my $nav_menu_tree = @@ -254,6 +298,12 @@ 'url' => "links.html", 'title' => "An incomplete list of links I find cool and/or useful.", }, + { + 'text' => "Site Map", + 'url' => "site-map/", + 'title' => "A site map for the site with all the pages", + }, + ], }; @@ -283,18 +333,33 @@ "essays/", "essays/Index/", "essays/open-source/", "essays/life/", "links.html"); - my @pages = (map { +{ 'path' => $_, 'title' => "Title for $_", 'content' => "

Content for $_

" } } @page_paths); +# Add the site-map page. +{ + my $site_map_path = "site-map/"; + my $site_map_generator = + HTML::Widgets::NavMenu->new( + path_info => "/$site_map_path", + current_host => "default", + hosts => \%hosts, + tree_contents => $nav_menu_tree + ); + push @pages, + { + 'path' => $site_map_path, + 'title' => "Site Map", + 'content' => join("\n", @{$site_map_generator->gen_site_map()}), + }; +}; + foreach my $page (@pages) { my $path = $page->{'path'}; - my $title = $page->{'title'}; - my $content = $page->{'content'}; my $nav_menu = HTML::Widgets::NavMenu->new( path_info => "/$path", @@ -305,8 +370,6 @@ my $nav_menu_results = $nav_menu->render(); - my $nav_menu_text = join("\n", @{$nav_menu_results->{'html'}}); - my $file_path = $path; if (($file_path =~ m{/$}) || ($file_path eq "")) { @@ -319,31 +382,72 @@ mkpath($1, 0, 0755); open my $out, ">", $full_path or die "Could not open \"$full_path\" for writing!"; - - print {$out} <<"EOF"; + + + my $template = + Template->new( + { + 'POST_CHOMP' => 1, + } + ); + + my $vars = + { + 'title' => $page->{'title'}, + 'css_style' => $css_style, + 'nav_menu_text' => join("\n", @{$nav_menu_results->{'html'}}) . "\n", + 'content' => $page->{'content'} . "\n", + 'breadcrumbs' => $nav_menu_results->{leading_path}, + 'nav_links' => $nav_menu_results->{'nav_links_obj'}, + }; + + my $nav_links_template = <<'EOF'; +[% USE HTML %] -$title +[% title %] +[% FOREACH key = nav_links.keys.sort %] + +[% END %] + +
-

$title

-$content +

[% title %]

+[% content %]
EOF + $template->process(\$nav_links_template, $vars, $out); + close($out); }