2010-05-11 21:38:52 +00:00
|
|
|
module Admin
|
|
|
|
class ThemeAssetsController < BaseController
|
|
|
|
|
2010-07-22 22:10:40 +00:00
|
|
|
include ActionView::Helpers::SanitizeHelper
|
|
|
|
extend ActionView::Helpers::SanitizeHelper::ClassMethods
|
2010-06-02 14:31:01 +00:00
|
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
sections 'settings', 'theme_assets'
|
2010-07-22 22:10:40 +00:00
|
|
|
|
2010-07-13 20:01:40 +00:00
|
|
|
respond_to :json, :only => [:create, :update]
|
2010-07-22 22:10:40 +00:00
|
|
|
|
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? }
|
2010-07-06 00:05:47 +00:00
|
|
|
@flash_assets = assets.find_all { |a| a.movie? }
|
2010-07-22 22:10:40 +00:00
|
|
|
|
2010-06-02 00:39:05 +00:00
|
|
|
if request.xhr?
|
2010-07-13 00:46:17 +00:00
|
|
|
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
|
2010-07-22 22:10:40 +00:00
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
def create
|
2010-06-02 14:31:01 +00:00
|
|
|
params[:theme_asset] = { :source => params[:file] } if params[:file]
|
2010-07-22 22:10:40 +00:00
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
create! do |success, failure|
|
|
|
|
success.json do
|
2010-07-22 22:10:40 +00:00
|
|
|
render :json => {
|
|
|
|
:status => 'success',
|
|
|
|
:name => truncate(@theme_asset.slug, :length => 22),
|
|
|
|
:slug => @theme_asset.slug,
|
|
|
|
:url => @theme_asset.source.url,
|
|
|
|
:vignette_url => @theme_asset.vignette_url,
|
|
|
|
:shortcut_url => @theme_asset.shortcut_url
|
2010-07-13 00:46:17 +00:00
|
|
|
}
|
2010-06-02 14:31:01 +00:00
|
|
|
end
|
2010-07-13 00:46:17 +00:00
|
|
|
failure.json { render :json => { :status => 'error' } }
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
|
|
|
end
|
2010-07-22 22:10:40 +00:00
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
2010-07-22 22:10:40 +00:00
|
|
|
|
2010-07-23 20:09:54 +00:00
|
|
|
end
|