July 2009

Jul 31, 2009
drupal-javascript-and-jquery.jpg

After reading Drupal 6 Javascript and jQuery (Matt Butcher, Pact Publishing), I gained a new appreciation for writers attempting to expound on a one specific aspect of Drupal development. jQuery, for example, can be used by nearly every layer of Drupal, from module building to theming, from the file system to forms. How does one boil down the many and varied applications of this multi-purpose tool into a reasonably sized book? I think Matt Butcher did a fantastic job of doing just that.

The book was not quite what I expected, and that's a good thing. For one, the author assumed a minimal amount of experience from the reader, and started at square one with some basic terminology and a first 'hello, world' tutorial. Like most tech tutorial books, the chapters are comprised of 1-3 mini projects where some new ideas or techniques are introduced. For the most part, each chapter builds on previous chapters, illustrating more complex functionality. Another thing that struck me from the start and continued to impress me throughout was the quality and creativeness of the example projects. While few of the examples were production-ready, they solved common issues in a compelling way. Here's a quick list of some of the mini-projects:

  • Load an RSS feed via AJAX
  • Create a live in-page alert when new comments are added
  • Create a text editor
  • Create a random, rotating node teasers in jQuery
  • Write a jQuery plugin

A lot of these projects have crossed my mind as things I'd like to dig into at some point anyway. In addition to being interesting ideas, these projects are also executed in a way that brings together many aspects of Drupal. Having used jQuery and Drupal for a couple of years now, I felt like I knew the basics, but I was pleasantly surprised to learn something new in virtually every project. Some things I learned, but didn't expect to:

  • How to use JSON - I've been wanting to wrap my mind around that for a while
  • How to use translations in jQuery
  • What are Drupal behaviors - If you don't know about them now, you absolutely need to! They solve one of the more complex problems I've dealt with in complex jQuery apps
  • How to theme in jQuery - Awesome, I didn't know you could do that
  • Creating jQuery functionality in themes - I had thought this was a purely modular job, but no!

By the time you make it through the book, you've been introduced to all of the major parts of Drupal. If I had known nothing about Drupal from the start, I would come out the other end with the ability to create themes, modules, and jQuery plugins. Not bad for 318 pages, probably half of which is code. And the fact that I was still satisfied even having worked with Drupal and jQuery for the last couple of years says something to the depth of the material covered.

I was excited enough about the new stuff I learned that I picked up a module that had been languishing for a while and re-wrote a bunch of the code using the principles addressed in this book. The code is now a whole lot easier to understand and debug. The 2 major concepts I applied were object oriented javascript and Drupal behaviors. Drupal behaviors is binding jQuery actions to html elements on the fly, so if you load up some new content via ajax, you can then attach all the jQuery stuff to it without affecting the rest of the page (like accidently attaching an action a second time, which can have undesirable consequences). I've found all kinds of ways of dealing with this is the past, and they've all been really ugly in comparison. Behaviors are a breath of fresh air, and there were lots of examples in Drupal 6 Javascript and jQuery to really anchor the coolness of them.

Minor Nitpicks

My criticisms of the book are really minor in comparison with my praise. There were quite a few typos and consistency errors. In another genre of book I wouldn't be as concerned, but when dealing with code where one misplaced character can break an entire script, running into typos in the text reduces confidence that the code will work if copied verbatim, especially for the unexperienced programmer. I actually worked through every example up until the last two chapters, and was pleased to find out that they all (with one exception) worked as advertised. The one exception was in Chapter 7 where a module is required that does not produce valid JSON. It took me a while to discover the problem, look and find a patch to the module. One more really minor thing is that I felt that the tone vacillated a bit, assuming at times that the reader was new to programming, and at others more experienced. Sometimes a good bit of work went into describing more complex programming conventions, and at other times they were more casually alluded to.

Summary

Overall, I was really happy to spend the time reading this book. I'm not the fastest reader, and working through the code examples takes me some time, but it was worth it. It anchored some important Drupal 6 conventions, illustrated some best practices for jQuery which can extend from simple to complex projects, and introduced me to some of the ways that jQuery integrates with the different aspects of Drupal. I'm looking forward to reading more from Matt, and would recommend this book to anyone aspiring to jQuery ninja-dom.

Notes in the margin

I made several notes in the margin of the book that didn't make it into the above review, so here they are for those interested:

  • Until later on in the book, the example code snippets were short, which I appreciated
  • I liked the idea of introducing jQuery in the theme layer in early chapters. Really simple, good call.
  • Good callout in the translation chapter, which says 'hey, translations are really important, don't skip this chapter'. By the title, it was the least interesting chapter to me, but I really enjoyed it.
  • Excellent job covering lots of gotchas: Syntax coloring, can't call ajax on a different domain
  • Creating a javascript templating engine - weird and cool!
  • Would have liked a chapter on jQuery.getScript() - dynamically load javascript
  • How to handle cookies in jQuery - yea!
  • I like the .info file trick - stick your own stuff in there, use it later
  • I really liked the using caching for search auto-complete example. Will definitely use that one in the future.
Jul 29, 2009

Skip to the video

