Friday, August 7, 2009

FocusPad

I have created a new iPhone app called FocusPad. It is ideally suited for use with the Autofocus task management system. It is currently in beta testing. Some screenshots are below.









Wednesday, November 26, 2008

Merb and logins

I am using Merb now instead of Rails, and I am loving it. Expect more blogs about this soon.

For right now, I want to share a little tip: to implement a Log In link in your code, do this:

link_to "Log in", url(:login)

This uses the merb-auth slice that comes with a standard Merb app.

Sunday, June 15, 2008

HTML and CSS are today’s assembly code

See how Haml and Sass make HTML and CSS look like assembly code -- my latest post to Resourceful Idiot.

Thursday, June 12, 2008

RESTful databases

I just wrote my first post for Resourceful Idiot about the new crop of document-oriented databases. Check it out!

Tuesday, June 3, 2008

Unobtrusive Rails remote links and forms

I blogged a few days ago about Unobtrusive Javascript. As I mentioned, Rails has not exactly embraced it.

For example:
  • The helper methods link_to_remote and remote_form_for embed Javascript right into the HTML.

  • link_to_remote does not automatically fall back on a normal URL call if Javascript is unavailable. You can make this happen by adding an extra param with the same path as the remote path, but this is not very DRY.
After doing some research and some experimentation, I found a clean solution for the issues above by using LowPro:
  • In your views, use normal link_to and form_for calls instead of the remote versions, but set their class to "remote". For example:
      <%= link_to "Add", item, :class => "remote" %>
  • Get your app to work correctly using the normal calls, by having your controller render full views as usual.

  • Grab lowpro.js and add it to your public/javascripts folder.

  • Add the following code to your application.js file:
      Event.addBehavior({
    'a.remote' : Remote.Link,
    'form.remote': Remote.Form});
  • In your controller, for each action that will be called remotely, add "format.js" to your respond_to block:
      respond_to do |format|
    format.html
    format.js
    end
  • For each of the remote actions, create an RJS file. For example, create.js.rjs.
  • In your RJS file, do the appropriate actions. For example, render a partial:
      page.replace_html item_id,
    :partial => "item",
    :object => @item
The links and forms of class "remote" will be called normally if Javascript is disabled, and remotely if Javascript is present. Perfect! This is especially nice for debugging, as I can comment out the lines in application.js and force all links and forms to use normal calls.

Note that there is an Unobtrusive Javascript plugin (UJS) that uses LowPro under the hood, but it does not work with Rails 2.0. Dan Webb, the author of both of UJS and LowPro, is no longer maintaining UJS nor does he use or endorse it. Instead he uses LowPro directly. You can read why here.

7actions: a todo list site


We all have lots of things to do. Several years ago I worked with David Allen, the author of Getting Things Done, at a company called Actioneer. Long before he wrote the book, David understood that all PIMs at the time were flawed, being calendar-based and not allowing for the interruptions and uncertainties of life. We were determined to make a great PIM that did not have these shortcomings. I attended several of his time-management seminars, and I was deeply impressed with his approach and philosophy, at both a professional and personal level.

Unfortunately, Outlook came out, and the MS bulldozer swept everyone, good and bad, out of the way. Actioneer never did make that PIM, to my great disappointment. But I never forgot the mission.

With Outlook diminishing in importance and the general shift toward Web applications, online todo lists are starting to make sense. And this finally gives me an opportunity to write one that embraces everything I learned from David and my experiences at Actioneer: 7actions is born.

The basic problem with most todo lists is that almost everything on them is not something you can actually do. For example, "buy a car" is not an action that you can complete. You need to dig in and find the "next action". Maybe you decide "find a dealer" is the next action. Then you realize that even that requires more digging; you first have to call your friend to see where he bought his car. Finally you have something you can actually take action on to move your todo forward.

Some people call these multi-step todos "projects", but that sounds too formal and heavy-handed for my tastes. A project sounds like a big deal to start and finish, and almost no one see "find a dealer" as a real project.

The 7actions site is designed to help you discover your next actions and get them done. You can dig as deeply as you need to into each todo by clicking on it. You can pull out the next actions by starring them. When you complete an action, check it off. Simple!

Check out the site: 7actions.com

There is still a lot to do for it to be finished. But the basic pieces are in place. I will be moving into it this week, and I am sure I will discover many changes that need to be made. I expect it to get better and mature quickly, since I will be depending on it to keep me organized!

The site was written in Rails, and it uses remote AJAX calls where appropriate to avoid full page loads. It also has some genuine fanciness: you can drag and drop list items to sort them, thanks to the built-in Script.aculo.us framework. The nice thing is that all of this is done unobtrusively, and the site still works even if Javascript is not available.

Sunday, June 1, 2008

Being Unobtrusive

The Unobtrusive JavaScript movement resonates with me. Simply put:
  • Keep JavaScript away from your HTML
  • Make your site work even if JavaScript is unavailable or disabled
It's not hard to do, but you need to adopt this philosophy up front when developing a new site. Here is the basic idea:
  1. Develop your site with no JavaScript. Use plain old HTML for all your functionality.
  2. Create a separate .js file and include it with your pages. If JavaScript is disabled, the file will be ignored.
  3. In your .js files, add magic to your existing page elements by modifying them via DOM.
This is relatively new thinking in the JavaScript world, and not everyone has bought into it. For example, Rails embeds JavaScript right into ERb files via the helper methods, and it depends on JavaScript in ways you might not even know about (e.g. links that use PUT or DELETE fail when JavaScript is disabled).

In future posts I will talk about some of the solutions that are out there to more easily make your JavaScript unobtrusive.