Jan
10


After downloading and using radiant 0.9 and globalize, I realized that I wanted to redirect the users by default with their geo location.
So I installed GeoIP and then I had to do these little modifications to the Globalize plugin.
First, I edit the file config/environment.rb and added this line, in order to load GeoIP with the application

config.gem 'geoip'

Then I updated the file vendor/extensions/globalize2/lib/globalize2/application_controller_extensions.rb

module Globalize2
  module SiteControllerExtensions
    def self.included(base)
      base.class_eval do
        alias_method_chain :find_page, :globalize

        alias_method_chain :show_page, :homepage_redir
      end
    end

    def show_page_with_homepage_redir
      url = params[:url]
      if Array === url
        url = url.join('/')
      else
        url = url.to_s
      end

      if url == '/'
        locale = params[:locale] || cookies[:locale] || session[:locale] || Globalize2Extension.ip_lookup(request.remote_ip)
        redirect_to CGI.unescape('/' + locale + '/') and return
      end

      show_page_without_homepage_redir
    end

    def find_page_with_globalize(url)
      globalized_url = '/' + I18n.locale + '/' + url
      find_page_without_globalize(globalized_url)
    end
  end
end



So, as you can see on the code, I also check if the user has the language selected in a cookie, and when the user selects (or get a locale by default), I set the cookie with the locale, so the next time the user came into the site, he will see the last language selected.
Finally, I updated the file vendor/extensions/globalize2/globalize2_extension.rb and added the following method, where I get the country code from the user, and I set the locale based on his country ip, or the default locale.

  def ip_lookup(ip)
    g = GeoIP.new( File.join(File.dirname(__FILE__), '..', '..', 'gems', 'geoip-0.8.6', 'GeoIP.dat'))
    r = g.country(ip)
    country_code = r[3]
    case country_code
      when 'DE'
        'de'
      when 'GB'
        'uk'
      when 'AU'
        'au'
      when 'FR'
        'fr'
      when ' US'
        'us'
      else
        'us'
    end
  end

And finally, we need to tell Radiant to load the GeoIP library, so in the same file, we add

  extension_config do |config|
    config.gem 'geoip', :source => 'http://github.com'
  end



So that’s all, now you have GeoIP working with globalize and Radiant 0.9 :)

Jan
09


After installing Radiant 0.9 and Globalize, I realized I had to redirect the user to their language site.


So, if the user has been assigned to the locale en, when he vist http://mysite.com he should be redirected to http://mysite.com/en


Why? Because I had some files under images with locales, and I had some flash issues that were not going to work from the homepage address.


So I ended updating the file vendor/extensions/globalize2/lib/globalize2/site_controller_extensions.rb

module Globalize2
  module SiteControllerExtensions
    def self.included(base)
      base.class_eval do
        alias_method_chain :find_page, :globalize

        alias_method :o riginal_show_page, :show_page
        alias_method :show_page, :check_homepage_redir

      end
    end

    def check_homepage_redir
      url = params[:url]
      if Array === url
        url = url.join('/')
      else
        url = url.to_s
      end

      if url == '/'
        locale = params[:locale] || cookies[:locale] || session[:locale] || Globalize2Extension.ip_lookup(request.remote_ip)
        redirect_to CGI.unescape('/' + locale + '/') and return
      end

      original_show_page
    end

    def find_page_with_globalize(url)
      globalized_url = '/' + I18n.locale + '/' + url
      find_page_without_globalize(globalized_url)
    end
  end
end
Dec
30

In the last months, I joined Vaganga, to work in what I believe, the next travel site to buy your touristic packages with an excellent price.
When I joined the company, the source code was being started by an American company called Xillent, and it was a real disaster, I don’t know where they learn to develop websites, but if you want to have a daily post in Daily WTF, be sure to hire them. So I ended rewriting a big part of the code, and luckily, we already released the first version of the web site, and although I have thought (and I’m already working) in migrating all the site to rails, while working to support the current PHP version, the site was released and it’s ready to be used.
Some points to consider to use this site for your next trip ;) :

  • It’s cheaper that many other sites, it’s one of the cheapest web sites out there.
  • Besides great prices, you can be part of the Vaganga community, with important benefits
  • We maintain an history of all your buys, an in little time, we will have discounts for people that buy on the site

For now, the site is working with VAGANGA

Dec
30


I’ve been playing with many CMS, I developed and worked on many web sites, and although Radiant 0.9 was not yet released (Radiant 0.9 RC1 was released), the updates that we have in Radiant 0.9 are great and we should strongly consider start using Radiant 0.9 right now. I don’t understand why they didn’t name it 1.0, since it’s really mature.


The actual support for multiple languages, with plugins like globalize2, save the images automatically in Amazon S3, which is pretty cheap, and you can host your site on herko for $0, and start paying once you have thousand of visits, well, I’m having dreams right now about it, but Radiant stop being a toy some time ago to be a real mature CMS and one more of the reasons that many people is migrating to Rails (because of the CMS :) ), anyway, I love playing with Radiant :P


Let’s get started. There is an excellent guide wrote by Aissac to install Radiant with Paperclip and Globalize2, but if you follow the guide step by step, you will find some troubles (I did), so I left you here a step by step guide, for beginners, so you can get your Radiant 0.9 RC 1 plus the most used plugins with support for multiple languages.


Assuming you already have installed ruby, rails, rubygem, etc. the first step is to install Radiant 0.9 RC 1, we can download it from the next address:
http://radiantcms.org/downloads/radiant-0.9.0-rc1.gem


Once you download it, execute the command:

