#!/usr/bin/perl # Created: Thu Sep 12 02:13:50 CDT 2002 # Documentation added: Tue Sep 24 16:37:22 PDT 2002 # =head1 NAME present - simple outline presentation generator =head1 SYNOPSIS present [-n NAME] [-t] FILE present [-n NAME] -c FILE =head1 DESCRIPTION Present turns a textual outline into simple HTML slides. It does very minimal processing of the input other than determining the indentation level of the outline item (as indicated by the number of TAB characters at the beginning of each line.) =cut use Getopt::Std; use vars qw($opt_c); &getopts("n:ct"); # this is where the icons are @icon_names = qw(left.gif right.gif up.gif); # first decide which file we are going to use $file = $ARGV[0]; $pres = $file; $pres =~ s/\..*$//; $pres = $opt_n if $opt_n; =head1 OPTIONS The B<-n> option gives the name of the presentation, which is used to name all the HTML files. If you do not indicate the name of the presentation using B<-n>, present will assume that the name of the presentation should be the same as the name of the file, minus any extension. For example, a file named F would by default have the name F, with slides named F, F, etc. If you gave the C<-n bar> option, then the slides would be named F, F, etc. The B<-c> option means that you want to clean up the directory, deleting any files which would be created by an ordinary run of present. The B<-t> option means that you would like present to generate a set of text-only presenter's notes that you can print out and refer to during your talk, instead of having to watch the screen. These notes are generated by using my favorite HTML renderer, C. The B<-t> option will cause text and Postscript versions to be generated. The Postscript version is the same as the text version (i.e., no fancy formatting or graphics) but easier to print on a laser printer. Present uses Enscript to generate the Postscript version. =cut # pull in the presentation now that we have found it (initializes @slide array) $slideno = 0; $result = do $file; if ($result == undef) { die "Couldn't load presentation from $file\n"; } if ($opt_c) { # clean up only # erase index.html unlink "index.html"; # erase icons unlink @icon_names; # erase pages of presentation for ($slideno = 0; $slideno <= $#slide; $slideno++) { unlink "${pres}-${slideno}.html"; } # erase presenter's notes unlink "${pres}-notes.txt"; unlink "${pres}-notes.ps"; exit 0; } =head1 FILES Let's say you have a presentation called foo. You will have one (important) input file, called F. This contains your outline. The input format is as follows: $slide[$slideno]++ = <HTML is allowed. You can even have graphics. END $slide[$slideno]++ = < array is populated with text. When you have written your presentation the next thing to do is run present on it. When you do so, the following files will be generated: F - List with links to (& titles of) all your slides; links to presenter's notes. Good place to start and end. F ... F - Your slides. F, F - Presenter's notes. =cut $toc_file = "index.html"; # print navigation bar at bottom and top of slide. # uses prev_file, next_file, toc_file, prestitle, slideno, slide sub navbar { print SLIDE "\"[prev]\"\n"; print SLIDE "\"[next]\"\n"; print SLIDE "\"[toc]\"\n"; print SLIDE '   ', "$prestitle -- "; if ($slideno <= $#slide) { print SLIDE 1+$slideno, " of ", 1+$#slide, "
\n"; } else { print SLIDE 1+$#slide, " slides
\n"; } } =head1 OTHER FEATURES Each slide has a nice navigation bar at the top and bottom, with previous, next, and up icons stolen from Apache. The navigation bar also says the name of the presentation, the number of the current slide, and the total number of slides, so your audience knows how long it has to suffer. In case you are wondering, the last slide is followed by the table of contents, which is followed by the first slide. The up arrow takes you to the table of contents from any slide. So, no two slides are ever more than 2 clicks apart. Ever seen someone try to jump around in their presentation in, well, that I presentation program? =cut # print out the top of the slide, nav bar, title, html header etc. # uses title. sub do_topofslide { my ($title) = @_; print SLIDE "\n"; print SLIDE "", $title, ""; print SLIDE "\n"; &navbar; print SLIDE "
"; print SLIDE "

