Sha256: 2b1c6b8c7f8ccbc40e734f2167d14b102c890b534d1232e2a77e03d2d5a74cd7

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 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
    puts "cloudhdr_notification_update"
    puts params
    puts "request.raw_post-------------------------------------------------------"
    puts request.raw_post
    puts "request.body.read-------------------------------------------------------"
    puts request.body.read
    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

2 entries across 2 versions & 1 rubygems

Version Path
cloudhdr_rails-0.0.14 app/controllers/cloudhdr_controller.rb
cloudhdr_rails-0.0.13 app/controllers/cloudhdr_controller.rb