升级至 rails4

This commit is contained in:
yafeilee 2014-03-28 21:31:21 +08:00
parent 00140a1255
commit cc70226a90
34 changed files with 425 additions and 513 deletions

View File

@ -1,5 +0,0 @@
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks

61
Gemfile
View File

@ -1,49 +1,42 @@
source 'http://rubygems.org'
#source 'http://ruby.taobao.org'
if ENV['RAILS_ENV'] == 'production'
source 'https://rubygems.org'
else
source 'http://ruby.taobao.org'
end
gem 'rails', '3.2.6'
ruby '2.0.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'rails', '4.0.4'
gem 'sass-rails', '~> 4.0.2'
gem 'coffee-rails', '~> 4.0.1'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem "mongoid"
gem "mongoid-pagination"
gem "bson_ext"
gem "redcarpet"
gem "simple_form"
gem "mini_magick"
gem 'carrierwave-mongoid'
gem 'html_truncator'
gem 'nokogiri'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
group :development do
gem 'quiet_assets'
gem 'guard'
gem 'guard-rails'
gem 'guard-rspec', require: false
gem 'guard-bundler', require: false
end
group :test do
#gem 'capybara'
#gem 'cucumber-rails'
#gem 'factory_girl'
#gem 'mongoid-rspec', :require => false
gem 'capybara'
gem 'factory_girl'
gem 'mongoid-rspec', :require => false
gem 'database_cleaner'
end
group :test, :development do
gem "rspec-rails", ">= 2.8.1"
end
gem 'jquery-rails'
gem 'capistrano'
gem 'rvm-capistrano'
#gem "bluecloth"
gem "redcarpet"
gem "simple_form"
gem 'database_cleaner'
gem "mini_magick"
gem 'carrierwave-mongoid'
gem 'html_truncator'
gem 'nokogiri'

View File

