Sha256: 842c86f5bf60c6326311274ca6413a08bc544b70a65ac43fea6b333e8035709f

Contents?: true

Size: 1.52 KB

Versions: 9

Compression:

Stored size: 1.52 KB

Contents

module Admin
  class ThemeAssetsController < BaseController

    include ActionView::Helpers::SanitizeHelper
    extend ActionView::Helpers::SanitizeHelper::ClassMethods
    include ActionView::Helpers::TextHelper
    include ActionView::Helpers::NumberHelper

    sections 'settings', 'theme_assets'

    respond_to :json, :only => [:create, :update]

    def index
      @assets = current_site.theme_assets.visible(params[:all]).order_by([[:slug, :asc]])
      @assets = @assets.group_by { |a| a.folder.split('/').first.to_sym }
      @js_and_css_assets = (@assets[:javascripts] || []) + (@assets[:stylesheets] || [])

      if request.xhr?
        @images = @assets[:images]
        render :action => 'images', :layout => false and return
      else
        @snippets = current_site.snippets.order_by([[:name, :asc]]).all.to_a
      end
    end

    def edit
      resource.performing_plain_text = true if resource.stylesheet_or_javascript?
      edit!
    end

    def create
      params[:theme_asset] = { :source => params[:file] } if params[:file]

      create! do |success, failure|
        success.json do
          render :json => {
            :status       => 'success',
            :url          => @theme_asset.source.url,
            :local_path   => @theme_asset.local_path(true),
            :size         => number_to_human_size(@theme_asset.size),
            :date         => l(@theme_asset.updated_at, :format => :short)
          }
        end
        failure.json { render :json => { :status => 'error' } }
      end
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
locomotive_cms-0.0.4.beta9 app/controllers/admin/theme_assets_controller.rb
locomotive_cms-0.0.4.beta8 app/controllers/admin/theme_assets_controller.rb
locomotive_cms-0.0.4.beta7 app/controllers/admin/theme_assets_controller.rb
locomotive_cms-0.0.4.beta5 app/controllers/admin/theme_assets_controller.rb
locomotive_cms-0.0.4.beta4 app/controllers/admin/theme_assets_controller.rb
locomotive_cms-0.0.4.beta3 app/controllers/admin/theme_assets_controller.rb
locomotive_cms-0.0.4.beta2 app/controllers/admin/theme_assets_controller.rb
locomotive_cms-0.0.4.beta1 app/controllers/admin/theme_assets_controller.rb
locomotive_cms-0.0.4 app/controllers/admin/theme_assets_controller.rb