HTML-Widgets-NavMenu

 view release on metacpan or  search on metacpan

examples/article-examples/simple/H-W-NM-simple.pl  view on Meta::CPAN

navigation menus for 10 years now. I find navigation menus to be a fascinating
subject, and think everyone should be interested in them.
</p>
EOF
    },
    {
        'path'    => "links/",
        'title'   => "Cool Links",
        'content' => <<'EOF',
<h2>Perl-Related Links</h2>

<ul>
<li>
<a href="http://www.perl.com/">Perl.com - a site with Perl articles</a>.
</li>
<li>
<a href="http://www.perl.org/">Perl.org</a> - the homepage of the Perl
community.
</li>
<li>
<a href="http://perl-begin.berlios.de/">Perl Beginners' Site</a>
</li>
</ul>
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, oct('0755'), );
    open my $out, ">", $full_path
        or die "Could not open \"$full_path\" for writing!";

    print {$out} <<"EOF";
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>$title</title>
<style type="text/css">
$css_style
</style>
</head>
<body>
<div class="navbar">
$nav_menu_text
</div>
<div class="body">
<h1>$title</h1>
$content
</div>
</body>
</html>
EOF

    close($out);
}



( run in 1.004 second using v1.01-cache-2.11-cpan-1edf4fed603 )