#!/usr/bin/perl -w # Copyright © 2000-2008 Jamie Zawinski . # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # Created: 28-Nov-00. # # This script generates/updates the template wrapper and menu contents on # all of the DNA Lounge pages. It goes like this: # # - read the target file, and extract the "content" portions of it # (the sections between "RIGHT_START and RIGHT_END", etc.) # - take the template file, and insert the content into it; # - generate a menu for the target file, and splice that in too; # - write the result out to the target file. # # In this way, we ensure that any changes to the template file always get # pushed down into every file that uses it. require 5; use diagnostics; use strict; use bytes; my $progname = $0; $progname =~ s@.*/@@g; my $version = q{ $Revision: 1.60 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; my $verbose = 0; my $fgcolor = "#00FF00"; my $bgcolor = "#000000"; my $head_color = "#004400"; my $bd_color = "#00EE00"; my $dim_color = "#666666"; my @menu = ("375 Eleventh Street
\nSan Francisco, CA 94103", " Calendar calendar/latest.html", " Directions directions/", " Dinner Menu kitchen/", " Private Parties booking/", " Contacting Us contact/", "", " Flyer Archive flyers/latest.html", " Photo Gallery gallery/latest.html", " Webcasts webcast/", " Merchandise store/", "", " Behind the Scenes backstage/", " What's New backstage/log/latest.html", ); my @months = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); # Returns the HTML for the left column menu table for a document living # at the given URL (really, relative path from the root.) # sub make_menu_html($$) { my ($current_url, $base) = @_; if ($base) { error ("base must be an absolute URL: $base") unless ($base =~ m@^http://[^/]+/(.*)$@); $current_url = $1; } error ("relative urls only, please: $current_url") if ($current_url =~ m@/^http:|^[/.]@); $current_url =~ s@\.tmp$@@i; $current_url =~ s@/index.s?html?$@/@i; my $depth = 0; $_ = $current_url; while (m@^[^/]+/(.*)$@) { $depth++; $_ = $1; } my $prefix; if ($base) { $prefix = $base; } else { $prefix = "../" x $depth; } my $current_indent = 0; my $output = ""; foreach my $item (@menu) { $_ = $item; my ($indented, $label) = m@^(\s*)(.*)$@s; $indented = length($indented) / 2; $indented = $current_indent if ($label eq ''); # blank lines my $item_url; if ($label =~ m@^(.*)( \s+|\t\s*)(.*)$@s) { $label = $1; $item_url = $3; $item_url =~ s/^\s*//; $item_url =~ s/\s*$//; $item_url = "" if $item_url =~ m@^!@; # bang means link disabled } if ($label eq '' && $item_url) { error ("blank label with a url? $item_url"); } $label =~ s/^\s*//; $label =~ s/\s*$//; if ($indented > $current_indent) { if ($current_indent == 0) { $output .= " " x ($current_indent * 2); $output .= "

\n"; } while ($indented > $current_indent) { $output .= " " x ($current_indent * 2); $output .= "

\n"; $current_indent++; } } elsif ($indented < $current_indent) { while ($indented < $current_indent) { $current_indent--; $output .= " " x ($current_indent * 2); $output .= "
\n"; } if ($current_indent == 0) { $output .= " " x ($current_indent * 2); $output .= "

\n"; } } $output .= " " x ($current_indent * 2); my $expanded_item_url = expand_latest_url ($item_url, $current_url); if (!defined($item_url)) { if ($label eq '') { $output .= "
\n"; } else { $output .= "$label
\n"; } } elsif ($expanded_item_url eq $current_url) { $output .= "$label
\n"; } elsif ($item_url eq "") { $output .= "$label
\n"; } else { $output .= "$label
\n"; } } while ($current_indent > 0) { $current_indent--; $output .= " " x ($current_indent * 2); $output .= "\n"; } $output .= "

\n"; # at end of menu 1 while ($output =~ s/
(\s*

)/$1/gsi); # lose BR before P 1 while ($output =~ s/

(\s*