WebWarp HTML Support

WebWarp®
by Morgan Davis

WebWarp is an application written in Perl that allows greater control, convenience and flexibility in generating web pages. Its document templates contain a mixture of special commands and HTML instructions.

In its most simple mode, WebWarp's warp engine scans directories looking for files ending in .tmpl and produces an .html version of the file containing the warped contents. WebWarp also supports Server Side Include (SSI) source templates that end with a .stmpl extension, generating the coresponding .shtml output file.

However, WebWarp's advantages include more than just generating custom web pages in preprocessor fashion (otherwise known as warping). It can use a configuration file that describes the attributes of entire web sites. (A site is a symbolically named directory hierarchy).

For example, a webmaster can tweak an attribute in the configuration file, say a background color, warp the site with one command, and it is completely rebuilt with the new attribute. Libraries of external functions can be written in Perl to extend WebWarp's repertoire. Again, change or add a new function, warp your site, and the global change takes effect.

Because it can be easily extended, a single WebWarp function could generate a massive amount of HTML, duplicated in scores of HTML files. (Before HTML frames, people would have killed for this capability). Unlike static frames of HTML, such functions also can know the identity of the page being warped in order to generate customized page-independent output (e.g., "do this" most of the time, but "do that" only when this page is the home page).

WebWarp's daemon mode puts it into the background to monitor an entire hierarchy of sites and regenerates pages automatically. In daemon mode, pages can be assigned mandatory update periods or can be updated only when source templates change (ala make). The webmaster has complete control over scheduling.


WebWarp Syntax

WebWarp commands are fashioned as HTML comments with unique characters that look like old-style Perl function calls. For example:

<!-- &function(arguments); -->

The formatting is quite precise so as to provide a wholly unique pattern detected by WebWarp.


Built-In Functions

WebWarp includes built-in functions listed in the table below. However, WebWarp can be easily extended by adding libraries of custom Perl scripts for user-defined functions.

Function Description
bigcaps Sets type in bigger caps than smallcaps.
dummytext Generates random Latin verbiage to fill space.
eval Inserts evaluated Perl experssion.
image Inserts an image with sizing attributes.
imagemap Creates standard and client-side imagemap references.
include Includes a file into the warp process.
pageindex Generates a hierarchical index of warped pages.
require Loads a Perl function library.
set Sets attributes for the current page.
smallcaps Sets type in small caps.


bigcaps("text", size)

Sets type in bigger caps than smallcaps. This function allows you to create headline-style phrases in capital letters, a popular style first used by Netscape, but one which is tedious to typeset directly in HTML. The size argument is the SIZE attribute for the <FONT> tag for the initial capital letters. Example:

<!-- &bigcaps("This is an Example of BigCaps", 4); -->

generates the following:

THIS IS AN EXAMPLE OF BIGCAPS


dummytext(length)

Generates random Latin verbiage to fill space. This is handy for pushing out blocks of text to test tables or generally dummy up a page before actual copy is inserted. The amount of text is controlled by length:

<!-- &dummytext(200); -->

generates the following:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tati.


eval(expr)

Inserts evaluated Perl expression. The result of evaluating the Perl expression expr is inserted into the HTML code. This can be used to obtain virtually any information that can be accessed through Perl.

<!-- &eval(`uptime` . "<br>" . $ENV{'TERM'} . "<br>" . scalar localtime); -->

generates the following:

5:38PM up 35 days, 20:53, 4 users, load averages: 0.25, 0.22, 0.23
vt200
Fri Nov 22 17:38:58 1996


image("picture", "alt", border, "extra")

Inserts an image with sizing attributes. Use this function to include an image with automatic HEIGHT and WIDTH sizing. picture refers to a picture file. GIF, JPEG, and other popular formats are supported for auto-sizing. If included, alt is used to define the ALT attribute, border the BORDER attribute, and extra to include custom IMG tag attributes such as HSPACE.

<!-- &image("picture.jpg", "My Family", 0, "HSPACE=5"); -->


imagemap("picture", "map", "name", "alt")

Creates standard and client-side imagemap references. picture is the name of a picture file. map refers to a standard .map file which is parsed and the coresponding client-side MAP tags are inserted. name is required in order to reference the map for client-side support. If included, alt is used to define the ALT attribute.

<!-- &imagemap("picture.jpg", "family.map", "family", ""); -->


include("file")

Includes a file into the warp process. file is a pathname to a file to include. If the pathname is partial, it is searched for in the directory of the source file. Files brought into the warp process are parsed for WebWarp commands and handled accordingly. Any other data is inserted into the output file.

<!-- &include("fizzbin"); -->


pageindex("site")

Generates a hierarchical index of warped pages. site is an identifier in the [site_dir] section of the warp.conf file which points to the base directory of the site hierarchy.

<!-- &pageindex("homeport"); -->


require("list")

Loads a Perl function library. list is a list of one more library names separated by commas. This is akin to the Perl function by the same name which is used to pull in Perl code, thus the location of required files must exist in Perl's library include paths. Use this before referencing external WebWarp commands found in your own libraries.

