2005-08-02 10:56:09 +02:00
|
|
|
# Load the Rails framework and configure your application.
|
|
|
|
# You can include your own configuration at the end of this file.
|
|
|
|
#
|
|
|
|
# Be sure to restart your webserver when you modify this file.
|
|
|
|
|
|
|
|
if RUBY_VERSION < '1.8.2'
|
|
|
|
puts 'Instiki requires Ruby 1.8.2+'
|
2005-01-15 21:26:54 +01:00
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
2005-01-21 20:00:45 +01:00
|
|
|
# Enable UTF-8 support
|
|
|
|
$KCODE = 'u'
|
2005-01-21 20:17:25 +01:00
|
|
|
require 'jcode'
|
2005-01-21 20:00:45 +01:00
|
|
|
|
2005-08-02 10:56:09 +02:00
|
|
|
# The path to the root directory of your application.
|
|
|
|
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../')
|
|
|
|
|
|
|
|
# The environment your application is currently running. Don't set
|
|
|
|
# this here; put it in your webserver's configuration as the RAILS_ENV
|
|
|
|
# environment variable instead.
|
|
|
|
#
|
|
|
|
# See config/environments/*.rb for environment-specific configuration.
|
|
|
|
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
|
|
|
|
|
|
|
|
# Load the Rails framework. Mock classes for testing come first.
|
|
|
|
ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
|
|
|
|
|
|
|
|
# Then model subdirectories.
|
|
|
|
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
|
|
|
|
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"])
|
|
|
|
|
|
|
|
# Followed by the standard includes.
|
|
|
|
ADDITIONAL_LOAD_PATHS.concat %w(
|
|
|
|
app
|
|
|
|
app/models
|
|
|
|
app/controllers
|
|
|
|
app/helpers
|
|
|
|
app/apis
|
|
|
|
components
|
|
|
|
config
|
|
|
|
lib
|
|
|
|
vendor
|
|
|
|
vendor/rails/railties
|
|
|
|
vendor/rails/railties/lib
|
|
|
|
vendor/rails/actionpack/lib
|
|
|
|
vendor/rails/activesupport/lib
|
|
|
|
vendor/rails/activerecord/lib
|
|
|
|
vendor/rails/actionmailer/lib
|
|
|
|
vendor/rails/actionwebservice/lib
|
|
|
|
vendor/RedCloth-3.0.3/lib
|
|
|
|
vendor/rubyzip-0.5.8/lib
|
|
|
|
).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
|
|
|
|
|
|
|
|
# Prepend to $LOAD_PATH
|
|
|
|
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
|
2005-01-15 21:26:54 +01:00
|
|
|
|
2005-03-25 20:11:41 +01:00
|
|
|
# Require Rails libraries.
|
|
|
|
require 'rubygems' unless File.directory?("#{RAILS_ROOT}/vendor/rails")
|
|
|
|
|
|
|
|
require 'active_support'
|
2005-08-02 10:56:09 +02:00
|
|
|
require 'active_record'
|
2005-01-15 21:26:54 +01:00
|
|
|
require 'action_controller'
|
2005-08-09 04:20:28 +02:00
|
|
|
require 'action_mailer'
|
|
|
|
require 'action_web_service'
|
2005-04-04 08:48:42 +02:00
|
|
|
|
2005-08-02 10:56:09 +02:00
|
|
|
# Environment-specific configuration.
|
2005-03-25 20:11:41 +01:00
|
|
|
require_dependency "environments/#{RAILS_ENV}"
|
2005-08-02 10:56:09 +02:00
|
|
|
ActiveRecord::Base.configurations = File.open("#{RAILS_ROOT}/config/database.yml") { |f| YAML::load(f) }
|
|
|
|
ActiveRecord::Base.establish_connection
|
2005-03-25 20:11:41 +01:00
|
|
|
|
|
|
|
# Configure defaults if the included environment did not.
|
2005-08-02 10:56:09 +02:00
|
|
|
begin
|
|
|
|
RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
|
|
|
|
RAILS_DEFAULT_LOGGER.level = (RAILS_ENV == 'production' ? Logger::INFO : Logger::DEBUG)
|
|
|
|
rescue StandardError
|
2005-01-15 21:26:54 +01:00
|
|
|
RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
|
2005-08-02 10:56:09 +02:00
|
|
|
RAILS_DEFAULT_LOGGER.level = Logger::WARN
|
|
|
|
RAILS_DEFAULT_LOGGER.warn(
|
|
|
|
"Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " +
|
|
|
|
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
|
|
|
|
)
|
2005-01-15 21:26:54 +01:00
|
|
|
end
|
|
|
|
|
2005-08-02 10:56:09 +02:00
|
|
|
[ActiveRecord, ActionController, ActionMailer].each { |mod| mod::Base.logger ||= RAILS_DEFAULT_LOGGER }
|
|
|
|
[ActionController, ActionMailer].each { |mod| mod::Base.template_root ||= "#{RAILS_ROOT}/app/views/" }
|
|
|
|
|
|
|
|
# Set up routes.
|
2005-02-21 14:34:27 +01:00
|
|
|
ActionController::Routing::Routes.reload
|
2005-08-02 10:56:09 +02:00
|
|
|
|
2005-02-21 14:34:27 +01:00
|
|
|
Controllers = Dependencies::LoadingModule.root(
|
2005-03-25 20:11:41 +01:00
|
|
|
File.join(RAILS_ROOT, 'app', 'controllers'),
|
|
|
|
File.join(RAILS_ROOT, 'components')
|
2005-02-21 14:34:27 +01:00
|
|
|
)
|
2005-03-25 20:11:41 +01:00
|
|
|
|
2005-08-02 10:56:09 +02:00
|
|
|
require_dependency 'instiki_errors'
|