@ -1,181 +1,238 @@
GEM
remote: http://ruby.taobao.org/
specs:
actionmailer (3.2.6)
actionpack (= 3.2.6)
mail (~> 2.4.4)
actionpack (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
actionmailer (4.0.4)
actionpack (= 4.0.4)
mail (~> 2.5.4)
actionpack (4.0.4)
activesupport (= 4.0.4)
builder (~> 3.1.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
activerecord (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
bson (1.6.4)
bson_ext (1.6.4)
bson (~> 1.6.4)
builder (3.0.0)
capistrano (2.12.0)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
carrierwave (0.6.2)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.4)
activesupport (= 4.0.4)
builder (~> 3.1.0)
activerecord (4.0.4)
activemodel (= 4.0.4)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.4)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.4)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
arel (4.0.2)
atomic (1.1.16)
bson (2.2.1)
bson_ext (1.5.1)
builder (3.1.4)
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
carrierwave-mongoid (0.2.1)
carrierwave (~> 0.6.1)
mongoid (~> 2.1)
coffee-rails (3.2.2)
json (>= 1.7)
mime-types (>= 1.16)
carrierwave-mongoid (0.7.0)
carrierwave (>= 0.8.0, < 0.11.0)
mongoid (>= 3.0, < 5.0)
mongoid-grid_fs (~> 1.3)
celluloid (0.15.2)
timers (~> 1.1.0)
celluloid-io (0.15.0)
celluloid (>= 0.15.0)
nio4r (>= 0.5.0)
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.3)
database_cleaner (0.8.0)
diff-lcs (1.1.3)
coffee-script-source (1.7.0)
connection_pool (1.2.0)
database_cleaner (1.2.0)
diff-lcs (1.2.5)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
highline (1.6.13)
hike (1.2.1)
html_truncator (0.3.0)
nokogiri (~> 1.4)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.7.3)
mail (2.4.4)
i18n (>= 0.4.0)
execjs (2.0.2)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
ffi (1.9.3)
formatador (0.2.4)
guard (2.6.0)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
pry (>= 0.9.12)
thor (>= 0.18.1)
guard-bundler (2.0.0)
bundler (~> 1.0)
guard (~> 2.2)
guard-rails (0.5.0)
guard (>= 2.0.0)
guard-rspec (4.2.8)
guard (~> 2.1)
rspec (>= 2.14, < 4.0)
hike (1.2.3)
html_truncator (0.4.0)
nokogiri (~> 1.5)
i18n (0.6.9)
jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
listen (2.7.1)
celluloid (>= 0.15.2)
celluloid-io (>= 0.15.0)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.5)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.19)
mini_magick (3.4)
method_source (0.8.2)
mime-types (1.25.1)
mini_magick (3.7.0)
subexec (~> 0.2.1)
mongo (1.6.2)
bson (~> 1.6.2)
mongoid (2.4.11)
activemodel (~> 3.1)
mongo (<= 1.6.2)
tzinfo (~> 0.3.22)
mini_portile (0.5.3)
minitest (4.7.5)
mongoid (4.0.0.beta1)
activemodel (>= 4.0.0)
moped (~> 2.0.beta6)
origin (~> 2.1)
tzinfo (>= 0.3.37)
mongoid-grid_fs (1.9.2)
mime-types (>= 1.19, < 3.0)
mongoid (>= 3.0, < 5.0)
mongoid-pagination (0.2.0)
activesupport
mongoid
multi_json (1.3.6)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.5.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.5)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
mongoid-rspec (1.4.6)
mongoid (>= 3.0.0.rc)
rake
rspec (>= 2.9)
moped (2.0.0.beta6)
bson (~> 2.2)
connection_pool (~> 1.2)
optionable (~> 0.2.0)
multi_json (1.9.2)
nio4r (1.0.0)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
optionable (0.2.0)
origin (2.1.0)
polyglot (0.3.4)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
quiet_assets (1.0.2)
railties (>= 3.1, < 5.0)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.6)
actionmailer (= 3.2.6)
actionpack (= 3.2.6)
activerecord (= 3.2.6)
activeresource (= 3.2.6)
activesupport (= 3.2.6)
bundler (~> 1.0)
railties (= 3.2.6)
railties (3.2.6)
actionpack (= 3.2.6)
activesupport (= 3.2.6)
rack-ssl (~> 1.3.2)
rails (4.0.4)
actionmailer (= 4.0.4)
actionpack (= 4.0.4)
activerecord (= 4.0.4)
activesupport (= 4.0.4)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.4)
sprockets-rails (~> 2.0.0)
railties (4.0.4)
actionpack (= 4.0.4)
activesupport (= 4.0.4)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
redcarpet (2.1.1)
rspec (2.10.0)
rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0)
rspec-mocks (~> 2.10.0)
rspec-core (2.10.1)
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
rspec-rails (2.10.1)
thor (>= 0.18.1, < 2.0)
rake (10.2.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.3)
ffi (>= 0.5.0)
redcarpet (3.1.1)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.10.0)
rvm-capistrano (1.2.2)
capistrano (>= 2.0.0)
sass (3.1.19)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
simple_form (2.0.2)
actionpack (~> 3.0)
activemodel (~> 3.0)
sprockets (2.1.3)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
sass (3.2.18)
sass-rails (4.0.2)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0.0)
simple_form (3.0.1)
actionpack (>= 4.0.0, < 4.1)
activemodel (>= 4.0.0, < 4.1)
slop (3.5.0)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
subexec (0.2.2)
thor (0.15.3)
tilt (1.3.3)
treetop (1.4.10)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
subexec (0.2.3)
thor (0.19.1)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
tilt (1.4.1)
timers (1.1.0)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.5)
tzinfo (0.3.39)
uglifier (2.5.0)
execjs (>= 0.3.0)
multi_json (~> 1.3)
json (>= 1.8.0)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
bson_ext
capistrano
capybara
carrierwave-mongoid
coffee-rails (~> 3.2.1)
coffee-rails (~> 4.0.1)
database_cleaner
factory_girl
guard
guard-bundler
guard-rails
guard-rspec
html_truncator
jquery-rails
mini_magick
mongoid
mongoid-pagination
mongoid-rspec
nokogiri
rails (= 3.2.6)
quiet_assets
rails (= 4.0.4)
redcarpet
rspec-rails (>= 2.8.1)
rvm-capistrano
sass-rails (~> 3.2.3)
sass-rails (~> 4.0.2)
simple_form
uglifier (>= 1.0.3)
uglifier (>= 1.3.0)

27
Guardfile Normal file
View File

@ -0,0 +1,27 @@
guard :bundler do
watch('Gemfile')
end
guard 'rails' do
watch('Gemfile.lock')
watch(%r{^(config|lib)/.*})
end
guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
end

