Close and Go BackBack to Viget

Facebook Connect UX Challenges

Justin Marney
Justin Marney, Former Staffer, January 14, 2009

Recently, our very own Ryan Moede weighed in on Facebook's newest API addition, Facebook Connect. Around the same time I began to research the technical challenges that Facebook Connect posed by attempting to add Facebook Connect to an existing application. Using Facebooker and some custom Facebooker extensions I was able to successfully integrate authentication, registration, and news feed features. During this process I came across several user-experience challenges surrounding the Facebook Connect authentication mechanism. Depending on the nature of your FB Connect application, these issues might present some real headaches for both users and developers.

Continue reading "Facebook Connect UX Challenges"

The Making of VigeTurf - Development

Matt Swasey
Matt Swasey, Former Staffer, January 14, 2009

The making of VigeTurf brought together folks from all our labs.  In this series, we're pulling back the curtain to give a detailed explanation of how it was created. Here, it's all about the application.

When the VigeTurf team came to me asking questions like, "Can we generate unique URLs that have holiday words in them?" and "Can we have a Twitter-like application?", I was pretty stoked.  This was going to be a nice opportunity to test some of the new developments going on inside the Rails community -- and to add my own to it. 

I decided to start by building the Twitter-like application, which ended up having holiday-themed captcha and a curse-word-swap-for-silly-word feature that kept everything clean.  To generate captchas, I used zendesk's captcha plugin.  This would generate random characters using imagemagick libraries through rmagick.  However, we wanted holiday-themed phrases rather than random characters.  So, I edited the image generation script to pull from a random word generator, which further pulled from a list of "holiday" words our office compiled.  Patch to come.

Then, I tackled the VigeTurf creations themselves.  Erik's Flash needed to push two different kinds of data types -- file uploading and file capture -- that the Rails application would intercept and write to the file system.  So we paired for several hours to make it happen.

mig_and_erik_435Here are Erik and I being awesome.

First, when a user chooses to "Upload" a unique background image to create the turf, the Flash has to push that file to the Rails application.  I don't know so much about Flash and the way all this happens, so forgive any slips in terminology.  All I knew was that I was getting some params that had two key values, :Filedata and :Filename.  I simply pushed the :Filedata values into a blob attribute on an ImageFile model instance, and the :Filename to the name attribute.  After that, I would use an after_create hook to write the image to the file system:

In the controller action:

  @image_file           = ImageFile.new
  @image_file.blob      = params[:Filedata]
  @image_file.name      = params[:Filename]
  @image_file.filename  = @image_file.name
  @image_file.directory = APP_CONFIG["upload_dir"]
  @image_file.save
  
  render :nothing => true

After the grass on the Flash had grown and need to be saved again, the data coming back was much different.  This time, it was in a binary/octet-stream.  The Flash essentially took a snapshot of the image with the grass cut away, and then pushed it as a binary stream to a second end point in the Rails application.  At that point, I dumped the binary stream to a file system.

In the controller:

  @image_file           = ImageFile.new(:turf => true)
  @image_file.blob      = request.body
  @image_file.name      = JoyGen.unique_words!
  @image_file.filename  = @image_file.name + ".jpg"
  @image_file.directory = APP_CONFIG["finished_dir"]
  @image_file.save
  
  render :text => turf_address(@image_file.name)

As you can see, I'm just taking the incoming requests body and dumping it straight to the file system.  No mime-type checking needed, since I know it's only coming from one place internally.  This would need to be resilient if you were going to accept streams from more than one consistent source.

Also, you might notice that I am setting the image_files name to JoyGen.unique_words!  This is a small library developed to pick three random words from a text file provided.

For those of you interested, here the the JoyGen module: 

 

  module JoyGen
    WORDS ||= IO.readlines(Rails.root + "/lib/holiday_words.txt")

    def self.unique_words!(amount = 3, options = {})
      delimiter  = options[:delimiter] || "-"
      max_length = options[:max_length] || 8
      min_length = options[:min_length] || 3

      url = Array.new
      amount.times { url << scrubbed_word(min_length, max_length) }
      url.join(delimiter)
    end

    private
    def self.word
      WORDS[rand(WORDS.length)].chomp
    end

    def self.scrubbed_word(min, max)
      @word = word
      if @word.length >= min && @word.length <= max
        @word.gsub(/( *|_*|-*)/, '').downcase
      else
        scrubbed_word(min, max)
      end
    end  
  end

 

Take an in-depth look at how the other pieces came together.

A Gaggle Of Git Tips

Mark Cornick
Mark Cornick, Former Staffer, January 11, 2009

Almost a year ago, our first post about Git hit this blog. Since then, our posts about Git have been popular with you, our readers. Clinton’s overview of git-svn, for example, remains one of our most popular posts, months after he first wrote it.

Like much of the Ruby and Rails world, we’re using Git every day, and finding little ways to exploit its power for fun and profit. This post brings together several of our little Git discoveries. Some are profound; some are subtle. Some are well-documented in the literature; some are hidden in corners of the Git source. All of them, however, have made our lives a little easier—and we hope they’ll do the same for you.

Continue reading "A Gaggle Of Git Tips"

Rails Authentication Plugin: simplest_auth

Tony Pitale
Tony Pitale, Former Staffer, January 09, 2009

simplest_auth is a plugin for Rails applications where RESTful Authentication is overkill – it handles authentication and nothing else.

Continue reading "Rails Authentication Plugin: simplest_auth"

Radarb: A Ruby Gem That Makes Using the Outside.in API Simple

Justin Marney
Justin Marney, Former Staffer, January 08, 2009

What is outside.in?

Outside.in is a hyperlocal news and information service:

Hyperlocal means news and information on a level beyond what traditional media provides. Until now, most "local" sites didn’t actually get more, well, local than cities or towns. They assumed that just because you live in a specific city or town you are looking for the same news as everyone else. Hyperlocal content gives you the news and information for the area right around where you are, like the block around your office or the neighborhood where you live.

What is outside.in Radar?

outside.in Radar is the first local news experience that puts you at the center of the action. It is customized to exactly where you are and what’s going on right around you.

Examples include tweets, news stories, and blog posts in your immediate area (surrounding blocks or neighborhoods).

What is the outside.in Radar API?

The outside.in API is a means by which developers can easily integrate Radar results into their own applications. Send it a latitude and longitude and get back stories, tweets, and other outside.in user-generated content for the surrounding area. A sample query returns XML that looks like:

Continue reading "Radarb: A Ruby Gem That Makes Using the Outside.in API Simple"

We're the Developers

at Viget Labs. We write about web development trends, tips, best practices, industry events, and our projects — all with an emphasis on Ruby on Rails.

Contact Us

Have any questions, comments, ideas, or secrets to share? Let us know.


How many hours in a day?

Sorry, you need to have Javascript enabled to use this form. (Don't blame us, blame the spammers!) If you'd like to contact us, please visit our Contact page.