Sha256: 7a11f8b0d11aa28107db8b980c950f3cfd1afb579a5a958db89bbd2983d9035f

Contents?: true

Size: 1.02 KB

Versions: 11

Compression:

Stored size: 1.02 KB

Contents

module Locomotive
  class ThemeAssetPresenter < BasePresenter

    delegate :content_type, :folder, :plain_text, :to => :source

    def local_path
      self.source.local_path(true)
    end

    def url
      self.source.source.url
    end

    def size
      number_to_human_size(self.source.size)
    end

    def dimensions
      self.source.image? ? "#{self.source.width}px x #{self.source.height}px" : nil
    end

    def updated_at
      I18n.l(self.source.updated_at, :format => :short)
    end

    def can_be_deleted
      self.ability.try(:can?, :destroy, self.source)
    end

    def included_methods
      default_list = %w(content_type folder local_path url size dimensions can_be_deleted updated_at)
      default_list += %w(plain_text) if plain_text?
      super + default_list
    end

    private

    def plain_text?
      # FIXME: self.options contains all the options passed by the responder
      self.options[:template] == 'update' && self.source.errors.empty? && self.source.stylesheet_or_javascript?
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc12 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc11 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc10 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc9 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc8 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc7 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc6 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc5 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc4 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc2 app/presenters/locomotive/theme_asset_presenter.rb
locomotive_cms-2.0.0.rc1 app/presenters/locomotive/theme_asset_presenter.rb