2005-01-16 20:12:22 +01:00
|
|
|
if RUBY_VERSION < '1.8.1'
|
|
|
|
puts 'Instiki requires Ruby 1.8.1+'
|
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-01-19 00:38:36 +01:00
|
|
|
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../') unless defined? RAILS_ROOT
|
2005-01-15 21:26:54 +01:00
|
|
|
RAILS_ENV = ENV['RAILS_ENV'] || 'production' unless defined? RAILS_ENV
|
|
|
|
|
|
|
|
unless defined? ADDITIONAL_LOAD_PATHS
|
2005-03-25 20:11:41 +01:00
|
|
|
# Mocks first.
|
2005-01-15 21:26:54 +01:00
|
|
|
ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
|
2005-01-19 00:38:36 +01:00
|
|
|
|
2005-03-25 20:11:41 +01:00
|
|
|
# Then model subdirectories.
|
2005-01-15 21:26:54 +01:00
|
|
|
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
|
2005-03-25 20:11:41 +01:00
|
|
|
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"])
|
2005-01-19 00:38:36 +01:00
|
|
|
|
2005-03-25 20:11:41 +01:00
|
|
|
# Followed by the standard includes.
|
2005-01-15 21:26:54 +01:00
|
|
|
ADDITIONAL_LOAD_PATHS.concat %w(
|
2005-03-25 20:11:41 +01:00
|
|
|
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
|
2005-01-15 21:26:54 +01:00
|
|
|
vendor/madeleine-0.7.1/lib
|
2005-02-11 00:11:47 +01:00
|
|
|
vendor/RedCloth-3.0.3/lib
|
2005-01-15 21:26:54 +01:00
|
|
|
vendor/rubyzip-0.5.6
|
2005-03-25 20:11:41 +01:00
|
|
|
).map { |dir| "#{File.expand_path(File.join(RAILS_ROOT, dir))}"
|
2005-01-15 21:26:54 +01:00
|
|
|
}.delete_if { |dir| not File.exist?(dir) }
|
2005-01-19 00:38:36 +01:00
|
|
|
|
2005-03-25 20:11:41 +01:00
|
|
|
# Prepend to $LOAD_PATH
|
2005-01-15 21:26:54 +01:00
|
|
|
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
|
|
|
|
end
|
|
|
|
|
2005-03-25 20:11:41 +01:00
|
|
|
# Require Rails libraries.
|
|
|
|
require 'rubygems' unless File.directory?("#{RAILS_ROOT}/vendor/rails")
|
|
|
|
|
|
|
|
require 'active_support'
|
2005-01-15 21:26:54 +01:00
|
|
|
require 'action_controller'
|
|
|
|
require 'active_record_stub'
|
2005-01-17 22:22:41 +01:00
|
|
|
require 'instiki_errors'
|
2005-01-15 21:26:54 +01:00
|
|
|
|
2005-03-25 20:11:41 +01:00
|
|
|
# Environment specific configuration
|
|
|
|
require_dependency "environments/#{RAILS_ENV}"
|
|
|
|
|
|
|
|
# Configure defaults if the included environment did not.
|
2005-01-15 21:26:54 +01:00
|
|
|
unless defined? RAILS_DEFAULT_LOGGER
|
|
|
|
RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
|
|
|
|
ActionController::Base.logger ||= RAILS_DEFAULT_LOGGER
|
2005-01-25 23:06:34 +01:00
|
|
|
if defined? INSTIKI_DEBUG_LOG and INSTIKI_DEBUG_LOG
|
|
|
|
RAILS_DEFAULT_LOGGER.level = Logger::DEBUG
|
|
|
|
ActionController::Base.logger.level = Logger::DEBUG
|
|
|
|
else
|
|
|
|
RAILS_DEFAULT_LOGGER.level = Logger::INFO
|
|
|
|
ActionController::Base.logger.level = Logger::INFO
|
|
|
|
end
|
2005-01-15 21:26:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
ActionController::Base.template_root ||= "#{RAILS_ROOT}/app/views/"
|
2005-02-21 14:34:27 +01:00
|
|
|
ActionController::Routing::Routes.reload
|
|
|
|
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
|
|
|
|
|
|
|
require 'wiki_service'
|
|
|
|
Socket.do_not_reverse_lookup = true
|