Class: Locomotive::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/locomotive/configuration.rb

Constant Summary collapse

@@defaults =
{
  name:                   'LocomotiveApp',
  domain:                 'example.com',
  reserved_subdomains:    %w{www admin email blog webmail mail support help site sites},
  # forbidden_paths:      %w{layouts snippets stylesheets javascripts assets admin system api},
  reserved_slugs:         %w{stylesheets javascripts assets admin locomotive images api pages edit},
  locales:                %w{en de fr pl pt pt-BR it nl nb es ru et ja zh-CN cs bg sk sr},
  site_locales:           %w{en de fr pl pt pt-BR it nl nb es ru et ja zh-CN cs bg sk sr},
  cookie_key:             '_locomotive_session',
  enable_logs:            false,
  enable_admin_ssl:       false,
  delayed_job:            false,
  default_locale:         :en,
  mailer_sender:          '[email protected]',
  manage_subdomain:       false,
  manage_manage_domains:  false,
  ui:                     {
    latest_entries_nb:    5,
    max_content_types:    2,
    per_page:             10
  },
  rack_cache:             {
    verbose:     true,
    metastore:   URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
    entitystore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
  },
  devise_modules:             [:rememberable, :database_authenticatable, :token_authenticatable, :recoverable, :trackable, :validatable, :encryptable, { encryptor: :sha1 }],
  context_assign_extensions:  { },
  models_for_templatization:  [],
  csrf_protection:            false,
  theme_assets_checksum:      false,
  asset_host:                 nil
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



40
41
42
# File 'lib/locomotive/configuration.rb', line 40

def initialize
  @@settings = self.class.get_from_hash(@@defaults)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



80
81
82
# File 'lib/locomotive/configuration.rb', line 80

def method_missing(name, *args, &block)
  self.settings.send(name, *args, &block)
end

Class Method Details

.settingsObject



44
45
46
# File 'lib/locomotive/configuration.rb', line 44

def self.settings
  @@settings
end

Instance Method Details

#manage_domains?Boolean

Returns:



56
57
58
# File 'lib/locomotive/configuration.rb', line 56

def manage_domains?
  self.manage_domains == true
end

#manage_subdomain?Boolean

Returns:



52
53
54
# File 'lib/locomotive/configuration.rb', line 52

def manage_subdomain?
  self.manage_subdomain == true
end

#manage_subdomain_n_domains?Boolean

Returns:



60
61
62
# File 'lib/locomotive/configuration.rb', line 60

def manage_subdomain_n_domains?
  self.manage_subdomain? && self.manage_domains?
end

#multi_sites?Boolean

Returns:



48
49
50
# File 'lib/locomotive/configuration.rb', line 48

def multi_sites?
  self.multi_sites != false
end

#multi_sites_or_manage_domains?Boolean

Returns:



64
65
66
# File 'lib/locomotive/configuration.rb', line 64

def multi_sites_or_manage_domains?
  self.multi_sites? || self.manage_domains?
end

#reserved_subdomainsObject



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/locomotive/configuration.rb', line 68

def reserved_subdomains
  if self.multi_sites?
    if self.multi_sites.reserved_subdomains.blank?
      @@defaults[:reserved_subdomains]
    else
      self.multi_sites.reserved_subdomains
    end
  else
    []
  end
end