By

DogOnRails, only a smaller piece of a bigger picture.

I noticed that I've been referring to DogOnRails a lot in my Ruby Examples (because I don't like exposing our clients' code to the outside world if I can avoid it), so I better talk about what it is other than it being an abstract example I use here!

What is Dog On Rails?

DogOnRails is a WifiDog Captive Portal Authentication Server. Unlike the WifiDog server, it is written in Ruby on Rails (hence the name). It originally started out as a small hobby project so I could use it to run on a Linksys WRT54G at my apartment and have it redirect to my Dreamhost account. Then some other people saw that I was working on the project on Google Code and started to help me out with it. Then I started doing this Meraki FreeTheNet stuff, which gave me a new platform to put WifiDog client, and this was the perfect opportunity to de-mystify the whole process.

So, why is it cool?

The original concept of WifiDog is what drew me to it. The original WifiDog project was designed so that Captive Portals, which were only being used by WISPs at the time could be used to display both user-centric and location-centric information to the user so that they would learn more about the area around them. The reason I started working with DogOnRails was because I am able to add more features faster with Rails than I would be able to with PHP, and the fact that I dislike the Smarty Templating Engine, which made adding larger features a major hassle.

There is also the fact that the project seemed to cater more and more to the WISP community than its original purpose, so I felt the server no longer was interesting.

The thing that I like about it is the fact that this allows anyone who can hack Ruby on Rails to add more features onto something that normally would require that you write in C or Shell Script. By moving the authentication off the device, you can do much more with the process than simple authentication, you could redirect the user to what you want to see before they are on their way. And since they're using YOUR bandwidth anyway. The analogy here is showing a visitor to your house around before they sit down and watch television. It's not always necessary, but it's a good courtesy for those who haven't been to your house before.

Oh yeah, did I mention that it was voted the Best of HackDay 1. I think that bars it from competing in Hack Day 2. I have a whole new killer app for that. :P

So, what features did you add during HackDay?

I added the following features:

  • User-Agent detection for mobile devices
  • GoogleMaps Functionality
  • GoogleEarth Functionality

The User-Agent detection was much easier than I thought. I borrowed Alexei's iPhone to test the final design, and at the end I was able to get the UserAgent detection to show the view easily, the code looks like this:


user_agent = request.user_agent.downcase
mobile = false

# Mobile Request URI
[ 'iphone' , 'ipod' ].each { |b|
mobile = true if user_agent.include? b
}

The rest is pretty self-explanitory at this point! After that was added, it was just a matter of doing some iPhone-based CSS. I used Facebook as an example of how to do this, and after cursing WebKit/Safari's existance, I managed to get something that didn't require a LOT of resizing to get working.

Of course, the following features were added post-hackday:

  • ROBIN/Open-Mesh Update Recieving - (Can't update settings yet, can get the Mesh status)
  • Improved GoogleMaps Functionality - Looks more like the Merkai Map
  • Per Node Auditing
  • Graphs using gruff
  • MAC Address Blocking
  • Facebook Functionality

That's right, DogOnRails is now a Facebook application as well. The idea behind this is to encourage people to grow Wifi networks like they would grow their own garden. Make it so that there's a certain level of pride for having the nodes up and working. It's very, very early alpha stages, but it exists and it currently looks like this:

Facebook Screen

It needs a lot more polish, but it's going to be used by the FreeTheNet group in the coming month, and will be the replacement to the Meraki Dashboard that we have been looking it. There will probably be more changes to this, and to other things like this. But, when I refer to DogOnRails, I'm referring to a real app, and not some abstract thing like in a textbook.

And I will keep using it as an example of what to do and what NOT to do for many posts to come.