March 16, 2004 AL du Pisani is a South African, working at a large financial institution, where he looks after their Lotus Notes environment. He has been using computers off and an for the past twenty years. His first exposure to OS/2 was with 2.11. It is still the preferred environment, and is what he runs at home. He is also a fan of Science Fiction. If you have a comment about the content of this article, please feel free to vent in the OS/2 e-Zine discussion forums. There is also a Printer Friendly version of this page. |
|
Case Study: Redeveloping a web site with PPWizardI am a member of a South African based Science Fiction club. And the webmaster of the club's web site. In December 2003 I had some time at hand, and redeveloped the web site with PPWizard.
This case study covers my experiences. It is hoped that it would be of
help to people having a web site that have become just too much to
maintain by hand.
| |||
Why redevelop?When I took over the web site, I took it over from somebody who had taken it over from the original developer. This meant that neither myself or my predecessor knew what the original vision for the web site was, and each of us had extended it as and when required.After a couple of years, there were parts of the web site that were seriously out of date, and parts that were obsolete. Other parts were in serious need of some attention and care. I have maintained the web site using Mozilla in edit mode. This was unsatisfatory for two reasons: For one, I was unhappy with the ammount to HTML code generated, where I had no idea what the code meant and did. For another, there were a bug with the generated code, in that the background image would always be reset to the path on the development machine, and not the relative address to the image resource. This meant that I have to go in and edit the page by hand after every change done with Mozilla. The original site design was also frames based, with the home page a T shaped 3 frame design, with a graphical logo on top, a table of contents on the left, and the requisite information page on the right. I was unhappy with this design, and was looking for a non-frames based design. What I wanted to achieve
What I achievedI managed to achieve all of the above goals, to some extent.
While developing, I also made the decision to standardize all images to the PNG format, where possible. My (new) favourites icon and the page background are the only two image resources that are not in PNG format. This is a style issue more than anything else. DocumentationAs mentioned above, the documentation for HTML 4.01 is good. To understand how HTML 4.01 works, I had to read nothing more that the standard document. There were, however, one or two exceptions to this level of documentation. The DIV and SPAN tags are the two major exceptions I found.I really hated the documentation for CSS2. I always had the problem of finding the scope of where directives was valid, and where not. The main problem I had with the documentation was that all the basic directives are documented, in a basic fashion. But anything more advanced, such as how to mix and match directives to get the result you wanted, at more than basic level, was conspicious by it's absence. In the end I managed to get something working, but I was unhappy with it, and are still trying to find out how to get a table centred on a page. The PPWizard documentation fall between these two experiences. Once again, the basic elements are covered in detail. Some of the intermediate functionality are also covered. However, I found the advanced stuff to be covered in insufficient detail. Or, in other words, I could often not figure out if what I wanted to to was possible, or how to do it, using the documentation. I do not know how much of this is due to the fact that I am not a full time programmer, and need a little bit more sympatetic documentation. I do feel that more of the examples should include not only the code on what to do, but the resulting generated HTML. I do not know how much trouble that would be for the author to generate. I also found the INF format documentation for PPWizard to be much easier to use than the HTML format documentation. I have also not contacted the author of PPWizard for assistance, first trying to see if I could redevelop the site with only the supplied documentation and published articles. PPWizardSo, what is PPWizard? PPWizard is a HTML pre-processor. A program to generate HTML pages from a PPWizard template file or files. It is also a REXX pre-processor, and is written in REXX. If you can program in REXX, PPWizard is understandable. Why PPWizard? Because ever since I read some articles on OS/2 e-Zine on PPWizard, I thought that it might be useful, and help me with looking after my web site. It just took longer than I anticipated to get round to it. I installed the newest version of PPWizard available at the time, namely 03.268. (Versions 04.026 and 04.051 have since been released.) PPWizard Source filesThe two standard PPWizard file type are the template file, extention .it, and the header file, extention .ih. The template files can be regarded as source files of HTML pages. The header files are the files in which PPWizard definitions are declared for use in the template files. I created a template file for each HTML page, a shared header file, with common definitions used in all HTML pages, and a couple of page specific header files. I also created a project file, with the .ppw extention, where I declared the list of input files, the output directory, and the depends directory. I have a bit of a problem with the project file. I originally planned to have a web site structure with a set of pages in a sub directory. (Directions to various venues) However, I could not find anything in the documentation on project files that told me how to set this up the way I wanted to do it. I had to settle doing it the way the PPWizard documentation showed it done. I also could not find out how to declare each template file individually, in the project file, but had to declare all of them with a *.it directive. The output directory works well, as does the depends directory. In the depends directory PPWizard generates the dependancy files, showing how each HTML page fits together. When generating a new set of HTML pages, PPWizard checks the dependancy chain to see if any file in the chain have changed, and then generates new HTML pages only for the pages where a file have been changed. This sounds like a slow process. It is not. My 15 pages are usually generated in about 5 seconds. This include all dependency checking. PPWizard basicsAt the heart of PPwizard are 3 directives, namely #define, #evaluate, and #include. Once you understand how and where to use these three directives, you are well on your way to be able to generate new HTML pages. #defineSyntax: #define definitionName valueWith the #define directive, you declare a definition and assign it a value. This definition is then available for use elsewere. Example: #define MyName A.L. du Pisani This assigns the value "A.L. du Pisani" to the definition MyName. As you can see, the value can consist of more than one word, and may even span multiple lines. #evaluateSyntax: #evaluate definitionName calculation
With the #evaluate directive, you calculate a value and assign it to
the definition. This calculation can happen immediately, or can be
defered until needed.
Example: #evaluate LastUpdateDate FormatTime("%d %B %Y")
This calculates the date in the format "Day Monthname Year" and assign
it to the definition LastUpdateDate. The FormatTime() function is a
PPWizard macro used to calculate time variables.
You can declare each definition in each template file, but a more
common scenario is to put a number of definitions together in a header
file. To enable the template file to make use of the definitions in the
header file, it must know where to find the definitions. This is where
the #include directive is used, and it tells the template file where to
find the header file.
When PPWizard runs through the template file to generate the HTML page,
every instance of <$definitionName> is replaced by the value assigned
to the definition definitionName.
Example:
This definition have a value assigned to it, and does not change. Every
time that the definition is called up, the same value is returned.
Example:
A passed definition is a definition where the user have to pass a value
to the definition.
Example:
The variable
PPWizard inline comments start with the characters ";;". Everything
after the ";;" characters is ignored.
"\" is the line continuation character where all spaces before the
line continuation character is reduced to one, and the next physical
line is appended, without a line break.
Example:
Result: Definition MultiLine is assigned the value
"This is a multi line definition"
"%\" is the line continuation character where the next physical line is
appended, with an explicit line break.
Example:
Result: Definition TwoLine is assigned the value
It is possible to use both line continuation characters in a single
definition.
Once I started to look at my current pages, I saw that the HTML HEAD
portions was similar, and I started to look for a definition that would
cover all cases.
I ended up with the following set of definitions:
All of these definitions are stored in a common header file.
The HTML 4.01 standard recomend that the date and time of the last
update to the HTML page be inserted into the HTML HEAD. The format is
specified in ISO8601, and the specific format used is
"YYYY-MM-DDThh:mm:ssTZD". 4 digit year, 2 digit month, 2 digit day, a T
to seperate the date and time portion, 2 digit hour, 2 digit minute, 2
digit second, and a time zone designator, which for me is "+02:00"; 2
hours east of GMT.
The definition FileUpdateDateTime is the calculated definition of the
current date and time, in the above format, without the time zone
designator. This definition is used in the definition Head_Date, where
the time zone designator is added.
I have put all of the images used on the web site into an Image sub
directory. I declared the ImagePath definition once, and used it every
time I refer to an image resource. Should I need to change the path to
the Image directory, I only need to change the ImagePath definition
once to change it everywhere.
I declared a number of definitions, used only in the main HTML HEAD
definition. This may be redundant, but I wanted an HTML HEAD definition
that was clear and easy to understand.
For internationalization purposes, I declared the language used and the
display character encoding set explicitely.
Most of the other definitions should be self explanetory.
The Title and Keywords files are to be passed by the user, once per
template page.
To use the above definition, each of my template files start with the
following lines of code:
Where common.ih is the name of the PPWizard header file in which I
store all common definitions, and I change the values passed in the
Title and Keywords variables to reflect the current page's information.
This results in the following HTML code being generated:
As you can see, PPWizard adds one line to the header, where it tell you
what product generated the page, version, and where to get the
software.
In the next article I will look at more standard page elements, where a
single element can be used to define the entire look and feel of a
page.
PPWizard: Get the newest version of the program and the documentation
from the
website of Dennis Bareis
HTML 4.01 and CSS2 standards: Get the newest and official documentation
from the World Wide Web Consortium.
|
|||||
|