A confession…

I must admit to being influenced by blog templates greatly at the moment. Which is why I’m having great fun with a new work intranet system I’m developing. Picks yer style, makes yer smile. I may even put some ‘hidden’ extras (easter eggs, I think they’re called) for those that want them, involving people from work … hmm, ideas ahoy.

This also links in with my general excitement about web applications. How many other programs do you use where you can “skin” it with a single click, and even develop your own skins very easily? OK, OK, Winamp, Firefox etc. But they are all freeware/open source things (we open source people tend to be interested in making the whole of a program a positive user experience) so have thousands, perhaps millions, of potential developers and beta testers. Still, it’s an exciting area to be working in. Do you want screenshots? OK, they’ll be here in the next post…

The future is bright…

Every now and again I get really excited about something. My heart gave a little flutter just now when I read this article because, in a nutshell, that’s what I’ve been trying to do for the last couple of years. Proper web-based applications. Websites that Do Things.

So the fact that this stuff is now beginning to really hit the world in a big way is quite exciting. The cutting edge is quite a nice place to be.

I’m in love…

With an Apache extension. Don’t worry, it’s nothing to do with Native American Indians and the amazing results available through spam emails. It’s the wonderful mod_rewrite extension, available at all good website hosting companies. It really is wonderful, and you may be seeing a lot more of it very near here in the not too distant future.

However, as is my way, I may be trying to go beyond my abilities too soon. Which is fine, as long as it’s not for an important client, and as long as the site doesn’t crash (see the “Don’t rush it” entry below).

Actually, I was talking about that entry with the inamorata the other day, and she described me as “unconciously incompetant”. It must be love.

Don’t rush it…

Just don’t. Ever.

Good grief, that’s been a frightening few days. And all because I rushed something on Tuesday night that wasn’t that urgent after all. Now, who’s going to place bets that this (finally) teaches me a lesson. 200-1, I reckon.

But it does give me a good excuse to post my first proper code example. This one is classic ASP (VBScript), and is very useful when you need to hard-write a lot of files with only minor changes such as the title, keywords, description and a bit of page content between them. You can always see it in action as well, if you want. Oh, and one more thing, this (and any code peovided on this blog) is given without any guarantees or warranty whatsoever.

' all you need to do to that is create your html template and replace some
' of the elements in it with the codified equivalents. here's a list:
' page title = %%pagetitle%%
' meta keywords = %%pagekeywords%%
' meta description = %%pagedescription%%
' page content = %%pagecontent%%
' level (string of ../'s to the root, for image paths etc) = %%lev%%

' grab the template file
templatepath = "template.htm"
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath(templatepath), 1)
bodytext = f.readall
Set f=Nothing
Set fs=Nothing

' this is the function that is called to create the final HTML code
function getBody(bodytext,pagetitle,pagekeywords,pagedescription,lev,pagecontent)
getbody = bodytext
getbody = "" & vbcrlf & getbody
getbody = replace(getbody,"%%pagetitle%%",pagetitle)
getbody = replace(getbody,"%%pagekeywords%%",pagekeywords)
getbody = replace(getbody,"%%pagedescription%%",pagedescription)
getbody = replace(getbody,"%%lev%%",lev)
getbody = replace(getbody,"%%pagecontent%%",pagecontent)
end function

' start your loop (from a database, for example)
' for each item create the HTML and save the file like this:
set fs=Server.CreateObject("Scripting.FileSystemObject")
set tfile=fs.CreateTextFile(server.mappath("path/to/your/file.html"))
tfile.Write getBody(bodytext,"Page title","keywords","description","../../../","This is the page content")
set tfile=nothing
set fs=nothing
' go to the next item