#!/usr/bin/perl use strict; use warnings; use HTML::Widgets::NavMenu; use File::Path; my $css_style = <<"EOF"; a:hover { background-color : palegreen; } .body { float : left; width : 70%; padding-bottom : 1em; padding-top : 0em; margin-left : 1em; background-color : white } .navbar { float : left; background-color : moccasin; width : 20%; border-color : black; border-width : thick; border-style : double; padding-left : 0.5em; } .navbar ul { font-family: sans-serif; font-size : small; margin-left : 0.3em; padding-left : 1em; } EOF my $nav_menu_tree = { 'host' => "default", 'text' => "Top 1", 'title' => "T1 Title", 'subs' => [ { 'text' => "Home", 'url' => "", }, { 'text' => "About Me", 'title' => "About Myself", 'url' => "me/", }, { 'text' => "Links", 'title' => "Hyperlinks to other Pages", 'url' => "links/", }, ], }; my %hosts = ( 'hosts' => { 'default' => { 'base_url' => ("http://web-cpan.berlios.de/modules/" . "HTML-Widgets-NavMenu/article/examples/simple/dest/"), }, }, ); my @pages = ( { 'path' => "", 'title' => "John Doe's Homepage", 'content' => <<'EOF',

Hi! This is the homepage of John Doe. I hope you enjoy your stay here.

EOF }, { 'path' => "me/", 'title' => "About Myself", 'content' => <<'EOF',

My name is John Doe and I've been exploring the art and science of creating navigation menus for 10 years now. I find navigation menus to be a fascinating subject, and think everyone should be interested in them.

EOF }, { 'path' => "links/", 'title' => "Cool Links", 'content' => <<'EOF',

Perl-Related Links

EOF }, ); 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", current_host => "default", hosts => \%hosts, tree_contents => $nav_menu_tree, ); 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 "")) { $file_path .= "index.html"; } my $full_path = "dest/$file_path"; $full_path =~ m{^(.*)/[^/]+$}; # mkpath() throws an exception if it isn't successful, which will cause # this program to terminate. This is what we want. mkpath($1, 0, 0755); open my $out, ">", $full_path or die "Could not open \"$full_path\" for writing!"; print {$out} <<"EOF"; $title

$title

$content
EOF close($out); }