View File

@ -13,7 +13,7 @@ class Admin::PostsController < ApplicationController
end
def create
@post = Post.new( params[:post] )
@post = Post.new( post_params )
if @post.save
flash[:notice] = "success!"
redirect_to root_path
@ -27,9 +27,13 @@ class Admin::PostsController < ApplicationController
end
def preview
text = params[:text] || ""
text = params.permit(:text)[:text] || ""
rd = Redcarpet::Render::HTML.new(:hard_wrap=>true)
md = Redcarpet::Markdown.new(rd, :autolink=>true)
render :text => md.render(text)
end
def post_params
params.require(:post).permit(:title, :content, :type)
end
end

View File

@ -3,7 +3,5 @@ class Photo
include Mongoid::Timestamps
field :image
attr_accessible :image
mount_uploader :image, PhotoUploader
end

View File

@ -1,68 +1,28 @@
require File.expand_path('../boot', __FILE__)
#require 'rails/all'
# head
# Pick the frameworks you want:
require "active_model/railtie"
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
Bundler.require(:default, Rails.env)
module WBlog
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}/extras)
# 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 = :cacher, :garbage_collector, :forum_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 = 'Beijing'
# 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
# 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]
I18n.config.enforce_available_locales = true
config.time_zone = 'Beijing'
config.action_controller.action_on_unpermitted_parameters = :log
# Enable escaping HTML in JSON.
#config.active_support.escape_html_entities_in_json = true
# Use SQL instead of Active Record's schema dumper when creating the 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
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
#config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
# generators
config.generators.assets = false
config.generators.helper = false
config.generators do |g|
g.test_framework :rspec, view_specs: false
end
end
end

View File

@ -1,5 +1,3 @@
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

View File

@ -1,25 +0,0 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

View File

@ -1,39 +0,0 @@
require 'rvm/capistrano'
require 'bundler/capistrano'
#default_run_options[:shell] = '/bin/bash'
default_run_options[:pty] = true
set :application, "wblog"
set :repository, "git://github.com/windy/wblog.git"
set :user, "ruby"
set :use_sudo, false
set :rvm_ruby_string, '1.9.3-p194'
set :rvm_type, :system
set :keep_releases, 5
set :scm, :git
set :branch, "master"
set :deploy_via, :remote_cache
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
role :web, "yafeilee.me" # Your HTTP server, Apache/etc
role :app, "yafeilee.me" # This may be the same as your `Web` server
role :db, "yafeilee.me", :primary => true # This is where Rails migrations will run
#role :db, "your slave db-server here"
#
set :deploy_to, "/home/ruby/app_wblog"
before "deploy:finalize_update","link_uploads"
task :link_uploads do
run "ln -nsf #{shared_path}/uploads #{release_path}/public/uploads"
end
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end

View File

@ -1,37 +1,39 @@
WBlog::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in config/application.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 web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching
# Show full error reports and disable caching.
config.consider_all_requests_local = true
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
# Print deprecation notices to the Rails logger
# 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
# Raise exception on mass assignment protection for Active Record models
#config.active_record.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
#config.active_record.auto_explain_threshold_in_seconds = 0.5
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
port: 25,
domain: ENV["DOMAIN_NAME"],
authentication: "plain",
user_name: ENV["SENDGRID_USERNAME"],
password: ENV["SENDGRID_PASSWORD"]
}
# Send email in development mode.
config.action_mailer.perform_deliveries = true
end

View File

@ -1,67 +1,90 @@
WBlog::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests
# Code is not reloaded between requests.
config.cache_classes = true
# Full error reports are disabled and caching is turned on
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Don't fallback to assets pipeline if a precompiled asset is missed
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs
# Generate digests for assets URLs.
config.assets.digest = true
# Defaults to nil and saved in location specified by config.assets.prefix
# config.assets.manifest = YOUR_PATH
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# See everything in the log (default is :info)
# config.log_level = :debug
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js )
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
config.assets.precompile += %w( vendor/modernizr.js )
# Disable delivery errors, bad email addresses will be ignored
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
# the I18n.default_locale when a translation can not be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
port: 25,
domain: ENV["DOMAIN_NAME"],
authentication: "plain",
user_name: ENV["SENDGRID_USERNAME"],
password: ENV["SENDGRID_PASSWORD"]
}
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
end

