WebDNA

Introduction

WebDNA is the new technology introduced in WebCatalog 2.0 that adds incredible power to any web site. It lies somewhere between HTML with its simple text file tags, and SQL, with its ability to construct sophisticated database searches and output formatted results. By enhancing the best aspects of multiple technologies, WebDNA gives webmasters greater freedom to design dynamic, automated web sites.

What follows is an introduction to using WebDNA at your web site. This does not define the full breadth of the technology. Instead it describes some common web site functions that, before WebDNA, required you to manually update pages or install multiple CGI's. WebDNA can be used for very complex functions. These sophisticated functions are beyond the scope of this introduction. Unless otherwise noted, all WebDNA tags are case insensitive. By convention, tags are usually entered as lower case. The one exception to the case insensitivity is the HTML tag "<!HAS_WEBDNA_TAGS>" that usually appear in HTML files containing WebDNA. This tag must be entered with capital letters.

 

Part I

WebDNA Installation

WebDNA requires a Windows, Macintosh or UNIX web server. Most servers that support CGIs and/or plug-ins should work without any trouble. Consult the individual product's owners manual for information on server installation and CGI setup. Run the WebDNA installer in order to install WebDNA on your server.

In order to access WebDNA from your web server, configure a Suffix Mapping that invokes WebDNA whenever a file ending with a certain extension is accessed. For the purposes of this introduction, and the included examples, map all ".tpl" extensions to WebDNA. Consult the Web servers owners manual if you are unsure how to do this. If you are using WebSTAR, run the "Configure WebSTAR" application that is included to automatically set a ".tpl" suffix mapping.

Administration

Lnk to WebDNA's Administration page to confirm its default settings. Using a web browser , go to the URL http://www.yourdomain.com/WebCatalog/index.html and select "Administration". Type the name or IP address of your particular server instead of www.yourdomain.com. You will be asked to enter the administration username and password. By default, the username is "admin" and the password is "admin". You should immediately select "Security" from the administration home page in order to change your admin password. From the security page click "Show All Users". The only user should be "admin". Click "Edit" and change the password to one of your choosing. From now on, you must enter "admin" and your new password when performing any administration functions.

 

Part II

Your First WebDNA Page

Let's start with something very simple -- putting today's date onto a web page. Normally your web server software sends the HTML files on your disk without changing it in any way. So if you wanted to put today's date on a page you would have to manually edit that page every day. With WebDNA, all pages on your site can display "dynamic" information that changes from time to time, without manual intervention from you. We call these special pages "templates", and they look a lot like plain HTML, but with some special tags we call "WebDNA" tags.

Create a text file on your web server called Today.tpl and type the following into it:

<!HAS_WEBDNA_TAGS>
<html>
<body>
Today's date is [date]
</body>
</html>

Now use your web browser to view the URL http://yourserver/Today.tpl -- notice that today's date is displayed instead of the literal text [date]. Note: If you see the word [date] instead, then that means you don't have your web server's Suffix Mappings set properly to cause WebDNA to intercept all files that end in ".tpl". WebDNA won't work until you correct this.

WebDNA works by looking for any text inside square brackets, like [date], [time], [ThisURL] (and dozens more) and replacing that text with the appropriate information. WebDNA does not change the text files on your disk -- it creates new HTML on-the-fly each time someone visits a URL at your site. WebDNA does this so quickly that you can comfortably set up your web server to send all HTML through WebDNA without any noticeable slowdown.

 

Part III

Common Headers and Footers

Your next use of WebDNA will be to organize common components of your web pages (such as company headers or footers) into separate files that can be updated easily in one place. The following files are assumed to be in the root web server folder. Create a new text file (using a text editor or HTML layout application) called header.inc. Enter some HTML like the following that describes your company header:

<center><h1>WebDNA Software Corp.</h1></center>
<center><b>HOME | PRODUCTS | SUPPORT | STORE</b></center>

The ".inc" file extension is a convention only -- it is short for "include", but you may name the file anything. Notice that the standard HTML headers and footers (<html>, <body>, etc.) are left out of the file. The contents of this file will be inserted in the middle of other HTML pages that already have those HTML tags. If you are using an HTML layout application that automatically places these HTML codes, open the file with a text editor after you have designed the header, and remove them manually. This may seem like a lot of work, however, this is only required for the included HTML files and not all the files at your site.

Next create your company home page that will include this header. Create a file called home.tpl. Note that we use the ".tpl" extension so the page is served via WebDNA. Eventually you may decide to set up your web server so that all ".html" files are sent through WebDNA, but for simplicity in this tutorial we will assume that only ".tpl" files are used. Design the body of the page like the following:

<!HAS_WEBDNA_TAGS>
<html>
<body>
[include file=/header.inc]
<p>Welcome to WebDNA Software Corp's home page. Browse our site and then
purchase immediately from our online store.
</body>
</html>