<!-- &require("morgan,headline,whatsnew"); -->


set("variable", "value")

Sets attributes for the current page. This function can be used to assign a value to any arbitrary attribute name, either one used by WebWarp itself, or by external functions. Attributes that WebWarp uses are:

Attribute Values Explanation
always 0 or 1 If the refresh attribute is set, this attribute can be used to force WebWarp to warp the page upon the next refresh interval regardless of its modification state.
data Unspecified Used internally to hold the .tmpl file data for pages that are periodically refreshed when the open attribute is used for additional efficiency.
open 0 or 1 Used in conjunction with refreshed pages, this attribute determines if the target HTML file should remain open while WebWarp runs in daemon mode. For pages that are always refreshed often, this can provide a performance improvement at the cost of additional memory. For an example, see HomePort San Diego which updates current date, time, weather, and other information each minute.
opened 0 or 1 Used internally to determine if the target HTML file has already been opened.
noindex 0 or 1 If true, causes the page to be excluded from pageindex output.
pageindex 0 or 1 Used internally to designate if a pageindex function is used. If true, following scanning of an entire hierarchy, all pages with this attribute set will be recreated so that a complete index can be inserted. There is no need to set this attribute manually since WebWarp will do it each time it encounters a pageindex function.
parsed 0 or 1 Used internally to determine if .tmpl file data has already been parsed for locating external WebWarp functions.
perm Perl LIST Maintained internally to hold the mode, owner, and group permissions of the .tmpl file for use when the HTML file is created.
refresh Range of seconds Defines how often the page should be automatically warped if modified when WebWarp is run in daemon mode.
reload Range of seconds Specifies how often the client-side browser will request an automatic reload of the page. This effectively inserts a META tag into the HEAD tag of the page.
update Unix clock time Used internally to hold the last time the document was updated. There is no reason to modify this attribute.


smallcaps("text", size)

Sets type in small caps. This function allows you to create phrases in capital letters, a popular style first used by Netscape, but one which is tedious to typeset directly in HTML. The size argument is the SIZE attribute for the <FONT> tag for only the lowercase letters. Example:

<!-- &smallcaps("This is an Example of SmallCaps", 1); -->

generates the following:

THIS IS AN EXAMPLE OF SMALLCAPS


Code Samples

First, here's a complete WebWarp source template:


<!-- &require("frame,nav,software"); -->
<!-- &top("New Users Home Page","Welcome Home!"); -->
	Now that your account is established, you may
	wish to obtain additional software to enhance your services.
	<p>
	<b>Just click on the icons to get free software!
	To return to this page, click the Home icon on the toolbar.</b>
	<p>
	<hr size=5>
	<!-- &nav("home"); -->
	<hr size=5>
	<p>
	<center>
	<font size=1>Best experienced with<br>
	<a href="http://www.microsoft.com/ie/"
	><!-- &image("/art/IE_ANIMATED.GIF", "", 0); --></a><br>
	Click here to start!<br><br><br>	
	<font size=1 color=<!-- &eval($frame{sidetext}); -->>
	  Copyright © 1996 CTSNET<br>A division of Datel Systems
	</font>
	</center>
<!-- &mid("bgcolor=EEF0F8"); -->
 <center>
 <!-- &software("win","Windows"); -->
 <p>
 <!-- &software("mac","Macintosh"); -->
 </center>
<!-- &bot(); -->

Now here is the resulting HTML output:


<!--
	WebWarp (C) 1996 Morgan Davis
	http://www.home.cts.com/index.html
	Mon Nov 18 13:30:10 1996
-->
<html><head><title>New Users Home Page</title></head>

<body topmargin=0 leftmargin=0 rightmargin=0 bgcolor="#C8DCF0" text="#000000" >
<font face=arial size=2 color=black>

<table cellpadding=8 cellspacing=0 border=0 width=100%>
 <tr height=60>
  <td width=200 bgcolor=white align=center>
   <a href=http://www.cts.com/><img width=144 height=26 src="/art/cts.gif" alt="" border=0></a><br>
   
  </td>
  <td bgcolor="#336699" align=right> 
   <b><font  color=white size="+2">New Users Home Page</font></b>
  </td>
 </tr>
 <tr valign=top>
  <td height=95% width=200 bgcolor="#CCDDEE" background=/art/navbg.jpg>
   <font color=black size=2>
    <b>Welcome Home!</b>
   </font>
   <p>
   <font color=black size=2>

	Now that your account is established, you may
	wish to obtain additional software to enhance your services.
	<p>
	<b>Just click on the icons to get free software!
	To return to this page, click the Home icon on the toolbar.</b>
	<p>
	<hr size=5>
	<nobr><font face=arial size="2">    <a href="http://www.cts.com/"><img width=21 height=13 src="/ctsart/point.gif" alt="" border=0 align=middle> <b><font size="2">CTSNET Home Page</font></b></a><br><br>
    <a href="http://www.cts.com/support/"><img width=21 height=13 src="/ctsart/point.gif" alt="" border=0 align=middle> <b><font size="2">Customer Service</font></b></a><br><br>
    <a href="http://www.homeport-sd.com/"><img width=21 height=13 src="/ctsart/point.gif" alt="" border=0 align=middle> <b><font size="2">HomePort San Diego</font></b></a><br><br>
    <a href="http://home.microsoft.com/access/allinone.asp"><img width=21 height=13 src="/ctsart/point.gif" alt="" border=0 align=middle> <b><font size="2">Search</font></b></a><br><br>
    <a href="http://www.homeport-sd.com/marketplace/"><img width=21 height=13 src="/ctsart/point.gif" alt="" border=0 align=middle> <b><font size="2">Marketplace</font></b></a><br><br>
