merge

This script merges an HTML template file with an HTML content file. Use of this script can be helpful in maintaining a group of files, each having different content, with a common look and feel which may change over time.

How to call the script

This script can be called with three different types of URL's:
  1. A path and two arguments, allowing you to specify both the template file and the content file: http://host/cgi-bin/script/~user/path?template?content
    Question marks separate the path and two arguments. First is the common part of the path to both the template file and the content file. Second is the part of the path unique to the template file, and third is the part of the path unique to the content file.

    For example, if the URL for the template file is http://host/~abc0/my/stuff/one/template.html and the URL for the content file is http://host/~abc0/my/stuff/two/content.html the script should be called with the URL http://host/cgi-bin/script/~abc0/my/stuff?one/template.html?two/content.html

  2. One argument, to ask for help: http://host/cgi-bin/script?help
    (It only matters that there is one argument following a question mark; the argument can be anything.)

  3. No arguments: http://host/cgi-bin/script/~user/path/content
    This is simply shorthand for http://host/cgi-bin/script/~user/path?template.html?content which assumes that the template file resides in the same directory as the content file, and that the template file is called template.html

The template file

The template file is a standard HTML page, with placeholders where content is to be inserted. The placeholders take the form #insert-html=label, where #insert-html= indicates that something should be inserted, and label is what should be inserted.

Simple Example

Here is a simple example of a template file. Note that the file is a complete, valid HTML file.
    <!DOCTYPE HTML PUBLIC "-//W32/DTD HTML 3.2//EN">
    <HTML>
    <HEAD>
    <TITLE>
    #insert-html = TITLE
    </TITLE>
    <BASE HREF="http://$ENV{HTTP_HOST}/~abc0/my/stuff/index.html">
 
    <!-- The BASE statement is necessary if any relative links are
    in the template or content files. Without the BASE statement, those
    links would be relative to the CGI directory -->

    </HEAD>
    <BODY>
    <IMG SRC="images/logo.gif">
    #insert-html = CONTENT
    <P>
    <FONT SIZE=-1>
    #insert-html = MAINTAINER
    #insert-html = DATE
    </FONT>
    </BODY>
    </HTML>
The statement #insert-html=label can be can be indented or inside HTML comments (<-- #insert-html=label -->), but must be on a line by itself.

More Realistic Example

Since the whole point of this script is to be able to maintain a look across multiple pages, more than likely, you'll have a fairly complex template.

Source

    <!DOCTYPE HTML PUBLIC "-//W32/DTD HTML 3.2//EN">
    <HTML>
    <HEAD>
    <TITLE>
    <!-- *** Insert title *** -->
    #insert-html = TITLE
    </TITLE>
    <BASE HREF="http://www.lehigh.edu/~ludoc/offcampus/index.html">
    </HEAD>
    <BODY BGCOLOR="#FFFFCC"
    TEXT="#000000" LINK="#008000" VLINK="#800000" ALINK="#FF0000">
    <TABLE>
    <TR>
    <TD>
    <IMG SRC="images/30x30.gif" ALT="">
    </TD>
    <TD>
    <A HREF="http://www.lehigh.edu">
    <IMG SRC="images/lu.gif" ALT="Lehigh University" BORDER="0"></A>
    </TD>
    </TR>
    </TABLE>
    <IMG SRC="images/rul_hori.gif" ALT="">
    <TABLE>
    <TR>
    <TD VALIGN=top>
    <BR>
    <IMG SRC="images/ppp.gif" ALIGN="top" BORDER="0" ALT=""> 
    </TD>
    <TD>
    <BR>
    <!-- *** Insert content *** -->
    #insert-html = CONTENT
    <P>
    <FONT SIZE=-1>
    <!-- *** Insert maintainer and date *** -->
    #insert-html = MAINTAINER
    #insert-html = DATE
    </FONT>
    <P>
    <HR>
    <FONT SIZE=-1>
    <A HREF="http://www.lehigh.edu/ir/">
    <IMG SRC="images/ir3.gif" ALIGN="top" BORDER="0" ALT="">
    Back to Information Resources</A>
    </FONT>
    </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    

Object

Here's what the template looks like if viewed directly (images will probably be broken, and I've removed HEAD elements):
Lehigh University


#insert-html = CONTENT

#insert-html = MAINTAINER #insert-html = DATE


Back to Information Resources

The content file

The content file contains HTML, and can be a standard HTML page. The only elements of the content file which are used by this script are the ones between #start-html=label and #end-html=label pairs. This pair of delimiters shows the beginning and the end of the block to be inserted at the place #insert-html=LABEL in the template file.

Sample Source

Note that anything in the content file which is not between #start-html=LABEL and #end-html=LABEL pairs is only there for convenience while viewing and editing the content file. Like with template files, the #start-html=label and #end-html=label statements can be can be indented or inside HTML comments (such as <-- #start-html=label -->), but each statement must be on a line by itself.
    <!DOCTYPE HTML PUBLIC "-//W32/DTD HTML 3.2//EN">
    <BODY>

    #start-html = TITLE
    Lehigh Off-Campus Internet
    #end-html = TITLE

    <P>

    #start-html = CONTENT
    <H1>Lehigh Off-Campus Internet</H1>

    Welcome to Lehigh University Information Resources's home page for 
    Lehigh Off-Campus connectivity.
    <P>

    <HR>

    <H2>Connection Software</H2>

    Check out our <A HREF="matrix.html">software chart</A> to find out
    what software
    is available for making connections to Lehigh. Here, you can 
    find out what versions are current, get more information about the
    various packages, download most of the software, and find installation
    and troubleshooting guides.
    <P>

    #end-html = CONTENT
    <P>

    #start-html = MAINTAINER
    drb2@lehigh.edu
    #end-html = MAINTAINER
    <P>

    #start-html = DATE
    97November20
    #end-html = DATE

    </BODY>
    </HTML>

    

Sample Object

#start-html = TITLE Lehigh Off-Campus Internet #end-html = TITLE

#start-html = CONTENT

Lehigh Off-Campus Internet

Welcome to Lehigh University Information Resources's home page for Lehigh Off-Campus connectivity.


Connection Software

Check out our software chart to find out what software is available for making connections to Lehigh. Here, you can find out what versions are current, get more information about the various packages, download most of the software, and find installation and troubleshooting guides.

#end-html = CONTENT

#start-html = MAINTAINER drb2@lehigh.edu #end-html = MAINTAINER

#start-html = DATE 97November20 #end-html = DATE