Skip to content

Commit

Permalink
Update to rails 3
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Nov 14, 2011
1 parent 9ff70a8 commit c9fa49c
Show file tree
Hide file tree
Showing 41 changed files with 4,011 additions and 2,258 deletions.
25 changes: 25 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
source 'http://rubygems.org'

gem 'rails', '3.0.0'

gem 'pg'
gem 'libxml-ruby', '>= 2.0.5', :require => 'libxml'
gem 'rmagick', :require => 'RMagick'
gem 'oauth', '>= 0.4.3'
gem 'oauth-plugin', '>= 0.3.14'
gem 'httpclient'
gem 'SystemTimer', '>= 1.1.3', :require => 'system_timer'
gem 'sanitize'

# Should only load if memcache is in use
gem 'memcached'

# Should only load if we're not in database offline mode
gem 'composite_primary_keys', '>= 3.0.0.0'

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development, :test do
gem 'timecop'
end
7 changes: 2 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'
OpenStreetMap::Application.load_tasks
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base

protect_from_forgery

if STATUS == :database_readonly or STATUS == :database_offline
session :off

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/diary_entry_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ def list
end

def rss
request.format = :rss

if params[:display_name]
user = User.find_by_display_name(params[:display_name], :conditions => { :status => ["active", "confirmed"] })

Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/_head.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"/>
<%= javascript_strings %>
<%= javascript_include_tag 'prototype' %>
<%= javascript_include_tag 'rails' %>
<%= javascript_include_tag 'site' %>
<%= javascript_include_tag 'menu' %>
<!--[if lt IE 7]><%= javascript_include_tag 'pngfix' %><![endif]--> <!-- thanks, microsoft! -->
Expand All @@ -16,5 +17,6 @@
<%= tag("meta", { :name => "description", :content => "OpenStreetMap is the free wiki world map." }) %>
<%= style_rules %>
<%= yield :head %>
<%= csrf_meta_tag %>
<title><%= t 'layouts.project_name.title' %><%= ' | '+ h(@title) if @title %></title>
</head>
4 changes: 4 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run OpenStreetMap::Application
49 changes: 49 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
require File.expand_path('../boot', __FILE__)

require File.expand_path('../preinitializer', __FILE__)

require 'rails/all'

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)

module OpenStreetMap
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/lib)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
config.active_record.observers = :spam_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
config.active_record.schema_format = :sql
end
end
123 changes: 13 additions & 110 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,110 +1,13 @@
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb

RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)

module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end

def booted?
defined? Rails::Initializer
end

def pick_boot
(vendor_rails? ? VendorBoot : GemBoot).new
end

def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end

def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end

def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
end
end

class Boot
def run
load_initializer
Rails::Initializer.run(:set_load_path)
end
end

class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
Rails::GemDependency.add_frozen_gem_path
end
end

class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer'
end

def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
else
gem 'rails'
end
rescue Gem::LoadError => load_error
$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.)
exit 1
end

class << self
def rubygems_version
Gem::RubyGemsVersion rescue nil
end

def gem_version
if defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION
elsif ENV.include?('RAILS_GEM_VERSION')
ENV['RAILS_GEM_VERSION']
else
parse_gem_version(read_environment_rb)
end
end

def load_rubygems
min_version = '1.3.1'
require 'rubygems'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end

rescue LoadError
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end

def parse_gem_version(text)
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end

private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
end
end
end
end

# All that for this:
Rails.boot!
require 'rubygems'

# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gemfile)
62 changes: 4 additions & 58 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,59 +1,5 @@
# Be sure to restart your server when you modify this file
# Load the rails application
require File.expand_path('../application', __FILE__)

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )

# Specify gems that this application depends on and have them installed with rake gems:install
unless STATUS == :database_offline
config.gem 'composite_primary_keys', :version => '2.2.2'
end
config.gem 'libxml-ruby', :version => '>= 2.0.5', :lib => 'libxml'
config.gem 'rmagick', :lib => 'RMagick'
config.gem 'oauth', :version => '>= 0.4.3'
config.gem 'oauth-plugin', :version => '0.3.14'
config.gem 'httpclient'
config.gem 'SystemTimer', :version => '>= 1.1.3', :lib => 'system_timer'
config.gem 'sanitize'
config.gem 'i18n', :version => '>= 0.5.0'
if defined?(MEMCACHE_SERVERS)
config.gem 'memcached'
end

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
if STATUS == :database_offline
config.frameworks -= [ :active_record ]
config.eager_load_paths = []
end

# Activate observers that should always be running
config.active_record.observers = :spam_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'UTC'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de

# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
config.active_record.schema_format = :sql
end
# Initialize the rails application
OpenStreetMap::Application.initialize!
35 changes: 22 additions & 13 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
# Settings specified here will take precedence over those in config/environment.rb
OpenStreetMap::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log

# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
end

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
Loading

0 comments on commit c9fa49c

Please sign in to comment.