Site creation programs

Previous page Next page

Programs

Here I describe how the programs make_menu, make_pages and make_sitemap are used to create finished web pages. The Checking page describes how check_pages is used to check the "finished" pages.

Please refer to the sections describing the organisation of the files used.

The programs make_menu and make_pages build the web site from files written by the user. One creates the XHTML for the menus, and the other combines the menu XHTML with the content XHTML and all the other necessary bits to create complete web pages. The completed pages are written to the COMPLETE directory where they can be checked using check_pages before being uploaded to the actual site. Program make_sitemap creates a file of links to all the HTML files in the COMPLETE directory.

The programs make_menu and make_pages each take a single input file. The default file name for menu description files is menu.txt and for page description files is pages.txt. If you use a different name, this name must be typed after the program name.

To make a fresh copy of the whole of sourgumdrop.org.uk I do the following:


In directory GAMES/DESCRIPTIONS I run make_menu:

python ../SCRIPTS/make_menu.py

This puts a file called menu in GAMES/DESCRIPTIONS

Then for each of the 4 games and SITE_MAKER I do the 
following (using Minestein as an example):

In directory GAMES/MINESWEEPER/DESCRIPTIONS I run make_menu:

python ../../SCRIPTS/make_menu.py

This puts a file called menu in GAMES/MINESTEIN/DESCRIPTIONS

In directory GAMES/MINESWEEPER/DESCRIPTIONS I run make_pages:

python ../../SCRIPTS/make_pages.py

This puts completed files in GAMES/COMPLETE

In directory GAMES/COMPLETE I run check_pages:

python ../SCRIPTS/check_pages.py

This reports all linking and validation errors.

Figure 1. Making a new copy of the sourgumdrop.org.uk site

Obviously it is important that, if it has changed, the main menu is updated first, as it is present in all pages. Normally, of course, only the content for one of the games would have changed, and I would only run the two make programs for that particular game. After that I can use check_pages to find any errors. If required, I locate the exact cause of validation errors using the W3C Markup Validation Service. I use Firefox to check through the pages to see if everything looks OK. In theory I then have to try it in all target browsers to see if it works, but if I've only made changes using well tried XHTML and CSS, it will probably be OK.

What I'm describing here are the requirements for a site that is complicated enough to require two levels of menus. If the site being managed only has one menu, then only about 1/6th of the above is necessary. Only the top set of directories (See Figure 3) is needed and the 2 make programs need only be run once each. In fact, as the menus rarely change, it is usually only necessary to run make_pages and check_pages.

Generating the XHTML for menus

The menus used in the SourGumdrop web site are generated using the program make_menu. It reads a simple text file which defines the content and structure of the menu and generates the corresponding XHTML.

To generate the menu XHTML for, say the Minesweeper game, I do the following:


In directory GAMES/MINESWEEPER/DESCRIPTIONS I run make_menu:

python ../../SCRIPTS/make_menu.py

This assumes that menu.txt is the menu description file and
puts a file called menu in GAMES/MINESTEIN/DESCRIPTIONS

Figure 2. Generating the XHTML for the Minestein menu.

If you have a site with only one menu the command is slightly different:


In directory GAMES/DESCRIPTIONS I run make_menu:

python ../SCRIPTS/make_menu.py

This assumes that menu.txt is the menu description file and
this puts a file called menu in GAMES/DESCRIPTIONS

Figure 3. Generating the XHTML for a site with a single menu.


Making the finished pages

The program make_pages is run after the menu XHTML is generated. If you have a site like sourgumdrop.org.uk with two levels of menu you must generate the menu code for all changed menus first. Then run make_pages from each of the DESCRIPTIONS directories. If you only have one menu, generate the menu XHTML and then run make_pages in the DESCRIPTIONS directory. In both cases the finished pages will be written to the COMPLETE directory.

After generating the menu XHTML, to make a fresh copy of the Minesweeper pages I do the following:


In directory GAMES/MINESWEEPER/DESCRIPTIONS I run make_pages:

python ../../SCRIPTS/make_pages.py

This assumes that pages.txt is the page description file and
puts completed files in GAMES/COMPLETE

Figure 4. Generating the complete XHTML for Minestein.

Making the sitemap

It is helpful to include a sitemap on your website pages. The program make_sitemap creates a file of links to all the .html files in the current directory. Using a text editor this text can be spliced into a copy of another top page to create a sitemap with the site header and footer. make_sitemap is run in the COMPLETE directory after all the other files have been made.

Custom error pages

If you mistype the name of a file on a website the server will respond with a "404 Not Found" error. You can override this response and instead display your own more helpful custom error page. For this site I display a page which in addition to the 404 error message includes the sitemap. To enable this I had to edit the .htaccess file and place the custom 404 page (created from a copy of the sitemap.html file) in a separate directory.

Last updated: 2012-10-28    Sitemap