|
The site has changed many times, either to incorporate new features and events, or to improve
the look, feel and function of the site. The most consistent element, however, has been a short 'C'
program to take the plain text stories and convert them into complete web pages. This is done
off-line.
The program is quite simply, and has the following functions:
- Collate work (stories, poems, novels, etc) from their associated sub-directories and assign
them to their authors
- Sort the authors into alphabetical order, then sort these lists into genres, to allow one page
for poetry, one for stories, and so on
- Build cross-referencing links between the pages, and build 'biography' pages for prominent authors
on the site
- Add standard 'templates' (containing the BNW stylings) to text pages containing news, information
about writing groups and competitions.
The most recent change has been to utilise VBScript. Not in the processing (that's still done off-line with
'C'), but in the display.
The size of a typical page is about 4K. The auxiliary code for layout is about 10K. This amounts to a lot of wasted space.
And unnecessary uploads. In 'poetry' for example (all genre pages are similar in structure), there are
four main elements:
- The title and menu
- The poem/story, etc
- A list of other work in the same genre
- Copyright and footer
Now, the title and footers don't change often. The poem (once created) certainly doesn't, but the list of other work does.
Frequently.
Normally, this requires each page in that genre ('poetry', say, or 'short stories') be
rebuilt and uploaded when a new poem or story is added. However, by splitting the page into four, and
using VBScript, the four elements can be joined together using INCLUDE. This occurs dynamically when the page is
requested. This in turn means any new story requires two uploads: one for the story, and one for the new list of stories!
The code looks similar to this:
<!-- #INCLUDE FILE="templates/cmn_header.asp" -->
<!-- #INCLUDE FILE="poetry/Triangle.asp" -->
<!-- #INCLUDE FILE="poetry_ListOfWork.asp" -->
<!-- #INCLUDE FILE="templates/cmn_footer.asp" -->
This benefits the webmaster in other ways. One of them is that you can near identical pages, with subtle changes. For instance,
by creating a variable that consists of the poem name, and its author, you can include it in the <TITLE>
tag very easily. This helps ranking on search engines, and gives the page a more individual - and therefore professional - feel.
For example, the file poetry/Triangle.asp might begin:
szTitle = "Triangle by Andrew Mayne"
<!-- #INCLUDE FILE="templates/cmn_header.asp" -->
... etc ...
Whilst cmn_header.asp would include
...
<TITLE><%=szTitle%></TITLE>
...
This expands the 'szTitle' variable, giving the page a unique title.
Moving On To Menus
Variables can be used to do more than just replace text. They can build small portions of your site.
The menus on Brand New Writers are a
good example of this.
Above, I said that 'cmn_header.asp' contained all the basic HTML startup code. That is true. However,
it actually does a little more than that; it also includes the menu.
We have five menus on our site. Depending on which page you are viewing, the VBScript will
determine which menu is applicable. Furthermore,
each menu is composed of graphical buttons which use an alternative image when a visitor is viewing
that particular page. I used 'home1.gif' for the 'Home Page' button, and 'home1b.gif' for the 'Home Page' button, when
selected.
VBScript has instructions for testing the value of variables, as well as setting them. It can perform different
actions if the variable is one thing, or if it is another. The command, if you hadn't guess, is called
If! We can then write a simple piece of code to load a graphic, depending on the value of our variable,
Taking the above problem, let us solve it in two parts (buttons, then menus) and re-create
our files, (Note: case is very important in VB, make sure you use capitals as indicated)
szTitle = "Triangle by Andrew Mayne"
iButtonSelected = 2
<!-- #INCLUDE FILE="templates/cmn_header.asp" -->
Now, when the web server reads 'cmn_header.asp' it can use the variable, 'iButtonSelected' to
draw the button with the appropiate image. eg
<% If iButtonSelected = 1 Then %>
<IMG SRC="pix/home1b.gif">
<% Else %>
<IMG SRC="pix/home1.gif">
<% End If%>
<% If iButtonSelected = 2 Then %>
<IMG SRC="pix/home2b.gif">
<% Else %>
<IMG SRC="pix/home2.gif">
<% End If%>
... You can repeat this for as many buttons as you have ...
You can also use this idea, to determine which menu to display, either as
<% If iMenu = 0 Then %>
... include menu code here ...
<% End If%>
<% If iMenu = 1 Then %>
... include menu code here ...
<% End If%>
<% If iMenu = 2 Then %>
... include menu code here ...
<% End If%>
or the following (which behaves in exactly the same way),
<% If iMenu = 0 Then %>
... include menu code here ...
<% Else If iMenu = 1 Then %>
... include menu code here ...
<% Else If iMenu = 2 Then %>
... include menu code here ...
<% End If
End If
End If %>
You can include the menu code, either by copying the 'if iButtonSelected = 2' code from above,
or include a separate file for the menu.
There's a number of idea presented here. If you're not used to working in this fashion, it might
require a little work to adapt your site to use it. But once you have done so, upgrading any part becomes
a very simple operation.
|