Tuesday, November 15, 2011

Project Genesis: Report 9

A huge bump in the road. I have been forced to recreate the whole web framework of the upcoming cloud service. I have been hard at work for the last two days and maybe I will be able to finish the work tomorrow.

Last week
Last week I managed to finish up everything on Stoffi in order to release the beta. The only thing left was to confirm everything and do some testing before release.

Then, as I needed to add translation to the website (since part of it is displayed inside Stoffi it needs to be displayed in the same language as Stoffi) I came to a dead end.

I have been using Rails 2.3 for a while now and Rails 3 have been out for quite some time. This time around the guys behind Rails have been hard at work migrating all existing documentation to Rails 3. It has been really hard from time to time to find documentation for Rails 2. On several occasions I've had to tweak example code and snippets in order to get it to work.

But setting up the routes for translation finally killed Rails 2 for me. There was no way I could get the routes setup properly so I went ahead and upgraded the app to Rails 3.

The upgrade was a disaster. I actually managed to get all of my code to work with Rails 3 but the recaptcha plugin threw some errors and the upgrade plugin provided by the Rails guys didn't upgrade all my files, so I got stuck with some bastard hybrid app that was neither 2 nor 3. I decided to create a whole new Rails 3 app and just move my code into it.

The biggest problem was that my faithful restful_authentication plugin didn't work with Rails 3. So I have moved to Devise. It is really slick and I got registration and login working yesterday. I then moved on to make sure that the translation routes worked properly and I got everything working late last night.

The translation system of Stoffi is actually pretty awesome.

Path
First, it looks for a locale in the path. So for example www.stoffiplayer.com/en/news will give you news in English and www.stoffiplayer.com/sv/news will give you news in Swedish.

Top domain
If no locale is found (like in www.stoffiplayer.com/news) then it will check the top level domain. This means that if we ever register stuff like stoffiplayer.se or stoffiplayer.ru, then the website will detect the language using the TLD.

Subdomain
If that fails (like when it's stoffiplayer.com) then it will look at the subdomains. This means that we could register stuff like se.stoffiplayer.com and ja.stoffiplayer.com, but since my SSL certificate only covers stoffiplayer.com and no subdomains I don't think we'll ever do this.

Browser setting
If no locale still haven't been detected then it will check the "Accept-language" parameter in the HTTP header sent from the browser. This means that if you set a language in your browser the website will detect it and display the proper language.

Location
If your browser doesn't send out any information about the language then Stoffi will do a lookup on your IP address (don't worry, it's not saved anywhere) and detect which country it originates from.

This week
Right now I am working on getting the OAuth client part working again so it's possible to connect to your Facebook, Twitter or Google account.

When this is done I'll move in the OAuth provider code so we can have Stoffi Music Player, Stoffi Remote and other third parties login and access the cloud services.

Lastly, I will get back the support for mobile and embedded views and the Juggernaut code so we can push out changes of objects to clients.

When all that is done I will verify that everything works, both on the website and in Stoffi, and also check with Gadd so the iOS app is still working. Then I'll do the beta release.

Challenges
I think that getting the OAuth provider stuff working in Rails 3 will be a challenge. The only instructions for the plugin are a blog post from the author and it dates back to 2007. The plugin may have been updated since then but we'll see how it works out. I haven't found any other plugin either.

I may also require some effort to get Juggernaut to play with our new setup but that plugin is very well maintained and will hopefully not offer too much trouble.

Since I am currently two weeks behind schedule on the beta release there may be a need to postpone the stable release of Zhou (we need to test it properly in beta before we release it into stable). But if I make that decision I'll make another post about it here on the blog.