--- mitgcm.org/front_content/Assemble.pl 2003/12/03 03:36:29 1.1 +++ mitgcm.org/front_content/Assemble.pl 2005/04/02 22:12:59 1.6 @@ -1,56 +1,93 @@ -#! /usr/bin/env perl +#! /usr/bin/perl # Ed Hill # Tue Dec 2 20:17:27 EST 2003 # Assemble the web pages from XML files. -open(TOP,") { - chomp($line); - length($line) > 0 and @top_list[$top_list++] = $line; -} +$topdir = "."; +$file_list = $topdir . "/order.txt"; +open(ORDER,$file_list) or die "ERROR: can't open \"$file_list\"\n"; +$_ = join(" ", ); +s/\n//s; +@flist = split(" ", $_); open(TEMPL,"; -mkdir html; +system("rm -rf html"); +system("mkdir html"); -foreach $file (@top_list) { +print "Parsing files ... "; +foreach $file (@flist) { + $fname = $topdir . "/" . $file; + open(INF,$fname) or die "ERROR: can't open \"$fname\"\n"; + $all = join "", ; + $_ = $all; + /; + close(INF); + # Get the body $_ = $f_all; /(.*)<\/body>/s and $body = $1; + # Get the title $_ = $f_all; /" . $f . "
\n"; + foreach $fm (@flist) { + $ind = ""; + $name = $name0{$fm}; + if (length($name1{$fm}) > 0) { + $ind = "   "; + $name = $name1{$fm}; + } + if (length($ind) > 0 and ($name0{$fm} ne $cname)) { + next; + } + if ($fm ne $file) { + $_ = $fm; + s/.xml/.html/; + $tmp = $ind . "" . $name . "
\n"; } else { - $tmp = "" . $name . "\n"; + $tmp = $ind . "" . $name . "
\n"; } $menu = join "", $menu, $tmp; } + # $tmp = "Search
\n"; + # $menu = join "", $menu, $tmp; + # Create the output $_ = $template; s//$title/s; s//$menu/s; s//$body/s; + $content = $_; - $out_name = ">./html/" . $file . ".html"; + $_ = $file; + s/.xml/.html/; + $out_name = ">./html/" . $_; open(OUT,$out_name) or die "ERROR: can't open \"$out_name\"\n"; - print OUT $_; + print OUT $content; close(OUT); - close(INF); } +print " done\n";