Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Weber Files Explained

Keywords:   .web .weber files

Question:

I'm in the process of learning Webbatch.

I have used Winbatch and is very please with the product. On the other hand, I'm still very confused about this whole process of where to put things, the difference between .Web and .Weber files. I need help....

Answer:

The best information about how weber files interact with WebBatch is at:

http://www.bulldogbeach.com/weberfiles/

Also the readme.txt file is very important, but here's a quick overview:

  1. .web files are interpreted by WebBatch, just like WinBatch files. They usually live in a directory within /webcgi/

  2. weber.web is the weber file interpreter, and it's written in WebBatch, so it likes to live in a directory within /webcgi/ (for example, /webcgi/myproject/weber.web)

    The weber file "verbs" are WebBatch files, so they have a .web extension. They want to live in the same directory as weber.web (for example, /webcgi/myproject/url.web). The only difference between a "verb" WebBatch file and a regular WebBatch file is that it expects certain parameters to be passed to it, and then it usually writes something to the HTML output using webout(). Other than that, they're just standard WebBatch files. You can write your own verbs pretty easily.

    weber files are processed by the weber.web program, which wants them to live in a directory inside the directory where weber.web is (for example, /webcgi/myproject/weber/someweberfile.weber)

  3. The only thing that's really tricky about this is that weber.web wants to know where it lives, because it uses that information to build urls and find its "verb" files and the weber files. That information is >hard-coded< into the current version of weber.web. Look for a line that says:
    
         cd='myproject'
    
    and change it to say:
    
         cd='nameofyourfolder'
    

About weber files:

Basically they usually look pretty much like HTML, with one addition: some things appear in {curly braces}. Anything outside of {curly braces} is ignored by the weber.web processor.

Anything inside {curly braces} is basically an instruction for weber.web, that tells it to call one of the "verb" routines. The "verb" routine does something; usually it uses WebBatch's "webout()" command to insert something into the HTML output, but it doesn't really have to, it could do anything WebBatch does.

If you put the name of an html file or another weber file in {curly braces}, then weber.web will go process that file and insert it into the HTML output. This lets you build websites based on templates. For example, the main template for our website looks like this:


	-----
	;currentpage subpage style format

	{header.weber?*currentpage* *style* *format*}
	<CENTER>
	<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
	<TR VALIGN=middle>
	{navbar.weber?*currentpage* *subpage* *style* *format*}
	{*currentpage*-*subpage*.weber?*style* *format*}
	{footer.weber?*currentpage* *subpage* *style* *format*}
	-----

This file creates every page on our website, in every available "style" and format.

We have 3 parameters that need to passed:

These parameters are particular to our website -- weber files don't require parameters but they make life more useful.

Then it gets our standard header file inserted, which wants some parameters passed to it. After that there's some standard HTML, and after that, our navigation bar gets inserted, then the actual page we want gets inserted, then the footer.

It's cryptic, but pretty flexible. You can do practically anything you want with this system.


Question:

What I don't understand is, WHY does {random?29} tell the server to run a WebBatch program? The servers usually are expecting some kind of #exec or cgi= type of thing to run a server program. Certainly the servers don't know what WebBatch is. This has me quite puzzled: what mechanism tells the server to look for anything in curly braces and run a _WebBatch_ program, stick the result of the program in the place of the curly braces, THEN process the HTML code....?

Answer:

The secret is in the URL for the page. For example, here's the URL for the main page on the http://webbatch.windowware.com site:

http://webbatch.windowware.com/webcgi/webbatch.exe?budu/weber.web+index.weber+main+null

  1. The "/webcgi/webbatch.exe" portion of the url is the actual mechanism to get the server to hand the request over to WebBatch.

  2. "?budu/weber.web" tells WebBatch which WebBatch file to run, in this case the weber file processor (which is written in WebBatch). The weber file processor is the program that actually parses the curly braces and calls the appropriate WebBatch subroutines or inserts the appropriate subpages.

  3. "+index.weber" tells the weber file processor which weber file to process.

  4. "+main+null" are parameters passed (by position) to the weber file ("index.weber"). In this case "main" & "null" identify sub-subpages to be inserted into the contents of index.weber during processing, but they can also be passed, set & tested like regular function parameters in a standard programming language.

Now, I can never keep these URLs straight -- they're way too long for me to remember & type by hand, and I created the dang things!

So there's a {url} verb that automatically creates & inserts the proper URL into your HTML code. The {url} verb is smart enough to adjust for the current server name & cgi directory structure. In addition to making the URLs easier to read & write in your source code, it also makes the site much more portable.

For example, the actual weber file code to create the above URL would be:


        {url?index.weber main null}

The {url} verb also knows where you like to store your gifs & jpegs, and you can easily customize it to suit your own purposes. PS: I suppose there's probably a way to configure some web servers to automatically hand every request over to a particular CGI program (ie, webbatch.exe), but that would depend on your server software. This technique works for any server.


Article ID:   W12461
Filename:   Weber Files Explained.txt