January 28, 2007 @ 01:10 PM by nap · 0 comments
Drupal has served me pretty well for a number of projects in the past. But as we shift our development focus towards Ruby-based projects, it seems like an ideal time to consider migrating my own blogging platform to something Rails-driven. Nothing against Drupal itself of course. Hell, for a PHP project it's pretty slick.
But it still just leaves me feeling like I'm flirting with an old (and somewhat unattractive) ex-girlfriend. It's not you, it's me.
The obvious candidates seem to be Typo and Mephisto. Another option would be to, of course, roll my own. But does the world really need another half-baked blogging engine? Probably not. If anyone has other recommendations let me know. Looks like I'm leaning towards Mephisto at this point.
January 25, 2007 @ 03:45 PM by nap · 0 comments
I've been spending some time lately looking at different templating packages for Rails, in hopes of finding something cleaner and sexier than the standard ERB (rhtml) recipe, that also helps avoid common HTML pitfalls that cause pages not to validate.
My search has pretty much boiled down to two candidates at this point. The first is Markaby, which has been around for a while now and lets us represent our XHTML in Ruby code. The other candidate is the new kid on the block, Haml, which just reached a 1.0 last week and has it's own proprietary CSS-ish syntax. Let's take a look at brief look at both of them...
Here's some ERB:
<div class="column" id="content">
<h2 class="entry_title"><%= h @thing.name %></h2>
<div class="entry_link"><%= link_to('link', @thing.link) %></div>
</div>
This is probably what we're all used to and there's no arguing that it works well enough, but... Well, it's kind of ugly, isn't it? To represent this same thing in Markaby, we install the plugin and create a template with a .mab extension and stick this in it:
div.column.content! {
h2.entry_title @thing.name
div.entry_link link_to 'link', @thing.link
}
That sure looks better to me. Nice and compact, clean. The best part is that Markaby is actually valid Ruby syntax. This buys us a couple things: first of all, it means that our view won't run at all if we end up with a syntax error in it, which in turn means that it's valid XHTML. Slick.
The downside is, of course, performance. It requires rendering for every single tag and property, which makes it slow in comparison to ERB, since just the inline Ruby snippets in the rhtml file have to be processed and inserted into a mostly pre-rendered HTML template. I also have some minor gripes about the use of bang instead of pound for representing element IDs, and the fact that it blows up when I put a yield in my Markaby layout code (I have to use @content_for_layout, which is deprecated now).
Anyway, enough about that. Let's talk about Haml for a second. Install the plugin, and create a view with a .haml extension. Here's the same chunk of code we saw before written in Haml:
.column#content
%h2.entry_title= @thing.name
.entry_link= link_to('link', @thing.link)
Haml defines it's own syntax, which borrows from familiar CSS markup, and takes advantage of whitespace sensitivity for nesting. This latter bit is great news if you're one of those undercover Python people hiding amongst us (I'm not one of you, now go away). It generates really nice clean appropriately nested HTML for output too.
Although it's fairly easy to read and satisfies our cleanliness criteria, there are some immediate downsides to the fact that the markup is proprietary. Firstly, it means the files still have to be parsed and re-rendered by Rails, for a performance hit -- same as we'd get with Markaby or any other higher-level template language for that matter. It also means that your editor isn't going to be able to help you with syntax highlighting unless it has explicit support through a plugin.
I can see why people like Haml, it's compact and kind of fun (see the tutorial for more). But all things considered, I really can't see any reason I'd use it instead of Markaby, which feels much more natural to me and has the added benefit of Ruby syntax validation. Perhaps if it were to represent a significant performance increase -- this seems doubtful -- but I haven't seen any real benchmarks. In any case, I don't think I'll be using it any time soon.
If I were to choose one of these two, I'd have to go with Markaby. I'm quite smitten by the idea of writing template code in pure Ruby, and the syntax validation enforcement is extremely desirable. As bizarre as it may seem, I love the idea of a page failing to run because of a syntax error in my "HTML" markup. Still, the performance issues give me pause. An even bigger issue is that of fragment caching, which sadly seems to be currently busted in Markaby. So, all things considered, I guess I'm sticking with ERB in my view templates, coupled with assert_valid_markup for my validation testing needs. At least for now. Even thought it makes me cringe a bit.
If I've missed anything worth considering about either of these templates, or if there are other options, please drop me a line. I'd love to hear what the rest of the community is using for their high-volume web apps...
January 21, 2007 @ 08:27 PM by nap · 0 comments
The kind folks over at JetBrains have finally got around to releasing a 0.1 Beta of their Ruby Plugin to the IDEA Repository. If you're an IntelliJ user, it's now as easy as going to the plugin manager in Preferences and selecting the Ruby plugin for installation. The workflow is the same as I described earlier but this release brings some important bugfixes; console output is now available, starting/stopping the WEBrick server now works as expected, etc.
In case you haven't checked it out, the integrated Rails generators and Rake tasks rock, there's an RDoc toolbar with lookup, goto class functionality, code formatting, and a bunch of other goodies, all detailed in the Release Notes. I got all excited when I saw keyword completion in the list; but it turns out that it's really just that -- although a ticket for proper code completion is listed in the issue tracker it looks like it'll still be awhile before we get to feel that love. Syntax highlighting in rhtml/builder templates will be huge also (in the roadmap).
I've been using RadRails as my RoR IDE so far, but now that the IntelliJ plugin is mature enough to work with I'll probably start migrating over. Don't get me wrong; RadRails is a great project (and free!), but IntelliJ is my IDE of choice for Java dev, and I'm psyched to see it evolving into a platform for Ruby development too.
January 18, 2007 @ 09:20 PM by nap · 0 comments
Wow what a big day. Immediately after the release of Rails 1.2.0, we get a quickie bugfix bump to 1.2.1 and a great post by DHH summarizing the features in the release. On top of this, we get Prototype 1.5.0, complete with a new web presence and some surprisingly good documentation.
January 18, 2007 @ 11:56 AM by nap · 0 comments
Looks like 1.2 has been officially released. I'm sure that I'm not the first to notice :-p. To update your gems:
gem update rails --source http://gems.rubyonrails.org --include-dependencies
Enjoy!
January 16, 2007 @ 10:10 AM by nap · 0 comments
If you're in the seacoast NH area (north of Boston), don't forget to attend the first meeting of the Seacoast Ruby/Rails User Group tonight from 7-9 at the UNH campus. Apparently there was such an overwhelming response that Scott had to move the location to Morse Hall in order to accommodate the additional heads. Wow, cool. More information and directions are on Scott's blog. See you there!
January 15, 2007 @ 09:22 AM by nap · 0 comments
FreeBSD 6.2 was released this morning. Lots of bugfixes and new features, including official support for binary updates with freebsd-update. Cvsup away!
January 13, 2007 @ 08:36 PM by nap · 0 comments
This time around the event runs from May 17th to the 20th. Am I gonna go? I'm debating. It seems like a great opportunity to hear a bunch of great speakers, absorb some mad knoweldge, and meet like-minded Rubyists. Plus it's in Portland Oregon (the other Portland), a city I've always wanted to visit, and a mere 2 hours from a good friend of mine in Eugene.
The thing that gives me pause is, of course, the cost. Registration is rumored to be a whopping $800 for the 4-day event this year, roughly double the 2006 event price. Ouch. Does this dramatic price hike reflect significantly increased offerings, or is it just because Rails has moved a bit closer to the mainstream -- meaning that more corporate entities are capable of coughing up the usual exorbitant conference fees to send employees? Sigh. In either case, as a self-employed developer type that's painful. Only half as painful as WWDC. But still, painful.
Of course, if you have the time and the skills, CD Baby is sponsoring a HackFest to send the top 20 patch contributors free of charge (inc hotel). You've got until the 22nd to make your impact as measured here. And yes, I'm a bit late in posting that news.
January 07, 2007 @ 05:24 PM by nap · 0 comments
I'm usually not prone to MLP (mindless link propagation) but sometimes I just can't help it. Case in point:
this cool l'il bit of JavaScript. Good for a quick chuckle.
January 03, 2007 @ 04:09 PM by nap · 0 comments
Back from my requisite holiday visitations and feeling refreshed. Now it's time to get back to work. Here's some tentative goals for the new year:
- Get up earlier in the morning. Start work earlier in the morning. Finish work earlier in the evening.
- Focus more on Ruby this year, less on Java. Delete PHP from resume.
- Get a gym membership and actually go on a regular basis.
- Take a break from client (ie paid) work for a change and get one of my own ideas off the ground before summer.
- Print some damn business cards. Stop coming up with cute excuses about why they're lame and learn to conform. Just a little.
- Go to at least one conference. Go to at least one UG semi-regularly.
- Bathe the dog more often. He is a stank factory.