iPhone on Rails – Creating an iPhone optimised version of your Rails site using iUI and Rails 2

iPhone on Rails – Creating an iPhone optimised version of your Rails site using iUI and Rails 2: After upgrading trawlr.com to Rails 2 I thought I’d make use of some of the new features and attempt to create an iPhone version of the site. With Rails 2 you can create a mime type specifically for the iPhone and then use that format in a respond_to block (along with views such as index.iphone.erb). [IPhone therefore I am. Actually not yet… but I’ll get there.]
Source:

Ruby stuffs

Two things worth noting:

def something(x = 0)
  ...
end

doesn’t ensure that x is set to a value of zero, because the method could be called with nil [something(nil)] so to ensure a default value of zero even in the face a call with nil

def something(x = 0)
  x ||= 0
  ...
end

would do the trick.

The second is that when adding text and an object’s property

x = 'some string'
y = x + something.description

that if something.description is nil, the addition will fail, but if you interpolate ala

x = 'some string'
y = x + "#{something.description}"

something.description evaluates to empty string and therefore won’t fail.

Two subtle regressions our tests caught today when refactoring, but were not easy to see in the code.
Onward!

The seven rules of unobtrusive JavaScript

The seven rules of unobtrusive JavaScript: I’ve found the following rules over the years developing, teaching and implementing JavaScript in an unobtrusive manner. They have specifically been the outline of a workshop on unobtrusive JavaScript for the Paris Web conference 2007 in Paris, France. I hope that they help you understand a bit why it is a good idea to plan and execute your JavaScript in this way. It has helped me deliver products faster, with much higher quality and a lot easier maintenance. [Good stuff.]

scripteka

Prototype UI: Prototype UI is a javascript library based on Prototype 1.6 and Script.aculo.us. It's an extensive and fast growing library of UI components which can be used in complex web applications. Currently, Prototype UI provides such modules as Carousel, Modal window, Shadow and Context menu which can be used as one package or independently.”[Scripteka is collection of prototype.j extensions and libs. Excellent.]
Source: Scripteka

Making the OpenSocial API feel more at home

Making the OpenSocial API feel more at home:

Chris Chabot has been doing a lot of experimentation with the new OpenSocial APIs. He has written up his experience and created two prototype wrappers.

The first short article has some general information and background.

The second article includes the first library you can tell to load (owner, viewer, ownerFriends and/or
viewerFriends) information, and presents this information in an uniform way (instead of having to do different type of calls for different information fields) and with proper consistent error handling. With it you can very easily create your first OpenSocial container application in a friendly prototype style environment. You can take a direct look at the library itself.

The third article contains a Ajax.Request implementation, since Prototype’s version won’t work well or even at all in the cross domain environment of open social containers, it allows you to re-use your current Prototype based programs by trying to mimic Prototype’s Ajax call as well as possible given the constraints of the situation. Under the hood, _IG_FetchContent is used to talk back to the server.

It is good to see people take the raw APIs and make them feel more like their library of choice.

[Hmmm.]
Source: Ajaxian