#!/usr/local/bin/perl # # vv - a Perl script for producing "Virtual Viewgraphs", a chain of linked frames # of HTML pages for talks, presented directly off the web, or from a laptop # cache of web pages. # # Released into the public domain by Aake Nordlund, NBIfAFG & TAC, Copenhagen, # 18-sep-98. # # NO support is provided, this "use as is" software, provided as a service to # those, who in principle could have written this piece of perl code themselves, # and / or are smart enough to adjust it to their own needs and preferences. # # Syntax: vv [ -f ] [ -p pp ] [ -c sz ] [ -t sz ] 1.sld 2.sld 3.sld ... # # -f : "fold" section headers (just try it) # -p pp : percentage width of the contents fram (default 22) # -c sz : relative size of contents text (-1 is default) # -t sz : relative size of talks text (+1 is default) # # The files 1.sld etc contain ascii data (and embedded HTML) in the form # (see also http://www.tac.dk/~padoan/talks/dust/[0123].sld): # # title: Protogalaxies at high z [ only one per talk ] # section: Introduction [ one per file ] # head: Acknowledgements [ one per slide # o Collaborators: # + James Dunlop # + Jose Franco # [ blank line separates slides ] # head: Galaxies at High Redshift # o When are galaxies formed? # - Observing distant galaxies is the only direct method to study galaxy formation and evolution. ##################################################################### sub beginHTML { $file="$sep1$s$sep2$pg.html"; $page="$sep1$s$sep2"."page"."$pg.html"; if ($sep2 eq ":") { $icons="file:///Macintosh HD/Desktop Folder/Computer Physics/HTML/Icons"; } else { $icons="http://www.astro.ku.dk/Icons"; }; #$prv=$cur; #$cur="../$s/index$pg.html"; #print STDERR "page=$page prv=$prv cur=$cur\n"; open (PGE,">$page"); $html=""; $html0=" $title
$title "; $html1="($s.$pg)

"; } ##################################################################### sub endHTML { $pg++; print PGE "$html0$section$html1

$head

$html "; close (PGE); } ##################################################################### sub doIndex { open(IDX,">$_[0]"); $psize1 = 100-$psize; print IDX " Contents "; close(IDX); } ##################################################################### sub setLevel { # print "\nsetLevel: level=$level olevel=$olevel\n"; while ($level > $olevel) { $olevel++; if ($olevel == 0) { &beginHTML; } elsif ($olevel == 1) { } elsif ($olevel == 2) { $html=$html."

\n"; } else { $html=$html.' ' x ($olevel-1); $html=$html."
\n"; } else { $html=$html.' ' x ($olevel-1); $html=$html."\n"; } $olevel--; } } ##################################################################### sub doText{ $html=$html."

$_

