WebProcessor 1.3a

By Seumas McNally , copyright 1998 Longbow Digital Arts.

Introduction:

This program originated from a combination of my dislike for supposed "WYSIWYG" HTML editors, and a desire to make manual web site creation as easy as possible. I prefer tables over frames on web sites, but the problem with tables is that when creating menu bars and titles on multiple pages, the table code has to be duplicated on every page, making it initially time consuming doing the cut and paste, and also very hard to globally update if stylistic changes are needed.

WebProcessor takes the drudgery out of manually creating a multi-page web site by allowing you to "compile" source files and header files into resultant .html files quickly and easily. You can define global options or write navigation menu code in one file, and it can be easily "included" in any number of other HTML files. Converting an existing site to WebProcessor source form is easy, as the source and header files are really just plain HTML files with extra commands and comments added that WebProcessor reads and filters out. If you take an existing file named "foo.html", rename it to "foo.src", and run WebProcessor on it, the new "foo.html" file produced should be identical to the original. From there you will be able to add WebProcessor directives to the .src file to super-charge the structure of your web site.

Program Usage:

Clicking the "single file" button will let you select one .src source file to be compiled into an .html file. Clicking the "Compile all files in Source directory" button will search for and compile all files ending in ".src" in the Source directory into .html files. You can select the Source directory by clicking the button to the right of the Source directory name display. If you check the Scan Recursively box, all sub-directories of the Source directory will be searched for .src files as well. Note that when e.g. "foobar.src" is compiled, the output will be written to "foobar.html", overwriting anything that was previously in foobar.html. When using WebProcessor to create .html files, do not edit those resultant .html files, only edit the .src and .inc files that created them. To put your web page on the internet, you only have to upload the generated .html files, not the .src and .inc files.

Normally the finished .html files go to the same directory where their .src file was located, but you can override this by specifying an Output directory and checking the Use Output Directory box, which will cause all .src files compiled in the Source directory to write their output .html files to the specified Output directory. When scanning sub-directories of the Source directory recursively, the relative paths are used for the Output directory, e.g. if your Source directory is c:\source\, your Output directory is c:\web\, and there is a file c:\source\foo\bar.src to be compiled, the output will be written to c:\web\foo\bar.html. Note that the c:\web\foo\ must already exist, as it will not be automatically created. Also note that the Output directory does not affect compiling single files, which will always be output to the same directory as the source file.

If you want to organize all your .inc header files into one directory for easy management, you can do that simply by selecting a Global Include directory. When an #include directive is encountered in a source file, the file to be included will first be looked for in the directory with the source file, and if not found there it will then be looked for in the Global Include directory. If the include file can't be found anywhere, an error will be returned.

Note that your included files could be named ".txt", ".htm", or something else, it's up to you. To compile source files named other than ".src" into output files named other than ".html", you will have to use the command line version of the WebProcessor (wc.exe) for now. wc.exe can be used to compile any generic text files into larger output files for any special needs you might have.

New in version 1.3a: You can now select the output file extension (".html", ".htm", ".asp", ".shtml", ".txt", etc.) in the GUI, though the input source files must still be named ".src".

Command Directives:

All WebProcessor specific directives are preceded by a "#" (pound sign) character as the first character on the line. A "#" followed by a space or a second "#" is treated as a comment, and is ignored and filtered out of the output. All command directives must be lowercase.

#include "<filename>"

Includes the contents of <filename> at that position in the source file. It is essentially an automated copy and paste, except that it does NOT alter any of the source files, it only changes what gets output to the resultant .html file. Files that are included can include other files, and so on. Circular inclusion (A includes B which includes A) will be quietly ignored. Example usage:
#include "header.inc"
#include "special/menubar.inc"
The included file is first looked for in the directory where the file with the #include directive resides, then in the directory where the original source file is located. To include a file located in the parent of the directory with the current file you would do e.g. #include "..\header.inc".

#define <symbol> <value>

Sets the value of <symbol> to equal <value>. The symbol, or variable, may be any contiguous string of letters (a-z,A-Z), numbers (0-9), or underscores ("_"), without spaces or other punctuation. Symbol names are case sensetive, so e.g. "foo" is different from "Foo". The value is everything after the symbol until the end of the line, and can include spaces. After being defined, whenever the symbol is encountered in the source that follows (including files that are "included") it is replaced with its defined value, in the same manner you would do a Search and Replace in a word processor. As with includes, defines do not modify your source files, they only change the output files. To avoid confusion, you may want to place underscores before and after all of your defined constants, e.g.
#define _Title_ My Web Page
#define _Foo_ I hope you enjoy your stay at
Welcome to "_Title_"!  _Foo_ _Title_!

outputs:

Welcome to "My Web Page"!  I hope you enjoy your stay at My Web Page!
There are a number of pre-defined symbols that you can use in your source or header files (they can be redefined or undefined if required). Note that they are only "current" as of the time the source files are compiled into an .html file, so you can use them to e.g. create a "Last updated on:" line on a web page. Note that pre-defined symbols will always consist of all uppercase letters with underscores before and after, so you should avoid naming your own defined symbols in the same style.

NameDefined To
_INFILENAME_The path and filename of the source file being compiled
_INFILETITLE_The filename (without path) of the source file being compiled
_OUTFILENAME_The path and filename of the output file being created
_OUTFILETITLE_The filename (without path) of the output file being created
_WEEKDAY_Current day of the week (Monday, Tuesday, etc.)
_MONTH_Current month (January, February, etc.)
_DAY_Current day of the month
_YEAR_Current four digit year
_TIME_Current time as of compilation (e.g. "11:03 PM")

#undefine <symbol>

