forked from publify/publify
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Frédéric de Villamil
committed
Sep 3, 2010
1 parent
637472f
commit 2181591
Showing
25 changed files
with
3,822 additions
and
2,060 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
TypoBlog::Application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 TypoBlog::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.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! | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
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. | ||
|
||
# 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' | ||
# Initialize the rails application | ||
TypoBlog::Application.initialize! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
# 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 | ||
TypoBlog::Application.configure do | ||
# 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.action_controller.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 | ||
# Don't care if the mailer can't send | ||
config.action_mailer.raise_delivery_errors = false | ||
|
||
def log_to(stream) | ||
ActiveRecord::Base.logger = Logger.new(stream) | ||
ActiveRecord::Base.clear_active_connections! | ||
end | ||
def log_to(stream) | ||
ActiveRecord::Base.logger = Logger.new(stream) | ||
ActiveRecord::Base.clear_active_connections! | ||
end | ||
|
||
config.log_level = :debug | ||
config.log_level = :debug | ||
end |
Oops, something went wrong.