diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-24 04:13:16 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-24 04:13:16 +0200 |
| commit | e0a7e0fec760ba12c8067a37e10c96f1f05876e2 (patch) | |
| tree | d0cf745592a46aee4d4913911fd34c7c24515220 /config | |
| parent | 6424e10be5a89f175a74c71c55660412a169b8b8 (diff) | |
Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade
- Converted plugins to gems (Gemfile)
- Updated config structure (application.rb, boot.rb, environment.rb)
- Converted routes to Rails 3 DSL
- Converted named_scope to scope throughout models
- Converted find(:all, :conditions) to where() chains
- Fixed has_many :order to use ordering scope
- Updated session store and secret token configuration
- Fixed exception_notification middleware configuration
- Patched Ruby 2.4 / Rails 3.2 incompatibilities:
- Integer/Float duration arithmetic (ActiveSupport)
- Arel visit_Integer for PostgreSQL adapter
- create_database String/Integer coercion
- ActionController consider_all_requests_local
- Migrated taggings schema for acts-as-taggable-on
- Replaced dynamic_form gem with custom form_error_messages helper
- Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for)
- Fixed admin layout yield
- Updated test suite for Rails 3 APIs
Diffstat (limited to 'config')
| -rw-r--r-- | config/application.rb | 60 | ||||
| -rw-r--r-- | config/boot.rb | 113 | ||||
| -rw-r--r-- | config/environment.rb | 88 | ||||
| -rw-r--r-- | config/environments/development.rb | 27 | ||||
| -rw-r--r-- | config/environments/production.rb | 53 | ||||
| -rw-r--r-- | config/environments/test.rb | 45 | ||||
| -rw-r--r-- | config/initializers/activesupport_duration_patch.rb | 53 | ||||
| -rw-r--r-- | config/initializers/arel_patch.rb | 12 | ||||
| -rw-r--r-- | config/initializers/exception_notifier.rb | 6 | ||||
| -rw-r--r-- | config/initializers/postgresql_adapter_patch.rb | 30 | ||||
| -rw-r--r-- | config/initializers/ruby2.rb | 16 | ||||
| -rw-r--r-- | config/initializers/session_store.rb | 16 | ||||
| -rw-r--r-- | config/locales/de.yml | 5 | ||||
| -rw-r--r-- | config/routes.rb | 89 |
14 files changed, 308 insertions, 305 deletions
diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000..9b7ae67 --- /dev/null +++ b/config/application.rb | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | # Put this in config/application.rb | ||
| 2 | require File.expand_path('../boot', __FILE__) | ||
| 3 | |||
| 4 | require 'rails/all' | ||
| 5 | |||
| 6 | Bundler.require(:default, Rails.env) if defined?(Bundler) | ||
| 7 | |||
| 8 | require 'action_controller' | ||
| 9 | |||
| 10 | module ActionController | ||
| 11 | class Base | ||
| 12 | def self.consider_all_requests_local=(val) | ||
| 13 | # no-op: controlled via config.consider_all_requests_local in environment files | ||
| 14 | end | ||
| 15 | end | ||
| 16 | end | ||
| 17 | |||
| 18 | module Cccms | ||
| 19 | class Application < Rails::Application | ||
| 20 | config.autoload_paths += [config.root.join('lib')] | ||
| 21 | config.encoding = 'utf-8' | ||
| 22 | # Settings in config/environments/* take precedence over those specified here. | ||
| 23 | # Application configuration should go into files in config/initializers | ||
| 24 | # -- all .rb files in that directory are automatically loaded. | ||
| 25 | |||
| 26 | # Add additional load paths for your own custom dirs | ||
| 27 | # config.load_paths += %W( #{RAILS_ROOT}/extras ) | ||
| 28 | |||
| 29 | # Only load the plugins named here, in the order given (default is alphabetical). | ||
| 30 | # :all can be used as a placeholder for all plugins not explicitly named | ||
| 31 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] | ||
| 32 | |||
| 33 | # Allowed Tags | ||
| 34 | # strong em b i p code pre tt samp kbd var sub sup dfn cite big small | ||
| 35 | # address hr br div span h1 h2 h3 h4 h5 h6 ul ol li dt dd abbr | ||
| 36 | # acronym a img blockquote del ins | ||
| 37 | |||
| 38 | # Allowed Attributes: | ||
| 39 | # href src width height alt cite datetime title class name xml:lang abbr)) | ||
| 40 | |||
| 41 | # Add tags to whitelist with: | ||
| 42 | # config.action_view.sanitized_allowed_tags = 'table', 'tr', 'td' | ||
| 43 | |||
| 44 | # Add attributes to whitelist with: | ||
| 45 | # config.action_view.sanitized_allowed_attributes = 'id', 'class', 'style' | ||
| 46 | |||
| 47 | # Activate observers that should always be running | ||
| 48 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer | ||
| 49 | |||
| 50 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. | ||
| 51 | # Run "rake -D time" for a list of tasks for finding time zone names. | ||
| 52 | config.time_zone = 'Berlin' | ||
| 53 | |||
| 54 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. | ||
| 55 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] | ||
| 56 | config.i18n.default_locale = :de | ||
| 57 | |||
| 58 | config.filter_parameters += [:password, :password_confirmation] | ||
| 59 | end | ||
| 60 | end | ||
diff --git a/config/boot.rb b/config/boot.rb index 9834fc4..b92444f 100644 --- a/config/boot.rb +++ b/config/boot.rb | |||
| @@ -1,111 +1,2 @@ | |||
| 1 | # Don't change this file! | 1 | require 'rubygems' |
| 2 | # Configure your app in config/environment.rb and config/environments/*.rb | 2 | require 'bundler/setup' |
| 3 | |||
| 4 | RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) | ||
| 5 | ENV['NLS_LANG'] = 'de_DE.UTF8' | ||
| 6 | |||
| 7 | module Rails | ||
| 8 | class << self | ||
| 9 | def boot! | ||
| 10 | unless booted? | ||
| 11 | preinitialize | ||
| 12 | pick_boot.run | ||
| 13 | end | ||
| 14 | end | ||
| 15 | |||
| 16 | def booted? | ||
| 17 | defined? Rails::Initializer | ||
| 18 | end | ||
| 19 | |||
| 20 | def pick_boot | ||
| 21 | (vendor_rails? ? VendorBoot : GemBoot).new | ||
| 22 | end | ||
| 23 | |||
| 24 | def vendor_rails? | ||
| 25 | File.exist?("#{RAILS_ROOT}/vendor/rails") | ||
| 26 | end | ||
| 27 | |||
| 28 | def preinitialize | ||
| 29 | load(preinitializer_path) if File.exist?(preinitializer_path) | ||
| 30 | end | ||
| 31 | |||
| 32 | def preinitializer_path | ||
| 33 | "#{RAILS_ROOT}/config/preinitializer.rb" | ||
| 34 | end | ||
| 35 | end | ||
| 36 | |||
| 37 | class Boot | ||
| 38 | def run | ||
| 39 | load_initializer | ||
| 40 | Rails::Initializer.run(:set_load_path) | ||
| 41 | end | ||
| 42 | end | ||
| 43 | |||
| 44 | class VendorBoot < Boot | ||
| 45 | def load_initializer | ||
| 46 | require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" | ||
| 47 | Rails::Initializer.run(:install_gem_spec_stubs) | ||
| 48 | Rails::GemDependency.add_frozen_gem_path | ||
| 49 | end | ||
| 50 | end | ||
| 51 | |||
| 52 | class GemBoot < Boot | ||
| 53 | def load_initializer | ||
| 54 | self.class.load_rubygems | ||
| 55 | load_rails_gem | ||
| 56 | require 'initializer' | ||
| 57 | end | ||
| 58 | |||
| 59 | def load_rails_gem | ||
| 60 | if version = self.class.gem_version | ||
| 61 | gem 'rails', version | ||
| 62 | else | ||
| 63 | gem 'rails' | ||
| 64 | end | ||
| 65 | rescue Gem::LoadError => load_error | ||
| 66 | $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) | ||
| 67 | exit 1 | ||
| 68 | end | ||
| 69 | |||
| 70 | class << self | ||
| 71 | def rubygems_version | ||
| 72 | Gem::RubyGemsVersion rescue nil | ||
| 73 | end | ||
| 74 | |||
| 75 | def gem_version | ||
| 76 | if defined? RAILS_GEM_VERSION | ||
| 77 | RAILS_GEM_VERSION | ||
| 78 | elsif ENV.include?('RAILS_GEM_VERSION') | ||
| 79 | ENV['RAILS_GEM_VERSION'] | ||
| 80 | else | ||
| 81 | parse_gem_version(read_environment_rb) | ||
| 82 | end | ||
| 83 | end | ||
| 84 | |||
| 85 | def load_rubygems | ||
| 86 | min_version = '1.3.2' | ||
| 87 | require 'rubygems' | ||
| 88 | unless rubygems_version >= min_version | ||
| 89 | $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) | ||
| 90 | exit 1 | ||
| 91 | end | ||
| 92 | |||
| 93 | rescue LoadError | ||
| 94 | $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) | ||
| 95 | exit 1 | ||
| 96 | end | ||
| 97 | |||
| 98 | def parse_gem_version(text) | ||
| 99 | $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ | ||
| 100 | end | ||
| 101 | |||
| 102 | private | ||
| 103 | def read_environment_rb | ||
| 104 | File.read("#{RAILS_ROOT}/config/environment.rb") | ||
| 105 | end | ||
| 106 | end | ||
| 107 | end | ||
| 108 | end | ||
| 109 | |||
| 110 | # All that for this: | ||
| 111 | Rails.boot! | ||
diff --git a/config/environment.rb b/config/environment.rb index 57b9ef2..6fdeb06 100644 --- a/config/environment.rb +++ b/config/environment.rb | |||
| @@ -1,86 +1,2 @@ | |||
| 1 | # Be sure to restart your server when you modify this file | 1 | require File.expand_path('../application', __FILE__) |
| 2 | 2 | Cccms::Application.initialize! | |
| 3 | # Specifies gem version of Rails to use when vendor/rails is not present | ||
| 4 | RAILS_GEM_VERSION = '2.3.15' unless defined? RAILS_GEM_VERSION | ||
| 5 | |||
| 6 | # Bootstrap the Rails environment, frameworks, and default configuration | ||
| 7 | require File.join(File.dirname(__FILE__), 'boot') | ||
| 8 | |||
| 9 | # monkey patch for 2.0. Will ignore vendor gems. | ||
| 10 | if RUBY_VERSION >= "2.0.0" | ||
| 11 | module Gem | ||
| 12 | def self.source_index | ||
| 13 | sources | ||
| 14 | end | ||
| 15 | |||
| 16 | def self.cache | ||
| 17 | sources | ||
| 18 | end | ||
| 19 | |||
| 20 | SourceIndex = Specification | ||
| 21 | |||
| 22 | class SourceList | ||
| 23 | # If you want vendor gems, this is where to start writing code. | ||
| 24 | def search( *args ); []; end | ||
| 25 | def each( &block ); end | ||
| 26 | include Enumerable | ||
| 27 | end | ||
| 28 | end | ||
| 29 | end | ||
| 30 | |||
| 31 | Rails::Initializer.run do |config| | ||
| 32 | # Settings in config/environments/* take precedence over those specified here. | ||
| 33 | # Application configuration should go into files in config/initializers | ||
| 34 | # -- all .rb files in that directory are automatically loaded. | ||
| 35 | |||
| 36 | # Add additional load paths for your own custom dirs | ||
| 37 | # config.load_paths += %W( #{RAILS_ROOT}/extras ) | ||
| 38 | |||
| 39 | # Specify gems that this application depends on and have them installed with rake gems:install | ||
| 40 | # config.gem "bj" | ||
| 41 | # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" | ||
| 42 | # config.gem "sqlite3-ruby", :lib => "sqlite3" | ||
| 43 | # config.gem "aws-s3", :lib => "aws/s3" | ||
| 44 | |||
| 45 | # config.gem "rake", :version => ">= 0.8.3" | ||
| 46 | # config.gem "rack", :version => ">= 0.9.1" | ||
| 47 | config.gem "pg" | ||
| 48 | config.gem "thinking-sphinx", :lib => 'thinking_sphinx', :version => '1.5.0' | ||
| 49 | config.gem "libxml-ruby", :lib => 'xml' | ||
| 50 | config.gem "erdgeist-chaos_calendar", :lib => "chaos_calendar", :source => "http://gems.github.com" | ||
| 51 | |||
| 52 | # Only load the plugins named here, in the order given (default is alphabetical). | ||
| 53 | # :all can be used as a placeholder for all plugins not explicitly named | ||
| 54 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] | ||
| 55 | |||
| 56 | # Allowed Tags | ||
| 57 | # strong em b i p code pre tt samp kbd var sub sup dfn cite big small | ||
| 58 | # address hr br div span h1 h2 h3 h4 h5 h6 ul ol li dt dd abbr | ||
| 59 | # acronym a img blockquote del ins | ||
| 60 | |||
| 61 | # Allowed Attributes: | ||
| 62 | # href src width height alt cite datetime title class name xml:lang abbr)) | ||
| 63 | |||
| 64 | # Add tags to whitelist with: | ||
| 65 | # config.action_view.sanitized_allowed_tags = 'table', 'tr', 'td' | ||
| 66 | |||
| 67 | # Add attributes to whitelist with: | ||
| 68 | # config.action_view.sanitized_allowed_attributes = 'id', 'class', 'style' | ||
| 69 | |||
| 70 | # Activate observers that should always be running | ||
| 71 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer | ||
| 72 | |||
| 73 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. | ||
| 74 | # Run "rake -D time" for a list of tasks for finding time zone names. | ||
| 75 | config.time_zone = 'Berlin' | ||
| 76 | |||
| 77 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. | ||
| 78 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] | ||
| 79 | config.i18n.default_locale = :de | ||
| 80 | |||
| 81 | end | ||
| 82 | |||
| 83 | require 'awesome_patch' | ||
| 84 | |||
| 85 | ExceptionNotifier.exception_recipients = %w(erdgeist@ccc.de) | ||
| 86 | ExceptionNotifier.sender_address = %("CCCMS Error" <error@www.ccc.de>) | ||
diff --git a/config/environments/development.rb b/config/environments/development.rb index 85c9a60..6446686 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb | |||
| @@ -1,17 +1,20 @@ | |||
| 1 | # Settings specified here will take precedence over those in config/environment.rb | 1 | # Settings specified here will take precedence over those in config/environment.rb |
| 2 | 2 | ||
| 3 | # In the development environment your application's code is reloaded on | 3 | Cccms::Application.configure do |
| 4 | # every request. This slows down response time but is perfect for development | 4 | # In the development environment your application's code is reloaded on |
| 5 | # since you don't have to restart the webserver when you make code changes. | 5 | # every request. This slows down response time but is perfect for development |
| 6 | config.cache_classes = false | 6 | # since you don't have to restart the webserver when you make code changes. |
| 7 | config.cache_classes = false | ||
| 7 | 8 | ||
| 8 | # Log error messages when you accidentally call methods on nil. | 9 | # Log error messages when you accidentally call methods on nil. |
| 9 | config.whiny_nils = true | 10 | config.whiny_nils = true |
| 10 | 11 | ||
| 11 | # Show full error reports and disable caching | 12 | # Show full error reports and disable caching |
| 12 | config.action_controller.consider_all_requests_local = true | 13 | config.action_controller.consider_all_requests_local = true |
| 13 | config.action_view.debug_rjs = true | 14 | config.action_controller.perform_caching = false |
| 14 | config.action_controller.perform_caching = false | ||
| 15 | 15 | ||
| 16 | # Don't care if the mailer can't send | 16 | # Don't care if the mailer can't send |
| 17 | config.action_mailer.raise_delivery_errors = false \ No newline at end of file | 17 | config.action_mailer.raise_delivery_errors = false |
| 18 | |||
| 19 | config.active_support.deprecation = :log | ||
| 20 | end | ||
diff --git a/config/environments/production.rb b/config/environments/production.rb index 1768ab7..2f933de 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb | |||
| @@ -1,36 +1,39 @@ | |||
| 1 | # Settings specified here will take precedence over those in config/environment.rb | 1 | # Settings specified here will take precedence over those in config/environment.rb |
| 2 | 2 | ||
| 3 | # The production environment is meant for finished, "live" apps. | 3 | Cccms::Application.configure do |
| 4 | # Code is not reloaded between requests | 4 | # The production environment is meant for finished, "live" apps. |
| 5 | config.cache_classes = true | 5 | # Code is not reloaded between requests |
| 6 | config.cache_classes = true | ||
| 6 | 7 | ||
| 7 | # Full error reports are disabled and caching is turned on | 8 | # Full error reports are disabled and caching is turned on |
| 8 | config.action_controller.consider_all_requests_local = false | 9 | config.action_controller.consider_all_requests_local = false |
| 9 | config.action_controller.perform_caching = true | 10 | config.action_controller.perform_caching = true |
| 10 | 11 | ||
| 11 | # See everything in the log (default is :info) | 12 | # See everything in the log (default is :info) |
| 12 | config.log_level = :info | 13 | config.log_level = :info |
| 13 | 14 | ||
| 14 | # Use a different logger for distributed setups | 15 | config.active_support.deprecation = :notify |
| 15 | # config.logger = SyslogLogger.new | ||
| 16 | 16 | ||
| 17 | # Use a different cache store in production | 17 | # Use a different logger for distributed setups |
| 18 | # config.cache_store = :mem_cache_store | 18 | # config.logger = SyslogLogger.new |
| 19 | 19 | ||
| 20 | # Enable serving of images, stylesheets, and javascripts from an asset server | 20 | # Use a different cache store in production |
| 21 | # config.action_controller.asset_host = "http://assets.example.com" | 21 | # config.cache_store = :mem_cache_store |
| 22 | 22 | ||
| 23 | # Disable delivery errors, bad email addresses will be ignored | 23 | # Enable serving of images, stylesheets, and javascripts from an asset server |
| 24 | # config.action_mailer.raise_delivery_errors = false | 24 | # config.action_controller.asset_host = "http://assets.example.com" |
| 25 | 25 | ||
| 26 | # Enable threaded mode | 26 | # Disable delivery errors, bad email addresses will be ignored |
| 27 | # config.threadsafe! | 27 | # config.action_mailer.raise_delivery_errors = false |
| 28 | 28 | ||
| 29 | ActionMailer::Base.delivery_method = :sendmail | 29 | # Enable threaded mode |
| 30 | ActionMailer::Base.sendmail_settings = { | 30 | # config.threadsafe! |
| 31 | :location => '/usr/sbin/sendmail', | ||
| 32 | :arguments => '-i -t' | ||
| 33 | } | ||
| 34 | ActionMailer::Base.perform_deliveries = true | ||
| 35 | ActionMailer::Base.raise_delivery_errors = true | ||
| 36 | 31 | ||
| 32 | ActionMailer::Base.delivery_method = :sendmail | ||
| 33 | ActionMailer::Base.sendmail_settings = { | ||
| 34 | :location => '/usr/sbin/sendmail', | ||
| 35 | :arguments => '-i -t' | ||
| 36 | } | ||
| 37 | ActionMailer::Base.perform_deliveries = true | ||
| 38 | ActionMailer::Base.raise_delivery_errors = true | ||
| 39 | end | ||
diff --git a/config/environments/test.rb b/config/environments/test.rb index 496eb95..728e147 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb | |||
| @@ -1,27 +1,32 @@ | |||
| 1 | # Settings specified here will take precedence over those in config/environment.rb | 1 | # Settings specified here will take precedence over those in config/environment.rb |
| 2 | 2 | ||
| 3 | # The test environment is used exclusively to run your application's | 3 | Cccms::Application.configure do |
| 4 | # test suite. You never need to work with it otherwise. Remember that | ||
| 5 | # your test database is "scratch space" for the test suite and is wiped | ||
| 6 | # and recreated between test runs. Don't rely on the data there! | ||
| 7 | config.cache_classes = true | ||
| 8 | 4 | ||
| 9 | # Log error messages when you accidentally call methods on nil. | 5 | # The test environment is used exclusively to run your application's |
| 10 | config.whiny_nils = true | 6 | # test suite. You never need to work with it otherwise. Remember that |
| 7 | # your test database is "scratch space" for the test suite and is wiped | ||
| 8 | # and recreated between test runs. Don't rely on the data there! | ||
| 9 | config.cache_classes = true | ||
| 11 | 10 | ||
| 12 | # Show full error reports and disable caching | 11 | # Log error messages when you accidentally call methods on nil. |
| 13 | config.action_controller.consider_all_requests_local = true | 12 | config.whiny_nils = true |
| 14 | config.action_controller.perform_caching = false | ||
| 15 | 13 | ||
| 16 | # Disable request forgery protection in test environment | 14 | # Show full error reports and disable caching |
| 17 | config.action_controller.allow_forgery_protection = false | 15 | config.action_controller.consider_all_requests_local = true |
| 16 | config.action_controller.perform_caching = false | ||
| 18 | 17 | ||
| 19 | # Tell Action Mailer not to deliver emails to the real world. | 18 | # Disable request forgery protection in test environment |
| 20 | # The :test delivery method accumulates sent emails in the | 19 | config.action_controller.allow_forgery_protection = false |
| 21 | # ActionMailer::Base.deliveries array. | ||
| 22 | config.action_mailer.delivery_method = :test | ||
| 23 | 20 | ||
| 24 | # Use SQL instead of Active Record's schema dumper when creating the test database. | 21 | # Tell Action Mailer not to deliver emails to the real world. |
| 25 | # This is necessary if your schema can't be completely dumped by the schema dumper, | 22 | # The :test delivery method accumulates sent emails in the |
| 26 | # like if you have constraints or database-specific column types | 23 | # ActionMailer::Base.deliveries array. |
| 27 | # config.active_record.schema_format = :sql \ No newline at end of file | 24 | config.action_mailer.delivery_method = :test |
| 25 | |||
| 26 | # Use SQL instead of Active Record's schema dumper when creating the test database. | ||
| 27 | # This is necessary if your schema can't be completely dumped by the schema dumper, | ||
| 28 | # like if you have constraints or database-specific column types | ||
| 29 | # config.active_record.schema_format = :sql | ||
| 30 | |||
| 31 | config.active_support.deprecation = :raise | ||
| 32 | end | ||
diff --git a/config/initializers/activesupport_duration_patch.rb b/config/initializers/activesupport_duration_patch.rb new file mode 100644 index 0000000..c2b431d --- /dev/null +++ b/config/initializers/activesupport_duration_patch.rb | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | class Integer | ||
| 2 | def days | ||
| 3 | ActiveSupport::Duration.new(self * 86400, [[:days, self]]) | ||
| 4 | end | ||
| 5 | alias :day :days | ||
| 6 | |||
| 7 | def weeks | ||
| 8 | ActiveSupport::Duration.new(self * 7 * 86400, [[:days, self * 7]]) | ||
| 9 | end | ||
| 10 | alias :week :weeks | ||
| 11 | |||
| 12 | def hours | ||
| 13 | ActiveSupport::Duration.new(self * 3600, [[:seconds, self * 3600]]) | ||
| 14 | end | ||
| 15 | alias :hour :hours | ||
| 16 | |||
| 17 | def minutes | ||
| 18 | ActiveSupport::Duration.new(self * 60, [[:seconds, self * 60]]) | ||
| 19 | end | ||
| 20 | alias :minute :minutes | ||
| 21 | |||
| 22 | def seconds | ||
| 23 | ActiveSupport::Duration.new(self, [[:seconds, self]]) | ||
| 24 | end | ||
| 25 | alias :second :seconds | ||
| 26 | |||
| 27 | def months | ||
| 28 | ActiveSupport::Duration.new(self * 30 * 86400, [[:months, self]]) | ||
| 29 | end | ||
| 30 | alias :month :months | ||
| 31 | |||
| 32 | def years | ||
| 33 | ActiveSupport::Duration.new((self * 365.25 * 86400).to_i, [[:years, self]]) | ||
| 34 | end | ||
| 35 | alias :year :years | ||
| 36 | end | ||
| 37 | |||
| 38 | class Float | ||
| 39 | def days | ||
| 40 | ActiveSupport::Duration.new((self * 86400).to_i, [[:days, self]]) | ||
| 41 | end | ||
| 42 | alias :day :days | ||
| 43 | |||
| 44 | def hours | ||
| 45 | ActiveSupport::Duration.new((self * 3600).to_i, [[:seconds, (self * 3600).to_i]]) | ||
| 46 | end | ||
| 47 | alias :hour :hours | ||
| 48 | |||
| 49 | def minutes | ||
| 50 | ActiveSupport::Duration.new((self * 60).to_i, [[:seconds, (self * 60).to_i]]) | ||
| 51 | end | ||
| 52 | alias :minute :minutes | ||
| 53 | end | ||
diff --git a/config/initializers/arel_patch.rb b/config/initializers/arel_patch.rb new file mode 100644 index 0000000..753a72b --- /dev/null +++ b/config/initializers/arel_patch.rb | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | require 'arel' | ||
| 2 | module Arel | ||
| 3 | module Visitors | ||
| 4 | [ToSql, DepthFirst].each do |visitor| | ||
| 5 | visitor.class_eval do | ||
| 6 | def visit_Integer(o, collector = nil) | ||
| 7 | collector ? collector << o.to_s : o.to_s | ||
| 8 | end | ||
| 9 | end | ||
| 10 | end | ||
| 11 | end | ||
| 12 | end | ||
diff --git a/config/initializers/exception_notifier.rb b/config/initializers/exception_notifier.rb new file mode 100644 index 0000000..bc7c385 --- /dev/null +++ b/config/initializers/exception_notifier.rb | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | Cccms::Application.config.middleware.use ExceptionNotification::Rack, | ||
| 2 | :email => { | ||
| 3 | :email_prefix => "[CCCMS] ", | ||
| 4 | :sender_address => %("CCCMS Error" <error@www.ccc.de>), | ||
| 5 | :exception_recipients => %w(erdgeist@ccc.de) | ||
| 6 | } | ||
diff --git a/config/initializers/postgresql_adapter_patch.rb b/config/initializers/postgresql_adapter_patch.rb new file mode 100644 index 0000000..57df6a2 --- /dev/null +++ b/config/initializers/postgresql_adapter_patch.rb | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | require 'active_record/connection_adapters/postgresql_adapter' | ||
| 2 | |||
| 3 | module ActiveRecord | ||
| 4 | module ConnectionAdapters | ||
| 5 | class PostgreSQLAdapter | ||
| 6 | def create_database(name, options = {}) | ||
| 7 | options = options.reverse_merge(:encoding => "utf8") | ||
| 8 | |||
| 9 | option_string = options.symbolize_keys.inject("") do |memo, (key, value)| | ||
| 10 | memo + case key | ||
| 11 | when :owner | ||
| 12 | " OWNER = \"#{value}\"" | ||
| 13 | when :template | ||
| 14 | " TEMPLATE = \"#{value}\"" | ||
| 15 | when :encoding | ||
| 16 | " ENCODING = '#{value}'" | ||
| 17 | when :tablespace | ||
| 18 | " TABLESPACE = \"#{value}\"" | ||
| 19 | when :connection_limit | ||
| 20 | " CONNECTION LIMIT = #{value}" | ||
| 21 | else | ||
| 22 | "" | ||
| 23 | end | ||
| 24 | end | ||
| 25 | |||
| 26 | execute "CREATE DATABASE #{quote_table_name(name)}#{option_string}" | ||
| 27 | end | ||
| 28 | end | ||
| 29 | end | ||
| 30 | end | ||
diff --git a/config/initializers/ruby2.rb b/config/initializers/ruby2.rb new file mode 100644 index 0000000..d2d62aa --- /dev/null +++ b/config/initializers/ruby2.rb | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | if Rails::VERSION::MAJOR == 2 && RUBY_VERSION >= '2.0.0' | ||
| 2 | module ActiveRecord | ||
| 3 | module Associations | ||
| 4 | class AssociationProxy | ||
| 5 | def send(method, *args) | ||
| 6 | if proxy_respond_to?(method, true) | ||
| 7 | super | ||
| 8 | else | ||
| 9 | load_target | ||
| 10 | @target.send(method, *args) | ||
| 11 | end | ||
| 12 | end | ||
| 13 | end | ||
| 14 | end | ||
| 15 | end | ||
| 16 | end | ||
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index b3e1098..507dc3c 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb | |||
| @@ -1,15 +1 @@ | |||
| 1 | # Be sure to restart your server when you modify this file. | Cccms::Application.config.session_store :cookie_store, :key => '_cccms_session' | |
| 2 | |||
| 3 | # Your secret key for verifying cookie session data integrity. | ||
| 4 | # If you change this key, all old sessions will become invalid! | ||
| 5 | # Make sure the secret is at least 30 characters and all random, | ||
| 6 | # no regular words or you'll be exposed to dictionary attacks. | ||
| 7 | ActionController::Base.session = { | ||
| 8 | :key => '_cccms_session', | ||
| 9 | :secret => 'b50f62033369e6039f2ece511f83f10f70301024709e189ab28d42379a26b7bfd0739fb83d89b6b76dba350569e5b9d83ee4abedbd9da468deea963512e4102b' | ||
| 10 | } | ||
| 11 | |||
| 12 | # Use the database for sessions instead of the cookie-based default, | ||
| 13 | # which shouldn't be used to store highly confidential information | ||
| 14 | # (create the session table with "rake db:sessions:create") | ||
| 15 | # ActionController::Base.session_store = :active_record_store | ||
diff --git a/config/locales/de.yml b/config/locales/de.yml index fca8c11..5f77d79 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml | |||
| @@ -18,7 +18,10 @@ de: | |||
| 18 | abbr_day_names: [So, Mo, Di, Mi, Do, Fr, Sa] | 18 | abbr_day_names: [So, Mo, Di, Mi, Do, Fr, Sa] |
| 19 | month_names: [~, Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember] | 19 | month_names: [~, Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember] |
| 20 | abbr_month_names: [~, Jan, Feb, Mär, Apr, Mai, Jun, Jul, Aug, Sep, Okt, Nov, Dez] | 20 | abbr_month_names: [~, Jan, Feb, Mär, Apr, Mai, Jun, Jul, Aug, Sep, Okt, Nov, Dez] |
| 21 | order: [ :day, :month, :year ] | 21 | order: |
| 22 | - :day | ||
| 23 | - :month | ||
| 24 | - :year | ||
| 22 | 25 | ||
| 23 | time: | 26 | time: |
| 24 | formats: | 27 | formats: |
diff --git a/config/routes.rb b/config/routes.rb index c2590bd..5e3eb3f 100644 --- a/config/routes.rb +++ b/config/routes.rb | |||
| @@ -1,38 +1,57 @@ | |||
| 1 | ActionController::Routing::Routes.draw do |map| | 1 | Cccms::Application.routes.draw do |
| 2 | filter :locale | ||
| 2 | 3 | ||
| 3 | map.filter :locale | 4 | root :to => 'content#render_page', :page_path => ['home'], :locale => 'de' |
| 4 | 5 | ||
| 5 | map.root( | 6 | resources :assets |
| 6 | :locale => 'de', | 7 | resources :tags |
| 7 | :controller => 'content', | 8 | resources :occurrences |
| 8 | :action => 'render_page', | 9 | resources :events |
| 9 | :page_path => ['home'] | 10 | |
| 10 | ) | 11 | resources :pages do |
| 11 | map.resources :assets | 12 | member do |
| 12 | map.resources :tags | 13 | get :preview |
| 13 | map.resources :occurrences | 14 | put :sort_images |
| 14 | map.resources :events | 15 | end |
| 15 | map.resources :pages, :member => {:preview => :get, :sort_images => :put} | ||
| 16 | map.resources :nodes, :member => {:publish => :put, :unlock => :put} do |node| | ||
| 17 | node.resources :revisions, :member => {:restore => :put}, :collection => {:diff => :post} | ||
| 18 | end | 16 | end |
| 19 | map.logout '/logout', :controller => 'sessions', :action => 'destroy' | 17 | |
| 20 | map.login '/login', :controller => 'sessions', :action => 'new' | 18 | resources :nodes do |
| 21 | map.admin_search 'admin/search', :controller => 'admin', :action => 'search' | 19 | member do |
| 22 | map.search 'search', :controller => "search", :action => 'index' | 20 | put :unlock |
| 23 | map.resources :users | 21 | put :publish |
| 24 | map.resources :menu_items, :member => {:sort => :post} | 22 | end |
| 25 | map.resource :session | 23 | |
| 26 | 24 | resources :revisions do | |
| 27 | map.rss 'rss/:action', :controller => 'rss' | 25 | collection do |
| 28 | map.rss 'rss/:action.:format', :controller => 'rss' | 26 | post :diff |
| 29 | 27 | end | |
| 30 | map.connect ':controller/:action/:id' | 28 | member do |
| 31 | map.connect ':controller/:action/:id.:format' | 29 | put :restore |
| 32 | 30 | end | |
| 33 | map.connect 'galleries/*page_path', | 31 | end |
| 34 | :controller => 'content', :action => 'render_gallery' | 32 | end |
| 35 | 33 | ||
| 36 | map.content '/*page_path', | 34 | match '/logout' => 'sessions#destroy', :as => :logout |
| 37 | :controller => 'content', :action => 'render_page' | 35 | match '/login' => 'sessions#new', :as => :login |
| 36 | match 'admin/search' => 'admin#search', :as => :admin_search | ||
| 37 | match 'search' => 'search#index', :as => :search | ||
| 38 | |||
| 39 | resources :users | ||
| 40 | |||
| 41 | resources :menu_items do | ||
| 42 | member do | ||
| 43 | post :sort | ||
| 44 | end | ||
| 45 | end | ||
| 46 | |||
| 47 | resource :session | ||
| 48 | |||
| 49 | match 'rss/:action' => 'rss#index', :as => :rss | ||
| 50 | match 'rss/:action.:format' => 'rss#index' | ||
| 51 | |||
| 52 | match '/:controller(/:action(/:id))' | ||
| 53 | match '/:controller(/:action(/:id.:format))' | ||
| 54 | |||
| 55 | match 'galleries/*page_path' => 'content#render_gallery' | ||
| 56 | match '/*page_path' => 'content#render_page', :as => :content | ||
| 38 | end | 57 | end |
