Sha256: 667dbd13209ba7042173ad9ffda30da89eca4360af2c284ea2d627dd2246bad6

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Admin
  class ThemeAssetsController < BaseController

    include ActionView::Helpers::TextHelper

    sections 'settings', 'theme_assets'
   
    respond_to :json, :only => [:create, :update]
   
    def index
      assets = current_site.theme_assets.all
      @non_image_assets = assets.find_all { |a| a.stylesheet? || a.javascript? }
      @image_assets = assets.find_all { |a| a.image? }
      @flash_assets = assets.find_all { |a| a.movie? }
      
      if request.xhr?
        render :action => 'images', :layout => false and return
      end
    end
    
    def create
      params[:theme_asset] = { :source => params[:file] } if params[:file]
      
      create! do |success, failure|
        success.json do
          render :json => { 
            :status => 'success', 
            :name => truncate(@theme_asset.slug, :length => 22),
            :url => @theme_asset.source.url,
            :vignette_url => @theme_asset.vignette_url
          }
        end
        failure.json { render :json => { :status => 'error' } }
      end
    end
        
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locomotive_cms-0.0.3.3 app/controllers/admin/theme_assets_controller.rb
locomotive_cms-0.0.3.1 app/controllers/admin/theme_assets_controller.rb