jQuery with Rails 3

One of the most talked about features in Rails 3 is its plug & play architecture with various frameworks like Datamapper in place of ActiveRecord for the ORM or jQuery for javascript. However, I've yet to see much info on how to actually do this with the javascript framework.

Fortunately, it looks like a lot of the hard work has already been done. Rails now emits HTML that is compatible with the unobtrusive approach to javascript. Meaning, instead of seeing a delete link like this:

you'll now see it written as

This makes it very easy for a javascript driver to come along, pick out and identify the relevant pieces, and attach the appropriate handlers.

So, enough blabbing. How do you get jQuery working with Rails 3? I'll try to make this short and sweet.

Grab the jQuery driver at http://github.com/rails/jquery-ujs and put it in your javascripts directory. The file is at src/rails.js

Include jQuery (I just use the google hosted version) and the driver in your application layout or view. In HAML it would look something like.

Structure and Interpretation of Computer Programs (SICP) for Kindle

I just started reading the SICP book (Structure and Interpretation of Computer Programs, by Abelson, Sussman, and Sussman) which MIT Press has so graciously made available on their website. I'm not very fond of sitting in front of a computer screen to read books, so I mirrored their copy locally and converted it into a prc file (using Mobipocket Creator) so I could read it on my Kindle.

Here it is for anyone else who wants to save a bit of time.

It is provided under Creative Commons Attribution-Noncommercial 3.0 Unported License.

Ubiquity Commands Updated

Ubiquity 0.5 was released a few weeks ago, and I finally got around to updating my commands. If you were using my W3C or Drupal API Ubiquity commands, they are now 0.5 compatible. Please update your command source.

March Phoenix Drupal Meetup

The March Phoenix Drupal meetup will be held next Tuesday, March 10th at 7pm. The meetup is moving on to the ASU campus thanks to the help of Chris Yates. Event details can be found on the DrupalPHX group page.

Chris will be giving a presentation about the Mars Image Explorer project and how they are utilizing Drupal within that project. There's also been mention of DrupalCon attendees sharing a bit about what went on at the conference.

Hope you all can make it.

Phoenix Metro Drupal Meetup Next Tuesday

There will be a Phoenix Drupal meetup next Tuesday evening at Macayo's in Tempe. See official event details and sign up HERE. This meeting is a chance for local Drupal developers to get together and discuss what's going on in their Drupal world and Drupal in general. While we are working on a more presentation friendly meeting spot for future meetups, this will give us a chance to at least meet and gauge community interest level. Hope to see you there!

Getting Started with Exhibit using Drupal and Views (part 3)

In this last episode of getting started with Exhibit and Drupal, we'll embellish the Exhibit we created in part 2 by adding some additional views, exploring the use of lenses and expressions, and adding another facet. Our final Exhibit can be seen here.

Adding Views to your Exhibit

So the first thing we'll do is add several additional views to our Exhibit. The tabular view is nice and provides some great functionality, but Exhibit provides some additional views that are great at visually enhancing the way your data is displayed. We'll start by adding a calendar view. To do this you'll need the following code pasted within your viewPanel:

<div ex:role="view"
      ex:viewClass="Calendar"
      ex:label="Calendar"
      ex:start=".field_date_value"
      ex:end=".field_date_value2"
      ex:eventLabel=".title"
      ex:formats="date { mode: short; 
                         show: date-time; 
                         template: 'MM/dd/yyyy' } 
                  item { title: expression(.title) }"></div>

Getting Started with Exhibit using Drupal and Views (part 2)

Ok, now that we know a bit about Exhibit and how Drupal can help us create Exhibits, let's start by getting our Drupal data in Exhibit JSON format.

Setup

The setup I'm using for this tutorial includes a Drupal 6 installation with the following modules enabled: Exhibit, Views 2, CCK, Date, Location, and GMap. I'm only using CCK, Date, Location and GMap to create a custom Event node type with date and location fields. I've also added taxonomies to the Event node type for event type and tags. You can create your own node type and add whatever fields you would like. I'm using this setup to demonstrate the broadest possible uses of Exhibit. With this Event node type, we'll be able to create an Exhibit complete with Calendar, Timeline, Map, and Interactive Table displays. You can visit my playground here: http://d6demo.joshhuckabee.com

Create Exhibit JSON from your Views

Getting Started with Exhibit using Drupal and Views (part 1)

In this multi-part tutorial I will show you how to create interactive Exhibit displays of you Drupal data using the Views, CCK, and Exhibit modules. I'll start with a brief overview of Exhibit and how it works, then move on to explain how to get your Drupal data in a format that Exhibit can use, and finally, I'll show you how to setup the Exhibit. If you're already familiar with how Exhibit works, you'll probably want to wait for part two of this series.

What is Exhibit?

Ubiquity - A New Direction in Web UI

Mozilla labs has released a slick new Firefox extension called Ubiquity that aims to streamline the most common tasks you do in your browser as well as make things that seemed otherwise overly difficult or complicated, much more easier. I've seen it being called everything from "Quicksilver for Firefox" to "mashups for dummies". There's plenty of buzz around the net to fill you in on the details, so I won't go into that here.

I certainly like what I see in Ubiquity. It goes way beyond what Quiksilver does (or can do) and its more thant just a "mashup". Its capabilities are virtually limitless. But, what I've liked most so far about Ubiquity is how easy it is to extend. In a matter of about an hour I saw the headline on reddit about "the future of the web browser", watched Aza's cool video, wrote two simple, trivial commands, published my commands, and watched as over a dozen different people (whom I don't know nor didn't pay) downloaded and began using those commands. That says a lot about the tool and the creators over at Mozilla labs.

Its definitely something to check out if you haven't done so already.

Oh, and about those commands. The first allows you to submit any page you're on to the W3C's markup validator. Just ubiq "validate" and hit enter. You can catch that one here.

The last command I wrote is basically a shortcut to Drupal's API. Ubiq "drupal" followed by a core function, file name, constant, global or topic, hit enter and you'll land softly on the correct Drupal API page.

Drupal API Ubiquity Command

One last thing, if you haven't heard about the IE Death March, go show your support.

Free Up Resources on Your Drupal Web Server

If you're not using the InnoDB engine in your MySQL databases, make sure its disabled in your my.conf by uncommenting or adding the skip-innodb directive. This simple change can free up some precious resources since MySQL is now only required to start up one engine.

Before I turned off the InnoDB engine my memory footprint looked like this:

             total       used       free     shared    buffers     cached
Mem:          1022       1012         10          0        133        673
-/+ buffers/cache:        205        817
Swap:         2047          0       2047

After I turned off InnoDB an restarted MySQL...

             total       used       free     shared    buffers     cached
Mem:          1022        982         39          0        133        676
-/+ buffers/cache:        172        849
Swap:         2047          0       2047

That small change saved me 33MB of memory. Thats about 3% of the 1GB I have on my small VPS.