Sporkmonger

purveyor of fabulously ambiguous eating utensils

GentleCMS Development Log: Part 1

Posted by sporkmonger
Written June 26th, 2006

I got a lot of work on GentleCMS done while I was at RailsConf. I’ll probably start putting regular entries up on my progress so that it doesn’t get too quiet around here.

I checked in support for search/indexing with Ferret, which may eventually either be replaced with Hyper Estraier or I might work on making the indexing code modular enough to support either implementation. Not sure. Seth Fitzsimmons gave a presentation at RailsConf that sort of threw a wet blanket on my enthusiasm for Ferret—If Ferret isn’t sufficiently stable, I’ll have to work out an alternative, but we’ll see. It hasn’t crashed on me yet, but I haven’t really done anything interesting with it either.

The start of templating is in place, with the dependancy tracking handled by the indexing code. The basic templating stuff works, but right now, setting file dependancies is still a very manual task, and that needs to be fixed. I’ll have to finish work on the generated properties code to get that working. Representation caching hasn’t been written either, and that’s a major prerequisite for the templating system.

Filtering, however, is working perfectly. The filters I’ve currently finished writing are:

  • textile
  • markdown
  • tidy-page
  • tidy-fragment

Chaining filters is trivial, so you can apply tidy-fragment to a textile page if you like, or really, any combination of filters. I’d like to add in support for sanitized (X)HTML and BBCode by default. I can probably lift the sanitization code from FeedTools fairly easily, though I really ought to clean it up first. It’s honestly kinda messy. Does anyone know if there’s a BBCode implementation for Ruby? I’m sure it wouldn’t be hard to write, but no sense reinventing the wheel if it’s already out there. I’ll probably lift Typo’s syntax-highlighting code as well if Scott et alii don’t mind.

The theming engine has a long way to go, and I’m really not sure exactly how I should go about implementing it. I started writing it during Rails Day, but I think it might need to be scrapped and restarted.

Authentication/authorization is still non-existant, I’ll get around to it when I have more to work with. I’m planning on having an authentication proxy of sorts so that you can script the attachment of, say, an OpenID identity to an account or set of privileges within GentleCMS. This should allow you to let people sign into their OpenID account, and have the CMS treat that user as if they’d signed into an anonymous GentleCMS account with a specific set of privileges. Or at least, it should go something like that. I’m not sure exactly. OpenID will probably be the only “Identity 2.0” protocol that will be natively supported, but I intend to make it reasonably simple to add in support for other authentication systems as plugins.

Last but not least, I decided to use RSpec for the testing framework for GentleCMS. I know, I know, we’re not supposed to call it a “testing framework”, but I’m going to anyways, since I’m guessing that I’ll get a few raised eyebrows from the people who haven’t used it yet if I called it a “specification framework”. I’ve decided to practice BDD in the development of GentleCMS (at least, from here forward anyways). I’m still finishing implementing the specifications for the code I have so far (yes, I know, naughty me for not doing it first from the beginning, but I promise that I’m repenting). From what I’ve gotten done so far, I have to say, I’m really impressed. It’s clear that a lot of refinement has gone into BDD and actually practicing it is definitely resulting in much more thorough testing than I normally would be doing. Beyond that, RSpec feels like a much more natural way of expressing testing code… er, specification code.

I had a few problems with RSpec getting it going though. I initially was trying to use RSpec with the RSpec on Rails plugin, but it didn’t seem to supply rake tasks for some unknown reason. I wrote my own rake task for it instead, but there were bunches of problems and eventually I gave up on it. But… then I noticed that there was actually a Rails generator for RSpec on the RSpec homepage. I installed it and it worked… fairly well. Now, this isn’t really a criticism of RSpec or the RSpec generator, because actually, Test::Unit under Rails has the exact same problem (the RSpec generator actually borrowed this code). If you don’t have a valid connection to the database through database.yml, neither RSpec nor Test::Unit will work very well. There’s some problems with fixtures because the testing frameworks assume you are using ActiveRecord. Which I’m not. So I did a little bit of hacking on both Rails’ testing code and the RSpec generator. Then I discovered that RSpec’s rake task isn’t keen on testing a Rails app that has no model specifications. So I had to hack that too since I have no ActiveRecord models. My general feeling here is that RSpec shouldn’t be throwing a generic exception in the case where no specifications are found. If no specifications are found, that may be because there’s nothing to specify, as opposed to that the programmer was too lazy to specify. This case should probably be handled more elegantly. IIRC, Rails’ Test::Unit support also has this problem (though I haven’t checked recently). Plus a huge chunk of my code resides in my Rails app’s lib directory, so I added a new rake task for executing the specifications for the lib directory.

Finally, RCov is awesome. And RSpec’s tight integration with RCov is really, really nice. There is a tiny, though easily fixable, problem with RSpec’s RCov support within the Rails environment. By default, RSpec tells RCov to exclude the lib/spec/ directory from the code coverage reporting, but in the rails environment, the specifications are actually in the spec/ directory, so they aren’t excluded. I’d like to see the ability to pass in a list of directories to have RCov exclude from within the Rake tasks. Should be trivial to do. I’ll have a patch written for it shortly. Actually, I’ll probably write up patches for all of the issues I’ve run into so far. Largely because, right now, I’m the only person who can actually run my specifications since I’ve hacked my local copies of ActiveRecord, Rails, and RSpec to get things working correctly. I already submitted a patch/ticket regarding the Rails issue.

Of this I’m sure: RSpec is now my preferred choice for ensuring that my code works as intended.

Leave a Response

NOTE: I'm afraid Javascript needs to be on in order to comment.

Comments should be formatted using Textile.

Ruby code should be enclosed within a <macro:code lang="ruby"> element. Other languages are supported. For output you can simply omit the lang attribute.