GeodSoft logo   GeodSoft

Writing and Implementing the Page Maintenance Script

Design a static site and extract the common elements from it into a Perl script. Use <BODY> tags and comments as anchors. Wish list adaptive navigation aids and figure out how to program them.

Update 5/20/2000

Writing the script, after having defined what it was to do as clearly as I had was a simple programming problem that was almost boring. All the larger HTML pieces were simply cut and pasted from an existing static page. Where there was to be changing content, the HTLM code was deleted or moved and replace by a variable that was initialized to the correct HTML contents by a function. The only tricky piece was getting the logic right to highlight in red, exactly the pages that I wanted highlighted in the site map.

Actually applying the script was in some ways more challenging (or at least more work) than writing it. I could have saved myself a considerable amount of manual work with a little more forethought. Because I had no idea when I started what kinds of markers I was going to be using, I did not include any in the static HTML files I wrote even though I knew fairly early where they would go. This was a mistake. I should have created standard arbitrary markers such as <-- Marker One Start --> and <-- Marker One End --> as soon as I had a clear idea where they would be going. These could have been globally replaced by one of several means at the appropriate time once I decided what the real markers would be.

As it was I had to manually edit every file in the system to insert the markers. At least I did this stupid task intelligently setting up in a text editor the complete set of markers, with spacing as appropriate for each set of files. Then for each file I'd copy the whole set to the clipboard then paste them into the first location in a file. I'd then hold the shift key and mark those that were to be moved further into the file and cut them into the clipboard. I'd move to the next location and repeat until I got to the bottom of the file.

The script is written so that new files don't need markers. It will format simple pages with no header or footer elements and insert the standard page headers and footers automatically. I could not do this with the original files because they already had a multilevel table structure and navigation aids that would have been preserved and largely duplicated where the individual page content goes. If I don't start with a simple unformatted page then new pages will need to be copied form existing ones or a template page that has the necessary markers.

I did have one real scare when I got to the Sample Site section. The Sample Site is no longer included in this site; it was part of a client project with a site design using several levels of tables that needed to be nested inside the content area of this site which also uses several levels of tables. I'd started building the site in this area and thought that I had preserved the table structure from this area throughout the site. At some early point I had changed some of the HTML code that needed to be standard. Careful comparison of the sample section page with others showed exactly what HTML code needed to be added and where so that these pages would start with standard code. This left malformed HTML code with a start TD tag immediately following another start TD tag. This required the addition of one start TABLE and one start TR tag immediately after the end of the standard page headers to create valid HTML code. A close TR and TABLE tag also had to be added just before the start of the standard page footer to balance the HTML code.

These extra codes were inserted in the same manner and as part of the same operation as the standard markers that I had to add anyhow. This mistake actually proved to be beneficial. In my original design the sample pages butted up directly against the left hand column of the outer page containing the search form and site map. This made the identity of the nested pages not as clear as it could have been. The forced addition of the new table resulted in a small pale blue border, the standard background color of, completely surrounding the embedded page and making it very clear that you were looking at a site within a site.

Further because of the difference in how IE and Netscape handle table background colors, where the background of the inner site was different than that of the outer site there was a tiny cell that showed as a heavy vertical line surrounded by the background blue. Early in making the nested pages, I'd added a cell with a tiny transparent .gif to force the graphics of the inner pages away from the left hand column of the outer page. Later cell spacing accomplished the necessary spacing but I didn't realize I had an extra unnecessary cell.

With the new inner table and the extra background slice in Netscape now creating a very obvious dark stripe on light background, I reexamined the coding and asked my self what useful purpose the cell formed. Thinking of none, I removed it and eliminated the largest difference in appearance between IE and Netscape. The size of the left background margin of the inner page in IE decreased dramatically in size. From the beginning, I'd struggled with minor differences in appearance between the nested pages and the original design I'd done for the client. With the addition of the new table and the removal of the unnecessary spacing cell, I finally got a nested page that had almost exactly the same alignment and finer spacing details that the original design had.

After making a first pass through the site working on individual pages and directories, I ran the script on the entire site, experimenting with the relative positions of the powered by graphics and the site map and some other minor variations. Finally I made a quick start on splitting the page that describes ATLA's web site which has been my largest web project into separate pages in an new directory. I focused only individual page content and creating the text file that defined the table of contents and link order. The script then built these components in a few seconds where I'd spent a few hours creating the first table of contents and links and constantly revising them as pages were added to the Making This Site section.

From now on, I know I can make almost any kind of visual, stylistic or navigational change to the site and apply it to the whole site in less than a minute. Even if I want to create a new or modify an existing feature that adapts to its context, I only need to add or change a few lines of script code. Such changes are done only when they are needed and the web server serves static pages that put almost no load on the server. Personally I believe that a custom maintenance script like this is more cost effective and flexible than almost any commercially available site management product.

Script Update (5/20/00)

Except for some preliminary testing related to how Perl was handling directory names, I'd focused my energies on developing and testing the maintenance script on NT. I finally got around updating the content on the Linux machine and running the script on that machine. I got quite a surprise as soon as I viewed the result in Netscape. The order of elements on the left with the search form and site map was completely shuffled around. It turned out that it wasn't the script itself but the text file that has the platform specific tags for the powered by graphics still had some extraneous table elements.

In the current version the left column is just one large table data element with the parts separated with HTML breaks. The extra table data elements that were added when the script was run caused Netscape to decide that the search form and graphics were not inside a table data element and apparently Netscape displays such content after the table, changing the order the content appears on the page.

The other thing that I ran into on Linux is that the script creates a lot of backup files when it runs on the site. On NT this is no problem. "del *.bk? /s" will delete all the backup files in a few seconds. On UNIX like system, the recursive rm command won't descend into a directory unless the directory name matches the name that's given to delete. It's real easy to delete all the files and directories but not so easy to delete a specific subset of files in the current directory and all sub directories. find will do it but the command is long enough and the syntax just tricky enough that I often end up looking an man pages before I get it right. I decided it was simpler just to pull out the relevant lines from the standardization script and make a dedicated perl script that will delete all files matching a wild card file spec in the current and all subdirectories without deleting any directories.

While trying to find what was causing the different page appearance I noted that pages from the NT system were appearing with extra blank lines in the HTML source that were not present in the source from the Linux system. There was also nothing in the script to account for these blank lines. There are a number of places that I open an HTML tag on one line and close it on another. For certain kinds of repeated elements this makes keeping the source code clean and consistent and avoids introducing white space where it might affect the HTML display in a browser. It appears that whenever the NT web server encounters these, it adds an extra linefeed as it transmits the HTML page. It doesn't appear to have any practical effect but is odd and really not appropriate.

transparent spacer

Top of Page - Site Map

Copyright © 2000 - 2014 by George Shaffer. This material may be distributed only subject to the terms and conditions set forth in (or These terms are subject to change. Distribution is subject to the current terms, or at the choice of the distributor, those in an earlier, digitally signed electronic copy of (or cgi-bin/ from the time of the distribution. Distribution of substantively modified versions of GeodSoft content is prohibited without the explicit written permission of George Shaffer. Distribution of the work or derivatives of the work, in whole or in part, for commercial purposes is prohibited unless prior written permission is obtained from George Shaffer. Distribution in accordance with these terms, for unrestricted and uncompensated public access, non profit, or internal company use is allowed.

Home >
About >
Designing >

What's New
Email address

Copyright © 2000-2014, George Shaffer. Terms and Conditions of Use.