2011-10-30 23:02:41 +00:00
|
|
|
module Locomotive
|
2010-05-11 21:38:52 +00:00
|
|
|
class ThemeAssetsController < BaseController
|
|
|
|
|
|
|
|
sections 'settings', 'theme_assets'
|
2010-07-22 22:10:40 +00:00
|
|
|
|
2011-12-06 11:39:32 +00:00
|
|
|
respond_to :json, :only => [:index, :create, :update, :destroy]
|
2011-02-04 09:39:23 +00:00
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
def index
|
2011-11-16 00:39:16 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html {
|
|
|
|
@assets = ThemeAsset.all_grouped_by_folder(current_site)
|
|
|
|
@js_and_css_assets = (@assets[:javascripts] || []) + (@assets[:stylesheets] || [])
|
|
|
|
@snippets = current_site.snippets.order_by([[:name, :asc]]).all.to_a
|
|
|
|
render
|
|
|
|
}
|
|
|
|
format.json {
|
|
|
|
render :json => current_site.theme_assets.by_content_type(params[:content_type])
|
|
|
|
}
|
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
|
|
|
|
2011-11-16 00:39:16 +00:00
|
|
|
def new
|
2011-12-07 01:09:13 +00:00
|
|
|
@theme_asset = current_site.theme_assets.build(params[:id])
|
|
|
|
respond_with @theme_asset
|
2011-02-04 10:18:34 +00:00
|
|
|
end
|
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
def create
|
2011-12-07 01:09:13 +00:00
|
|
|
@theme_asset = current_site.theme_assets.create(params[:theme_asset])
|
|
|
|
respond_with @theme_asset, :location => edit_theme_asset_url(@theme_asset._id)
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
2010-07-22 22:10:40 +00:00
|
|
|
|
2011-11-16 00:39:16 +00:00
|
|
|
def edit
|
2011-12-07 01:09:13 +00:00
|
|
|
@theme_asset = current_site.theme_assets.find(params[:id])
|
|
|
|
@theme_asset.performing_plain_text = true if @theme_asset.stylesheet_or_javascript?
|
|
|
|
respond_with @theme_asset
|
2011-11-16 00:39:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2011-12-07 01:09:13 +00:00
|
|
|
@theme_asset = current_site.theme_assets.find(params[:id])
|
|
|
|
@theme_asset.update_attributes(params[:theme_asset])
|
|
|
|
respond_with @theme_asset, :location => edit_theme_asset_url(@theme_asset._id)
|
2011-11-16 00:39:16 +00:00
|
|
|
end
|
2011-02-04 09:39:23 +00:00
|
|
|
|
2011-11-16 00:39:16 +00:00
|
|
|
def destroy
|
2011-12-07 01:09:13 +00:00
|
|
|
@theme_asset = current_site.theme_assets.find(params[:id])
|
|
|
|
@theme_asset.destroy
|
|
|
|
respond_with @theme_asset
|
2011-02-04 09:39:23 +00:00
|
|
|
end
|
|
|
|
|
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
|