The "<!HAS_WEBDNA_TAGS>" comment is used to explicitly state that the file contains WebDNA tags and should be processed accordingly. WebDNA has a preference setting that you can change so that this comment is not needed; however, it is a good idea to require this comment since it prevents WebDNA from interpreting pages that do not contain any WebDNA tags. Although this comment can be anywhere at the beginning of the page, by convention it is placed before the beginning "<html>" tag.

WebDNA's tags look like HTML tags except they are enclosed with square brackets ( '[' and ']' ) rather than angle brackets. Like HTML tags, WebDNA tags sometimes require parameters that describe or modify their behavior. The WebDNA tag that we are using is [include]. [Include], as you might suspect, inserts the contents of another file in place of the tag. The file that should be included is determined by the value of the "file" parameter. The value in this case is "/header. html". The file is specified in the standard URL manner: beginning the path with a slash '/' means you start from the root Web server folder, otherwise it is relative to the current location. At this time you may not specify an include file from another server (i.e. [include http://www.domain.com/file.inc] won't work because the included file must reside on the same disk as WebDNA itself).

Use your web browser to view the URL http://www.yourdomain.com/home.tpl. The page you see is the combination of the header and your body text.

Dynamic HTML

Although the last example dynamically builds the HTML file that is returned to the user, the data that is displayed each time doesn't change. WebDNA includes many ways to dynamically create the content of a page so it changes automatically. The easiest way to provide this functionality is by including the values of standard WebDNA variables. Using the home page we created in the last example, we will include the date and time the page is accessed. Although this is very simple, minor tweaks like this make your site seem much more professional.

After the WebDNA text in the last example, add the following tags:

<center>[date], [time]</center>

Thus the home page now looks similar to the following:

<!HAS_WEBDNA_TAGS>
<html>
[include file=/header.html]
<center>[date], [time]</center>
<body>
<p>Welcome to WebDNA Software Corp's home page. Browse our site
and then purchase immediately from our online store.
</body>
</html>

Many WebDNA tags do not require any parameters and are replaced by their value. The text that is replaced depends on the tag. In addition to [date] and [time], you may include the IP Address of the machine accessing the page, the page that referred you to this one, a random number, or many other more.

Showing and Hiding HTML

Next we will add a special employees-only link to the home page. WebDNA provides many ways to protect pages, or portions of a page, from specific visitors. One of the basic methods is by showing or hiding portions of HTML. Some WebDNA tags enclose and act upon a block of text. This is very similar to the way the HTML "<body>" tag encloses the body of an HTML file. In order to show our employees-only link to people internally, but hide it to the outside world, we will enclose the link with the WebDNA [showif] context. A context is the WebDNA term for enclosing tags. Like the ending HTML tags, the ending context tag is the name of the context preceded by the forward slash. Since these enclosing tags may be nested, the result of the specific context may depend upon an enclosing context. Add the following WebDNA text before the ending "</body>" tag (substitute the first three numbers describing your IP address for the one given).

[showif [ipaddress]~207.067.226]
<a href="employee.tpl">Employee-only link</a><br>
[/showif]

First notice how you can use WebDNA tags anywhere in a WebDNA expression. The [showif] context has a single parameter, a comparison, that decides whether to show the enclosing text or not. In this example, you are comparing the first three numbers of the visitors IP address to your company's IP address. The tilde character '~' is used to specify a "begins with" comparison. It is important not to have any extra space characters in the expression (just one between the "showif" and the beginning of the comparison). Also, the IP address is always "normalized" by WebDNA with preceding 0's so that each number is three characters long.

Password Protection

The last thing we will do in this section is show how WebDNA can be used to provide integrated password protection for your Web site. Even though the employee link is only visible to people inside your organization, you still want to prevent people from linking directly to the employee page. Create a page called employee.tpl. At the top of the page include the following WebDNA text:

[protect admin]

Although it doesn't have to be in a specific location, it is a standard convention to precede the beginning "<html>" tag with the [protect] tag. The [protect] tag takes one parameter: the group(s) that is able to view the page. WebDNA has a special database called Users.db that is used to describe the username, password, and group(s) for individuals at your Web site. Administration of this database can be done via the built-in administration page mentioned earlier.

Any WebDNA page that contains the [protect] tag requires that the incoming username and password be in the Users.db database. If that person isn't found, the standard password dialog box is shown on the client side so the visitor has a chance to enter a proper password.

The employee page looks something like the following:

<!HAS_WEBDNA_TAGS>
[protect admin]
<html>
<body>
<p>This is top secret employee information.
</body>
</html>

Link to http://www.yourserver.com/employee.tpl. If you haven't restarted your Web browser since performing the WebDNA administration functions earlier, you won't be asked for a password. Quit your browser and link to the employee page again. This time you should be asked to enter a username and password. Enter "admin" and your new password to view this page.

 

Part V

Conclusion

This introduction should make you familiar with a few of the features of WebDNA. As mentioned at the beginning of this document, it is not meant to describe the breadth of capabilities. However, you should be familiar enough with the technology to use the tutorials and reference contained in the manual.