Adam Monsen

April 24, 2010

Grails: alternate views for mobile (iPhone) clients

Filed under: Default — Tags: , — adam @ 11:08 am PST

I figured out a semi-cool setup to provide alternate views if the client is found to be, for instance, a Mobile Safari browser on an iPhone. I wanted to share my findings since I’ve seen related questions asked here or there, and I have a question at the end about a potential improvement.

First, I made a filter:

detectMobile (controller:'*', action:'*') {
  before = {
    if (request.getHeader('user-agent') =~ /(?i)iphone/) {
      request['isMobile'] = true
    } else {
      request['isMobile'] = false
    }
    return true // keep processing other filters and the action
  }
  after = { }
  afterView = { }
}

Next, I added the following to a controller:

def afterInterceptor = { model, modelAndView ->
  if (request['isMobile']) {
    modelAndView.viewName = modelAndView.viewName + "_m"
  }
}

For that controller, if a request comes in from a mobile device, a view ending in “_m” is loaded, instead of the default view. The view “list.gsp” would have a counterpart mobile view “list_m.gsp”, and that’s what would be served to iPhone clients. That’s it, so far.

One bit that would be handy would be to add this closure to every controller, rather than have to copy and paste it to controllers that support mobile views. I’ve been meaning to see how the rest plugin dynamically adds methods to every controller in case that is similar to what I’m trying to do, but if anyone knows offhand what I need to do (or read) to automatically get the closure in every controller, please let me know.

April 14, 2010

The Power of Lightweight Markups: Presentations

Filed under: Default — Tags: , , , — adam @ 12:21 am PST

Are you busy clicking away at a slide deck for your next presentation? Want to try something a little different?

Non-nerdy folks following this blog, you’ll probably want to tune out now. Or not! I tried to write this for a wide audience, so come on down the rabbit hole if you dare.

(more…)

April 1, 2010

The Mifos user manual sprint; how we’ll break Brooks’s law

Filed under: Default — Tags: , , , — adam @ 4:08 pm PST

I’m really excited for the Mifos user manual sprint tomorrow. We’re using FLOSS Manuals to write our new user manual. FLOSS Manuals is an exciting way to write a book, it provides a framework for high-bandwidth collaboration, publishing to HTML and print, translating, and more. There are many examples of small teams (less than 10 people) publishing large, excellent books in short time periods (less than a week).

We’ll have a video feed going. I’ll be wearing my track suit.

Check out our coordination wiki page and stop by our IRC channel if you’d like to join in! If you’ve ever edited text on a wiki, are brave enough to learn how, or just want to see me in a track suit, come on by.

I suppose I should explain the title of this post. If we can establish a framework for software development on Mifos like we’re running this sprint, we can break Brooks’s law. Why not? The Ksplice folks did it, so we can too!

Powered by WordPress