View File

@ -1,5 +1,5 @@
WBlog::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
@ -7,31 +7,30 @@ WBlog::Application.configure do
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil
config.whiny_nils = true
# Show full error reports and disable caching
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = 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
# Raise exception on mass assignment protection for Active Record models
#config.active_record.mass_assignment_sanitizer = :strict
# Print deprecation notices to the stderr
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
end

View File

@ -1,7 +1 @@
# 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.
WBlog::Application.config.secret_token = 'b8fa45ddb4847771e49e67faf16986bddaf5b6dc7b290749c4b4857151b33c8ad376449ac16b036d09fc5d61b7b39d53bd12ea8f26049f295fd898e8447e840c'
WBlog::Application.config.secret_key_base = '2f44e06dc7bf1cf7ce972ef79e4f33531554a7491ff59dc08b3e7f97a412761f9ec28fa530b4c711d82de0053b8807eb0a4bb0c474313820eed9312a01ad9d4c'

View File

@ -1,8 +1,3 @@
# Be sure to restart your server when you modify this file.
WBlog::Application.config.session_store :cookie_store, key: '_WBlog_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 "rails generate session_migration")
# WBlog::Application.config.session_store :active_record_store
WBlog::Application.config.session_store :cookie_store, key: 'wblog_session'

View File

@ -1,8 +1,4 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
hello: "Hello world"
upload_photo: "上传图片"
comment: "查看评论"
announce_at: "发表在 "

View File

@ -1,17 +1,69 @@
development:
host: localhost
database: w_blog_development
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: w_blog_development
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
# Change the default write concern. (default = { w: 1 })
# write:
# w: 1
# Change the default consistency model to primary, secondary.
# 'secondary' will send reads to secondaries, 'primary' sends everything
# to master. (default: primary)
# read: secondary_preferred
# How many times Moped should attempt to retry an operation after
# failure. (default: 30)
# max_retries: 30
# The time in seconds that Moped should wait before retrying an
# operation on failure. (default: 1)
# retry_interval: 1
# Configure Mongoid specific options. (optional)
options:
# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false
# Include the _type field in serializaion. (default: false)
# include_type_for_serialization: false
# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false
# Protect id and type from mass assignment. (default: true)
# protect_sensitive_fields: true
# Raise an error when performing a #find and the document is not found.
# (default: true)
# raise_not_found_error: true
# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false
# Use Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true
# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
test:
host: localhost
database: w_blog_test
# set these environment variables on your prod server
production:
host: localhost
database: w_blog
# slaves:
# - host: slave1.local
# port: 27018
# - host: slave2.local
# port: 27019
sessions:
default:
database: w_blog_test
hosts:
- localhost:27017
options:
read: primary
# In the test environment we lower the retries and retry interval to
# low amounts for fast failures.
max_retries: 1
retry_interval: 0

View File

@ -16,7 +16,7 @@ WBlog::Application.routes.draw do
end
end
end
match '/about' => 'home#index'
match '/admin' => 'admin/posts#new'
match '/:type' => 'blogs#index'
get '/about' => 'home#index'
get '/admin' => 'admin/posts#new'
get '/:type' => 'blogs#index'
end

View File

@ -1,7 +0,0 @@
# This file should contain all the record creation needed to seed the database with its default values.
# 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' }])
# Mayor.create(name: 'Emanuel', city: cities.first)

View File

@ -5,7 +5,7 @@ describe HomeController do
describe "GET 'index'" do
it "returns http success" do
get 'index'
response.should be_success
expect(response).to redirect_to("http://who.yafeilee.me")
end
end

View File

@ -1,15 +0,0 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the Admin::PostsHelper. For example:
#
# describe Admin::PostsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe Admin::PostsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,15 +0,0 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the BlogsHelper. For example:
#
# describe BlogsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe BlogsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,15 +0,0 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the HomeHelper. For example:
#
# describe HomeHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe HomeHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,15 +0,0 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the PhotosHelper. For example:
#
# describe PhotosHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe PhotosHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "posts/create.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "posts/destroy.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "posts/edit.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "posts/index.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "posts/new.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "posts/update.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "blogs/index.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "blogs/show.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "home/index.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe "photos/create.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end