class Slices::Config

Constants

S3_TEMPFILE_KEY_PREFIX

Public Class Methods

add_asset_styles(options = {}) click to toggle source

Set the asset styles for the app, this is a hash with the keys as the style names and Papcerlip resize options

Slices::Config.add_asset_styles(
  :thumbnail      => "220x146#",
  :full_width     => "971x440#",
  :feature_full   => "971x475#",
  :slideshow      => "723x440>",
)

@param [Hash] options

# File lib/slices/config.rb, line 16
def self.add_asset_styles(options = {})
  @asset_styles = options.merge(admin_asset_styles)
end
asset_styles() click to toggle source

The list of asset styles in use

@return [Hash]

# File lib/slices/config.rb, line 23
def self.asset_styles
  @asset_styles || add_asset_styles
end
devise_for_options() click to toggle source

Options for devise_for.

@return [Hash] the options

# File lib/slices/config.rb, line 98
def self.devise_for_options
  @devise_options ||= {
    path: 'admin',
    controllers: {
      passwords:  'admin/auth/passwords',
      sessions:   'admin/auth/sessions',
    }
  }
end
devise_for_options=(options = {}) click to toggle source

Set options for devise_for.

@param [Hash] the options

# File lib/slices/config.rb, line 111
def self.devise_for_options=(options = {})
  @devise_options = options
end
i18n?() click to toggle source
# File lib/slices/config.rb, line 38
def self.i18n?
  !!(
    I18n.available_locales.many? ||
      Rails.application.config.i18n.available_locales.try(:many?)
  )
end
page_actions_template() click to toggle source

Page actions template path.

@return [String] the path

# File lib/slices/config.rb, line 84
def self.page_actions_template
  @page_actions_template || 'admin/site_maps/page_actions'
end
page_actions_template=(path) click to toggle source

Set page actions template path.

@param [String] the path

# File lib/slices/config.rb, line 91
def self.page_actions_template=(path)
  @page_actions_template = path
end
page_fields_template() click to toggle source

Page fields template path.

@return [String] the path

# File lib/slices/config.rb, line 70
def self.page_fields_template
  @page_fields_template || 'admin/pages/fields'
end
page_fields_template=(path) click to toggle source

Set page fields template path.

@param [String] the path

# File lib/slices/config.rb, line 77
def self.page_fields_template=(path)
  @page_fields_template = path
end
s3_credentials() click to toggle source

S3 credentaials taken from the papercip defaults

{
  :bucket => 'slices-demo',
  :access_key_id => 'access key id',
  :secret_access_key => 'secret access key',
}

@return Hash

# File lib/slices/config.rb, line 58
def self.s3_credentials
  default_options = Paperclip::Attachment.default_options
  {
    bucket: default_options[:fog_directory],
    access_key_id: default_options[:fog_credentials][:aws_access_key_id],
    secret_access_key: default_options[:fog_credentials][:aws_secret_access_key],
  }
end
s3_storage?() click to toggle source
# File lib/slices/config.rb, line 45
def self.s3_storage?
  Paperclip::Attachment.default_options[:storage].to_sym == :fog
end
snippets?() click to toggle source

Does this app use snippets? @return [Boolean]

# File lib/slices/config.rb, line 34
def self.snippets?
  @snippets || false
end
use_snippets!() click to toggle source

Enable snippets

# File lib/slices/config.rb, line 28
def self.use_snippets!
  @snippets = true
end

Private Class Methods

admin_asset_styles() click to toggle source
# File lib/slices/config.rb, line 116
def self.admin_asset_styles
  { admin: '180x180#' }
end
asset_convert_options() click to toggle source

Addition Paperclip convert options which are applied to all styles. This removes colour profiles, sets the dpi to 72 dpi (the image is not resampled). The colour depth is set to 8 bits per pixel

# File lib/slices/config.rb, line 123
def self.asset_convert_options
  Hash.new.tap do |options|
    asset_styles.keys.each do |style|
      next if style == :original
      options[style] = "-strip -density 72x72 -depth 8"
    end
  end
end