#!/usr/bin/perl # Filename: make_project # Author: David Ljung Madison # See License: http://MarginalHacks.com/License # Description: Makes all the HTML for a project page use strict; ################################################## # Setup the variables ################################################## my $PROGNAME = $0; $PROGNAME =~ s|.*/||; chdir('/WWW/web/MarginalHacks.com/Hacks/album/'); my $CHAPTERS = "Chapters"; sub printname { my ($chap) = @_; $chap =~ s/^\d+\.//; $chap =~ s/_/ /g; $chap = "Themes/Examples" if $chap eq "Themes"; $chap; } sub filename { my ($chap) = @_; return "/Contact/" if $chap =~ /^\d+\.Contact$/; return "Docs/" if $chap =~ /^\d+\.Documentation$/; return "index.html" if ($chap =~ /home$/i); $chap =~ s/\?//g; return "$'.html" if ($chap =~ /^\d+\./); return "$chap.html"; } ################################################## # Main code ################################################## opendir(DIR,$CHAPTERS) || die("Couldn't opendir $CHAPTERS\n"); my @chap = sort grep(! -d "$CHAPTERS/$_", readdir(DIR)); @chap = grep(!/\.eperl$/, @chap); @chap = grep(!/\.old$/, @chap); closedir(DIR); print "@chap\n"; open(HEADER,"Header") || die("Couldn't read Header\n"); my @header =
; close(HEADER); sub flags { my ($dir) = @_; opendir(D,$dir) || return; my @d = grep(-f "$dir/$_/flag.png", readdir D); closedir D; join(" ",map("$_", @d)); } foreach my $chap ( @chap ) { my $f = "$CHAPTERS/$chap"; print "eperl $f.eperl -o $f\n" if -f "$f.eperl"; system("eperl $f.eperl -o $f") if -f "$f.eperl"; next unless -s "$f"; open(CHAP,"<$f") || die("Couldn't read $f\n"); my @text = ; close CHAP; my $file = filename($chap); chmod 0644, $file; # Make temporarily writable open(CHAP,">$file") || die("Couldn't write $file\n"); print CHAP @header; print CHAP "\n"; print CHAP " \n"; print CHAP " \n"; print CHAP "
\n"; print CHAP " \n"; foreach my $c ( @chap ) { my $f = filename($c); my $h = ($f eq "index.html") ? "." : $f; my $p = printname($c); print CHAP " \n"; } print CHAP "
\n"; print CHAP "

"; print CHAP "" unless ($f eq $file); print CHAP "$p"; print CHAP "" unless ($f eq $file); print CHAP "
".flags($f) if $f eq "Docs/"; print CHAP "

\n"; print CHAP "

\n"; print CHAP "

\n"; if ($f =~ /Home/) { # Clustrmaps print CHAP "
\n"; # Download mirror print CHAP < Download mirror
courtesy PCWin.com
MIRROR } print CHAP "
\n"; print CHAP @text; print CHAP "
\n"; print CHAP "\n"; print CHAP "These pages were, of course, generated by a"; print CHAP " perl script with this"; print CHAP " source\n"; print CHAP "\n"; # # Blah # if ($chap =~ /^01/ && open(SP,"

\n"; # while () { print CHAP; } # } print CHAP "\n"; print CHAP "\n"; close CHAP; chmod 0444, $file; # Non-writable }