To celebrate by recent release from employment, I spent several days busting my butt to put the sexy back in administration. Namely, I updated the Drupal Navigate module to include some new features, and to fix some long-standing bugs that had been making administrators feel less than sexy for the last several months.

navigate.jpg

For the uninitiated, Navigate is an administration module that works a little like Administration Menu. It loads a sidebar with widgets which allow users to search the menu, nodes or users, construct favorite lists, and load up expandable / collapsable menus. It works really well for clients who aren't used to Drupal. The newest release allows admins to set default widget sets, and adjust user sets. You can also theme it (a funky lemon theme is included as an example).

There's a video demo below, but here's a quick list of improvements made in this release:

  • Made snappier through quicker transitions and fewer ajax calls
  • Added ability to manage default widget sets for users and user roles (all ajax, btw)
  • Made theming Navigate really easy
  • Fixed compatibility issues with Administration Menu
  • Added keyboard shortcuts
  • Added XHTML compliance
  • Added import / export ability for Favorites and for entire widget sets, so you can quickly deploy a set from one site to another
  • Added 'customize' permission, to keep *certain* users from messing up their own sets
  • Added ability to search users
  • Squashed some bugs
  • Re-factored lots of code to be more Drupal-esque
  • Made some minor layout adjustments

I'm hoping to put in some work to help with the current administration tools in D7, but before that, I needed to grease my wheels a bit with some contrib work to to anchor some jQuery techniques I'd learned, and re-familiarize myself with D6. It feels good getting so much done so fast. You can do that with contrib work, but it's hard to be that productive in core Drupal. Things just move at a different pace there. Now that I've gotten a bit out of my system, I think I can crack down a bit and start seeing what I can do for core.

And here's the demo video to celebrate Issue Queue Zero (at least for the D6 version):


Jul 5, 2009

Last weekend I attended DrupalCamp Colorado, and thought I should jot down a few of my personal highlights.

The Hostel

I reserved a dorm bed at a local hostel. Maybe the creepiest place I've ever been. When you register, on the counter is a ventriloquist doll, folded in half with it's legs behind his head. Next to the doll is a communal bowl of chips. Like, potato chips. BBQ flavored. Now, I appreciate the sharing attitude, but would have been far more comfortable plunging my hand into a bowl of individually wrapped candies. After a series of strange events which I hesitate to recount (just in case involved parties are tracking my posts) but which kind of pushed me over the edge of creepiness, a fellow attendee offered to let me stay at his place, and I gratefully accepted. After I presented at one session, someone who actually stayed at the hostel let me know that out of a couple of months of traveling through Europe and Asia, the Denver hostel was the dirtiest he'd seen, and I'd done good by not staying there. The result is a good story with lots of embellishments if you're (un?)fortunate enough to hear the whole tale in person.

The Sessions

I ended up attending a lot of sessions, which I haven't done at previous camps / Drupalcons. I got some good stuff out of the security session with Greg Knaddison, Ezra Gildesgame and Ben Jeavons. Also, got some D6 theming goodness, presented by Stephanie Pakrul and Jay Wolf from Top Notch Themes. The stuff going on with the Skinr module really got me excited, and hearing how TNT improved their conversion rates so drastically using just a few intuitive techniques and very little time was excellent. Ended up sitting in on a few sessions that were a little under my point on the learning curve, but I enjoyed those as well because I was watching for presentation styles, since I gave my first session ever on Sunday.

Good wifi access, fun backchannel discussion, excellent lunch with TNT people and my friend Josh Brauer. There was enough time between sessions to get some socializing done (my favorite part of Drupal events) and meet some Denver folks.

The People

I got a really good vibe from everyone at the Camp. In contrast to Drupalcon (I'm still pretty green when it comes to Drupal events), I enjoyed the atmosphere of a smaller event. Ended up talking to the same people several times, and felt less lost in the crowd. I met a lot of people I'd love to chat with again, and got to put a lot of faces to names I'd only seen in IRC. I came home seriously considering the idea of taking an extended vacation (6 months or a couple years) in the area, just to be around such an active, fun bunch of Drupal folks. The experience anchored my resolution to attend a decent-sized event at least once every couple of months, to keep connected with the really neat people that make up the Drupal community.

Giving a Presentation

I was thankful to have the opportunity to present a session, and that the audience was probably too sedated by the unlimited pizza lunch to judge me too harshly. It went well, at least from my perspective. I kept on time, didn't freak out, and managed to make a few people laugh. The goal of the session was to jumpstart folks who haven't really taken part in community discourse yet, and go over the basics of getting involved. So hopefully, a couple more folks are a little closer to making that leap, or better yet actually took it. I learned that 45 minutes is pitifully short to cover a subject in-depth, and that it would have been nice to have more time for answering questions and getting feedback about what was missing from the presentation so I can make it better next time.

Conclusionary Stuff

I'm looking forward to presenting again, got a little more excited about doing a DrupalCamp in Idaho, am considering taking my wife back to Denver to evaluate an extended vacation there, learned that if you teach something you end up believing it simply through extended exposure, was surprised at my stamina after waking up at 3am, hope to pay some hospitality forward in turn, and am looking forward to hooking up with a lot of the great folks at the camp again. Oh, and if I get back to Denver I'm totally hitting up Chedds. A grilled cheese bistro? Beautiful.