2008-01-12 06:53:29 +01:00
|
|
|
#####
|
2007-01-22 14:43:50 +01:00
|
|
|
# Bootstrap the Rails environment, frameworks, and default configuration
|
2008-01-12 06:53:29 +01:00
|
|
|
####
|
|
|
|
|
|
|
|
# Make sure we are using the latest rexml
|
2009-02-04 21:26:08 +01:00
|
|
|
rexml_versions = ['', File.dirname(__FILE__) + '/../vendor/plugins/rexml/lib/'].collect { |v|
|
2008-01-13 07:26:25 +01:00
|
|
|
`ruby -r #{v + 'rexml/rexml'} -e 'p REXML::VERSION'`.split('.').collect {|n| n.to_i} }
|
2009-02-04 21:26:08 +01:00
|
|
|
$:.unshift(File.dirname(__FILE__) + '/../vendor/plugins/rexml/lib') if (rexml_versions[0] <=> rexml_versions[1]) == -1
|
2008-01-12 06:53:29 +01:00
|
|
|
|
2009-02-04 23:39:13 +01:00
|
|
|
$:.unshift(File.dirname(__FILE__) + '/../vendor/plugins/rack/lib')
|
2007-01-22 14:43:50 +01:00
|
|
|
require File.join(File.dirname(__FILE__), 'boot')
|
2008-01-12 06:53:29 +01:00
|
|
|
|
2008-10-27 07:59:59 +01:00
|
|
|
require 'active_support/secure_random'
|
2007-01-22 14:43:50 +01:00
|
|
|
|
|
|
|
Rails::Initializer.run do |config|
|
2007-12-21 08:48:59 +01:00
|
|
|
|
|
|
|
# Secret session key
|
2008-09-01 22:35:34 +02:00
|
|
|
# The secret session key is automatically generated, and stored
|
|
|
|
# in a file, for reuse between server restarts. If you want to
|
|
|
|
# change the key, just delete the file, and it will be regenerated
|
|
|
|
# on the next restart. Doing so will invalitate all existing sessions.
|
|
|
|
secret_file = File.join(RAILS_ROOT, "secret")
|
|
|
|
if File.exist?(secret_file)
|
|
|
|
secret = File.read(secret_file)
|
|
|
|
else
|
2008-10-27 07:59:59 +01:00
|
|
|
secret = ActiveSupport::SecureRandom.hex(64)
|
2008-09-01 22:35:34 +02:00
|
|
|
File.open(secret_file, 'w', 0600) { |f| f.write(secret) }
|
|
|
|
end
|
2007-12-21 08:48:59 +01:00
|
|
|
config.action_controller.session = {
|
2008-09-01 22:35:34 +02:00
|
|
|
:session_key => "instiki_session",
|
|
|
|
:secret => secret
|
2007-12-21 08:48:59 +01:00
|
|
|
}
|
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
# Don't do file system STAT calls to check to see if the templates have changed.
|
|
|
|
#config.action_view.cache_template_loading = true
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
# Skip frameworks you're not going to use
|
|
|
|
config.frameworks -= [ :action_web_service, :action_mailer ]
|
|
|
|
|
|
|
|
# Use the database for sessions instead of the file system
|
|
|
|
# (create the session table with 'rake create_sessions_table')
|
2007-02-09 09:04:31 +01:00
|
|
|
#config.action_controller.session_store = :active_record_store
|
2007-01-22 14:43:50 +01:00
|
|
|
|
|
|
|
# Enable page/fragment caching by setting a file-based store
|
|
|
|
# (remember to create the caching directory and make it readable to the application)
|
2008-11-29 07:43:54 +01:00
|
|
|
config.cache_store = :file_store, "#{RAILS_ROOT}/cache"
|
2007-01-22 14:43:50 +01:00
|
|
|
|
|
|
|
# Activate observers that should always be running
|
|
|
|
config.active_record.observers = :page_observer
|
|
|
|
|
|
|
|
# Use Active Record's schema dumper instead of SQL when creating the test database
|
|
|
|
# (enables use of different database adapters for development and test environments)
|
2007-04-09 00:35:33 +02:00
|
|
|
config.active_record.schema_format = :sql
|
2007-01-22 14:43:50 +01:00
|
|
|
|
2007-03-31 17:06:51 +02:00
|
|
|
File.umask(0026)
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
# Instiki-specific configuration below
|
|
|
|
require_dependency 'instiki_errors'
|
|
|
|
|
2008-11-12 16:47:24 +01:00
|
|
|
#require 'jcode'
|
2008-12-18 16:21:26 +01:00
|
|
|
require 'caching_stuff'
|