RiCal and Google Calendar

by James Harrison on July 10th, 2009

So, there was a request on Twitter from ChainerCygnus to get Google Calendar support in Charactr, so I went ahead and implemented it. You can now access an iCal feed of skill changes on Charactr on the characters page, and it uses the Charactr API key to authenticate so it works in anything, no need for HTTP Basic authentication support or anything.

Implementing was actually really easy. I grabbed the RiCal gem off Github, threw in the config.gem line in environment.rb, and added this to the characters controller index action:

respond_to do |format|
  format.html
  format.ics do
    rna = ['(Untrained)','I','II','III','IV','V'] # Used below for roman numerals
    cal = RiCal.Calendar do |cal|
      cal.add_x_property('X-WR-CALNAME','Charactr')
      @characters.each do |char|
        if char.skills_in_training.length > 0
          char.skills_in_training.each do |s|
            cal.event do |e|
              e.summary "#{char.name} finishes #{s.type.name} #{rna[s.level]}"
              e.description "#{char.name} finishes #{s.type.name} #{rna[s.level]}"
              e.dtstart s.end_time-10.minutes
              e.dtstart s.end_time
            end# event
          end # skills loop
        end # skillintraining > 0
      end # char loop
    end # calendar
    render :text=>cal.export
  end
end

So as you can see, it’s a snap. Rails ships with a preconfigured MIME type for the :ics format, so it’s handled properly by nginx automatically. Still having some issues making Google Calendar accept the feed’s name as Charactr, mind you, but the rest works flawlessly and is available for all Charactr users right now.

On a side note, we’ve set up the @mmmetrics Twitter account as a shared account between all the MMMetrics team; if you’re having problems with any of the sites and use Twitter that’s a pretty good port of call. We’ll also be using that for announcements and so on, so it might make sense to follow if you’re interested in what we do.

It’s been a busy day on EVE Metrics 2, so I leave you with a few teaser screenshots. We’re almost done with the basic market view pages, and it’s now a matter of implementing the smaller features- market favourites, map features, and the APIs. EM2 won’t be an instant fullfilment of every feature promised over the past year or so; we’re taking the development slowly. EM2 at release won’t be as feature-packed as EM1, but it’ll work a whole lot better! Once we’ve gotten it released (hopefully in just under a week) we’ll be adding features and maintaining the site continuously to get all the features you want implemented without affecting performance.

Related posts:

2 Comments
  1. Onyx Asablot permalink

    Hows EM2.0 coming on? I’m looking forward to seeing what you have come up with :)

  2. We’ve got EM2 pencilled in for release on Thursday. No promises, of course (We were aiming for Monday but we’ve been having issues with finding time to finish off the last few items on our bugtracker) but that’s what we’re working towards.

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS