Weblog entry #43 for Steve
There have been several site outages in the past day or two. Now I'll tell you why ;)
The reason is that I've been refactoring the code that runs the site, a project called Yawns.
Initially the code was structured in several large monolithic files:
- index.cgi
The dispatcher, called for all pages. All this did was lookup the parameters and then call the appropriate function in "Pages.pl".
- Pages.pl
This file contains one function for each of the "pages" the site supports. For example there is a "view article" function which reads an article from the database and displays it along with any comments, etc.
- Data.pl
This is a collection of functions for interfacing with the database. The intention is that every database action is defined here - so that if we need to get the number of times an article has been read for use in Pages.pl we'll have the function defined here.
- Sidebar.pl
This file implements two functions, and just returns some "semi-static" content:
- The login box or user menu for display upon almost all pages.
- The user's menu - recent articles, topics, weblogs, etc. As defined by their preferences.
This shouldn't really justify a file of its own to be honest.
- Admin.pl
A small collection of functions for working with the submissions queue, and content generally. Not really applicable to regular visitors of the site.
As you can see whilst there is some nice seperation between notionally distinct areas of code there is no real organisation. To that end I've been refactoring the code massively.
The intention is that once things are done the code will be much more clean. So far I have a lot of smallish Perl modules:
- Yawns::Article - contains code for fetching/editting/updating an article.
- Yawns::Weblogs - Contains code for adding/editting/deleting and dispalying a weblog entry.
So all the code for one area will be in one module. Hopefully making it easier to change things without touching surrounding code.
Anyway I've made some "hasty" commits and updates and that is the source of the recent site breakage. I'm now being much more careful!
If there is any interest in the discussion of code/changes/updates I'll make more regular updates. (Although I've been saying that for months ;)
Comments on this Entry
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Put two linefeeds for a new line. I'm in the middle of changing this, because a lot of comment handling code is fragile - causing people to not have escaped "<" characters, etc.
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
It should all be fixed now.
Steve
--
[ Parent | Reply to this comment ]
Test
This is a test of <documentroot> and other Apache markup:
<virtualhost *>
DocumentRoot /var/www
</virtualhost>
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
That looks OK :)
Steve
--
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
[ Parent | Reply to this comment ]