diff --git a/.gitignore b/.gitignore index 70dcf78..a86c937 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ # Rails, Ruby, etc -/coverage/ /log/* /tmp/* /spec/tmp/* @@ -36,6 +35,8 @@ .bundle # Misc +/coverage/ +/backups /index/* rerun.txt pickle-email-*.html diff --git a/INSTALL.md b/INSTALL.md index 6b1f78f..c2277fb 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,11 +18,11 @@ Create a new upstart config and set permissions touch /etc/init/ensl.conf chown deploy /etc/init/ensl.conf -Add the following to `/etc/sudoers` to allow the `deploy` user to manage nginx, rbenv and upstart via sudo without a password +Add the following to `/etc/sudoers` to allow the `deploy` user to manage nginx, rbenv and upstart commands via sudo without a password # /etc/sudoers deploy ALL=NOPASSWD:/etc/init.d/nginx - deploy ALL=NOPASSWD:/home/deploy/.rbenv/bin/* + deploy ALL=NOPASSWD:/home/deploy/.rbenv/bin/rbenv deploy ALL=NOPASSWD:/usr/sbin/service ensl start, /usr/sbin/service ensl stop, /usr/sbin/service ensl restart ## Install MySQL & Memcached diff --git a/app/models/comment.rb b/app/models/comment.rb index d08bf6f..a2d42ad 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -20,8 +20,6 @@ class Comment < ActiveRecord::Base before_save :parse_text - # acts_as_indexed :fields => [:text] - def parse_text self.text_parsed = RbbCode::Parser.new.parse(text) end diff --git a/app/models/post.rb b/app/models/post.rb index 274d02f..9d13796 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -34,8 +34,6 @@ class Post < ActiveRecord::Base belongs_to :user belongs_to :topic - # acts_as_indexed :fields => [:text] - def number pages, i if i != -1 pages.per_page * (pages.current_page - 1) + i + 1 diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb index 49b720b..bf01bc3 100644 --- a/app/uploaders/image_uploader.rb +++ b/app/uploaders/image_uploader.rb @@ -1,42 +1,19 @@ # encoding: utf-8 class ImageUploader < CarrierWave::Uploader::Base - # Include RMagick or ImageScience support: include CarrierWave::RMagick - # include CarrierWave::ImageScience - # Choose what kind of storage to use for this uploader: storage :file - # storage :fog - # Override the directory where uploaded files will be stored. - # This is a sensible default for uploaders that are meant to be mounted: def store_dir "images" end - # Override filename def filename model.id.to_s + File.extname(@filename) unless @filename.nil? end - # Provide a default URL as a default if there hasn't been a file uploaded: - # def default_url - # "/images/fallback/" + [version_name, "default.png"].compact.join('_') - # end - - # Process files as they are uploaded: - # process :scale => [200, 300] - - # Add a white list of extensions which are allowed to be uploaded. - # For images you might use something like this: def extension_white_list %w(jpg jpeg gif png) end - - # Override the filename of the uploaded files: - # Avoid using model.id or version_name here, see uploader/store.rb for details. - # def filename - # "something.jpg" if original_filename - # end end diff --git a/config/deploy.rb b/config/deploy.rb index a6e2808..35824c9 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -2,6 +2,7 @@ lock '3.1.0' set :application, 'ensl' set :deploy_user, 'deploy' +set :deploy_to, '/var/www/virtual/ensl.org/deploy' set :pty, true set :scm, :git @@ -16,9 +17,27 @@ set :linked_files, %w{.env} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/local public/uploads} +set :writable_dirs, %w{public tmp} set :normalize_asset_timestamps, %{public/images public/javascripts public/stylesheets} namespace :deploy do + namespace :check do + desc "Check write permissions" + task :permissions do + on roles(:all) do |host| + fetch(:writable_dirs).each do |dir| + path = "#{shared_path}/#{dir}" + + if test("[ -w #{path} ]") + info "#{path} is writable on #{host}" + else + error "#{path} is not writable on #{host}" + end + end + end + end + end + desc 'Restart application' task :restart do invoke 'foreman:export' @@ -33,7 +52,7 @@ namespace :foreman do task :export do on roles(:app) do |host| within release_path do - execute "#{fetch(:rbenv_sudo)} bundle exec foreman export upstart /etc/init -a #{fetch(:application)} -u #{fetch(:deploy_user)} -l #{fetch(:deploy_to)}/shared/log" + execute fetch(:rbenv_sudo), "bundle exec foreman export upstart /etc/init -a #{fetch(:application)} -u #{fetch(:deploy_user)} -l #{fetch(:deploy_to)}/shared/log" end end end diff --git a/config/deploy/production.rb b/config/deploy/production.rb index eb564ea..d643c97 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -5,6 +5,4 @@ role :app, %w{deploy@ensl.org} role :web, %w{deploy@ensl.org} role :db, %w{deploy@ensl.org} -set :deploy_to, '/var/www/virtual/ensl.org/deploy' - server 'ensl.org', user: 'deploy', roles: %w{web app} diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index b94b0b7..a8f454d 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -5,6 +5,4 @@ role :app, %w{deploy@staging.ensl.org} role :web, %w{deploy@staging.ensl.org} role :db, %w{deploy@staging.ensl.org} -set :deploy_to, '/var/www/virtual/ensl.org/deploy' - -server 'staging.ensl.org', user: 'deploy', roles: %w{web app} \ No newline at end of file +server 'staging.ensl.org', user: 'deploy', roles: %w{web app}