Skip to content

Commit

Permalink
Adding Rails3 generated stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric de Villamil committed Sep 3, 2010
1 parent 637472f commit 2181591
Show file tree
Hide file tree
Showing 25 changed files with 3,822 additions and 2,060 deletions.
7 changes: 2 additions & 5 deletions Rakefile
@@ -1,10 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake, # 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. # 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'
require 'rake/testtask'
require 'rake/rdoctask'


require 'tasks/rails' TypoBlog::Application.load_tasks
4 changes: 4 additions & 0 deletions config.ru
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run TypoBlog::Application
77 changes: 77 additions & 0 deletions config/application.rb
@@ -0,0 +1,77 @@
require File.expand_path('../boot', __FILE__)

module TypoBlog
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.

# Setup the cache path
config.action_controller.page_cache_directory = "#{RAILS_ROOT}/public/cache/"
config.cache_store=:file_store, "#{RAILS_ROOT}/public/cache/"

# I need the localization plugin to load first
# Otherwise, I can't localize plugins <= localization
# Forcing manually the load of the textfilters plugins fixes the bugs with apache in production.
config.plugins = [ :localization, :all ]

config.load_paths += %W(
vendor/akismet
app/apis
).map {|dir| "#{RAILS_ROOT}/#{dir}"}.select { |dir| File.directory?(dir) }

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

# Disable use of the Accept header, since it causes bad results with our
# static caching (e.g., caching an atom feed as index.html).
config.action_controller.use_accept_header = false

# Activate observers that should always be running
config.active_record.observers = :email_notifier, :web_notifier
end

# Load included libraries.
#require 'uuidtools'

require 'migrator'
require 'rails_patch/active_record'
require 'rails_patch/active_support'
require 'login_system'
require 'typo_version'
$KCODE = 'u'
require 'jcode'
require 'transforms'

$FM_OVERWRITE = true
require 'filemanager'

ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
:long_weekday => '%a %B %e, %Y %H:%M'
)

ActionMailer::Base.default_charset = 'utf-8'

# Work around interpolation deprecation problem: %d is replaced by
# {{count}}, even when we don't want them to.
# FIXME: We should probably fully convert to standard Rails I18n.
require 'i18n_interpolation_deprecation'
class I18n::Backend::Simple
def interpolate(locale, string, values = {})
interpolate_without_deprecated_syntax(locale, string, values)
end
end

if RAILS_ENV != 'test'
begin
mail_settings = YAML.load(File.read("#{RAILS_ROOT}/config/mail.yml"))

ActionMailer::Base.delivery_method = mail_settings['method']
ActionMailer::Base.server_settings = mail_settings['settings']
rescue
# Fall back to using sendmail by default
ActionMailer::Base.delivery_method = :sendmail
end
end
end
123 changes: 13 additions & 110 deletions config/boot.rb
@@ -1,110 +1,13 @@
# Don't change this file! require 'rubygems'
# Configure your app in config/environment.rb and config/environments/*.rb

# Set up gems listed in the Gemfile.
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) gemfile = File.expand_path('../../Gemfile', __FILE__)

begin
module Rails ENV['BUNDLE_GEMFILE'] = gemfile
class << self require 'bundler'
def boot! Bundler.setup
unless booted? rescue Bundler::GemNotFound => e
preinitialize STDERR.puts e.message
pick_boot.run STDERR.puts "Try running `bundle install`."
end exit!
end end if File.exist?(gemfile)

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.2'
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!
83 changes: 4 additions & 79 deletions config/environment.rb
@@ -1,80 +1,5 @@
# Be sure to restart your server when you modify this file # Load the rails application
require File.expand_path('../application', __FILE__)


# Bootstrap the Rails environment, frameworks, and default configuration # Initialize the rails application
require File.join(File.dirname(__FILE__), 'boot') TypoBlog::Application.initialize!

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.

# Setup the cache path
config.action_controller.page_cache_directory = "#{RAILS_ROOT}/public/cache/"
config.cache_store=:file_store, "#{RAILS_ROOT}/public/cache/"

# I need the localization plugin to load first
# Otherwise, I can't localize plugins <= localization
# Forcing manually the load of the textfilters plugins fixes the bugs with apache in production.
config.plugins = [ :localization, :all ]

config.load_paths += %W(
vendor/akismet
app/apis
).map {|dir| "#{RAILS_ROOT}/#{dir}"}.select { |dir| File.directory?(dir) }

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

# Disable use of the Accept header, since it causes bad results with our
# static caching (e.g., caching an atom feed as index.html).
config.action_controller.use_accept_header = false

# Activate observers that should always be running
config.active_record.observers = :email_notifier, :web_notifier
end

# Load included libraries.
#require 'uuidtools'

require 'migrator'
require 'rails_patch/active_record'
require 'rails_patch/active_support'
require 'login_system'
require 'typo_version'
$KCODE = 'u'
require 'jcode'
require 'transforms'

$FM_OVERWRITE = true
require 'filemanager'

ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
:long_weekday => '%a %B %e, %Y %H:%M'
)

ActionMailer::Base.default_charset = 'utf-8'

# Work around interpolation deprecation problem: %d is replaced by
# {{count}}, even when we don't want them to.
# FIXME: We should probably fully convert to standard Rails I18n.
require 'i18n_interpolation_deprecation'
class I18n::Backend::Simple
def interpolate(locale, string, values = {})
interpolate_without_deprecated_syntax(locale, string, values)
end
end

if RAILS_ENV != 'test'
begin
mail_settings = YAML.load(File.read("#{RAILS_ROOT}/config/mail.yml"))

ActionMailer::Base.delivery_method = mail_settings['method']
ActionMailer::Base.server_settings = mail_settings['settings']
rescue
# Fall back to using sendmail by default
ActionMailer::Base.delivery_method = :sendmail
end
end

FLICKR_KEY='84f652422f05b96b29b9a960e0081c50'
36 changes: 19 additions & 17 deletions config/environments/development.rb
@@ -1,24 +1,26 @@
# Settings specified here will take precedence over those in config/environment.rb # Settings specified here will take precedence over those in config/environment.rb


# In the development environment your application's code is reloaded on TypoBlog::Application.configure do
# every request. This slows down response time but is perfect for development # In the development environment your application's code is reloaded on
# since you don't have to restart the webserver when you make code changes. # every request. This slows down response time but is perfect for development
config.cache_classes = false # 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. # Log error messages when you accidentally call methods on nil.
config.whiny_nils = true config.whiny_nils = true


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


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


def log_to(stream) def log_to(stream)
ActiveRecord::Base.logger = Logger.new(stream) ActiveRecord::Base.logger = Logger.new(stream)
ActiveRecord::Base.clear_active_connections! ActiveRecord::Base.clear_active_connections!
end end


config.log_level = :debug config.log_level = :debug
end

0 comments on commit 2181591

Please sign in to comment.