· 8 years ago · Jan 05, 2018, 01:12 PM
1require File.expand_path('../boot', __FILE__)
2require 'rss'
3require 'rexml/document'
4require 'net/http'
5require 'rails/all'
6require 'rails/railtie'
7# If you have a Gemfile, require the gems listed there, including any gems
8# you've limited to :test, :development, or :production.
9Bundler.require(:default, Rails.env) if defined?(Bundler)
10SITE = {}
11
12module Current
13 class Application < Rails::Application
14
15 Dir.glob("#{Rails.root}/lib/*.rb").map{ |lib| require_or_load(lib)}
16
17 unless Rails.env == 'development'
18 config.middleware.use ExceptionNotifier,
19 :email_prefix => "[Modeflowers ERROR]",
20 :sender_address => %{"Application Error"<modeflowers.error@modeflowers.com>},
21 :exception_recipients => %w{aris@kiranatama.com fery.f@kiranatama.com admin@modeexcel.com}
22
23 end
24 if Rails.env == 'development'
25 config.middleware.use "Rack::Bug",
26 :secret_key => "90dbcbfafd1327f0aefcd40334b6575e619df45259301e18170b20983ea2ef956db97c85b580f2c60ac4abb71f86a14bb47b712088484b98695a817226428c5a",
27 :password => "fery"
28 end
29
30 begin
31 require 'hodel_3000_compliant_logger'
32 config.logger = Hodel3000CompliantLogger.new("log/#{Rails.env}.log")
33 rescue => e
34 $stderr.puts "Hodel3000CompliantLogger unavailable, oink will be disabled. #{e.inspect}"
35 end
36
37 # Only load the plugins named here, in the order given (default is alphabetical).
38 # :all can be used as a placeholder for all plugins not explicitly named.
39 config.plugins = [:all]
40 # Activate observers that should always be running.
41 # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
42
43 # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
44 # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
45 config.time_zone = 'London'
46 # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
47 # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
48 # config.i18n.default_locale = :en
49
50 # JavaScript files you want as :defaults (application.js is always included).
51 config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
52
53 # Configure the default encoding used in templates for Ruby 1.9.
54 config.encoding = "utf-8"
55
56 # Configure sensitive parameters which will be filtered from the log file.
57 config.filter_parameters += [:password, :billing, :billing_address, :shipping_address]
58 config.session_store = {
59 :session_key => '_current_session',
60 :secret => '90dbcbfafd1327f0aefcd40334b6575e619df45259301e18170b20983ea2ef956db97c85b580f2c60ac4abb71f86a14bb47b712088484b98695a817226428c5a'
61 }
62 config.secret_token = "90dbcbfafd1327f0aefcd40334b6575e619df45259301e18170b20983ea2ef956db97c85b580f2c60ac4abb71f86a14bb47b712088484b98695a817226428c5a"
63 config.active_support.deprecation = :notify
64 config.action_controller.perform_caching = true
65 config.action_controller.page_cache_directory = "#{Rails.root.to_s}/tmp/cache"
66 config.action_controller.page_cache_extension
67 config.cache_store = :mem_cache_store, '127.0.0.1:11211', {:multithread => true }
68
69 memcache = YAML.load(File.open("#{Rails.root}/config/memcached.yml"))
70 memcache_options = { :c_threshold => memcache[Rails.env]['c_threshold'],
71 :compression => memcache[Rails.env]['compression'],
72 :debug => memcache[Rails.env]['debug'],
73 :namespace => memcache[Rails.env]['namespace'],
74 :readonly => memcache[Rails.env]['readonly'],
75 :urlencode => memcache[Rails.env]['urlencode']
76 }
77 CACHE = MemCache.new memcache_options unless defined?(CACHE)
78 CACHE.servers = memcache[Rails.env]['servers']
79 end
80
81 SITE[:current] = MultiDomain::SiteCache.new
82 Gibberish.load_languages! rescue nil #if you don't rescue, you'll crash during migrations
83
84 # passenger specific
85 begin
86 PhusionPassenger.on_event(:starting_worker_process) do |forked|
87 if forked
88 # # We're in smart spawning mode, so...
89 # # Close duplicated memcached connections - they will open themselves
90 CACHE.reset
91 end
92 end
93 # In case you're not running under Passenger (i.e. devmode with mongrel)
94 rescue NameError => error
95 end
96
97 ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag|
98 "<span class='fieldWithErrors'>#{html_tag}</span>"
99 end
100end