contents

intro
overview
requirements
cgi basics

dyno cgi
cgi headers
cgi parameters
accessing files
pipe basics
substitution basics
more substitution
table substitution

Dyno CGI: Pipes

The central cool feature of Dyno CGI is not the parsing of the input parameter list. That stuff is necessary and Dyno CGI makes it really easy for you, but the cool stuff is what it does with its Pipes, and the substitution variables they change on-the-fly.

Dyno CGI defines a base class OutputPipe. This class is able to take a character or string and process it. The base class only does two things. If the object is chained to another pipe, it sends the data to the next pipe. If there is no next pipe, it prints the data.

The power comes in the subclasses provided by Dyno CGI, and which you can write. Typically, a pipe will parse a file, process it, and pass it on for output, perhaps to the next pipe, and ultimately to the browser.

Because pipes can be chained together, a pipe can be written to do one simple parsing task. More complex operations can be accomplished by connecting a chain of pipes, each of which does part.

OutputPipe Subclasses

HTMLBodyPipe

This pipe parses an HTML file, looks for what's between <BODY> and </BODY>, and outputs that interior body data. This pipe is used by the function PrintFileBody to take a file and output just the body section. Often this pipe is chained to one that substitutes variables in a template file, allowing you to fill a template HTML file with the body of another file. This is demonstrated by Example 04.

SubstitutionPipe

This pipe lets you assign to it an array of SubstitutionAction objects. The pipe will parse its input, replacing variable markers with a call to the SubstitutionAction object assigned for that variable. In the simplest case, you can just use a TextSubstitutionAction, which replaces the variable with a string.

A variable marker is a special HTML comment, of this form:

<!--^n-->

where n is a digit 0 through 9, corresponding to the substitution string index of the strings you supplied. Essentially, this pipe lets you stick variables into your HTML file, and your CGI can then replace the variable markers with strings at runtime. Because the markers are in HTML comments, an HTML editor will leave them alone.

(The "Substitution Basics" page discusses usage of this pipe in detail.)

FieldSubstitutionPipe

This pipe is similar to SubstitutionPipe, but it's more flexible. Instead of using digits 0 to 9 to identify up to 10 variables, it uses variable markers of the form:

<!--^name-->

where name is any alphanumeric variable name string you want. Because names instead of digits are used, you aren't limited to just 10 variables. And instead of assigning a series of SubstitutionAction objects, you supply one FieldSubstitutionAction object, or a subclass. You give the FieldSubstitutionAction a VariableList object. The VariableList is basically of a set of name=value pairs, where name is a variable name and value is the string substituted for that variable.

Dyno CGI also supplies a couple of useful FieldSubstitutionAction subclasses that you can give to a FieldSubstitutionPipe:

TableSubstitutionAction is an abstract class, derived from FieldSubstitutionAction, that must be subclassed. It handles substituting to build a table.

TOCFilesTableSubstitutionAction is a subclass of TableSubstitutionAction, which reads a text file containing a one-ID-per-line table of contents, and then pulls data from one-per-ID text properties files to build the table. It's a simple way to provide a view into a sort of database that varies based on the database contents, without ever having to alter the HTML files (or the CGI code). This is demonstrated by Example 05.

(The "More Substitution" page discusses these advanced classes further.)