</font></nobr>
	<hr size=5>
	<p>
	<center>
	<font size=1>Best experienced with<br>
	<a href="http://www.microsoft.com/ie/"
	><img width=88 height=31 src="/art/IE_ANIMATED.GIF" alt="" border=0></a><br>
	Click here to start!<br><br><br>	
	<font size=1 color=black>
	  Copyright © 1996 CTSNET<br>A division of Datel Systems
	</font>
	</center>
   </font>
  </td>
  <td height=95% width=99% bgcolor=EEF0F8>
   <table width=99%>
    <tr>
     <td>

 <center>
 <table width=80%><tr bgcolor="#336699"><td colspan=2><font size=2 color=white>  <b>WINDOWS</b></font></td></tr>
<tr><td width=50><a href="http://www.microsoft.com/ie/download/"><img width=34 height=34 src="icons/ie.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.microsoft.com/ie/download/">Microsoft Internet Explorer</a></b></font><br><font size=1>Web browser</font></td></tr>
<tr><td width=50><a href="http://www.microsoft.com/ie/download/ieadd.htm"><img width=34 height=34 src="icons/msmail.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.microsoft.com/ie/download/ieadd.htm">Microsoft Internet Mail and News</a></b></font><br><font size=1>E-mail and Usenet news</font></td></tr>
<tr><td width=50><a href="http://www.eudora.com/light.html"><img width=34 height=34 src="icons/eudoralt.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.eudora.com/light.html">Eudora Light</a></b></font><br><font size=1>E-mail</font></td></tr>
<tr><td width=50><a href="http://www.netscape.com/comprod/mirror/client_download.html"><img width=34 height=34 src="icons/netscape.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.netscape.com/comprod/mirror/client_download.html">Netscape Navigator</a></b></font><br><font size=1>Web browser</font></td></tr>
<tr><td width=50><a href="http://www.cuteftp.com/"><img width=34 height=34 src="icons/cuteftp.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.cuteftp.com/">CuteFTP</a></b></font><br><font size=1>File transfer utility</font></td></tr>
<tr><td width=50><a href="http://www.forteinc.com/getfa/download.htm"><img width=34 height=34 src="icons/agent.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.forteinc.com/getfa/download.htm">Free Agent</a></b></font><br><font size=1>Usenet news</font></td></tr>
<tr><td width=50><a href="http://www.winzip.com/"><img width=34 height=34 src="icons/winzip.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.winzip.com/">WinZip</a></b></font><br><font size=1>ZIP file utility</font></td></tr>
</table>
 <p>
 <table width=80%><tr bgcolor="#336699"><td colspan=2><font size=2 color=white>  <b>MACINTOSH</b></font></td></tr>
<tr><td width=50><a href="http://www.microsoft.com/ie/download/"><img width=34 height=34 src="icons/ie.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.microsoft.com/ie/download/">Microsoft Internet Explorer</a></b></font><br><font size=1>Web browser</font></td></tr>
<tr><td width=50><a href="http://www.eudora.com/light.html"><img width=34 height=34 src="icons/eudoralt.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.eudora.com/light.html">Eudora Light</a></b></font><br><font size=1>E-mail</font></td></tr>
<tr><td width=50><a href="http://www.netscape.com/comprod/mirror/client_download.html"><img width=34 height=34 src="icons/netscape.gif" alt="" border=0></a></td><td><font size=2><b><a href="http://www.netscape.com/comprod/mirror/client_download.html">Netscape Navigator</a></b></font><br><font size=1>Web browser</font></td></tr>
</table>
 </center>
     </td>
    </tr>
   </table>
  </td>
 </tr>
</table>
</font>
</body>
</html>


It's worth mentioning that the above samples were sucked into this page using WebWarp's eval function. This was required for maximum laziness. Otherwise, tedious typesetting in HTML is needed to protect the angle brackets from interpretation by the browser (yes, even when blocked by <PRE> tags). Here's the code:

<!-- &eval(($_, ($_ = `cat index.html`) =~ s/</&lt;/g)[0]); -->

Fortunately, only the leading angle bracket needs to be converted. Unfortunately, a second substition for ampersands is needed. But the logic to do it really hurts my brain.


© 1996 Morgan Davis. All Rights Reserved.