2010-09-28 07:46:12 +00:00
|
|
|
require 'mimetype_fu'
|
2011-01-18 15:06:36 +00:00
|
|
|
require 'devise'
|
2010-10-15 00:05:21 +00:00
|
|
|
|
2010-09-28 06:04:40 +00:00
|
|
|
require 'locomotive/version'
|
2010-10-14 12:37:14 +00:00
|
|
|
require 'locomotive/core_ext'
|
2010-04-22 23:52:11 +00:00
|
|
|
require 'locomotive/configuration'
|
2010-06-14 13:04:01 +00:00
|
|
|
require 'locomotive/logger'
|
2010-05-30 23:57:33 +00:00
|
|
|
require 'locomotive/liquid'
|
2010-06-01 00:06:46 +00:00
|
|
|
require 'locomotive/mongoid'
|
2010-06-29 22:09:47 +00:00
|
|
|
require 'locomotive/carrierwave'
|
2010-06-14 13:04:01 +00:00
|
|
|
require 'locomotive/heroku'
|
2010-06-30 13:18:17 +00:00
|
|
|
require 'locomotive/custom_fields'
|
2010-07-06 00:05:47 +00:00
|
|
|
require 'locomotive/httparty'
|
2010-07-13 00:46:17 +00:00
|
|
|
require 'locomotive/inherited_resources'
|
2010-07-13 23:37:02 +00:00
|
|
|
require 'locomotive/admin_responder'
|
2010-07-29 23:21:48 +00:00
|
|
|
require 'locomotive/routing'
|
|
|
|
require 'locomotive/regexps'
|
|
|
|
require 'locomotive/render'
|
2010-09-22 22:59:30 +00:00
|
|
|
require 'locomotive/import'
|
2011-03-17 16:41:25 +00:00
|
|
|
require 'locomotive/delayed_job'
|
2010-10-11 14:26:46 +00:00
|
|
|
require 'locomotive/middlewares'
|
2010-09-28 09:19:55 +00:00
|
|
|
require 'locomotive/session_store'
|
2010-06-10 22:07:59 +00:00
|
|
|
|
2010-04-11 23:59:18 +00:00
|
|
|
module Locomotive
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-14 13:04:01 +00:00
|
|
|
include Locomotive::Heroku
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-04-11 23:59:18 +00:00
|
|
|
class << self
|
|
|
|
attr_accessor :config
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-04-11 23:59:18 +00:00
|
|
|
def config
|
|
|
|
self.config = Configuration.new unless @config
|
|
|
|
@config
|
|
|
|
end
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-04-11 23:59:18 +00:00
|
|
|
def self.configure
|
|
|
|
self.config ||= Configuration.new
|
|
|
|
yield(self.config)
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-03 15:32:40 +00:00
|
|
|
after_configure
|
2010-04-11 23:59:18 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-03 15:32:40 +00:00
|
|
|
def self.after_configure
|
|
|
|
raise '[Error] Locomotive needs a default domain name' if Locomotive.config.default_domain.blank?
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-14 13:04:01 +00:00
|
|
|
ActionMailer::Base.default_url_options[:host] = self.config.default_domain + (Rails.env.development? ? ':3000' : '')
|
2010-06-03 15:32:40 +00:00
|
|
|
|
2010-06-16 14:43:29 +00:00
|
|
|
# cookies stored in mongodb (mongoid_store)
|
2010-06-10 22:07:59 +00:00
|
|
|
Rails.application.config.session_store :mongoid_store, {
|
2010-06-16 14:43:29 +00:00
|
|
|
:key => Locomotive.config.cookie_key
|
2010-06-03 15:32:40 +00:00
|
|
|
}
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-14 13:04:01 +00:00
|
|
|
# Heroku support
|
|
|
|
self.enable_heroku if self.heroku?
|
2011-01-18 15:06:36 +00:00
|
|
|
|
|
|
|
# Devise
|
|
|
|
Devise.mailer_sender = self.config.mailer_sender
|
2011-03-04 23:29:40 +00:00
|
|
|
|
|
|
|
# Load all the dynamic classes (custom fields)
|
2011-03-16 17:24:15 +00:00
|
|
|
begin
|
|
|
|
ContentType.all.collect(&:fetch_content_klass)
|
|
|
|
AssetCollection.all.collect(&:fetch_asset_klass)
|
|
|
|
rescue ::Mongoid::Errors::InvalidDatabase => e
|
|
|
|
# let assume it's because of the first install (meaning no config.yml file)
|
|
|
|
end
|
2010-06-14 13:04:01 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-14 13:04:01 +00:00
|
|
|
def self.logger(message)
|
|
|
|
if Locomotive.config.enable_logs == true
|
|
|
|
Rails.logger.info(message)
|
|
|
|
end
|
2010-06-03 15:32:40 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
|
|
|
end
|