engine/app/controllers/admin/theme_assets_controller.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

2010-05-11 21:38:52 +00:00
module Admin
class ThemeAssetsController < BaseController
include ActionView::Helpers::TextHelper
2010-05-11 21:38:52 +00:00
sections 'settings', 'theme_assets'
respond_to :json, :only => [:create, :update]
2010-05-11 21:38:52 +00:00
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? }
2010-07-17 20:51:52 +00:00
@font_assets = assets.find_all { |a| a.font? }
2010-06-02 00:39:05 +00:00
if request.xhr?
render :action => 'images', :layout => false and return
2010-06-02 00:39:05 +00:00
end
2010-05-11 21:38:52 +00:00
end
def create
params[:theme_asset] = { :source => params[:file] } if params[:file]
2010-06-02 00:39:05 +00:00
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' } }
2010-05-11 21:38:52 +00:00
end
end
2010-05-11 21:38:52 +00:00
end
end