engine/app/controllers/admin/theme_assets_controller.rb

47 lines
1.3 KiB
Ruby
Raw Normal View History

2010-05-11 21:38:52 +00:00
module Admin
class ThemeAssetsController < BaseController
include ActionView::Helpers::SanitizeHelper
extend ActionView::Helpers::SanitizeHelper::ClassMethods
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.visible.all.order_by([[:slug, :asc]]).group_by { |a| a.folder.split('/').first.to_sym }
@js_and_css_assets = (@assets[:javascripts] || []) + (@assets[:stylesheets] || [])
2010-06-02 00:39:05 +00:00
if request.xhr?
render :action => 'images', :layout => false and return
else
@snippets = current_site.snippets.order_by([[:name, :asc]]).all.to_a
2010-06-02 00:39:05 +00:00
end
2010-05-11 21:38:52 +00:00
end
2010-10-10 14:37:34 +00:00
def edit
resource.performing_plain_text = true if resource.stylesheet_or_javascript?
edit!
end
2010-05-11 21:38:52 +00:00
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),
:slug => @theme_asset.slug,
:url => @theme_asset.source.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