Commit f0bd3b4d authored by dgt's avatar dgt Committed by azul
Browse files

Some preparations for rails 5.1

update some gems, replace before_filter / after_filter by before_action / after_action
and some more config changes (mostly commented out) and scripts generated by rails app:update task
parent 1189f70b
......@@ -11,6 +11,7 @@ end
##
# Rails is the framework we use.
#gem 'rails', '~> 5.1.6'
gem 'rails', '~> 5.0.7'
# Security updates
......@@ -30,7 +31,7 @@ gem 'i18n', '~> 0.7'
# improved gem to access mysql database
# locking in to latest major to fix API
gem 'mysql2', '~> 0.3.18'
gem 'mysql2', '~> 0.5.2'
# parsing and generating JSON
# locking in to latest major to fix API
......@@ -38,8 +39,8 @@ gem 'json', '~> 1.8'
# Markup language that uses indent to indicate nesting
# locking in to latest major to fix API
gem 'haml', '~> 4.0'
gem 'haml-rails', '~> 0.9.0'
gem 'haml', '~> 5.0'
gem 'haml-rails', '~> 1.0'
# Extendet scriptable CSS language
# locking in to latest major to fix API
......@@ -56,6 +57,7 @@ gem 'sass'
# tests do not pass
#gem 'prototype-rails', github: 'rails/prototype-rails', branch: '4.2'
gem 'prototype-rails', path: 'vendor/gems/prototype-rails'
#gem 'prototype-rails', path: '/home/dora/Dev/crabgrass_project/2018/august/prototype-rails-5-1'
# Full text search for the database
gem 'thinking-sphinx', '~> 3.4.2'
......@@ -150,6 +152,9 @@ gem 'greencloth', require: 'greencloth',
# version is rather strict for now as api may still change.
gem 'crabgrass_media', '~> 0.3.0', require: 'media',
path: 'vendor/gems/crabgrass-media'
#gem 'crabgrass_media', '~> 0.4.0', require: 'media',
# path: '/home/dora/Dev/crabgrass_project/crabgrass-media'
##
## not required, but a really good idea
......
......@@ -106,12 +106,13 @@ GEM
activesupport (>= 4.2.0)
gpgme (2.0.16)
mini_portile2 (~> 2.3)
haml (4.0.7)
haml (5.0.4)
temple (>= 0.8.0)
tilt
haml-rails (0.9.0)
haml-rails (1.0.0)
actionpack (>= 4.0.1)
activesupport (>= 4.0.1)
haml (>= 4.0.6, < 5.0)
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
html2haml (2.1.0)
......@@ -143,7 +144,7 @@ GEM
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.10.3)
mysql2 (0.3.21)
mysql2 (0.5.2)
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
......@@ -219,6 +220,7 @@ GEM
sqlite3 (1.3.13)
sys-uname (0.9.0)
ffi (>= 1.0.0)
temple (0.8.0)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
......@@ -274,8 +276,8 @@ DEPENDENCIES
factory_bot_rails
faker (~> 1.0.0)
greencloth!
haml (~> 4.0)
haml-rails (~> 0.9.0)
haml (~> 5.0)
haml-rails (~> 1.0)
http_accept_language (~> 2.0)
i18n (~> 0.7)
json (~> 1.8)
......@@ -283,7 +285,7 @@ DEPENDENCIES
mail-gpg (~> 0.3.3)
mime-types
minitest (~> 5.10.3)
mysql2 (~> 0.3.18)
mysql2 (~> 0.5.2)
nokogiri (~> 1.8.5)
phantomjs-binaries (~> 2.1.1)
poltergeist (~> 1.5)
......
class AssetsController < ApplicationController
before_filter :symlink_public_asset, only: :show
before_action :symlink_public_asset, only: :show
after_action :verify_authorized
prepend_before_filter :fetch_asset, only: %i[show destroy]
prepend_before_action :fetch_asset, only: %i[show destroy]
def show
authorize @asset
......
......@@ -71,7 +71,7 @@ module Common::Application::Authentication
session[:return_to] = nil
end
# When called with before_filter :login_from_cookie will check for an :auth_token
# When called with before_action :login_from_cookie will check for an :auth_token
# cookie and log the user back in if apropriate
def login_from_cookie
return unless cookies[:auth_token] && !logged_in?
......@@ -85,7 +85,7 @@ module Common::Application::Authentication
end
# note: this method is not automatically called. if you want to enable HTTP
# authentication for some action(s), you must put a prepend_before_filter in
# authentication for some action(s), you must put a prepend_before_action in
# place.
# however, a user who successfully uses HTTP auth on an action for which it
# was enabled will stay logged in and can then go and see other things.
......
......@@ -14,10 +14,10 @@ module Common::Application::BeforeFilters
included do
# the order of these filters matters. change with caution.
before_filter :set_session_locale
before_filter :set_session_timezone
before_filter :header_hack_for_ie6
before_filter :redirect_unverified_user
before_action :set_session_locale
before_action :set_session_timezone
before_action :header_hack_for_ie6
before_action :redirect_unverified_user
end
private
......@@ -48,11 +48,11 @@ module Common::Application::BeforeFilters
#
# To not require logins for specific actions, use this in your controllers:
#
# skip_before_filter :login_required, :only => [ :view, :index ]
# skip_before_action :login_required, :only => [ :view, :index ]
#
# To not require them for any action:
#
# skip_before_filter :login_required
# skip_before_action :login_required
#
def login_required
process_login
......
......@@ -217,7 +217,7 @@ module Common::Application::RescueErrors
def render_error_js(exception = nil, options = {})
error exception if exception.present?
log_exception(exception)
return if performed? # error in after_filter
return if performed? # error in after_action
render template: 'error/alert', locals: { exception: exception },
status: options[:status]
end
......
#
# controllers including this must have a before_filter setup()
# controllers including this must have a before_action setup()
# which must set @entity and @success_url
#
......
......@@ -12,10 +12,10 @@ module Common::Requests
helper_method :current_state
helper_method :request_path
helper_method :requests_path
before_filter :fetch_request, only: %i[update destroy show]
before_action :fetch_request, only: %i[update destroy show]
after_filter :create_notices, only: :create
after_filter :dismiss_notices, only: :update
after_action :create_notices, only: :create
after_action :dismiss_notices, only: :update
end
#
......
......@@ -4,7 +4,7 @@
#
# This module makes creating the records from the controller easy.
#
# If you follow the conventions all you need to do is add a after_filter for
# If you follow the conventions all you need to do is add a after_action for
# the actions you want to track:
#
# class Groups::GroupsController < ...
......@@ -12,7 +12,7 @@
# ...
#
# This will have the same effect as an after filter for track_action:
# after_filter :track_action, only: [:create, :destroy]
# after_action :track_action, only: [:create, :destroy]
#
# track_action will call Action.track(:create_group, options). It will include
# the following default arguments if the corresponding variables are set:
......@@ -54,7 +54,7 @@ module Common::Tracking::Action
module ClassMethods
def track_actions(*actions)
options = actions.extract_options!
after_filter :track_action, options.merge(only: actions)
after_action :track_action, options.merge(only: actions)
end
end
end
......@@ -9,7 +9,7 @@
#
class CronController < ActionController::Base
before_filter :allow_only_requests_from_localhost
before_action :allow_only_requests_from_localhost
def run
case params[:id]
......
if Rails.env.development?
class DebugController < ApplicationController
before_filter :authorization_required
before_action :authorization_required
# make the user assume the identity of another user
def become
......
......@@ -13,7 +13,7 @@
#
class EntitiesController < ApplicationController
before_filter :login_required
before_action :login_required
LIMIT = 20
......
class Group::AvatarsController < Group::BaseController
include_controllers 'common/avatars'
include_controllers 'common/always_perform_caching'
before_filter :setup
before_action :setup
protected
......
class Group::BaseController < ApplicationController
before_filter :fetch_group
before_action :fetch_group
# default permission for all group controllers
before_filter :login_required
before_action :login_required
after_action :verify_authorized
helper 'group/links'
......
class Group::DirectoryController < ApplicationController
before_filter :login_required
# skip_before_filter :login_required
before_action :login_required
# skip_before_action :login_required
# ^^ for now, disable public directories. The old behavior was to require
# authentication to browse the directory, so we don't want to change this
# unexpectedly without either giving groups some warning or adding an
# additional level to the permissions.
before_filter :set_default_path
before_action :set_default_path
helper 'group/directory'
......
class Group::GroupsController < Group::BaseController
include Common::Tracking::Action
before_filter :initialize_group, only: %w[new create]
before_filter :fetch_group, only: :destroy
before_filter :fetch_associations, only: :destroy
before_action :initialize_group, only: %w[new create]
before_action :fetch_group, only: :destroy
before_action :fetch_associations, only: :destroy
after_filter :notify_former_users, only: :destroy
after_action :notify_former_users, only: :destroy
def new
......
class Group::HomeController < Group::BaseController
skip_before_filter :login_required
skip_before_action :login_required
before_filter :fetch_wikis
after_filter :track_visit, if: :logged_in?
before_action :fetch_wikis
after_action :track_visit, if: :logged_in?
layout 'sidecolumn'
helper 'wikis/base', 'wikis/sections'
......
class Group::PagesController < Group::BaseController
skip_before_filter :login_required
skip_before_action :login_required
include_controllers 'common/page_search'
......
class Group::ProfilesController < Group::BaseController
before_filter :fetch_profile
before_action :fetch_profile
helper :profile
def edit
......
class Me::AvatarsController < Me::BaseController
include_controllers 'common/avatars'
include_controllers 'common/always_perform_caching'
before_filter :setup
before_action :setup
def destroy
if avatar = @entity.avatar
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment