#!/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 = " \n

outline

\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##i){ #remove the filebase tags $line =~ s###gi; $fileBase = $line; chop $fileBase; #or a templatefile tag? } elsif ($line =~ m##i){ $line =~s###gi; $templateFile = $line; #grab the file if possible $fileName = '/home/aharris/public_html/cgi-bin/slideshow/' . $templateFile; open TEMPLATE, "$fileName"; @template = #i)) { #get the next line $line = shift @lines; $currentLine++; #ignore the line if (!($line =~ m##i)){ #add this to the template array push @template, $line; } #end 'is it the end of the template' if } # end while loop #print &templatePreview; } # end processTemplate sub saveFile{ $fileBase = $topicTitle; #convert spaces to underscores $fileBase =~ s|\s|_|g; #kill trailing spaces $fileBase =~ s|__$||; $fileName = "/home/aharris/public_html/cgi-bin/slideshow/" . $fileBase . ".html"; open (OUTFILE, ">$fileName") or die "did not open file"; print OUTFILE start_html("$topicTitle"); print OUTFILE $keyHandler; print OUTFILE &makeIndex; print OUTFILE "@slides"; print OUTFILE $outline; print OUTFILE end_html(); close OUTFILE; #print the source code $fileName = "/home/aharris/public_html/cgi-bin/slideshow/" . $fileBase . ".txt"; open (SOURCE, ">$fileName"); print SOURCE $source; close SOURCE; } # end saveFile sub showEditor{ #shows the screen that contains the default text, has one big textarea print header(); print " "; print start_html('slideshow creation'); print h1("create a slide show"); print start_form(-name=>'theForm'); #create the text area with the default slideshow print " "; print "
\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.

Specifying the topic

The first thing you will need to do is specify the topic of your presentation. You will be able to refer to this in all your slides if you wish. Just put a value between <topic_title> and </topic_title>. notes:

Designing the template

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.

The special tags

<topic_title>: The topic of the entire presentation
<slide_title>: The title of the current slide
<slide_num>: The number of the current slide
<prev>: an internal url (using an anchor) to the previous slide
<next>: an internal url (using an anchor) to the next slide
<top>: an internal url (using an anchor) to the top (index) slide
<items>: an unordered list containing the slide items

General notes on using these tags

using the anchors(<next>, <prev>, and <top>)

using the <items> tag

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.

Writing the slides

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.

sneaky tricks

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.

Using the slideshow

The slideshow that is generated by this program is not permanently stored anywhere. If you want to use it, you will need to save it. On most browsers, you can use the 'save as' command from the 'file' menu to save whatever page you are currently on. Play with the program until you get the results you want, then save the file as normal HTML. You can then modify that file if you wish to fine-tune it, put it on your own site, or whatever.

Keyboard commands

A few keyboard commands have been added to the slideshow, so you can do presentations without a mouse. The keyboard command work as you are presenting the show, and only work with 4.0 and later browsers (tested in IE4.* and Nav 4.*). Here are the commands:
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

Credits

This program was written by Andy Harris. I retain the copyright, but feel free to use it if you wish. You may also copy the source code and use it on your own system if you have the appropriate access. Please do not charge for use of this code. If you enjoy the program, I'd love to hear from you. -
Andy "; print end_html(); } # end showEditor sub templatePreview{ #analyze template and show how it will look $preview = h1("template preview"); foreach $getALine (@template){ #work on a COPY, so we don't actually modify the template $line = $getALine; #fix the topic title $line =~ s##Slideshow Title Here#i; $line =~ s###i; #fix the slide title $line =~ s##Slide Title Here#i; $line =~ s###i; #fix the previous tag $line =~ s##"javascript:alert('this will show the previous slide')"#i; #fix the next tag $line =~ s##"javascript:alert('this will show the next slide')"#i; #fix the top tag $line =~ s##"javascript:alert('this will show the contents slide')"#i; #fix the items tag if ($line =~ m##i){ $line = ul(li(["item one", "item two", "item three", "item four", "item five"])); } # end 'items' if $preview .= $line; } # end foreach return $preview; } # end templatePreview