engine/app/controllers/admin/theme_assets_controller.rb
2010-07-17 22:51:52 +02:00

40 lines
1.1 KiB
Ruby

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? }
@font_assets = assets.find_all { |a| a.font? }
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