This is example 8 as described in the Wsmake User Manual.

It would be good to read examples 1-4 before going through this example.
So read them before reading this one.

We cover cgi scripts in this example.

This example can be found in the doc/examples/ex8/ directory of the source
distribution.

CGI scripts need special treatment in wsmake. Note that we are not talking
about a webpage pre-processor (like php,mod_perl) here. We're talking about
a shell script, perl script, or some other program that prints it's own

Content-type: text/html\n\n

At this point it is assumed that the reader understands what that line
means. If not, I recommend reading a book or webpage on building CGI
scripts before continuing.

With the way wsmake works, it prepends and appends data to the source file
and puts the result in the output area. But we can't do this with a CGI
script. So what we can do is tell wsmake that a certain Page is a CGI type,
and instead of prepending or appending, it puts all of the data that would
have been prepended into a header file, and all of the data that would have
been appended into a footer file. Then, the CGI script can read and print
out those two files at the beginning and end of it's processing. Another
nice thing we can do is parse the CGI script for SubTags just like a regular
Page, but this is optional of course.

In this example we are going to use a simple perl script named html/index.cgi.
It would be useful if you had perl installed so you can see what the output
would look like. (go to www.perl.com for perl)

There are 3 things to do in order to get a CGI script configured to work
with wsmake:
  Set the header and footer tagnames
  Set the page type
  Set the header and footer filenames

Setting the header and footer tagnames allows for wsmake to replace these
tagnames with the filenames of the header and footer. In our example, the
"source" perl script tries to open "<headerfile>" and "<footerfile>". So
we define the following in the PageGroup section:

  header_tagname "<headerfile>"
  footer_tagname "<footerfile>"

Now we need to tell wsmake that our particular Page is a CGI script. (that
is, any page we do not want to prepend or append the header and footer to)
This is done by using the page_type attribute in the Page section:

  page_type CGI

Now we are almost done, as it stands, wsmake will by default use the
filenames "header.html" and "footer.html", but it is better to specify
your own filenames:

  cgi_header "index-header.html"
  cgi_footer "index-footer.html"

These files will be created in the same directory that the script is in.
And the full filename, including the output directory, are what replace
"<headerfile>" and "<footerfile>" when the script is parsed.

Ok, this is the end of example 8.