", $title, "

"; } # print out each individual slide. for ($slideno = 0; $slideno <= $#slide; $slideno++) { $file = "${pres}-${slideno}.html"; $nextslideno = $slideno + 1; $prevslideno = $slideno - 1; if ($slideno == 0) { $prev_file = $toc_file; } else { $prev_file = "${pres}-${prevslideno}.html"; } if ($slideno == $#slide) { $next_file = $toc_file; } else { $next_file = "${pres}-${nextslideno}.html"; } $file = "${pres}-${slideno}.html"; open(SLIDE, ">$file") or die "Error: $file: $!\n"; @lines = split(/\n/, $slide[$slideno]); $titles[$slideno] = shift @lines; if ($slideno == 0) { $prestitle = $titles[$slideno]; } &do_topofslide($titles[$slideno]); print SLIDE "
    "; foreach $l (@lines) { $level = 0; while ($l =~ /^\t/) { $l =~ s/^\t//; $level++; } $l = "
  • $l
  • "; for ($j = 0; $j < $level; $j++) { $l = "
      $l
    "; } print SLIDE "$l\n"; } &do_bottomofslide; close SLIDE; } # prints out the bottom of the slide (nav bar, end of html tags). sub do_bottomofslide { print SLIDE "
"; print SLIDE "
"; &navbar; print SLIDE "\n"; print SLIDE "\n"; } # print out the table of contents - one link for each slide. $prev_file = "${pres}-" . $#slide . ".html"; $next_file = "${pres}-0.html"; open(SLIDE, ">$toc_file") or die "Error: $toc_file: $!\n"; &do_topofslide("Table of Contents"); print SLIDE "(Text and postscript notes are available for this presentation.)
\n" if $opt_t; for ($slideno = 0; $slideno <= $#slide; $slideno++) { print SLIDE "
  • (", 1+$slideno, ") ", $titles[$slideno], "...
  • "; } &do_bottomofslide; close SLIDE; # this is where the icon images are kept $icons = 0; $icon_images[$icons++] = <<'END'; begin 644 left.gif M1TE&.#EA%``6`*$``/___\S__P```````"'^3E1H:7,@87)T(&ES(&EN('1H M92!P=6)L:6,@9&]M86EN+B!+979I;B!(=6=H97,L(&ME=FEN:$!E:70N8V]M M+"!397!T96UB97(@,3DY-0`A^00!```!`"P`````%``6```"*XR/J2*IJ9O7"7O9L=#W=N%[SCP_4%0``.P`` ` end END $icon_images[$icons++] = <<'END'; begin 644 up.gif M1TE&.#EA%``6`*$``/___\S__P```````"'^3E1H:7,@87)T(&ES(&EN('1H M92!P=6)L:6,@9&]M86EN+B!+979I;B!(=6=H97,L(&ME=FEN:$!E:70N8V]M M+"!397!T96UB97(@,3DY-0`A^00!```!`"P`````%``6```"(XR/J+(O%\DS7=E```#L` ` end END # unpack the icons into the directory if they are not here. for ($i = 0; $i <= $#icon_names; $i++) { unless (-f $icon_names[$i]) { open(UU, "|uudecode") or die "uudecode: $!\n"; print UU $icon_images[$i]; close UU; } } # if we want text-only copy, run it all through w3m and string the results together if ($opt_t) { unlink "${pres}-notes.txt"; for ($s = 0; $s <= $#slide; $s++) { `w3m -dump ${pres}-${s}.html | fgrep -v "\[prev\]" >> ${pres}-notes.txt`; } `enscript -1 -B ${pres}-notes.txt -o ${pres}-notes.ps`; } =head1 SEE ALSO L, L =head1 VERSION HISTORY Present and its documentation were written over the course of a couple of weeks in September 2002 by Brian Gaeke. =head1 LICENSE Present is copyright 2002 by Brian Gaeke. Present may be redistributed and modified under the terms of the GNU General Public License, version 2. =cut # we're done exit 0;