Sha256: 8b1ffd892ba117e9188ac01e123a69e3813e1e41e2c0adcdcf7d0532e8d8a58e
Contents?: true
Size: 1.9 KB
Versions: 13
Compression:
Stored size: 1.9 KB
Contents
module Admin class ThemeAssetsController < BaseController include ActionView::Helpers::TextHelper sections 'settings', 'theme_assets' 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? } if request.xhr? render :action => 'images', :layout => false end end def new @asset = current_site.theme_assets.build end def edit @asset = current_site.theme_assets.find(params[:id]) end def create params[:theme_asset] = { :source => params[:file] } if params[:file] @asset = current_site.theme_assets.build(params[:theme_asset]) respond_to do |format| if @asset.save format.html do flash_success! redirect_to edit_admin_theme_asset_url(@asset) end format.json do render :json => { :status => 'success', :name => truncate(@asset.slug, :length => 22), :url => @asset.source.url, :vignette_url => @asset.vignette_url } end else format.html do flash_error! render :action => 'new' end format.json do render :json => { :status => 'error' } end end end end def update @asset = current_site.theme_assets.find(params[:id]) if @asset.update_attributes(params[:theme_asset]) flash_success! redirect_to edit_admin_theme_asset_url(@asset) else flash_error! render :action => 'edit' end end def destroy @asset = current_site.theme_assets.find(params[:id]) @asset.destroy flash_success! redirect_to admin_theme_assets_url end end end
Version data entries
13 entries across 13 versions & 1 rubygems