Removes the most recent definition of <symbol>. If the symbol was defined more than once, the next most recent definition will become current. If the final definition is undefined, then the symbol will revert to having no value and will not be replaced if encountered in the source from then on.

#killdefine <symbol>

Completely undefines <symbol>, no matter how many times it has been defined. You can use this when you want to make sure that a symbol is not defined for an upcoming conditional block.

#fileinfo "<filename>"

New in version 1.3: This directive lets you automatically include information about a data file or graphic image into your web page. The file is searched for in the same locations that the #ifexists directive checks. As soon as this directive is encountered, the following defined variables will be set internally:

NameDefined To
_FILENAME_The same name that you supplied in the #fileinfo directive
_FILETITLE_The file name by itself (without path, if any)
_FILEB_File size in Bytes
_FILEK_File size in Kilobytes
_FILEM_File size in Megabytes (xx.yy format)
_FILEW_If a .GIF or .JPEG, the width of the image in pixels
_FILEH_If a .GIF or .JPEG, the height of the image in pixels

It's easy to autmatically generate the appropriate width and height parameters for a .GIF or .JPEG/.JPG image to improve page loading times, or to display the size of a file available for download, e.g.

#fileinfo "arrow.gif"
<img src="_FILENAME_" width=_FILEW_ height=_FILEH_ alt="_FILENAME_">

#fileinfo "downloads/MyProg.zip"
<a href="_FILENAME_">Click to download _FILETITLE_ (_FILEM_ megabytes).</a>

#ifdef <symbol>
#ifndef <symbol>

Starts a compile-time conditional "if" block, based on whether <symbol> is currently defined. #ifdef is true if the symbol is defined, and #ifndef is true if the symbol has not been defined. If the conditional is false, all the lines up until the matching #else or #endif are treated as comments and are skipped by the compiler. If true, all the lines up until the matching #else or #endif are compiled as normal, but if there is an #else then any lines between it and the #endif will be skipped. Conditional blocks can be nested, but all #ifs must be paired with an equal number of matching #endifs within each individual source or header file.

#ifexists "<filename>"

New in version 1.3: Starts a conditional block based on whether or not the specified file exists on your hard drive. The file is first looked for in the directory that contains the current file being processed (possibly an included file), and then in the directory where the source file that is being compiled is located. Note that #ifexists will not find files in your Global Include directory, if one is set. e.g.
#ifexists "header2.inc"
#include "header2.inc"
#endif

#else

Used after an #if but before an #endif, it starts a block of code that will only be compiled if the preceding conditional was false, and not compiled if the conditional was true.

#endif

Ends a conditional block.

Advanced Techniques:

New in version 1.3: If you want to concatenate (without spaces) a symbol's value with other text made up of valid symbol characters (or other defined symbols), you can use the vertical bar "|" character between them instead of a space. When encountered before or after a defined symbol name, the "|" character will not appear in the output file. In all other instances a "|" in your source file will be unaffected. e.g.
#define _Path_ images/nifty/

##Wrong.
<img src="_Path_ball.jpg">
##Wrong too.
<img src="_Path_ ball.jpg">
##Right.
<img src="_Path_|ball.jpg">

outputs:

<img src="_Path_ball.jpg">
<img src="images/nifty/ ball.jpg">
<img src="images/nifty/ball.jpg">

New in version 1.3: Defined variables can now be used inside of WebProcessor directives (lines starting with the "#" character). To avoid confusion, symbols will only be expanded to their defined value if they have vertical bar "|" characters placed on both sides. If a symbol's value is the name of another symbol, it will be properly dereferenced automatically outside of a directive line, but inside a directive you will have to use an extra set of "|" characters around the symbol for each level if indirection. The same also holds true when using single "|" characters to concatenate symbols normally. e.g.

#define _foo_ animage.gif
#define _path_ graphics/

#define _file_ |_path_||_foo_|
##_file_ now contains the value "graphics/animage.gif".
#fileinfo |_file_|

#define _fileref_ _file_
##_fileref_ contains the value "_file_", so must be doubly
##dereferenced when used in directives.
#fileinfo ||_fileref_||

Example Pages:

The best way to learn is by example, so have a look at the source files in the Example directory. They are regular text files (with funny extensions) that you can open up in your favorite text editor. Notepad and Wordpad or Write work fine. To see the mini-web site they create, run WebProcessor, click on the button to select a Source file directory, go into the "Example" directory, click Open, then click Compile all files in Source directory. You should get no errors, and a report that the files were compiled. Now try opening up the finished HTML files and comparing them with the source and header files that created them.

Bugs and Features:

If you find any bugs in WebProcessor, or have an idea for a feature that you'd really like to see implemented in the next version, please drop me a line and let me know. I can be reached at the following email addresses:
longbow@sympatico.ca
sfmcnally@bix.com
longbow@longbowdigitalarts.com

If you're having trouble getting WebProcessor to do what you expect it should do, the first thing you should do is have a look at the produced HTML file in a text editor. That should show you exactly what WebProcessor is doing to create the file, and perhaps what you're doing wrong in your source files. If after that it still won't behave, drop me a line, and I'll either get it fixed or try to add the functionality you need. WebProcessor is here to make your life easier!

Shareware:

WebProcessor is Classic Shareware. That means that you're being given the opportunity to try out the full, uncrippled version of the software, but if you use it, like it, and want to encourage the development of new versions with more features in the future, you are asked to please show your support by sending $10.00 U.S. (suggested amount, U.S. and Canadian checks or money orders preferred) to:
  Seumas McNally
  4 MaryJane Street
  Providence Bay
  Ontario, P0P 1T0
  Canada
I hope you find the program useful!