diff --git a/Capfile b/Capfile index dac4cb9..b6f26f6 100644 --- a/Capfile +++ b/Capfile @@ -1,6 +1,27 @@ -load 'deploy' -# Uncomment if you are using Rails' asset pipeline - # load 'deploy/assets' -load 'config/deploy' # remove this line to skip loading any of the default tasks +# Load DSL and set up stages +require 'capistrano/setup' -default_run_options[:pty] = true \ No newline at end of file +# Include default deployment tasks +require 'capistrano/deploy' + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# +require 'capistrano/rvm' +# require 'capistrano/rbenv' +# require 'capistrano/chruby' +require 'capistrano/bundler' +require 'capistrano/rails/assets' +require 'capistrano/rails/migrations' +require 'capistrano/passenger' + +# Load custom tasks from `lib/capistrano/tasks' if you have any defined +Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index ccbc69f..7918403 100644 --- a/Gemfile +++ b/Gemfile @@ -58,9 +58,12 @@ group :development do gem 'spring' end -gem 'capistrano' -gem 'rvm-capistrano' -gem 'capistrano-ec2group' +gem 'capistrano', '~> 3.3.0' +gem 'capistrano-rails' +gem 'capistrano-bundler' +gem 'capistrano-passenger' +# gem 'rvm-capistrano' +# gem 'capistrano-ec2group' group :development, :test do gem 'rspec-rails' @@ -79,7 +82,6 @@ gem "figaro" gem 'redis-rails' gem 'meta-tags', :require => 'meta_tags' -#gem 'sitemap_generator' # Use ActiveModel has_secure_password gem 'bcrypt-ruby', :require => 'bcrypt' diff --git a/Gemfile.lock b/Gemfile.lock index 19d74c2..6d54e10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,15 +41,20 @@ GEM bullet (4.7.1) activesupport uniform_notifier (>= 1.4.0) - capistrano (2.15.5) - highline - net-scp (>= 1.0.0) - net-sftp (>= 2.0.0) - net-ssh (>= 2.0.14) - net-ssh-gateway (>= 1.1.0) - capistrano-ec2group (1.0.9) - capistrano (>= 2.1.0) - right_aws (>= 3.0.0) + capistrano (3.3.5) + capistrano-stats (~> 1.1.0) + i18n + rake (>= 10.0.0) + sshkit (~> 1.3) + capistrano-bundler (1.1.3) + capistrano (~> 3.1) + sshkit (~> 1.2) + capistrano-passenger (0.0.1) + capistrano (~> 3.0) + capistrano-rails (1.1.2) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) + capistrano-stats (1.1.1) capybara (2.2.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -67,6 +72,7 @@ GEM coffee-script-source execjs coffee-script-source (1.7.0) + colorize (0.7.5) compass (0.12.3) chunky_png (~> 1.2) fssm (>= 0.2.7) @@ -92,7 +98,6 @@ GEM json haml (4.0.5) tilt - highline (1.6.20) hike (1.2.3) i18n (0.6.11) jbuilder (1.5.3) @@ -124,13 +129,9 @@ GEM mocha (1.0.0) metaclass (~> 0.0.1) multi_json (1.10.1) - net-scp (1.1.2) - net-ssh (>= 2.6.5) - net-sftp (2.1.2) - net-ssh (>= 2.6.5) - net-ssh (2.7.0) - net-ssh-gateway (1.2.0) + net-scp (1.2.1) net-ssh (>= 2.6.5) + net-ssh (2.9.1) nokogiri (1.6.1) mini_portile (~> 0.5.0) pg (0.17.1) @@ -173,9 +174,6 @@ GEM redis-store (1.1.4) redis (>= 2.2) ref (1.0.5) - right_aws (3.1.0) - right_http_connection (>= 1.2.5) - right_http_connection (1.4.0) rspec-core (2.14.7) rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) @@ -191,8 +189,6 @@ GEM rubyzip (1.1.0) russian (0.6.0) i18n (>= 0.5.0) - rvm-capistrano (1.5.1) - capistrano (~> 2.15.4) sass (3.2.14) sass-rails (4.0.5) railties (>= 4.0.0, < 5.0) @@ -224,6 +220,10 @@ GEM sqlite3 (1.3.8) sqlite3-ruby (1.3.3) sqlite3 (>= 1.3.3) + sshkit (1.6.1) + colorize (>= 0.7.0) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) therubyracer (0.12.0) libv8 (~> 3.16.14.0) ref @@ -256,8 +256,10 @@ DEPENDENCIES binding_of_caller bootstrap-sass bullet - capistrano - capistrano-ec2group + capistrano (~> 3.3.0) + capistrano-bundler + capistrano-passenger + capistrano-rails capybara coffee-rails (~> 4.0.0) compass-rails @@ -275,7 +277,6 @@ DEPENDENCIES redis-rails rspec-rails russian (~> 0.6.0) - rvm-capistrano sass-rails selenium-webdriver spring diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 8f21310..46d0158 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,8 +1,8 @@ # Админка class AdminController < ApplicationController require 'bcrypt' - include Admin layout 'admin' + include Admin # Главная админки. Если админ, то отображает админку, иначе - рендерит форму логина # @note GET /admin diff --git a/app/controllers/concerns/admin.rb b/app/controllers/concerns/admin.rb index 5b92a4d..a3a9f72 100644 --- a/app/controllers/concerns/admin.rb +++ b/app/controllers/concerns/admin.rb @@ -2,27 +2,26 @@ module Admin extend ActiveSupport::Concern + # Проверяет содержимое сессии админа на право быть админом + # @return [Boolean] админ текущий юзер или нет + # @example + # unless is_admin? + # + # @see Admin#allow_access? + def is_admin? + session[:admin].try(:[], :value) + end + # Если юзер не админ, то делает редирект на главную # @note На вьюхах моделей и админки # @example # before_action :allow_access? # # @see AdminController - def _allow_access? - unless _is_admin? + def allow_access? + unless is_admin? notice = {class: "alert-danger", value: 'Сюда нельзя' } redirect_to root_path, notice: notice end end - - - # Проверяет содержимое сессии админа на право быть админом - # @return [Boolean] админ текущий юзер или нет - # @example - # unless is_admin? - # - # @see Admin#allow_access? - def _is_admin? - session[:admin].try(:[], :value) - end end \ No newline at end of file diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index a61735d..49ca0e1 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -2,7 +2,7 @@ class NewsController < ApplicationController include Admin - before_action :_allow_access?, only: [:index, :show, :edit, :new, :create, :update, :destroy] + before_action :allow_access?, only: [:index, :show, :edit, :new, :create, :update, :destroy] layout 'admin' diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 63b47d1..cdcfc5c 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,10 +1,5 @@ # Методы страниц для пользователей class PagesController < ApplicationController - include AuthorHelper - include ModalHelper - include SocialHelper - include PlacesCache - # Главная страница. Готовит новости, причины и места к отображению. # @note GET / # @note Также вызывается в случае пагинации. Тогда выдает либо пагинацию новостей, либо пагинацию причин. diff --git a/app/controllers/reasons_controller.rb b/app/controllers/reasons_controller.rb index cf6e1a3..4bb0d2b 100644 --- a/app/controllers/reasons_controller.rb +++ b/app/controllers/reasons_controller.rb @@ -2,7 +2,7 @@ class ReasonsController < ApplicationController include Admin - before_action :_allow_access?, only: [:index, :show, :edit, :new, :create, :update, :destroy] + before_action :allow_access?, only: [:index, :show, :edit, :new, :create, :update, :destroy] layout 'admin', except: [:get_one_random, :get_three_random] diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index f1e1a45..1e12fee 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -4,7 +4,7 @@ class StatsController < ApplicationController before_action :_get_stat before_action :_update_reason, only: [:vk_post, :tw_post, :fb_post, :bl_post] - before_action :_allow_access?, only: [:index] + before_action :allow_access?, only: [:index] layout 'admin', only: [:index]