Sha256: afa43b11650d37184f68109e9dbd43f1ab0d286fc2f71b78ff2c537febddb102

Contents?: true

Size: 1.7 KB

Versions: 10

Compression:

Stored size: 1.7 KB

Contents

class CloudhdrController < ApplicationController
  
  protect_from_forgery :except=>[:cloudhdr_notification_update,:zencoder_notification_update,:thumbnail_update,:multi_thumbnail_update]  
  
  def cloudhdr_notification_update
    full_params = params
    CloudhdrJob.update_from_cloudhdr(full_params)
    respond_to do |format|
      format.json  { render :json => {} }
    end
  end
    
  def thumbnail_update
    @img = Kernel.const_get(params[:class]).find params[:id]
    @random = params[:random]
    @live_vide = params[:live_video]
    respond_to do |format|
      format.js {}
    end
  end
  
  def multi_thumbnail_update
    @outputs = []
    params[:images].each do |image|
      # Format ex : Image_1_medium_db0ce8ba5d55c25eee7c767220d654fe
      # Format is : class_id_thumbnail_random
      match = image.match(/^(.*)_(.*)_(.*)_(.*)$/)
      hash = { 
        :elem_id     => image,
        :class_name  => match[1],
        :id          => match[2],
        :thumbnail   => match[3],
        :random      => match[4],
        :image       => Kernel.const_get(match[1]).find(match[2]) 
      }
      @outputs << hash
    end
    respond_to do |format|
      format.json {}
    end
  end
  
  
  # thanks to http://avdi.org/devblog/2009/07/14/recursively-symbolize-keys/
  #def symbolize_keys(hash)
    #puts "the hash = #{hash.class} : #{hash}"
    #return hash if !hash.is_a?(Hash)
    #hash.inject({}){|result, (key, value)|  
      #new_key = case key  
        #when String then key.to_sym  
      #else key  
      #end  
      #new_value = case value  
        #when Hash then symbolize_keys(value)  
      #else value  
      #end  
      #result[new_key] = new_value  
      #result  
    #}  
  #end
  
  
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cloudhdr_rails-0.0.10 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.9 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.8 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.7 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.6 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.5 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.4 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.3 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.2 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.1 app/controllers/cloudhdr_controller.rb