gem install radiant-0.9.0-rc1.gem



We generate our site

radiant new_site



And we edit the database configuration file (config/database.yml)

development:
  adapter: mysql
  database: new_site_development
  username: root
  password:
  host: localhost
  encoding: utf-8



We generate the database, and we end the installation of Radiant

rake db:create
rake db:bootstrap



Now we start installing the plugins, first, copy_move plugin

git clone git://github.com/pilu/radiant-copy-move.git vendor/extensions/copy_move
rake radiant:extensions:copy_move:update
rake radiant:extensions:copy_move:migrate



We install the reorder plugin, which will allow us to order our website pages

git clone git://github.com/radiant/radiant-reorder-extension.git vendor/extensions/reorder
rake radiant:extensions:reorder:update
rake radiant:extensions:reorder:migrate



We continue with paperclip

git clone git://github.com/kbingman/paperclipped.git vendor/extensions/paperclipped
rake radiant:extensions:paperclipped:migrate
rake radiant:extensions:paperclipped:update



Now we install globalize2, which allows multiple languages on our site (even if we are just thinking about just one language)

git clone git://github.com/Aissac/radiant-globalize2-extension.git vendor/extensions/globalize2
rake radiant:extensions:globalize2:migrate
rake radiant:extensions:globalize2:update



A intermediate step before continuing, we need to edit the file config/environment.rb, and after the commented line with config.extensions, we add:

  config.extensions = [ :copy_move, :paperclipped, :globalize2, :all ]



And now, we install globalize2-paperclipped, which allow us to globalize our assets :)

git clone git://github.com/Aissac/radiant-globalize2-paperclipped-extension.git vendor/extensions/globalize2_paperclipped
rake radiant:extensions:globalize2_paperclipped:migrate
rake radiant:extensions:globalize2_paperclipped:update



The chicken is ready!!! (Argentine phrase ;) ), now you can have your site with Radiant, in multiple languages, don’t forget to check each plugin documentation, in example, to setup many languages in globalize2, edit the file config/environment.rb and add to the end of it:

Radiant::Config['globalize.default_language'] = 'sp'
Radiant::Config['globalize.languages'] = 'en,de,fr'
Dec
30


This year (2009) I’ve been pretty busy, I assisted to 14 different subjects on the university, worked on a lot of interested projects, in Ruby on Rails, PHP, and some java and C++ as well. But I’m going to get some life back to my site, in special to get new customers and show the world I’m still here :)


Today I was trying to upgrade the site to wordpress 2.9, and all the plugins I have on the site. Once I updated everything in my local machine, I got a little surprise, the qtranslate plugin is not ready to work with wordpress 2.9


However, Quian Qin is working on the plugin to make it work with the new version of wordpress, so the update will have to wait until Qian Qin ends the work on the plugin, but I’m sure there are thousands of developers out there waiting for Quian Qin work in order to upgrade their sites.


http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=1271

Dec
30


During this year, I was working as a developer in a website known as Beacon Street Girls


While working there, I first developed a cool feature by using an api provided by Doink


I think it was a great featured, and while the site was live, we got a lot of videos from the users, but a couple of months ago, because of the financial crisis, the rails site where I was working went down and now they maintain a PHP version of the site.


You can check some screens of the work done


Dec
27

Last year I was working on a site that ended being pretty nice, Focus on Virtualization.


It’s a web site made for IDG and Microsoft, it was done in just two weeks, and one of the parts that I really liked were the tweets.


Some images:

Jul
22


Recently, I had to create a twitter live feed for a work I’m doing…. so I found the gems for searching in twitter, but all of them were working with the search.json api, but since my client wanted the same results that he saw in twitter.search.com, I created a lib for that project (following the gem example code), in order to use the search.atom api and parse the xml results with hpricot.

If you deal with the same problem, here you have the code

TwitterFeed.rb

Mar
31


While working for lasentinel, I was having some issues with the MOStlyCE editor, the problem was that there wasn’t a way to let the CMS administrator to upload images, media, etc. because it was throwing a js error, related to a callback function parameter: advimage_image_browser_callback.

The first thing I discovered, is that there was missing the UserFiles directory, if you want to allow your users to upload files for the articles they write, you have to search inside the mambots/editor/mostlyce for a compressed file, just extract these files in the /UserFiles directory.

But even when I did that, and configured one more time the MOStlyCE admin with the correct configuration, it was still throwing errors, I didn’t know why, so I tried to delete the molstyce admin module and mostlyce mambot and reinstall it again, but it was failing with the same errors.

The solution? I installed MOStlyCE 3.1. It looks much better than before and works fine with mambo.

So if you are having trouble with MOStlyCE in mambo (and I know there are a lot of people out there with that problem), don’t break your head, just uninstall the MOStlyCE admin component and MOStlyCE mambot, install the last version of MOStlyCE, search for the UserFiles.zip archive and extract to /UserFiles, set up the component in the administration screen and that’s all ;)

Mar
26


Now that rails 2.3.2 was released (the current version is rails 2.3.2.1), the rails team is following the road to rails 3.0, which means two things:

  1. There won’t be a 2.4 version :P
  2. You can expect a lot of new changes in the version 3.0

There would be a lot of changes in the rails internals, wich means that the plugins would probably need to be rewritten for rails 3.0.

The most exciting thing we will see in rails 3.0, is that merb is gonna be merged into rails, you can read the details here, here, here, here and here.

Rails 3.0 will also allow you to merge a complete ruby application inside another ruby application, with this feature, it will be probably possible to merge a complete forum, a complete gallery application, or whatever into your application in a easy way.