[Apachetoolbox-devel] first working copy
Brought to you by:
bryanandrews
|
From: Kevin J. M. Jr. <km...@wp...> - 2001-07-30 18:11:51
|
Hey guys,
Well, I've been cracking away on this project, and I think I finally got
some code that might be worth taking a look at. Really, it's still
nothing extremely functional, and probably not the prettiest code of
all. I figured I'd send this out before I got too involved though.
Perhaps I can get some feedback.
The file is named test.pl. It is in the
/home/groups/a/ap/apachetoolbox/kevin folder on the SourceForge servers.
Right now, the code works like this:
test.pl -- contains all the main code. I will probably delegate some of
this code to a separate file with subroutine definitions. As of right
now, I've encapsulated certain relevant blocks of code within curly
braces, but have not yet made them into subroutines. There are 2 hashes
that really drive this program as of right now:
%versions -- through a nifty little hack if you will, I came up
with a way to use our old versions file. Originally, I was going
to change the entire format of it, but then it dawned on me to make
a hash. It works very nicely, as something like $version{'MODMP3'}
gets you the version of mod_mp3, and you have a really good idea of
what this variable actually does :)
%menu -- this is really a hash of hashes. All the files in bin/
are read in and parsed. Each one of these files is treated as a
module prototype (TM? :)) if you will. Intentions right now are to
add depth corresponding to other modules (e.g. a bin/php which
would then contain one file per php module to add in). These files
contain minimum data right now, just enough to build a working
menu (more below).
etc/versions.conf -- file with version information. For the most part,
ripped right out of the 1.5.x distro. There's a couple things that need
to change, and I haven't updated this file yet to reflect that. The
general format is MODULENAME=VERSION.
bin/ files -- used to load in info representing a single module. Right
now, I'm using a tags based system for this. Not tags as in ML, but as
in CAPITALLETTERS=value. Right now, INDEX is the index value on the
menu. TITLE is the title to display. The TITLE value can take a
variable for the version, which is '$' followed by the value from
etc/versions.conf. The test.pl emulates interpolation of this variable.
In reality, the line is parsed, the '$' discarded, and the value after
the '$' is used as a key in the %version hash. This only works if the
version is the last part of the title (only place it makes sense, but
too restricting, rather too ugly from a coding perspective).
I think within the near future, I will write a perl class for the
modules. The class itself will be a pure virtual one. Then each module
will inherit it, and have to set certain values itself. This would in
effect, allow ATB itself to be infinitely extensible. Plop the new
module file into bin/ and add a line to etc/versions.conf. I'll
probably write a tool to add new modules too :)
One last note: this script is written with an 80 character / line
display in mind (what most ssh clients are). It should look fine at
higher rates, but most systems are this by default, so this is what I
coded for. So, with the number of modules increasing, assuming 25 line
display, we'll have to add page1) page2) page3) and so on links. I'll
come up with a way to do that dynamically :) Now, that's extensibility
for ya :-P
Please review the code. Ask any questions. I've provided comments
rather graciously, but not superfluously. I use a pretty strict coding
style. I know a lot of people don't exactly do it the same way I do. I
think we should draft some sort of best practices coding standard, but
it's not an issue as of yet. I don't expect everyone to do what I do,
but I expect it to be clear as to what you're doing, and commented well.
You'll notice that I prefer to space '('s away from if, for, while, and
so on, as in
if ($yo eq "true").
I also, like to drop my curly braces down to the next line. It looks
more like a block to me and is easier to read.
That is:
if ($yo eq "true")
{
print "yo\n";
}
Rather than:
if ($yo eq "true") {
print "yo\n";
}
Except for one line code jobs. Then I put it all on one line.
Like I said. Questions. Comments. Complaints. All is welcome.
--
Kevin
|