"; } ##################################################################### sub doBullet{ $html=$html."

 $_\n"; } ##################################################################### sub doList{ $html=$html.' ' x $level; $html=$html."
  • $_\n"; } ##################################################################### $csize="-1"; # Contents text size delta $psize="22"; # Percent contents frame $tsize="+1"; # Main text size delta $folded=0; # Folded table of contents? if (chdir("Macintosh HD:Desktop Folder:Computer Physics:HTML:Lectures")) { $sep1=":"; $sep2=":"; print STDERR "Macintosh:\n"; } else { $sep1=""; $sep2="/"; } open (LNK,">contents.html"); print LNK " Contents

    CONTENTS

    "; $s0 = -1; $d = `pwd`; chop($d); $sec=-1; #opendir(DIR,$d); #@files = sort(readdir(DIR)); #file: foreach (@files) { # next file unless /[0-z].sld$/; file: while ($#ARGV >= 0) { $_ = $ARGV[0]; print STDERR "$_ "; if (/-f/) { $folded=1; shift(@ARGV); next file; } elsif (/-c/) { $csize=$ARGV[1]; shift(@ARGV); print STDERR "csize: $csize "; shift(@ARGV); next file; } elsif (/-p/) { $psize=$ARGV[1]; shift(@ARGV); print STDERR "psize: $csize "; shift(@ARGV); next file; } elsif (/-t/) { $tsize=$ARGV[1]; shift(@ARGV); print STDERR "tsize: $tsize "; shift(@ARGV); next file; } shift(@ARGV); @s = split(/\./); $s = $s[0]; if ($s0 == -1) {$s0=$s;} $section = ''; stat($s) || mkdir($s,0755); open(O,">$s.html"); print O " $title "; close(O); #open (IN,"$s.sld") || die("cannot open $s.sld"); open (IN,"$_") || die("cannot open $s_"); $pg = 1; #&beginHTML; $olevel = -1; $r = ""; line: while () { chop; $n = split; s/ \& / & /g; s/{\\em \(.*\)}/\1<\/B>/; if ($_[0] eq "section:") { #shift; s/section: //; $section = $_; #$sec++; if ($sec == -1) {$sec0=$s;} $sec=$s; print STDERR "sec=$sec\n"; $nsub{$sec}=0; $text{$sec,0}=$section; $dir{$sec}=$s; print LNK "$s. $_
    \n"; $level=-1; next line; } elsif ($n == 0) { $level=-1; } elsif ($_[0] eq "title:") { s/title: //; $title = $_; } elsif ($_[0] eq "head:") { $level=0; s/head: //; $head=$_; $text{$sec,$pg}=$head; $nsub{$sec}++; print LNK "  $head
    \n"; } elsif ($_[0] eq "link:") { $level=0; s/link: //; $head=$_; $text{$sec,$pg}=$head; $_=; chop; $link{$sec,$pg}=$_; $nsub{$sec}++; print LNK "  $head
    \n"; } elsif (/^ [o\+-] /) { $level=5; s/^ *[o\+-] //; } elsif (/^ *[<]/) { $html=$html."$_"; next line; } elsif (/^ /) { $level=5; &setLevel; $html=$html."$_"; next line; } elsif (/^ [o\+-] /) { $level=4; s/^ *[o\+-] //; } elsif (/^ /) { $level=4; &setLevel; $html=$html."$_"; next line; } elsif (/^ [o\+-] /) { $level=3; s/^ *[o\+-] //; } elsif (/^ /) { $level=3; &setLevel; $html=$html."$_"; next line; } elsif (/^ [o\+-] /) { $level=2; s/^ *[o\+-] //; } elsif (/^ /) { $level=2; &setLevel; $html=$html."$_"; next line; } elsif (/^ *\\vskip/) { next line; } else { $level=1; } # print "\n n=$n level=$level str=$_\n"; &setLevel; if ($level == 1) {&doText;} elsif ($level == 2) {&doBullet;} elsif ($level >= 3) {&doList;} #select STDOUT; #print "$level $_\n"; } close (IN); $s++; $r = "../$s/"; $pg=0; &endHTML; } print STDERR "\n"; print LNK "
    "; close (LNK); #stat("index.html") || &doIndex("index.html", "$sec0/contents0.html", "$sec0/page1.html"); for ($i=$sec0; $i<=$sec; $i++) { # print "$text{$i,0} $nsub{$i}\n"; if ($i == $sec0) {$j0=0;} else {$j0=1;} for ($j=$j0; $j<=$nsub{$i}; $j++) { $idx="index$j.html"; $cnt="contents$j.html"; $right="page$j.html#head"; if ($link{$i,$j} ne "") {$right="$link{$i,$j}"} print STDERR "$idx $cnt $right\n"; if ($j == 0) {$right="front.html";} &doIndex ("$sep1$dir{$i}$sep2$idx", "$cnt", "$right"); $im = $i-1; $jm = $j-1; $prv = "index$jm.html"; if ($jm < 1) {$prv = "../$im/index$nsub{$im}.html";} if ($j == 0) {$prv ="../$sec/index$nsub{$sec}.html";} $ip = $i+1; $jp = $j+1; $nxt = "index$jp.html"; if ($jp > $nsub{$i}) {$nxt = "../$ip/index1.html";} if ($i == $sec && $j == $nsub{$sec}) {$nxt = "../$sec0/index0.html";} open(CNT,">$sep1$dir{$i}$sep2$cnt"); print CNT " Contents

    CONTENTS
     

    \n"; for ($ii=$sec0; $ii<=$sec; $ii++) { if ($ii == $i) { print CNT "$text{$ii,0}
    \n"; for ($jj=1; $jj<=$nsub{$ii}; $jj++) { if ($jj == $j) { print CNT "  $text{$ii,$jj}
    \n"; } else { print CNT "  $text{$ii,$jj}
    \n"; } } } else { if ($folded) { print CNT "$text{$ii,0}
    \n"; } else { print CNT "$text{$ii,0}
    \n"; for ($jj=1; $jj<=$nsub{$ii}; $jj++) { print CNT "  $text{$ii,$jj}
    \n"; } } } } print CNT "
    \n"; close(CNT); # print " $text{$i,$j}\n"; } } exit;