More Elbow Grease

So the code from my previous journal entry parses my xml file and builds a page that contains the last ten entries. What happens when you request a specific entry? In other words, if some kind soul were to use the perma-link for this entry ( http://www.xionic.net/~jkp/index.php?weblog=20031120) on his/her site to reference this entry, what happens when they click on the link? It all happens in the index.php file. Last time I stated that if $dd was not set, then go ahead and parse the xml file and build the page. When using the permalink, $dd gets set to the permalink number field which is 20031120 for this entry. That number is in fact the date of the entry, which gets broken down like this:

$year=$dd[0].$dd[1].$dd[2].$dd[3];
$month=$dd[4].$dd[5];
if (isset($dd[6])){
$day=$dd[6].$dd[7];
}

$M = $months[$month-1];
$dir = "weblog/" . $year . "/" . $month;

if (isset($day)){
$date="$M $day, $year";
$loc = $year . "/" . $month . "/" . $day;
$permalink="http://www.xionic.net/~jkp/index.php?weblog=$year$month$day";
echo "<div id=entry class=status>";
echo "<div id=title class=status>$date</div>";
echo "<a href=$permalink>$date</a><ul>";
require($loc);
echo "</ul><br>";
if (file_exists($comments)) {
echo "<p class=status>Comments...";
require ($comments);
}
echo "<a href=\"weblog/comments.php?dn=$val\" class=status>add a comment</a></div>";
}

So my journal entries are filed in a date-tree. With the the year and month being subdirectories and a single file for each day. If you look through the code you will also note that the comments for a single day are kept in their own file for each day. This tree structure has been quite simple to maintain, and has been very stable. How well does it scale? Hmmmm… Good question. I am sure that it scales much better than several solutions that I have seen that use a flat file style database to store the information, but perhaps not quite as well as a SQL driven data store would. As long as I am not trying to do any advanced queries or searches and just display a subset of entries this system has been quite responsive and easy to maintain.

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

WordPress Themes