I am never satisfied. I've been working on this thing for more than six years now. I finally rewrote it and rewrote it and rewrote it until I actually had something useful for the CIS Support Site. I think I've counted about ten major rewrites (or sometimes full do-overs) up to this point, so this makes the latest rewrite I embarked on two weeks ago number eleven.
In April, I suggested that I was Outgrowing Mason. Assuming that I complete the 0.11 branch of Contentment, Contentment is no longer Mason-based. Mason is really a nifty thing that I will use again, but Contentment was really abusing it. Mason is kind of a mini-CMS with a custom templating language, rudimentary file handling, and some other extras. The templates use Perl embedded in text which is neat-o for rapid templating of stuff—which is what I wanted with Contentment in the first few revisions (especially back before I knew that what I was doing would become Contentment 0.7—a do-over since 0.5 was a completely different code base). Mason mirrored some of the features I needed.
What I wanted at the time, was a way to easily identify the type of a file and dynamically convert that into HTML and then render that HTML in a custom theme. I also wanted the ability to auto-generate indexes of the files. The system used no database and, though I experimented with it a couple times, no caching. However, as I moved through Contentment 0.9 to add database support, form-handling, improved theming, etc. things started to get messy. The layered file system Mason wants to use is really not very flexible. Technically, you're supposed to be able to replace the file system resolver module with a custom handler, but that doesn't work very well. I did it, but had to hack in a couple of ugly spots to get it to work.
Also, embedding programming languages into text is my idea of a bad idea for anything but the simple. In my opinion, logic and content should not mix whenever possible. Thus, most of my Mason components were either 95% Perl or %95 HTML with a smattering of Perl. I don't need Mason in this case, I can just use Perl scripts directly or a templating language that doesn't mess up my HTML with embedded Perl.
Finally, Mason really hates handling non-Mason content. I'd managed to do it through creative use of autohandlers and dhandlers, but the solution was slow and unsatisfying. Contentment doesn't care what kind of file it's serving, so Contentment and Mason were again mismatched.
Without Mason, I was suddenly freed of several restrictions. Before I had organized the entire layout of the web documents under a directory named "docroots" which contained a "master" document root and a "site" document root, which were layered on top of each other in the usual Mason way. This was ugly. It made it hard for anyone unfamiliar with the system to find the files they were looking for and it resulted in all the features of Contentment being mixed together with a minimum of encapsulation. (I'm a computer scientist, I must have encapsulation!)
Additionally, each installation of Contentment required it's install directory to work well (including a generated Contentment::Config module to tell the system where to find it). This meant that the typical CPAN installation could not work well. I want this module to install with the usual CPAN way because it makes adoption of Contentment that much easier:
cpan Contentment
WIth the 0.11 rewrite, I now have a single document root, named "htdocs" (a familiar title). I have moved all of the Contentment specific stuff into a folder named "plugins" that separates the functionality into logical groups that can be loaded or not. This layout also eliminates the need for a custom library install and configuration module. Now, you just need to know where your plugin directory is kept.
The CPAN install thing is still a little iffy because while just running the above command should work (once I make a release), you won't have a working install without a plugins directory, the htdocs put into the correct place, and some other configuration. I'm working on a post-install setup script that will help with the rest. Since we have to configure a web server to use the app, I can't see how we can get it any simpler than this. At this point, the install looks more like:
cpan Contentment cd ~/.cpan/build/Contentment-*/ bin/setup-contentment
That won't work everywhere, so I'll probably come up with directions assuming a direct download and let the CPAN'ers figure out the rest from that. You'll have to read the docs to get anything useful anyway, so it's probably not a big deal.
Anyway, I really, really like where this is going currently. I'm hoping to have the old system dropped into 0.11 in another couple weeks and to have my web site operating off of it shortly thereafter. We'll see. I also need to update all the documentation. It's mostly right still, but the changes will require some tweaking.
Cheers.
