Sha256: b13994de4102158208336215b7f696efb709ffb8496ff96b351f7847a8aea797

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

class Ckeditor::ApplicationController < ::ApplicationController
  respond_to :html, :json
  
  before_filter :set_locale
  before_filter :find_asset, :only => [:destroy]
  before_filter :authenticate_administrator!
  
  protected
    
    def set_locale
      if !params[:langCode].blank? && I18n.available_locales.include?(params[:langCode].to_sym)
        I18n.locale = params[:langCode]
      end
    end
    
    def respond_with_asset(asset)
      file = params[:CKEditor].blank? ? params[:qqfile] : params[:upload]
	    asset.data = Ckeditor::Http.normalize_param(file, request)
	    
	    callback = ckeditor_before_create_asset(asset)
	    
      if callback && asset.save
        body = params[:CKEditor].blank? ? asset.to_json(:only=>[:id, :type]) : %Q"<script type='text/javascript'>
          window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, '#{Ckeditor::Utils.escape_single_quotes(asset.url_content)}');
        </script>"
        
        render :text => body
      else
        render :nothing => true
      end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fullstack-ckeditor-0.1.2 app/controllers/ckeditor/application_controller.rb