07/09/2002-08/09/2002 @00:41:23 ^01:34:04

blog template

NERDY PROGRAMMING CRAP UPDATE ALERT OF INTEREST ONLY TO, well, let's be honest, Felix seems to like this type of update but I don't think anyone else does.

I've made a template file format for my in-development makefile-driven site updating system. What you do is, you write a plain old HTML file with space for one entry, and then you modify it a bit with some good old <!-- BLOG FOO --> style stuff. Let's illustrate this with an example.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>S00P4R 1337!!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<h1>Th1s 1s mY s00p4r 1337 w3b 51t3!!!11</h1>

<!-- BLOG TOP -->
<h2><!-- BLOG TIME --></h2>
<!-- BLOG ENTRY -->

<!-- BLOG BOTTOM -->
<h1>Th4tz 4LL f01kZZ!!!!1</h1>

</body></html>

This is saved in a file called, say, "1337.template". Note how it's valid HTML (well I hope so, but I haven't checked:) ) This makes for easier development of the template; you can just feed it into a web browser to see how it looks.

Then you have the source blog files, in the format I described last week. For example:

<!-- BLOG 1031439400 1031439800 -->
<h3>4n0th3r uPd4t3</h3>
<p>1'm s0 s00p4r 1337!! R0fLM4o!!1</p>
<!-- BLOG 1031438000 1031439000 -->
<h3>Y4Y N3w s1t3 1s uP!</h3>
<p>T0d4y I s3t uP my n3w s1t3! 1sn't 1t 1337? L0L!</p>

This file would be named "1337.blog". Now I've spent most of the day making some really horrible, badly-written perl that combines .blog and .template files into plain old HTML files. In this case it would spit out "1337.html" as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>S00P4R 1337!!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<h1>Th1s 1s mY s00p4r 1337 w3b 51t3!!!11</h1>

<h2>7/9/2002 @22:56:40 ^23:03:20</h2>
<h3>4n0th3r uPd4t3</h3>
<p>1'm s0 s00p4r 1337!! R0fLM4o!!1</p>

<h2>7/9/2002 @22:33:20 ^22:50:00</h2>
<h3>Y4Y N3w s1t3 1s uP!</h3>
<p>T0d4y I s3t uP my n3w s1t3! 1sn't 1t 1337? L0L!</p>

<h1>Th4tz 4LL f01kZZ!!!!1</h1>

</body></html>

So basically it replicates everything between BLOG TOP and BLOG BOTTOM, replacing BLOG ENTRY with the relevant piece from the source blog file (which should be written so it can be put anywhere without breaking validity, like I said last week) and BLOG TIME with that entry header format that by now should be horribly familiar to readers of this site. It works this out from the two epoch times in the source (those long numbers starting 1031)

So there you go. I wonder if anyone could be bothered to follow this. It's coming along nicely but there's still quite a lot of stuff to do.