diff --git a/Rakefile b/Rakefile index 3bb0e8592a..08223ff3af 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/config.ru b/config.ru new file mode 100644 index 0000000000..260582accb --- /dev/null +++ b/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 diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000000..26264f3b06 --- /dev/null +++ b/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 diff --git a/config/boot.rb b/config/boot.rb index dd5e3b6916..ab6cb374de 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -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) diff --git a/config/environment.rb b/config/environment.rb index 1995223947..4affbcd72b 100644 --- a/config/environment.rb +++ b/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 -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! diff --git a/config/environments/development.rb b/config/environments/development.rb index 90b61e9b60..7d49b94546 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index 51774af654..b924fd09c4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,30 +1,32 @@ -# Settings specified here will take precedence over those in config/environment.rb +TypoBlog::Application.configure do + # Settings specified here will take precedence over those in config/environment.rb -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true + # The production environment is meant for finished, "live" apps. + # Code is not reloaded between requests + config.cache_classes = true -# Full error reports are disabled and caching is turned on -config.action_controller.consider_all_requests_local = false -config.action_controller.perform_caching = true -config.action_view.cache_template_loading = true + # Full error reports are disabled and caching is turned on + config.action_controller.consider_all_requests_local = false + config.action_controller.perform_caching = true + config.action_view.cache_template_loading = true -# See everything in the log (default is :info) -# config.log_level = :debug + # See everything in the log (default is :info) + # config.log_level = :debug -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new + # Use a different logger for distributed setups + # config.logger = SyslogLogger.new -# Use a different cache store in production -# config.cache_store = :mem_cache_store + # Use a different cache store in production + # config.cache_store = :mem_cache_store -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" + # Enable serving of images, stylesheets, and javascripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" -# Disable delivery errors, bad email addresses will be ignored -# config.action_mailer.raise_delivery_errors = false + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false -# Enable threaded mode -# config.threadsafe! + # Enable threaded mode + # config.threadsafe! -Migrator.offer_migration_when_available = true + Migrator.offer_migration_when_available = true +end \ No newline at end of file diff --git a/config/environments/test.rb b/config/environments/test.rb index 798ae11cd3..2f9697fcce 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,31 +1,33 @@ # Settings specified here will take precedence over those in config/environment.rb -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! -config.cache_classes = false +TypoBlog::Application.configure do + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + 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_controller.perform_caching = false -config.action_view.cache_template_loading = false + # Show full error reports and disable caching + config.action_controller.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.action_view.cache_template_loading = false -# Disable request forgery protection in test environment -config.action_controller.allow_forgery_protection = false + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false -# Tell Action Mailer not to deliver emails to the real world. -# The :test delivery method accumulates sent emails in the -# ActionMailer::Base.deliveries array. -config.action_mailer.delivery_method = :test + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test -# 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 + # 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 -require 'ruby-debug' -Migrator.offer_migration_when_available = false + require 'ruby-debug' + Migrator.offer_migration_when_available = false +end \ No newline at end of file diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 12dac50cc8..9e8b0131f8 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,6 +1,6 @@ # Be sure to restart your server when you modify this file. -# Add new inflection rules using the following format +# Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' @@ -8,8 +8,3 @@ # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end - -ActiveSupport::Inflector.inflections {|inflect| - inflect.uncountable %w(feedback) - inflect.singular "page_caches", "page_cache" -} diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index e9887d9178..72aca7e441 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,3 +1,5 @@ -Mime::Type.register_alias "application/xml", :googlesitemap -Mime::Type.register "application/rsd+xml", :rsd +# Be sure to restart your server when you modify this file. +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb new file mode 100644 index 0000000000..91e2dc26ca --- /dev/null +++ b/config/initializers/secret_token.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +TypoBlog::Application.config.secret_token = '08aac1f2d29e54c90efa24a4aefef843ab62da7a2610d193bc0558a50254c7debac56b48ffd0b5990d6ed0cbecc7dc08dce1503b6b864d580758c3c46056729a' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index f92d39bafd..da8e60468a 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,15 +1,8 @@ # Be sure to restart your server when you modify this file. -# Your secret key for verifying cookie session data integrity. -# If you change this key, all old sessions will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -ActionController::Base.session = { - :key => "_typo_session", - :secret => "8d7879bd56b9470b659cdcae88792622" -} +TypoBlog::Application.config.session_store :cookie_store, :key => '_typo_blog_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rake db:sessions:create") -# ActionController::Base.session_store = :active_record_store +# TypoBlog::Application.config.session_store :active_record_store diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000000..a747bfa698 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,5 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + hello: "Hello world" diff --git a/db/seeds.rb b/db/seeds.rb index 3174d0cb8a..664d8c74c8 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -2,6 +2,6 @@ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: -# +# # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -# Major.create(:name => 'Daley', :city => cities.first) +# Mayor.create(:name => 'Daley', :city => cities.first) diff --git a/public/404.html b/public/404.html index eff660b90c..9a48320a5f 100644 --- a/public/404.html +++ b/public/404.html @@ -1,23 +1,19 @@ - - - - + +
-You may have mistyped the address or the page may have moved.
- \ No newline at end of file + diff --git a/public/422.html b/public/422.html index b54e4a3cad..83660ab187 100644 --- a/public/422.html +++ b/public/422.html @@ -1,23 +1,19 @@ - - - - + + -Maybe you tried to change something you didn't have access to.
- \ No newline at end of file + diff --git a/public/500.html b/public/500.html index ec3bbf02c4..b80307fc16 100644 --- a/public/500.html +++ b/public/500.html @@ -1,23 +1,19 @@ - - - - + + -