#!/usr/local/bin/perl
#slideshow.cgi
#Creates a 'powerpoint-like' slideshow in HTML
#user can define a series of slides and an HTML-like template
#and a presentation will be automatically written that
#interpolates the outline into the template format
#by Andy Harris, 9/99
#to use this on your own server, the only thing you might have to
#change is the pointer to perl.
use CGI ':standard';
if (!param){
#This is the first time here. Give 'em the opening page
&showEditor;
} else {
#we have some data. Let's parse it out!!
$source = param('slideSource');
@lines = split /\n/, param('slideSource');
# set up global variables
$numLines = @lines;
$currentLine = 0;
$slideNum = 0;
$outline = " \noutline
\n";
@titles = ("index");
@slides = ();
#step through the lines
while ($currentLine < $numLines){
#grab the next line
$line = shift @lines;
$currentLine++;
#does this line contain a filebase tag?
if ($line =~m#?file_?base>#i){
#remove the filebase tags
$line =~ s#?file_?base>##gi;
$fileBase = $line;
chop $fileBase;
#or a templatefile tag?
} elsif ($line =~ m#?template_?file>#i){
$line =~s#?template_?file>##gi;
$templateFile = $line;
#grab the file if possible
$fileName = '/home/aharris/public_html/cgi-bin/slideshow/' . $templateFile;
open TEMPLATE, "$fileName";
@template = ;
close TEMPLATE
#how about a topicTitle tag?
} elsif ($line =~ m#?topic_?title>#i){
$line =~s#?topic_?title>##gi;
$topicTitle = $line;
#look for a slide
} elsif ($line =~ m# \n";
for ($i=0; $i <$numSlides; $i++){
$index .= Tr(td($i), td("$titles[$i]"));
} # end for loop
$index .= Tr(td("
\n";
$index .= "created using slideshow.cgi by Andy Harris \n";
$index .= "
"), td("outline"));
$index .= "
\n";
return $index;
} #end makeIndex
sub makeSlide{
#expects a slide number, a title, and an array of items
#returns back a string containing the HTML for the current slide
#grab the arguments
my ( $slideNum, $title, @items);
$slideNum = shift;
$title = shift;
@items = @_;
$slide = " \n";
foreach $getAline (@template){
#work on a copy of the line
$line = $getAline;
#fix the topic title
$line =~ s#
\n";
return $slide;
} # end makeSlide
sub makeSlideOutline{
#makes a form of the slide suitable for an outline
my ($title, @items);
$title = shift;
@items = @_;
$slideOutline = "";
$slideOutline .= h3("$title");
$slideOutline .= ul(li([@items]));
return $slideOutline;
} #end makeSlideOutline
sub processSlide{
# look through the stuff between slide and /slide,
# and put it in some variables for later analysis
#ignore this line, get the next one
$line = shift @lines;
$currentLine++;
#increment the slide number
$slideNum++;
#clean up the item array
@items = ();
#this is the slide title
$title = $line;
push @titles, $title;
#go until we see the
\n";
print button(-value=>'use the n241 template',
-onClick=>'blank241()');
print " Instructions \n";
print "
\n";
print submit('build the slideshow');
print end_form();
print hr();
print " \n";
print h2("Instructions:");
print "
overview
The slidemaker is a very simple program that automates the creation of
presentation slides (like powerpoint). This program is intended for
people who are interested in using HTML as a slide format (for
portability and ease of use). It allows you to generate a set of
slides using original extensions of HTML, and lets you set up a
template for how the slides will appear. You can use any HTML tricks
you want (Ok, frames may give you trouble) and the program will
incorporate them into the slideshow. The program will generate one
large web page, which you can save locally. All the links are
internal, so you don't have to mess with a large number of files, as
you did in the previous version.
The default slideshow is heavily commented, and you can probably figure it out just by modifying it.
The next part of the code is the template. This describes what a typical slide will look like. If you are just starting out, you can skip over the template and go straight to the slide section without any problems. The template is there so you can customize your slideshow in intriguing ways, but you can always just use the default template.
If you wish to modify the template, you will find it easy to do.This is pretty much standard html. In this version of slideshow, all the output is on the same page, so body tags will be ignored. You can use images if you wish, or embedded sound, or anything else you want, but things that you place in the template will go into EVERY slide. If something only belongs in one slide, use the slide segment to do that. You can use variations of the table tricks in the default template to get some nice background and font effects. If you are using a browser that supports cascading style sheets, you can use also CSS to make a background image or color.
In addition to any html features that can normally be part of a page, you can also access a number of 'special' tags inside the template. These tags will be replaced with values appropriate to each slide.
This tag is unique. What it does is return back a pre-formatted list of all the items in the current slide. It will already be in html form, as an unordered list. The items tag should be on a line by itself.
You can surround this tag with font tags to increase the default font size or change the color, you can place the font in a table for nicer formatting, and so on. See the default template for examples.
This is actually the easiest part. All you do is write down the data you want to show. Each item will be on its own line. Surround each slide with <slide></slide>tags. The first line inside a slide set will automatically be considered the slide's title. All the others will be 'talking points' for that slide.
You can embed any html you wish into the lines, including image references, embedded sounds, lists, or whatever. Each time you press the carriage return, you will be starting a new logical line, but you can write lines that include <br> tags or other tags that cut up a line. You'll probably have to experiment to get it.
| Keystroke | comand |
|---|---|
| i | Index. Go to index at top of show, reset counter |
| o | Outline. Go to outline at bottom of show. Does NOT reset counter |
| n | Next page. If end of show, go to index |
| p | Previous page |