style: rubocop autocorrect
This commit is contained in:
parent
22345d049d
commit
cf21b9311b
|
@ -0,0 +1,12 @@
|
|||
AllCops:
|
||||
Exclude:
|
||||
- 'bin/*'
|
||||
DisplayCopNames: true
|
||||
Layout/IndentHeredoc:
|
||||
EnforcedStyle: active_support
|
||||
Style/AndOr:
|
||||
AutoCorrect: false
|
||||
Style/EmptyElse:
|
||||
AutoCorrect: false
|
||||
Style/RaiseArgs:
|
||||
AutoCorrect: false
|
4
Capfile
4
Capfile
|
@ -3,6 +3,6 @@ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
|
|||
# Uncomment if you are using Rails' asset pipeline
|
||||
# load 'deploy/assets'
|
||||
|
||||
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
|
||||
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
|
||||
load 'config/deploy' # remove this line to skip loading any of the default tasks
|
||||
|
|
11
Gemfile
11
Gemfile
|
@ -2,11 +2,10 @@ source 'https://rubygems.org'
|
|||
|
||||
# ensure github urls use https rather than insecure git protocol.
|
||||
git_source(:github) do |repo_name|
|
||||
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
||||
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
|
||||
"https://github.com/#{repo_name}.git"
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# Core components
|
||||
##
|
||||
|
@ -55,7 +54,7 @@ gem 'prototype-rails', github: 'rails/prototype-rails', branch: '4.2'
|
|||
# legacy helper for form_remote_for and link_to_remote
|
||||
# there's only a 0.0.0 version out there it seems
|
||||
gem 'prototype_legacy_helper', '0.0.0',
|
||||
github: 'rails/prototype_legacy_helper'
|
||||
github: 'rails/prototype_legacy_helper'
|
||||
|
||||
##
|
||||
# Upgrade pending
|
||||
|
@ -101,7 +100,7 @@ gem 'will_paginate', '~> 3.1'
|
|||
|
||||
# state-machine for requests
|
||||
# locking in to latest major to fix API
|
||||
gem 'aasm' , '~> 3.4'
|
||||
gem 'aasm', '~> 3.4'
|
||||
|
||||
# lists used for tasks and choices in votes so far
|
||||
# continuation of the old standart rails plugin
|
||||
|
@ -128,7 +127,7 @@ gem 'RedCloth', '~> 4.2'
|
|||
|
||||
# extension of the redcloth markup lang
|
||||
gem 'greencloth', require: 'greencloth',
|
||||
path: 'vendor/gems/riseuplabs-greencloth-0.1'
|
||||
path: 'vendor/gems/riseuplabs-greencloth-0.1'
|
||||
|
||||
# media upload post processing has it's own repo
|
||||
# version is rather strict for now as api may still change.
|
||||
|
@ -190,7 +189,6 @@ group :test, :development do
|
|||
end
|
||||
|
||||
group :test, :ci do
|
||||
|
||||
##
|
||||
## TESTS
|
||||
##
|
||||
|
@ -224,4 +222,3 @@ group :test, :ci do
|
|||
end
|
||||
|
||||
gem 'bundler-audit'
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ unless Vagrant.has_plugin?('vagrant-vbguest')
|
|||
end
|
||||
|
||||
VAGRANTFILE_API_VERSION = 2
|
||||
SPHINX_DEV_CONF_PATH = 'config/sphinx/development.conf'
|
||||
SPHINX_DEV_CONF_PATH = 'config/sphinx/development.conf'.freeze
|
||||
|
||||
ruby_version_file = File.join(File.dirname(__FILE__), '.ruby-version')
|
||||
RUBY_VER = File.exist?(ruby_version_file) ? File.read(ruby_version_file) : '2.1.5'
|
||||
|
@ -56,7 +56,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||
SHELL
|
||||
|
||||
config.vm.provision "Install RVM and Ruby #{RUBY_VER} and Bundler",
|
||||
type: 'shell', privileged: false, inline: <<-SHELL
|
||||
type: 'shell', privileged: false, inline: <<-SHELL
|
||||
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 > /dev/null 2>&1
|
||||
curl -sSL https://get.rvm.io | bash -s stable > /dev/null 2>&1
|
||||
source $HOME/.rvm/scripts/rvm
|
||||
|
@ -111,13 +111,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||
SHELL
|
||||
|
||||
config.vm.provision 'Start Thinking Sphinx', run: 'always', type: 'shell',
|
||||
privileged: false, inline: <<-SHELL
|
||||
privileged: false, inline: <<-SHELL
|
||||
cd /vagrant/
|
||||
rake ts:start > /dev/null 2>&1
|
||||
SHELL
|
||||
|
||||
config.vm.provision 'PROVISIONING COMPLETE!', run: 'always', type: 'shell',
|
||||
privileged: false, inline: <<-SHELL
|
||||
privileged: false, inline: <<-SHELL
|
||||
echo -e '\nTo run the server:\n'
|
||||
echo -e '\n vagrant ssh\n'
|
||||
echo -e '\n cd /vagrant/\n'
|
||||
|
@ -127,4 +127,3 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||
config.vbguest.auto_reboot = true
|
||||
config.vbguest.auto_update = true
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#
|
||||
|
||||
class AccountsController < ApplicationController
|
||||
|
||||
layout 'notice'
|
||||
|
||||
##
|
||||
|
@ -43,9 +42,6 @@ class AccountsController < ApplicationController
|
|||
|
||||
# removed
|
||||
|
||||
|
||||
|
||||
|
||||
##
|
||||
## PASSWORD RESET
|
||||
##
|
||||
|
@ -81,7 +77,7 @@ class AccountsController < ApplicationController
|
|||
user_params[:email] = session[:signup_email_address]
|
||||
end
|
||||
user_params.permit :login, :email, :password, :password_confirmation,
|
||||
:language, :display_name
|
||||
:language, :display_name
|
||||
end
|
||||
|
||||
def reset_password_form
|
||||
|
@ -100,7 +96,7 @@ class AccountsController < ApplicationController
|
|||
return
|
||||
end
|
||||
|
||||
sleep(rand*3) # an attempt to make timing attacks harder
|
||||
sleep(rand * 3) # an attempt to make timing attacks harder
|
||||
|
||||
user = User.find_by_email params[:email]
|
||||
if user
|
||||
|
@ -147,5 +143,4 @@ class AccountsController < ApplicationController
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
# Likewise, all the methods added will be available for all controllers.
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
|
||||
protect_from_forgery
|
||||
|
||||
layout proc{ |c| c.request.xhr? ? false : 'application' } # skip layout for ajax
|
||||
layout proc { |c| c.request.xhr? ? false : 'application' } # skip layout for ajax
|
||||
hide_action :_layout_from_proc
|
||||
|
||||
include_controllers 'common/application'
|
||||
|
@ -20,7 +19,9 @@ class ApplicationController < ActionController::Base
|
|||
# this is used by the code that is included for both controllers and helpers.
|
||||
# this way, they don't need to know if they are in a view or a controller,
|
||||
# they can always just reference controller().
|
||||
def controller(); self; end
|
||||
def controller
|
||||
self
|
||||
end
|
||||
|
||||
# view() method lets controllers have access to the view helpers.
|
||||
def view
|
||||
|
@ -29,7 +30,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
# proxy for view's content_tag
|
||||
def content_tag(*args, &block)
|
||||
view.content_tag(*args,&block)
|
||||
view.content_tag(*args, &block)
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -37,18 +38,19 @@ class ApplicationController < ActionController::Base
|
|||
# overridden, but these defaults are pretty good. See models/mailer.rb.
|
||||
#
|
||||
def mailer_options
|
||||
from_address = current_site.email_sender.
|
||||
sub('$current_host',request.host)
|
||||
from_name = current_site.email_sender_name.
|
||||
sub('$user_name', current_user.display_name).
|
||||
sub('$site_title', current_site.title)
|
||||
from_address = current_site.email_sender
|
||||
.sub('$current_host', request.host)
|
||||
from_name = current_site.email_sender_name
|
||||
.sub('$user_name', current_user.display_name)
|
||||
.sub('$site_title', current_site.title)
|
||||
opts = {
|
||||
site: current_site, current_user: current_user,
|
||||
host: request.host, protocol: request.protocol,
|
||||
page: @page, from_address: from_address,
|
||||
from_name: from_name }
|
||||
opts[:port] = request.port_string.sub(':','') if request.port_string.present?
|
||||
return opts
|
||||
site: current_site, current_user: current_user,
|
||||
host: request.host, protocol: request.protocol,
|
||||
page: @page, from_address: from_address,
|
||||
from_name: from_name
|
||||
}
|
||||
opts[:port] = request.port_string.sub(':', '') if request.port_string.present?
|
||||
opts
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -76,7 +78,7 @@ class ApplicationController < ActionController::Base
|
|||
# as needed stylesheets are kept in public/stylesheets/as_needed
|
||||
#
|
||||
def self.stylesheet(*css_files)
|
||||
self.stylesheets = merge_requirements(self.stylesheets, *css_files)
|
||||
self.stylesheets = merge_requirements(stylesheets, *css_files)
|
||||
end
|
||||
|
||||
# We currently include all javascript in application.js as it's cached,
|
||||
|
@ -93,7 +95,7 @@ class ApplicationController < ActionController::Base
|
|||
# They'll be accessible in the class_attribute javascripts
|
||||
#
|
||||
def self.javascript(*js_files)
|
||||
self.javascripts = merge_requirements(self.javascripts, *js_files)
|
||||
self.javascripts = merge_requirements(javascripts, *js_files)
|
||||
end
|
||||
|
||||
def self.merge_requirements(current, *new_files)
|
||||
|
@ -104,5 +106,4 @@ class ApplicationController < ActionController::Base
|
|||
value += new_files
|
||||
current.merge index => value.uniq
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
class AssetsController < ApplicationController
|
||||
|
||||
before_filter :authorization_required
|
||||
before_filter :symlink_public_asset, only: :show
|
||||
permissions 'assets'
|
||||
permission_helper 'pages'
|
||||
guard :may_ACTION_asset?
|
||||
|
||||
prepend_before_filter :fetch_asset, only: [:show, :destroy]
|
||||
prepend_before_filter :fetch_asset, only: %i[show destroy]
|
||||
|
||||
def show
|
||||
file = file_to_send
|
||||
send_file private_filename(file),
|
||||
type: file.content_type,
|
||||
disposition: disposition(file)
|
||||
type: file.content_type,
|
||||
disposition: disposition(file)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@asset.destroy
|
||||
current_user.updated(@page)
|
||||
respond_to do |format|
|
||||
format.js {render 'common/assets/destroy' }
|
||||
format.js { render 'common/assets/destroy' }
|
||||
format.html do
|
||||
success ['attachment deleted']
|
||||
redirect_to(page_url(@page))
|
||||
|
@ -76,13 +75,13 @@ class AssetsController < ApplicationController
|
|||
|
||||
def thumb_name
|
||||
if params[:path] =~ /#{THUMBNAIL_SEPARATOR}(?<thumb>[a-z]+)$/
|
||||
$~['thumb'].to_sym
|
||||
$LAST_MATCH_INFO['thumb'].to_sym
|
||||
end
|
||||
end
|
||||
|
||||
# returns 'inline' for formats that web browsers can display, 'attachment' otherwise.
|
||||
def disposition(asset)
|
||||
if ['image/png','image/jpeg','image/gif'].include? asset.content_type
|
||||
if ['image/png', 'image/jpeg', 'image/gif'].include? asset.content_type
|
||||
'inline'
|
||||
else
|
||||
'attachment'
|
||||
|
@ -94,6 +93,4 @@ class AssetsController < ApplicationController
|
|||
def private_filename(asset_or_thumbnail)
|
||||
asset_or_thumbnail.private_filename
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@ class AvatarsController < ApplicationController
|
|||
@image = Avatar.find_by_id params[:id]
|
||||
if @image.nil?
|
||||
size = Avatar.pixels(params[:size])
|
||||
size.sub!(/^\d*x/,'')
|
||||
size.sub!(/^\d*x/, '')
|
||||
filename = "#{File.dirname(__FILE__)}/../../public/images/default/#{size}.jpg"
|
||||
send_data(IO.read(filename), type: 'image/jpeg', disposition: 'inline')
|
||||
else
|
||||
content_type = 'image/jpeg'
|
||||
data = @image.resize(params[:size], content_type);
|
||||
data = @image.resize(params[:size], content_type)
|
||||
response.headers['Cache-Control'] = 'public, max-age=86400'
|
||||
send_data data, type: content_type, disposition: 'inline'
|
||||
end
|
||||
|
@ -30,8 +30,7 @@ class AvatarsController < ApplicationController
|
|||
# if public/avatars is a symlink resolve it and use it's parent dir
|
||||
def self.page_cache_directory
|
||||
default = super
|
||||
cache_dir = (Pathname.new(default) + self.controller_name)
|
||||
cache_dir = (Pathname.new(default) + controller_name)
|
||||
cache_dir.exist? ? cache_dir.realpath.dirname : default
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -14,5 +14,4 @@ module Common::AlwaysPerformCaching
|
|||
true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -48,8 +48,6 @@
|
|||
require 'active_support/multibyte/chars'
|
||||
|
||||
module Common::Application::AlertMessages
|
||||
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
helper_method :translate_exception
|
||||
|
@ -79,13 +77,13 @@ module Common::Application::AlertMessages
|
|||
end
|
||||
|
||||
def alert_message(*args)
|
||||
options = Hash[args.collect {|i| [i, true] if i.is_a?(Symbol)}.compact]
|
||||
options = Hash[args.collect { |i| [i, true] if i.is_a?(Symbol) }.compact]
|
||||
type = determine_type(options)
|
||||
flsh = determine_flash(type, options)
|
||||
flsh[:messages] ||= []
|
||||
add_flash(type, *args).each do |msg|
|
||||
# allow options to override the defaults
|
||||
flsh[:messages] << msg.merge(options);
|
||||
flsh[:messages] << msg.merge(options)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -93,7 +91,7 @@ module Common::Application::AlertMessages
|
|||
# forces the alert messages to come later, even if we previously said :now.
|
||||
# this is used in case we did :now but then redirected later.
|
||||
#
|
||||
def force_later_alert()
|
||||
def force_later_alert
|
||||
flash[:messages] = flash.now[:messages]
|
||||
end
|
||||
|
||||
|
@ -110,7 +108,7 @@ module Common::Application::AlertMessages
|
|||
# At the same time redirect would alter the url in the users browser.
|
||||
# Maybe they just typed it wrong. So we better leave it there.
|
||||
#
|
||||
def raise_not_found(thing=nil)
|
||||
def raise_not_found(thing = nil)
|
||||
raise ErrorNotFound.new(thing)
|
||||
end
|
||||
|
||||
|
@ -121,13 +119,13 @@ module Common::Application::AlertMessages
|
|||
##
|
||||
|
||||
def add_flash(type, *args)
|
||||
if exception = args.detect{|a|a.is_a? Exception}
|
||||
if exception = args.detect { |a| a.is_a? Exception }
|
||||
add_flash_exception(exception)
|
||||
elsif record = args.detect{|a|a.is_a? ActiveRecord::Base}
|
||||
elsif record = args.detect { |a| a.is_a? ActiveRecord::Base }
|
||||
add_flash_record(record, args.extract_options!)
|
||||
elsif (messages = args.select{|a| a.is_a?(String) or a.is_a?(ActiveSupport::Multibyte::Chars)}).any?
|
||||
elsif (messages = args.select { |a| a.is_a?(String) or a.is_a?(ActiveSupport::Multibyte::Chars) }).any?
|
||||
add_flash_message(type, messages)
|
||||
elsif message_array = args.detect{|a| a.is_a?(Array)}
|
||||
elsif message_array = args.detect { |a| a.is_a?(Array) }
|
||||
add_flash_message(type, message_array)
|
||||
else
|
||||
add_flash_default(type)
|
||||
|
@ -135,41 +133,41 @@ module Common::Application::AlertMessages
|
|||
end
|
||||
|
||||
def add_flash_message(type, message)
|
||||
[{type: type, text: message}]
|
||||
[{ type: type, text: message }]
|
||||
end
|
||||
|
||||
def add_flash_default(type)
|
||||
msg = if(type == :error or type == :warning)
|
||||
:alert_not_saved.t;
|
||||
else
|
||||
:alert_saved.t;
|
||||
msg = if type == :error or type == :warning
|
||||
:alert_not_saved.t
|
||||
else
|
||||
:alert_saved.t
|
||||
end
|
||||
add_flash_message(type, msg)
|
||||
end
|
||||
|
||||
def add_flash_exception(exception)
|
||||
if exception.is_a? PermissionDenied
|
||||
[{type: :warning, text: [:alert_permission_denied.t, :permission_denied_description.t]}]
|
||||
[{ type: :warning, text: [:alert_permission_denied.t, :permission_denied_description.t] }]
|
||||
elsif exception.is_a? AuthenticationRequired
|
||||
[{type: :notice, text: [:login_required.t, :login_required_description.t]}]
|
||||
[{ type: :notice, text: [:login_required.t, :login_required_description.t] }]
|
||||
elsif exception.is_a? ErrorMessages
|
||||
exception.errors.collect do |msg|
|
||||
{type: :error, text: msg}
|
||||
{ type: :error, text: msg }
|
||||
end
|
||||
elsif exception.is_a? ActiveRecord::RecordInvalid
|
||||
add_flash_record(exception.record)
|
||||
elsif exception.is_a? CrabgrassException
|
||||
[{type: exception.options[:type] || :error, text: exception.message}]
|
||||
[{ type: exception.options[:type] || :error, text: exception.message }]
|
||||
else
|
||||
text = exception.respond_to?(:message) ? exception.message : exception
|
||||
[{type: :error, text: text.to_s}]
|
||||
text = exception.respond_to?(:message) ? exception.message : exception
|
||||
[{ type: :error, text: text.to_s }]
|
||||
end
|
||||
end
|
||||
|
||||
def add_flash_record(record, options = {})
|
||||
if record.respond_to?(:flash_message) && record.flash_message
|
||||
options[:count] ||= 1
|
||||
[ record.flash_message(options) ]
|
||||
[record.flash_message(options)]
|
||||
elsif record.errors.any?
|
||||
[{ type: :error,
|
||||
text: [:alert_not_saved.t, :alert_field_errors.t],
|
||||
|
@ -217,27 +215,26 @@ module Common::Application::AlertMessages
|
|||
I18n.t key, scope: scope, thing: thing, cascade: true
|
||||
end
|
||||
|
||||
# def exception_detailed_message(exception=nil)
|
||||
# return "Warning: Trying to get detailed message but no exception given." unless exception
|
||||
# message = exception.clean_message
|
||||
# file, line = exception.backtrace.first.split(":")[0, 2]
|
||||
# if File.exists?(file)
|
||||
# message << "\n\n"
|
||||
# code = File.readlines(file)
|
||||
# line = line.to_i
|
||||
# min = [line - 2, 0].max
|
||||
# max = line + 2
|
||||
# (min..max).each do |n|
|
||||
# if n == line
|
||||
# message << "=> "
|
||||
# else
|
||||
# message << " "
|
||||
# end
|
||||
# message << ("%4d" % n)
|
||||
# message << code[n].to_s
|
||||
# end
|
||||
# end
|
||||
# message
|
||||
# end
|
||||
# def exception_detailed_message(exception=nil)
|
||||
# return "Warning: Trying to get detailed message but no exception given." unless exception
|
||||
# message = exception.clean_message
|
||||
# file, line = exception.backtrace.first.split(":")[0, 2]
|
||||
# if File.exists?(file)
|
||||
# message << "\n\n"
|
||||
# code = File.readlines(file)
|
||||
# line = line.to_i
|
||||
# min = [line - 2, 0].max
|
||||
# max = line + 2
|
||||
# (min..max).each do |n|
|
||||
# if n == line
|
||||
# message << "=> "
|
||||
# else
|
||||
# message << " "
|
||||
# end
|
||||
# message << ("%4d" % n)
|
||||
# message << code[n].to_s
|
||||
# end
|
||||
# end
|
||||
# message
|
||||
# end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Common::Application::Authentication
|
||||
|
||||
def self.included(base)
|
||||
base.send :helper_method, :current_user, :logged_in?
|
||||
end
|
||||
|
@ -80,8 +79,8 @@ module Common::Application::Authentication
|
|||
if user && user.remember_token?
|
||||
user.remember_me
|
||||
self.current_user = user
|
||||
cookies[:auth_token] = { value: self.current_user.remember_token , expires: self.current_user.remember_token_expires_at }
|
||||
flash[:notice] = "Logged in successfully"
|
||||
cookies[:auth_token] = { value: current_user.remember_token, expires: current_user.remember_token_expires_at }
|
||||
flash[:notice] = 'Logged in successfully'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,20 +102,17 @@ module Common::Application::Authentication
|
|||
|
||||
private
|
||||
|
||||
@@http_auth_headers = %w(X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization)
|
||||
@@http_auth_headers = %w[X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization]
|
||||
# gets BASIC auth info
|
||||
def get_auth_data
|
||||
auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) }
|
||||
auth_key = @@http_auth_headers.detect { |h| request.env.key?(h) }
|
||||
auth_data = request.env[auth_key].to_s.split unless auth_key.blank?
|
||||
return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
|
||||
auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
|
||||
end
|
||||
|
||||
def load_user(id)
|
||||
user = User.find_by_id(id)
|
||||
if user
|
||||
user.seen!
|
||||
end
|
||||
return user
|
||||
user.seen! if user
|
||||
user
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -84,9 +84,7 @@ module Common::Application::BeforeFilters
|
|||
# sets the current locale
|
||||
#
|
||||
def set_session_locale
|
||||
if !language_allowed?(session[:language_code])
|
||||
session[:language_code] = nil
|
||||
end
|
||||
session[:language_code] = nil unless language_allowed?(session[:language_code])
|
||||
session[:language_code] ||= discover_language_code
|
||||
I18n.locale = session[:language_code].to_sym
|
||||
end
|
||||
|
@ -153,9 +151,9 @@ module Common::Application::BeforeFilters
|
|||
'en'
|
||||
elsif !logged_in? || current_user.language.empty?
|
||||
if Conf.enabled_languages.any?
|
||||
code = http_accept_language.compatible_language_from(Conf.enabled_languages)
|
||||
code = http_accept_language.compatible_language_from(Conf.enabled_languages)
|
||||
else
|
||||
code = http_accept_language.user_preferred_languages.first
|
||||
code = http_accept_language.user_preferred_languages.first
|
||||
end
|
||||
code ||= current_site.default_language
|
||||
code ||= 'en'
|
||||
|
@ -166,6 +164,4 @@ module Common::Application::BeforeFilters
|
|||
'en'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#
|
||||
|
||||
module Common::Application::ContextNavigation
|
||||
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
helper_method :setup_navigation
|
||||
|
@ -19,8 +17,7 @@ module Common::Application::ContextNavigation
|
|||
##
|
||||
|
||||
def setup_navigation(nav)
|
||||
return nav
|
||||
nav
|
||||
# this can be implemented by controller subclasses
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
module Common::Application::CurrentSite
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
# make current_site available to the views
|
||||
helper_method :current_site
|
||||
if Rails.env.test?
|
||||
hide_action :disable_current_site, :enable_current_site
|
||||
end
|
||||
hide_action :disable_current_site, :enable_current_site if Rails.env.test?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,5 +33,4 @@ module Common::Application::CurrentSite
|
|||
@current_site_disabled = false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
#
|
||||
# See the +guard+ method for details.
|
||||
|
||||
|
||||
module Common::Application::Guard
|
||||
|
||||
ACTION_ALIASES = HashWithIndifferentAccess.new(update: :edit,
|
||||
new: :create)
|
||||
|
||||
|
@ -47,7 +45,7 @@ module Common::Application::Guard
|
|||
|
||||
def permission_for_action(action)
|
||||
method = action_map[action]
|
||||
if !method
|
||||
unless method
|
||||
if Rails.env.development?
|
||||
raise ArgumentError.new("No Permission defined for #{action}")
|
||||
end
|
||||
|
@ -68,20 +66,20 @@ module Common::Application::Guard
|
|||
if actions = options[:actions]
|
||||
action_map.merge!(build_action_map(method, actions))
|
||||
else
|
||||
action_map.default=method
|
||||
action_map.default = method
|
||||
end
|
||||
end
|
||||
|
||||
def build_action_map(method, actions)
|
||||
actions = [actions] unless actions.is_a? Array
|
||||
Hash[actions.map{|action| [action, method]}]
|
||||
Hash[actions.map { |action| [action, method] }]
|
||||
end
|
||||
|
||||
def replace_wildcards(method, action)
|
||||
return method if method.is_a? Proc
|
||||
string = method.to_s
|
||||
string.sub!("ACTION", action.to_s)
|
||||
string.sub!("ALIAS", (ACTION_ALIASES[action] || action).to_s)
|
||||
string.sub!('ACTION', action.to_s)
|
||||
string.sub!('ALIAS', (ACTION_ALIASES[action] || action).to_s)
|
||||
string.to_sym
|
||||
end
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
module Common::Application::MockableTests
|
||||
|
||||
class ReturnValueError < StandardError
|
||||
end
|
||||
|
||||
def self.included(base)
|
||||
return unless Rails.env.test?
|
||||
base.class_eval do
|
||||
|
||||
hide_action :mock, :expect, :expect_or_raise, :verify
|
||||
|
||||
def mock
|
||||
|
@ -18,14 +16,14 @@ module Common::Application::MockableTests
|
|||
# * intercept it
|
||||
# * return the given return value
|
||||
def expect(*args)
|
||||
self.mock.expect *args
|
||||
mock.expect *args
|
||||
orig = args[0].to_s
|
||||
if ("!?".include?(orig[-1]))
|
||||
mock = "#{orig[0..-2]}_with_mock#{orig.last}"
|
||||
else
|
||||
mock = "#{orig}_with_mock"
|
||||
end
|
||||
self.class_eval <<-EOMETA
|
||||
mock = if '!?'.include?(orig[-1])
|
||||
"#{orig[0..-2]}_with_mock#{orig.last}"
|
||||
else
|
||||
"#{orig}_with_mock"
|
||||
end
|
||||
class_eval <<-EOMETA
|
||||
def #{mock}(*args)
|
||||
self.mock.#{orig}(*args)
|
||||
end
|
||||
|
@ -40,16 +38,16 @@ module Common::Application::MockableTests
|
|||
# * check if the return value is the given one
|
||||
# * raise an ReturnValueError otherwise
|
||||
def expect_or_raise(*args)
|
||||
self.mock.expect *args
|
||||
mock.expect *args
|
||||
orig = args[0].to_s
|
||||
if ("!?".include?(orig[-1]))
|
||||
if '!?'.include?(orig[-1])
|
||||
mock = "#{orig[0..-2]}_with_mock#{orig.last}"
|
||||
no_mock = "#{orig[0..-2]}_without_mock#{orig.last}"
|
||||
else
|
||||
mock = "#{orig}_with_mock"
|
||||
no_mock = "#{orig}_without_mock"
|
||||
end
|
||||
self.class_eval <<-EOMETA
|
||||
class_eval <<-EOMETA
|
||||
def #{mock}(*args)
|
||||
expected = self.mock.#{orig}(*args)
|
||||
run = #{no_mock}(*args)
|
||||
|
@ -66,9 +64,8 @@ module Common::Application::MockableTests
|
|||
end
|
||||
|
||||
def verify
|
||||
self.mock.verify
|
||||
mock.verify
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# they should override these methods for special behavior
|
||||
|
||||
module Common::Application::PaginationOptions
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
helper_method :pagination_params
|
||||
|
@ -24,7 +23,7 @@ module Common::Application::PaginationOptions
|
|||
page = opts[:page] || params[:page] || pagination_default_page
|
||||
per_page = opts[:per_page]
|
||||
|
||||
{page: page, per_page: per_page }
|
||||
{ page: page, per_page: per_page }
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -40,12 +39,11 @@ module Common::Application::PaginationOptions
|
|||
LinkRenderer::Pages
|
||||
end
|
||||
elsif request.xhr?
|
||||
(request.format == :html) ?
|
||||
request.format == :html ?
|
||||
LinkRenderer::ModalAjax :
|
||||
LinkRenderer::Ajax
|
||||
else
|
||||
LinkRenderer::Dispatch
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#
|
||||
|
||||
module Common::Application::Paths
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
helper_method :entity_path
|
||||
|
@ -36,25 +35,25 @@ module Common::Application::Paths
|
|||
|
||||
def entity_path(entity)
|
||||
if entity.is_a? String
|
||||
"/"+name
|
||||
'/' + name
|
||||
else
|
||||
"/"+entity.name
|
||||
'/' + entity.name
|
||||
end
|
||||
end
|
||||
alias_method :user_path, :entity_path
|
||||
alias_method :group_path, :entity_path
|
||||
alias user_path entity_path
|
||||
alias group_path entity_path
|
||||
|
||||
def entity_url(entity)
|
||||
urlize entity_path(entity)
|
||||
end
|
||||
alias_method :user_url, :entity_url
|
||||
alias_method :group_url, :entity_url
|
||||
alias user_url entity_url
|
||||
alias group_url entity_url
|
||||
|
||||
#
|
||||
# allow direct paths that bypass the dispatcher.
|
||||
#
|
||||
def direct_group_path(group,options={})
|
||||
"/groups/" + group.name + build_query_string(options)
|
||||
def direct_group_path(group, options = {})
|
||||
'/groups/' + group.name + build_query_string(options)
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -66,24 +65,24 @@ module Common::Application::Paths
|
|||
# this is not a resource route, but we create paths methods as if it was for consistency.
|
||||
#
|
||||
|
||||
def new_page_path(options={})
|
||||
def new_page_path(options = {})
|
||||
options[:owner] ||= params[:owner] || :me
|
||||
custom_create_path(options) || page_creation_path(options)
|
||||
end
|
||||
alias_method :create_page_path, :new_page_path
|
||||
alias create_page_path new_page_path
|
||||
|
||||
#
|
||||
# if page definition has a custom constroller, return a path for it.
|
||||
# otherwise, returns nil and modifies options hash as needed.
|
||||
#
|
||||
def custom_create_path(options={})
|
||||
def custom_create_path(options = {})
|
||||
if (page_type = options.delete(:page_type)).present?
|
||||
if (controller = page_type.definition.creation_controller).present?
|
||||
url_for controller: "/#{controller}", action: :new,
|
||||
owner: options[:owner]
|
||||
owner: options[:owner]
|
||||
else
|
||||
options[:type] = page_type.url
|
||||
return nil
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -115,27 +114,26 @@ module Common::Application::Paths
|
|||
#
|
||||
# pretty page path
|
||||
#
|
||||
def page_path(page, options={})
|
||||
|
||||
def page_path(page, options = {})
|
||||
# (1) context
|
||||
if page.owner_name
|
||||
path = [page.owner_name, page.name_url]
|
||||
elsif page.created_by_login
|
||||
# we can't use page.name_url, because there might be multiple pages
|
||||
# with the same name created by the same user.
|
||||
path = [page.created_by_login, page.friendly_url]
|
||||
else
|
||||
# there is some data corruption. not sure what to do.
|
||||
path = ['page', page.friendly_url]
|
||||
end
|
||||
path = if page.owner_name
|
||||
[page.owner_name, page.name_url]
|
||||
elsif page.created_by_login
|
||||
# we can't use page.name_url, because there might be multiple pages
|
||||
# with the same name created by the same user.
|
||||
[page.created_by_login, page.friendly_url]
|
||||
else
|
||||
# there is some data corruption. not sure what to do.
|
||||
['page', page.friendly_url]
|
||||
end
|
||||
|
||||
# (2) controller
|
||||
controller = options.delete(:controller)
|
||||
if controller and Rails.env == 'development' and controller.is_a?(Symbol)
|
||||
cntr = page.controller + '_' + controller.to_s
|
||||
unless page.controllers.include?(cntr)
|
||||
raise 'controller %s not defined for page type %s' % [cntr, page.class.name]
|
||||
end
|
||||
cntr = page.controller + '_' + controller.to_s
|
||||
unless page.controllers.include?(cntr)
|
||||
raise format('controller %s not defined for page type %s', cntr, page.class.name)
|
||||
end
|
||||
end
|
||||
path << controller
|
||||
|
||||
|
@ -144,7 +142,7 @@ module Common::Application::Paths
|
|||
|
||||
# (4) action
|
||||
action = options.delete(:action)
|
||||
path << action if [:sort, :new, :edit].include? action.to_sym
|
||||
path << action if %i[sort new edit].include? action.to_sym
|
||||
|
||||
anchor = options.delete :anchor
|
||||
path_string = '/' + path.select(&:present?).join('/')
|
||||
|
@ -153,11 +151,11 @@ module Common::Application::Paths
|
|||
URI.encode(path_string)
|
||||
end
|
||||
|
||||
def page_url(page, options={})
|
||||
def page_url(page, options = {})
|
||||
urlize page_path(page, options)
|
||||
end
|
||||
|
||||
def post_url(post, options={})
|
||||
def post_url(post, _options = {})
|
||||
page_post_url post.discussion.page, post
|
||||
end
|
||||
##
|
||||
|
@ -188,7 +186,7 @@ module Common::Application::Paths
|
|||
# the query string. The query string will correctly build array parameter
|
||||
# values.
|
||||
#
|
||||
def build_query_string(hash, only_keys=nil)
|
||||
def build_query_string(hash, only_keys = nil)
|
||||
elements = []
|
||||
|
||||
only_keys ||= hash.keys
|
||||
|
@ -199,13 +197,13 @@ module Common::Application::Paths
|
|||
if value.class == Array
|
||||
key << '[]'
|
||||
else
|
||||
value = [ value ]
|
||||
value = [value]
|
||||
end
|
||||
value.each { |val| elements << "#{key}=#{CGI.escape(val.to_param.to_s)}" }
|
||||
end
|
||||
|
||||
query_string = "?#{elements.join("&")}" unless elements.empty?
|
||||
query_string || ""
|
||||
query_string = "?#{elements.join('&')}" unless elements.empty?
|
||||
query_string || ''
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -214,4 +212,3 @@ module Common::Application::Paths
|
|||
request.protocol + request.host_with_port + path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -98,7 +98,6 @@
|
|||
#
|
||||
|
||||
module Common::Application::Permissions
|
||||
|
||||
def self.included(base)
|
||||
base.extend ClassMethods
|
||||
base.send :include, InstanceMethods
|
||||
|
@ -141,7 +140,6 @@ module Common::Application::Permissions
|
|||
add_template_helper(permission_class)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
@ -167,7 +165,7 @@ module Common::Application::Permissions
|
|||
when :allow
|
||||
true
|
||||
when Symbol, String
|
||||
self.send(method)
|
||||
send(method)
|
||||
else
|
||||
false
|
||||
end
|
||||
|
@ -186,12 +184,7 @@ module Common::Application::Permissions
|
|||
|
||||
# log perm info for the combination
|
||||
def add_permission_log(method)
|
||||
if Rails.env.development?
|
||||
permission_log[@permission_log_key] = method
|
||||
end
|
||||
permission_log[@permission_log_key] = method if Rails.env.development?
|
||||
end
|
||||
|
||||
end # end instance methods
|
||||
|
||||
end # end module
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
require 'cgi'
|
||||
|
||||
module Common::Application::Referrer
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
helper_method :referrer_params
|
||||
|
@ -26,12 +25,11 @@ module Common::Application::Referrer
|
|||
def referrer_params
|
||||
@referrer_params ||= begin
|
||||
hsh = HashWithIndifferentAccess.new
|
||||
CGI::parse(referrer.sub(/^.*\?/, '')).each do |key,value|
|
||||
CGI.parse(referrer.sub(/^.*\?/, '')).each do |key, value|
|
||||
hsh[key] = value.first if value.is_a? Array
|
||||
end
|
||||
hsh
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -39,19 +37,18 @@ module Common::Application::Referrer
|
|||
#
|
||||
def referrer
|
||||
@referrer ||= begin
|
||||
if request.env["HTTP_REFERER"].empty?
|
||||
if request.env['HTTP_REFERER'].empty?
|
||||
'/'
|
||||
else
|
||||
raw = request.env["HTTP_REFERER"]
|
||||
raw = request.env['HTTP_REFERER']
|
||||
server = request.host_with_port
|
||||
prot = request.protocol
|
||||
if raw.starts_with?("#{prot}#{server}/")
|
||||
raw.sub(/^#{prot}#{server}/, '').sub(/\/$/,'')
|
||||
raw.sub(/^#{prot}#{server}/, '').sub(/\/$/, '')
|
||||
else
|
||||
'/'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -28,13 +28,11 @@
|
|||
#
|
||||
|
||||
module Common::Application::RescueErrors
|
||||
|
||||
def self.included(base)
|
||||
base.extend ClassMethods
|
||||
base.class_eval do
|
||||
|
||||
class_attribute :rescue_render_map,
|
||||
instance_writer: false, instance_reader: false
|
||||
instance_writer: false, instance_reader: false
|
||||
|
||||
# order of precedence is bottom to top.
|
||||
rescue_from ActiveRecord::RecordInvalid, with: :render_error
|
||||
|
@ -49,8 +47,8 @@ module Common::Application::RescueErrors
|
|||
rescue_from AuthenticationRequired, with: :raise
|
||||
rescue_from PermissionDenied, with: :raise
|
||||
|
||||
#helper_method :rescues_path
|
||||
#alias_method_chain :rescue_action_locally, :js
|
||||
# helper_method :rescues_path
|
||||
# alias_method_chain :rescue_action_locally, :js
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,7 +76,7 @@ module Common::Application::RescueErrors
|
|||
#
|
||||
# rescue_render :update => lambda { blah blah }
|
||||
#
|
||||
def rescue_render(hsh=nil)
|
||||
def rescue_render(hsh = nil)
|
||||
if hsh
|
||||
# this has to be a copy so the super class is not affected.
|
||||
# see http://apidock.com/rails/v4.0.2/Class/class_attribute
|
||||
|
@ -92,20 +90,20 @@ module Common::Application::RescueErrors
|
|||
|
||||
protected
|
||||
|
||||
# # allows us to set a new path for the rescue templates
|
||||
# def rescues_path(template_name)
|
||||
# file = "#{Rails.root}/app/views/rescues/#{template_name}.erb"
|
||||
# if File.exists?(file)
|
||||
# return file
|
||||
# else
|
||||
# return super(template_name)
|
||||
# end
|
||||
# end
|
||||
# # allows us to set a new path for the rescue templates
|
||||
# def rescues_path(template_name)
|
||||
# file = "#{Rails.root}/app/views/rescues/#{template_name}.erb"
|
||||
# if File.exists?(file)
|
||||
# return file
|
||||
# else
|
||||
# return super(template_name)
|
||||
# end
|
||||
# end
|
||||
|
||||
#
|
||||
# handles suspected "cross-site request forgery" errors
|
||||
#
|
||||
def render_csrf_error(exception=nil)
|
||||
def render_csrf_error(_exception = nil)
|
||||
render template: 'account/csrf_error', layout: 'notice'
|
||||
end
|
||||
|
||||
|
@ -114,11 +112,11 @@ module Common::Application::RescueErrors
|
|||
# for ajax, no problem, we render some rjs.
|
||||
# for html, we try to to figure out the best template to render.
|
||||
#
|
||||
def render_error(exception=nil, options={})
|
||||
def render_error(exception = nil, options = {})
|
||||
if exception
|
||||
# options[:template] ||= exception.template
|
||||
# options[:redirect] ||= exception.redirect
|
||||
# options[:record] ||= exception.record
|
||||
# options[:template] ||= exception.template
|
||||
# options[:redirect] ||= exception.redirect
|
||||
# options[:record] ||= exception.record
|
||||
options[:status] ||= status_for_exception(exception)
|
||||
end
|
||||
respond_to do |format|
|
||||
|
@ -152,35 +150,31 @@ module Common::Application::RescueErrors
|
|||
#
|
||||
# How is this different than 'render_error' with format.js?
|
||||
#
|
||||
# def rescue_action_locally_with_js(exception)
|
||||
# respond_to do |format|
|
||||
# format.html do
|
||||
# if Rails.env.production? or Rails.env.development?
|
||||
# rescue_action_locally_without_js(exception)
|
||||
# else
|
||||
# render plain: exception
|
||||
# end
|
||||
# end
|
||||
# format.js do
|
||||
# add_variables_to_assigns
|
||||
# @template.instance_variable_set("@exception", exception)
|
||||
# @template.instance_variable_set("@rescues_path", File.dirname(rescues_path("stub")))
|
||||
# @template.send!(:assign_variables_from_controller)
|
||||
# render :template => 'rescues/diagnostics.rjs', :layout => false
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# def rescue_action_locally_with_js(exception)
|
||||
# respond_to do |format|
|
||||
# format.html do
|
||||
# if Rails.env.production? or Rails.env.development?
|
||||
# rescue_action_locally_without_js(exception)
|
||||
# else
|
||||
# render plain: exception
|
||||
# end
|
||||
# end
|
||||
# format.js do
|
||||
# add_variables_to_assigns
|
||||
# @template.instance_variable_set("@exception", exception)
|
||||
# @template.instance_variable_set("@rescues_path", File.dirname(rescues_path("stub")))
|
||||
# @template.send!(:assign_variables_from_controller)
|
||||
# render :template => 'rescues/diagnostics.rjs', :layout => false
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
private
|
||||
|
||||
def render_error_html(exception=nil, options={})
|
||||
if exception
|
||||
alert_message :error, exception
|
||||
end
|
||||
def render_error_html(exception = nil, options = {})
|
||||
alert_message :error, exception if exception
|
||||
|
||||
if options[:redirect]
|
||||
redirect_to options[:redirect]
|
||||
end
|
||||
redirect_to options[:redirect] if options[:redirect]
|
||||
|
||||
#
|
||||
# try to guess the best template to use for rendering the error.
|
||||
|
@ -200,15 +194,15 @@ module Common::Application::RescueErrors
|
|||
render action: action
|
||||
end
|
||||
elsif action.is_a?(Proc)
|
||||
self.instance_eval(&action)
|
||||
instance_eval(&action)
|
||||
end
|
||||
elsif params[:action] == 'update'
|
||||
render action: 'edit'
|
||||
elsif params[:action] == 'create'
|
||||
render action: 'new'
|
||||
elsif params[:action]
|
||||
render action: params[:action] # this is generally a bad idea. it probably means
|
||||
# that a GET request resulted in an error.
|
||||
render action: params[:action] # this is generally a bad idea. it probably means
|
||||
# that a GET request resulted in an error.
|
||||
end
|
||||
end
|
||||
rescue ActionView::MissingTemplate => exc
|
||||
|
@ -217,17 +211,15 @@ module Common::Application::RescueErrors
|
|||
end
|
||||
|
||||
# if we ended up redirecting, then ensure that any :now flash is changed to :later
|
||||
if @preformed_redirect
|
||||
force_later_alert
|
||||
end
|
||||
force_later_alert if @preformed_redirect
|
||||
end
|
||||
|
||||
def render_error_js(exception=nil, options={})
|
||||
def render_error_js(exception = nil, options = {})
|
||||
error exception if exception.present?
|
||||
log_exception(exception)
|
||||
return if performed? # error in after_filter
|
||||
render template: 'error/alert', locals: {exception: exception},
|
||||
status: options[:status]
|
||||
return if performed? # error in after_filter
|
||||
render template: 'error/alert', locals: { exception: exception },
|
||||
status: options[:status]
|
||||
end
|
||||
|
||||
def log_exception(exception)
|
||||
|
@ -236,7 +228,7 @@ module Common::Application::RescueErrors
|
|||
Rails.logger.warn Rails.backtrace_cleaner.clean(exception.backtrace).join("\n")
|
||||
end
|
||||
|
||||
#def flash_auth_error(mode)
|
||||
# def flash_auth_error(mode)
|
||||
# if mode == :now
|
||||
# flsh = flash.now
|
||||
# else
|
||||
|
@ -248,7 +240,5 @@ module Common::Application::RescueErrors
|
|||
# else
|
||||
# add_flash_message(flsh, :title => I18n.t(:login_required), :type => 'info', :text => I18n.t(:login_required_description))
|
||||
# end
|
||||
#end
|
||||
|
||||
# end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
module Common::Application::Tracking
|
||||
|
||||
protected
|
||||
|
||||
# controllers should call this when they want to record a trackingevent.
|
||||
# e.g. in order to update the page view count.
|
||||
def track(options={})
|
||||
def track(options = {})
|
||||
return unless Conf.tracking
|
||||
options.reverse_merge! current_user: current_user,
|
||||
group: @group,
|
||||
user: @user,
|
||||
action: :view
|
||||
group: @group,
|
||||
user: @user,
|
||||
action: :view
|
||||
::Tracking::Page.insert options
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#
|
||||
|
||||
module Common::Application::UrlIdentifiers
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
helper_method :action?
|
||||
|
@ -35,7 +34,7 @@ module Common::Application::UrlIdentifiers
|
|||
action == action_string
|
||||
elsif action.is_a? Symbol
|
||||
if action == :none
|
||||
action_string == nil
|
||||
action_string.nil?
|
||||
else
|
||||
action == action_symbol
|
||||
end
|
||||
|
@ -58,7 +57,7 @@ module Common::Application::UrlIdentifiers
|
|||
return true if cntr == controller_symbol
|
||||
end
|
||||
end
|
||||
return false
|
||||
false
|
||||
end
|
||||
|
||||
# return true if the current controller is page related.
|
||||
|
@ -81,7 +80,7 @@ module Common::Application::UrlIdentifiers
|
|||
return true if obj.to_s == params[:id].to_s
|
||||
end
|
||||
end
|
||||
return false
|
||||
false
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -110,9 +109,9 @@ module Common::Application::UrlIdentifiers
|
|||
if url_path.is_a?(String) or url_path.is_a?(Hash)
|
||||
url_for(url_path) =~ /^#{Regexp.escape(request.path)}$/i
|
||||
elsif url_path.is_a?(Array)
|
||||
!url_path.select { |path|
|
||||
url_for(path).match(/^#{Regexp.escape(request.path)}$/i) ? true : false
|
||||
}.empty?
|
||||
!url_path.select do |path|
|
||||
url_for(path) =~ /^#{Regexp.escape(request.path)}$/i ? true : false
|
||||
end.empty?
|
||||
else
|
||||
false
|
||||
end
|
||||
|
@ -120,7 +119,7 @@ module Common::Application::UrlIdentifiers
|
|||
|
||||
private
|
||||
|
||||
def compare_param(a,b)
|
||||
def compare_param(a, b)
|
||||
a = a.to_param
|
||||
b = b.to_param
|
||||
if b.empty?
|
||||
|
@ -145,7 +144,7 @@ module Common::Application::UrlIdentifiers
|
|||
end
|
||||
|
||||
def controller_symbol
|
||||
@controller_symbol ||= controller_string.gsub('/','_').to_sym
|
||||
@controller_symbol ||= controller_string.tr('/', '_').to_sym
|
||||
end
|
||||
|
||||
def action_string
|
||||
|
@ -159,6 +158,4 @@ module Common::Application::UrlIdentifiers
|
|||
nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#
|
||||
|
||||
module Common::Avatars
|
||||
|
||||
##
|
||||
## ACTIONS
|
||||
##
|
||||
|
@ -43,6 +42,4 @@ module Common::Avatars
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
module Common::Events
|
||||
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#
|
||||
|
||||
module Common::PageSearch
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
helper_method :xhr_page_search?
|
||||
|
@ -21,12 +20,12 @@ module Common::PageSearch
|
|||
def apply_path_modifiers(path)
|
||||
if params[:add]
|
||||
add_segment = parse_filter_path(params[:add])
|
||||
return path.merge(add_segment)
|
||||
path.merge(add_segment)
|
||||
elsif params[:remove]
|
||||
remove_segment = parse_filter_path(params[:remove])
|
||||
return path.remove(remove_segment)
|
||||
path.remove(remove_segment)
|
||||
else
|
||||
return path
|
||||
path
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -63,7 +62,7 @@ module Common::PageSearch
|
|||
# the page search code relies on this being defined by controllers that
|
||||
# include this mixin.
|
||||
#
|
||||
def page_search_path(*args)
|
||||
def page_search_path(*_args)
|
||||
raise 'you must define page_search_path()'
|
||||
end
|
||||
|
||||
|
@ -71,9 +70,7 @@ module Common::PageSearch
|
|||
# controllers including this mixin may define this to control which
|
||||
# filters are shown.
|
||||
#
|
||||
def show_filter?(filter)
|
||||
def show_filter?(_filter)
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -14,15 +14,12 @@
|
|||
#
|
||||
#
|
||||
module Common::Posts
|
||||
|
||||
def edit
|
||||
render template: 'common/posts/edit'
|
||||
end
|
||||
|
||||
def update
|
||||
if params[:save]
|
||||
@post.update_attribute('body', params[:post][:body])
|
||||
end
|
||||
@post.update_attribute('body', params[:post][:body]) if params[:save]
|
||||
redirect_to action: :show
|
||||
end
|
||||
|
||||
|
@ -30,6 +27,4 @@ module Common::Posts
|
|||
@post.destroy
|
||||
render template: 'common/posts/destroy'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ module Common::Requests
|
|||
helper_method :current_state
|
||||
helper_method :request_path
|
||||
helper_method :requests_path
|
||||
before_filter :fetch_request, only: [:update, :destroy, :show]
|
||||
before_filter :fetch_request, only: %i[update destroy show]
|
||||
|
||||
track_actions :update, if: :approved?
|
||||
|
||||
|
@ -57,9 +57,9 @@ module Common::Requests
|
|||
|
||||
def current_state
|
||||
case params[:state]
|
||||
when 'approved' then :approved;
|
||||
when 'rejected' then :rejected;
|
||||
else :pending;
|
||||
when 'approved' then :approved
|
||||
when 'rejected' then :rejected
|
||||
else :pending
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -67,11 +67,11 @@ module Common::Requests
|
|||
:thing_destroyed.tcap thing: I18n.t(@req.name, count: 1)
|
||||
end
|
||||
|
||||
def request_path(*args)
|
||||
def request_path(*_args)
|
||||
raise 'you forgot to override this method'
|
||||
end
|
||||
|
||||
def requests_path(*args)
|
||||
def requests_path(*_args)
|
||||
raise 'you forgot to override this method'
|
||||
end
|
||||
|
||||
|
@ -92,8 +92,8 @@ module Common::Requests
|
|||
|
||||
def mark
|
||||
case params[:mark]
|
||||
when 'reject' then :reject;
|
||||
when 'approve' then :approve;
|
||||
when 'reject' then :reject
|
||||
when 'approve' then :approve
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -122,4 +122,3 @@ module Common::Requests
|
|||
mark == :approve
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -43,12 +43,15 @@ module Common::Tracking::Action
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
def track_action(event = nil, options = {})
|
||||
event, options = nil, event if options.blank? && event.is_a?(Hash)
|
||||
if options.blank? && event.is_a?(Hash)
|
||||
options = event
|
||||
event = nil
|
||||
end
|
||||
event ||= "#{action_string}_#{controller_name.singularize}"
|
||||
event_options = options.reverse_merge current_user: current_user,
|
||||
group: @group,
|
||||
user: @user || current_user,
|
||||
page: @page
|
||||
group: @group,
|
||||
user: @user || current_user,
|
||||
page: @page
|
||||
::Tracking::Action.track event.to_sym, event_options
|
||||
end
|
||||
|
||||
|
@ -58,5 +61,4 @@ module Common::Tracking::Action
|
|||
after_filter :track_action, options.merge(only: actions)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#
|
||||
|
||||
class ContextPagesController < DispatchController
|
||||
|
||||
protected
|
||||
|
||||
def find_controller
|
||||
|
@ -39,7 +38,7 @@ class ContextPagesController < DispatchController
|
|||
|
||||
def finder
|
||||
@finder ||= Page::Finder.new params[:context_id],
|
||||
params[:id]
|
||||
params[:id]
|
||||
end
|
||||
|
||||
def controller_name
|
||||
|
@ -73,7 +72,7 @@ class ContextPagesController < DispatchController
|
|||
modify_action :new
|
||||
modify_params owner: @group.name if create_group_page?
|
||||
modify_params type: 'wiki',
|
||||
page: {title: new_title}
|
||||
page: { title: new_title }
|
||||
end
|
||||
|
||||
def prepare_params_for_not_found
|
||||
|
@ -84,11 +83,10 @@ class ContextPagesController < DispatchController
|
|||
params[:id].sub(/\+\d*/, '').split('+').join(' ').humanize
|
||||
end
|
||||
|
||||
#def controller_for_list_of_pages(name)
|
||||
# def controller_for_list_of_pages(name)
|
||||
# params[:action] = 'index'
|
||||
# params[:search] = {:text => name}
|
||||
# params[:controller] = 'search'
|
||||
# SearchController.new()
|
||||
#end
|
||||
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#
|
||||
|
||||
class ContextsController < DispatchController
|
||||
|
||||
protected
|
||||
|
||||
def find_controller
|
||||
|
@ -21,7 +20,7 @@ class ContextsController < DispatchController
|
|||
|
||||
def controller_for_group(name)
|
||||
# we are dealing with a committee!
|
||||
name.sub!(' ','+') if name =~ /\ /
|
||||
name.sub!(' ', '+') if name =~ /\ /
|
||||
|
||||
@group = Group.where(name: name).first!
|
||||
params[:group_id] = params[:id]
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#
|
||||
|
||||
class CronController < ActionController::Base
|
||||
|
||||
before_filter :allow_only_requests_from_localhost
|
||||
|
||||
def run
|
||||
|
@ -33,9 +32,6 @@ class CronController < ActionController::Base
|
|||
# this seems reasonable.
|
||||
#
|
||||
def allow_only_requests_from_localhost
|
||||
unless request.remote_addr == '127.0.0.1'
|
||||
render plain: 'not allowed'
|
||||
end
|
||||
render plain: 'not allowed' unless request.remote_addr == '127.0.0.1'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
if Rails.env.development?
|
||||
class DebugController < ApplicationController
|
||||
|
||||
before_filter :authorization_required
|
||||
|
||||
# make the user assume the identity of another user
|
||||
def become
|
||||
@user = User.find_by_login(params[:id])
|
||||
session[:user] = @user.id
|
||||
redirect_to (params[:url] || "/")
|
||||
redirect_to (params[:url] || '/')
|
||||
end
|
||||
|
||||
# call the debugger so we can set breakpoints
|
||||
def break
|
||||
debugger
|
||||
redirect_to (params[:url] || "/")
|
||||
redirect_to (params[:url] || '/')
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
#
|
||||
|
||||
class DispatchController < ApplicationController
|
||||
|
||||
# this is *not* an action, but the 'dispatch' method from ActionController::Metal
|
||||
# The only change here is that we don't return to_a(), but instead whatever
|
||||
# process() returns.
|
||||
def dispatch(action, request, response = ActionDispatch::Response.new)
|
||||
def dispatch(action, request, _response = ActionDispatch::Response.new)
|
||||
@action = action
|
||||
@_request = request
|
||||
@_env = request.env
|
||||
|
@ -32,7 +31,7 @@ class DispatchController < ApplicationController
|
|||
|
||||
# We want the modification to also apply to the newly instantiated controller.
|
||||
# So we have to modify the request - not just the Parameters instance.
|
||||
def modify_params(options={})
|
||||
def modify_params(options = {})
|
||||
request.parameters.merge! options
|
||||
@_params = nil
|
||||
end
|
||||
|
@ -41,5 +40,4 @@ class DispatchController < ApplicationController
|
|||
modify_params action: action
|
||||
@action = action
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,19 +13,18 @@
|
|||
#
|
||||
|
||||
class EntitiesController < ApplicationController
|
||||
|
||||
before_filter :login_required
|
||||
|
||||
LIMIT = 20
|
||||
|
||||
def index
|
||||
@entities = case params[:view]
|
||||
when 'recipients' then recipients
|
||||
when 'groups' then groups
|
||||
when 'users' then users
|
||||
when 'members' then members
|
||||
when 'all' then all
|
||||
else all
|
||||
when 'recipients' then recipients
|
||||
when 'groups' then groups
|
||||
when 'users' then users
|
||||
when 'members' then members
|
||||
when 'all' then all
|
||||
else all
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -55,7 +54,7 @@ class EntitiesController < ApplicationController
|
|||
if preload?
|
||||
User.friends_or_peers_of(current_user).all_with_access(current_user => :pester)
|
||||
elsif filter.present?
|
||||
recipients = User.with_access(current_user => [:view, :pester])
|
||||
recipients = User.with_access(current_user => %i[view pester])
|
||||
recipients.named_like(filter).limit(LIMIT)
|
||||
end
|
||||
end
|
||||
|
@ -89,7 +88,7 @@ class EntitiesController < ApplicationController
|
|||
if preload?
|
||||
groups + users
|
||||
else
|
||||
(groups + users).sort_by{|r|r.name}[0..(LIMIT-1)]
|
||||
(groups + users).sort_by(&:name)[0..(LIMIT - 1)]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -97,7 +96,7 @@ class EntitiesController < ApplicationController
|
|||
|
||||
def filter
|
||||
@query = params[:query]
|
||||
@query.present? ? "#{params[:query].strip}%" : ""
|
||||
@query.present? ? "#{params[:query].strip}%" : ''
|
||||
end
|
||||
|
||||
# the autocomplete will issues an empty query when first loaded.
|
||||
|
@ -106,6 +105,3 @@ class EntitiesController < ApplicationController
|
|||
filter.empty? and logged_in?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,19 +3,19 @@ class ExceptionsController < ApplicationController
|
|||
|
||||
def show
|
||||
@exception = env['action_dispatch.exception']
|
||||
@former_params = env["action_dispatch.request.parameters"]
|
||||
@former_params = env['action_dispatch.request.parameters']
|
||||
@status_code = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
|
||||
@rescue_response = ActionDispatch::ExceptionWrapper.rescue_responses[@exception.class.name]
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
format.html do
|
||||
render :show, status: @status_code, layout: (!request.xhr? && 'notice')
|
||||
}
|
||||
format.xml { render xml: details, root: "error", status: @status_code }
|
||||
format.json { render json: {error: details}, status: @status_code }
|
||||
end
|
||||
format.xml { render xml: details, root: 'error', status: @status_code }
|
||||
format.json { render json: { error: details }, status: @status_code }
|
||||
format.js { render_error_js(@exception, status: @status_code) }
|
||||
# let's send the error message out somehow.
|
||||
format.all { render json: {error: details}, status: @status_code }
|
||||
format.all { render json: { error: details }, status: @status_code }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -27,5 +27,4 @@ class ExceptionsController < ApplicationController
|
|||
description: translate_exception(:description)
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Group::AvatarsController < Group::BaseController
|
||||
|
||||
include_controllers 'common/avatars'
|
||||
include_controllers 'common/always_perform_caching'
|
||||
before_filter :setup
|
||||
|
@ -12,6 +11,4 @@ class Group::AvatarsController < Group::BaseController
|
|||
@entity = @group
|
||||
@success_url = group_settings_path(@group)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Group::BaseController < ApplicationController
|
||||
|
||||
before_filter :fetch_group
|
||||
|
||||
# default permission for all group controllers
|
||||
|
@ -19,9 +18,7 @@ class Group::BaseController < ApplicationController
|
|||
end
|
||||
|
||||
def setup_context
|
||||
if @group and !@group.new_record?
|
||||
@context = Context.find(@group)
|
||||
end
|
||||
@context = Context.find(@group) if @group and !@group.new_record?
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -34,6 +31,4 @@ class Group::BaseController < ApplicationController
|
|||
new_group_structure_path(group, type: 'council')
|
||||
end
|
||||
helper_method :new_group_council_path
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -19,9 +19,7 @@ class Group::DirectoryController < ApplicationController
|
|||
protected
|
||||
|
||||
def set_default_path
|
||||
if params[:path].empty?
|
||||
params[:path] = default_path
|
||||
end
|
||||
params[:path] = default_path if params[:path].empty?
|
||||
end
|
||||
|
||||
def default_path
|
||||
|
@ -71,4 +69,3 @@ class Group::DirectoryController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
class Group::EventsController < Group::BaseController
|
||||
|
||||
#permissions 'events'
|
||||
# permissions 'events'
|
||||
include_controllers 'common/events'
|
||||
|
||||
def index
|
||||
@events = Event.all
|
||||
render template: 'common/events/index'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,10 +4,12 @@ class Group::GroupsController < Group::BaseController
|
|||
# restricting the before filter to { :only => :destroy } doesn't work, because
|
||||
# then it changes position in the filter chain and runs after the guards, but
|
||||
# may_admin_group? requires @group to be set.
|
||||
def fetch_group() super if action? :destroy end
|
||||
def fetch_group
|
||||
super if action? :destroy
|
||||
end
|
||||
protected :fetch_group
|
||||
|
||||
before_filter :initialize_group, only: ['new', 'create']
|
||||
before_filter :initialize_group, only: %w[new create]
|
||||
before_filter :fetch_associations, only: :destroy
|
||||
|
||||
track_actions :create
|
||||
|
@ -15,8 +17,7 @@ class Group::GroupsController < Group::BaseController
|
|||
|
||||
guard :may_ALIAS_group?
|
||||
|
||||
def new
|
||||
end
|
||||
def new; end
|
||||
|
||||
#
|
||||
# responsible for creating groups and networks.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Group::HomeController < Group::BaseController
|
||||
|
||||
skip_before_filter :login_required
|
||||
# fetch_group already checks may_show_group?
|
||||
skip_before_filter :authorization_required
|
||||
|
@ -16,10 +15,9 @@ class Group::HomeController < Group::BaseController
|
|||
@group = options[:group]
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@pages = Page.paginate_by_path '/descending/updated_at/limit/30/',
|
||||
options_for_group(@group), pagination_params
|
||||
options_for_group(@group), pagination_params
|
||||
track
|
||||
end
|
||||
|
||||
|
@ -42,19 +40,17 @@ class Group::HomeController < Group::BaseController
|
|||
end
|
||||
|
||||
def track_visit
|
||||
memberships.update_all [ "total_visits = total_visits + 1, visited_at = ?",
|
||||
Time.now ]
|
||||
memberships.update_all ['total_visits = total_visits + 1, visited_at = ?',
|
||||
Time.now]
|
||||
end
|
||||
|
||||
def memberships
|
||||
@group.memberships.where(user_id: current_user)
|
||||
end
|
||||
|
||||
#helper_method :coming_from_wiki?
|
||||
# helper_method :coming_from_wiki?
|
||||
# will return true if we came from the wiki editor, versions or diffs
|
||||
#def coming_from_wiki?(wiki)
|
||||
# def coming_from_wiki?(wiki)
|
||||
# wiki and params[:wiki_id].to_i == wiki.id
|
||||
#end
|
||||
|
||||
# end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,12 +5,10 @@
|
|||
# update and destroy are handled by Me::RequestsController
|
||||
|
||||
class Group::InvitesController < Group::BaseController
|
||||
# requrires may_admin_group? as Group::BaseController
|
||||
# TODO: if it is an open group, admin should not be required.
|
||||
|
||||
# requrires may_admin_group? as Group::BaseController
|
||||
# TODO: if it is an open group, admin should not be required.
|
||||
|
||||
def new
|
||||
end
|
||||
def new; end
|
||||
|
||||
#
|
||||
# create some new invites, possibly of the type:
|
||||
|
@ -32,17 +30,17 @@ class Group::InvitesController < Group::BaseController
|
|||
|
||||
users.each do |user|
|
||||
reqs << RequestToJoinUs.create(created_by: current_user,
|
||||
recipient: user, requestable: @group)
|
||||
recipient: user, requestable: @group)
|
||||
end
|
||||
|
||||
groups.each do |group|
|
||||
reqs << RequestToJoinOurNetwork.create(created_by: current_user,
|
||||
recipient: group, requestable: @group)
|
||||
recipient: group, requestable: @group)
|
||||
end
|
||||
|
||||
emails.each do |email|
|
||||
req = RequestToJoinUsViaEmail.create(created_by: current_user,
|
||||
email: email, requestable: @group, language: I18n.locale.to_s)
|
||||
email: email, requestable: @group, language: I18n.locale.to_s)
|
||||
Mailer.invite_to_join_us(req, mailer_options).deliver
|
||||
reqs << req
|
||||
end
|
||||
|
@ -62,7 +60,7 @@ class Group::InvitesController < Group::BaseController
|
|||
end
|
||||
else
|
||||
success reqs.first, count: reqs.size
|
||||
params[:recipients] = ""
|
||||
params[:recipients] = ''
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -71,5 +69,4 @@ class Group::InvitesController < Group::BaseController
|
|||
.select { |req| req.valid? && !req.is_a?(RequestToJoinUsViaEmail) }
|
||||
.each { |req| Notice::RequestNotice.create! req }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#
|
||||
|
||||
class Group::MembershipRequestsController < Group::BaseController
|
||||
|
||||
include_controllers 'common/requests'
|
||||
|
||||
# may_admin_group? is required by default.
|
||||
|
@ -15,12 +14,12 @@ class Group::MembershipRequestsController < Group::BaseController
|
|||
guard create: :allow, update: :allow, destroy: :allow
|
||||
|
||||
def index
|
||||
@requests = Request.
|
||||
membership_related.
|
||||
having_state(current_state).
|
||||
send(current_view, @group).
|
||||
by_updated_at.
|
||||
paginate(pagination_params)
|
||||
@requests = Request
|
||||
.membership_related
|
||||
.having_state(current_state)
|
||||
.send(current_view, @group)
|
||||
.by_updated_at
|
||||
.paginate(pagination_params)
|
||||
render template: 'common/requests/index'
|
||||
end
|
||||
|
||||
|
@ -41,16 +40,16 @@ class Group::MembershipRequestsController < Group::BaseController
|
|||
|
||||
def type
|
||||
case params[:type]
|
||||
when 'destroy' then :destroy
|
||||
when 'join' then :join
|
||||
when 'destroy' then :destroy
|
||||
when 'join' then :join
|
||||
end
|
||||
end
|
||||
|
||||
def current_view
|
||||
case params[:view]
|
||||
when "incoming" then :to_group
|
||||
when "outgoing" then :from_group
|
||||
else :regarding_group;
|
||||
when 'incoming' then :to_group
|
||||
when 'outgoing' then :from_group
|
||||
else :regarding_group
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -63,7 +62,7 @@ class Group::MembershipRequestsController < Group::BaseController
|
|||
end
|
||||
|
||||
def create_join_request
|
||||
if !params[:cancel]
|
||||
unless params[:cancel]
|
||||
@req = RequestToJoinYou.create recipient: @group, created_by: current_user
|
||||
alert_message @req
|
||||
end
|
||||
|
@ -84,5 +83,4 @@ class Group::MembershipRequestsController < Group::BaseController
|
|||
success @req
|
||||
redirect_to requests_path(@req)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -53,9 +53,7 @@ class Group::MembershipsController < Group::BaseController
|
|||
@user = @membership.user
|
||||
end
|
||||
elsif action?(:create)
|
||||
if params[:user_name]
|
||||
@user = User.find_by_login(params[:user_name])
|
||||
end
|
||||
@user = User.find_by_login(params[:user_name]) if params[:user_name]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -63,6 +61,4 @@ class Group::MembershipsController < Group::BaseController
|
|||
params[:view] == 'groups'
|
||||
end
|
||||
helper_method :federation_view?
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Group::MyMembershipsController < Group::BaseController
|
||||
|
||||
guard create: :may_join_group?,
|
||||
destroy: :may_leave_group?
|
||||
|
||||
|
@ -16,5 +15,4 @@ class Group::MyMembershipsController < Group::BaseController
|
|||
redirect_to me_home_url
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Group::PagesController < Group::BaseController
|
||||
|
||||
skip_before_filter :login_required
|
||||
# fetch_group already checks may_show_group?
|
||||
skip_before_filter :authorization_required
|
||||
|
@ -7,20 +6,20 @@ class Group::PagesController < Group::BaseController
|
|||
include_controllers 'common/page_search'
|
||||
|
||||
def index
|
||||
@path = apply_path_modifiers( parsed_path() )
|
||||
@path = apply_path_modifiers(parsed_path)
|
||||
@pages = Page.paginate_by_path(@path, options_for_group(@group), pagination_params)
|
||||
render template: 'common/pages/search/index', locals: {hide_owner: true}
|
||||
render template: 'common/pages/search/index', locals: { hide_owner: true }
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def setup_navigation(nav)
|
||||
nav[:local] = [
|
||||
{active: false, visible: may_edit_group?, html: {partial: 'common/pages/search/create'}},
|
||||
{active: true, visible: true, html: {partial: 'common/pages/search/controls_active'}},
|
||||
{active: false, visible: true, html: {partial: 'common/pages/search/controls_possible'}}
|
||||
{ active: false, visible: may_edit_group?, html: { partial: 'common/pages/search/create' } },
|
||||
{ active: true, visible: true, html: { partial: 'common/pages/search/controls_active' } },
|
||||
{ active: false, visible: true, html: { partial: 'common/pages/search/controls_possible' } }
|
||||
]
|
||||
return nav
|
||||
nav
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -36,6 +35,4 @@ class Group::PagesController < Group::BaseController
|
|||
def show_filter?(filter)
|
||||
filter.section != :my_pages
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Group::PermissionsController < Group::BaseController
|
||||
|
||||
helper 'castle_gates'
|
||||
|
||||
def index
|
||||
|
@ -18,9 +17,7 @@ class Group::PermissionsController < Group::BaseController
|
|||
# don't allow altering any other holder than :public or
|
||||
# the group itself.
|
||||
# otherwise you could do all kinds of nasty things.
|
||||
if holder != @group
|
||||
head :bad_request and return
|
||||
end
|
||||
head :bad_request and return if holder != @group
|
||||
end
|
||||
|
||||
## FIXME: should we prevent the following cases?
|
||||
|
@ -45,6 +42,4 @@ class Group::PermissionsController < Group::BaseController
|
|||
group_permission_path(@group, id, *args)
|
||||
end
|
||||
helper_method :key_holder_path
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
class Group::ProfilesController < Group::BaseController
|
||||
|
||||
before_filter :fetch_profile
|
||||
helper :profile
|
||||
|
||||
def edit
|
||||
end
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if params[:clear_photo]
|
||||
|
@ -19,13 +17,11 @@ class Group::ProfilesController < Group::BaseController
|
|||
private
|
||||
|
||||
def fetch_profile
|
||||
if @group
|
||||
@profile = @group.profiles.public
|
||||
end
|
||||
@profile = @group.profiles.public if @group
|
||||
true
|
||||
end
|
||||
|
||||
def profile_params
|
||||
params.require(:profile).permit :place, :summary, {:picture => [ :upload ]}
|
||||
params.require(:profile).permit :place, :summary, picture: [:upload]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#
|
||||
#
|
||||
class Group::RequestsController < Group::BaseController
|
||||
|
||||
include_controllers 'common/requests'
|
||||
|
||||
# guard defaults to may_admin_group?
|
||||
|
@ -18,11 +17,11 @@ class Group::RequestsController < Group::BaseController
|
|||
rescue_render create: :index
|
||||
|
||||
def index
|
||||
@requests = Request.
|
||||
having_state(current_state).
|
||||
send(current_view, @group).
|
||||
by_updated_at.
|
||||
paginate(pagination_params)
|
||||
@requests = Request
|
||||
.having_state(current_state)
|
||||
.send(current_view, @group)
|
||||
.by_updated_at
|
||||
.paginate(pagination_params)
|
||||
render template: 'common/requests/index'
|
||||
end
|
||||
|
||||
|
@ -32,8 +31,8 @@ class Group::RequestsController < Group::BaseController
|
|||
#
|
||||
def create
|
||||
@req = requested_class.create! recipient: @group,
|
||||
requestable: @group,
|
||||
created_by: current_user
|
||||
requestable: @group,
|
||||
created_by: current_user
|
||||
success @req
|
||||
redirect_to request_path(@req)
|
||||
end
|
||||
|
@ -50,16 +49,14 @@ class Group::RequestsController < Group::BaseController
|
|||
end
|
||||
|
||||
def track_action
|
||||
if REQUEST_TYPES.has_key? params[:type]
|
||||
super "request_to_#{params[:type]}"
|
||||
end
|
||||
super "request_to_#{params[:type]}" if REQUEST_TYPES.key? params[:type]
|
||||
end
|
||||
|
||||
def current_view
|
||||
case params[:view]
|
||||
when "incoming" then :to_group
|
||||
when "outgoing" then :from_group
|
||||
else :regarding_group
|
||||
when 'incoming' then :to_group
|
||||
when 'outgoing' then :from_group
|
||||
else :regarding_group
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -70,5 +67,4 @@ class Group::RequestsController < Group::BaseController
|
|||
def requests_path(*args)
|
||||
group_requests_path(@group, *args)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
class Group::SettingsController < Group::BaseController
|
||||
|
||||
def show
|
||||
end
|
||||
def show; end
|
||||
|
||||
def update
|
||||
@group.update_attributes! group_params
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
class Group::StructuresController < Group::SettingsController
|
||||
include Common::Tracking::Action
|
||||
|
||||
guard :may_edit_group_structure?, actions: [:new, :create, :destroy]
|
||||
guard :may_edit_group_structure?, actions: %i[new create destroy]
|
||||
|
||||
track_actions :create
|
||||
|
||||
def show
|
||||
end
|
||||
def show; end
|
||||
|
||||
def new
|
||||
@committee = group_class.new
|
||||
|
@ -29,18 +28,18 @@ class Group::StructuresController < Group::SettingsController
|
|||
|
||||
def group_type
|
||||
case params[:type]
|
||||
when 'committee' then :committee
|
||||
when 'council' then :council
|
||||
else raise 'error'
|
||||
when 'committee' then :committee
|
||||
when 'council' then :council
|
||||
else raise 'error'
|
||||
end
|
||||
end
|
||||
helper_method :group_type
|
||||
|
||||
def group_class
|
||||
case group_type
|
||||
when :council then Group::Council
|
||||
when :committee then Group::Committee
|
||||
else raise 'error'
|
||||
when :council then Group::Council
|
||||
when :committee then Group::Committee
|
||||
else raise 'error'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Group::WikisController < Group::BaseController
|
||||
|
||||
guard :may_edit_group?
|
||||
permissions 'wikis'
|
||||
|
||||
|
@ -20,5 +19,4 @@ class Group::WikisController < Group::BaseController
|
|||
@private_wiki = @group.private_wiki
|
||||
@public_wiki = @group.public_wiki
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Me::AvatarsController < Me::BaseController
|
||||
|
||||
include_controllers 'common/avatars'
|
||||
include_controllers 'common/always_perform_caching'
|
||||
before_filter :setup
|
||||
|
@ -22,10 +21,8 @@ class Me::AvatarsController < Me::BaseController
|
|||
@success_url = me_settings_url
|
||||
end
|
||||
|
||||
def user_avatars_path(user, avatar)
|
||||
def user_avatars_path(_user, avatar)
|
||||
me_avatar_path(avatar)
|
||||
end
|
||||
helper_method :user_avatars_path
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# Abstract super class of all the Me controllers.
|
||||
#
|
||||
class Me::BaseController < ApplicationController
|
||||
|
||||
before_filter :login_required, :fetch_user
|
||||
|
||||
protected
|
||||
|
@ -15,5 +14,4 @@ class Me::BaseController < ApplicationController
|
|||
@context = Context::Me.new(current_user)
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
class Me::DestroysController < Me::BaseController
|
||||
|
||||
rescue_render update: :show
|
||||
|
||||
def show
|
||||
end
|
||||
def show; end
|
||||
|
||||
def update
|
||||
# these will be cleared after retire!
|
||||
|
@ -30,5 +28,4 @@ class Me::DestroysController < Me::BaseController
|
|||
notification = Notification.new(:user_destroyed, username: current_user.name)
|
||||
notification.create_notices_for(users_to_notify)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,33 +13,33 @@ class Me::DiscussionsController < Me::BaseController
|
|||
# GET /me/messages
|
||||
# we currently lack pagination and filtering for unread
|
||||
def index
|
||||
@posts = Post.private_messages(current_user).
|
||||
last_in_discussion.
|
||||
visible.
|
||||
order("created_at DESC").
|
||||
includes(:discussion)
|
||||
@posts = Post.private_messages(current_user)
|
||||
.last_in_discussion
|
||||
.visible
|
||||
.order('created_at DESC')
|
||||
.includes(:discussion)
|
||||
end
|
||||
|
||||
# GET /me/messages/penguin
|
||||
#def show
|
||||
# def show
|
||||
# @other_user = User.find_by_login(params[:id])
|
||||
# @discussion = current_user.discussions.from_user(@other_user).first
|
||||
# @discussion.mark!(:read, current_user)
|
||||
# @posts = @discussion.posts.paginate(post_pagination_params)
|
||||
#rescue exc
|
||||
# rescue exc
|
||||
# render_error exc
|
||||
#end
|
||||
# end
|
||||
|
||||
# PUT /me/messages/penguin
|
||||
#def update
|
||||
# def update
|
||||
# @other_user = User.find_by_login(params[:id])
|
||||
# @discussion = current_user.discussions.from_user(@user_user).first
|
||||
# if params[:state]
|
||||
# @discussion.mark!(params[:state], current_user)
|
||||
# end
|
||||
#rescue exc
|
||||
# rescue exc
|
||||
# render_error exc
|
||||
#end
|
||||
# end
|
||||
|
||||
protected
|
||||
|
||||
|
@ -47,5 +47,4 @@ class Me::DiscussionsController < Me::BaseController
|
|||
default_page = params[:page].blank? ? @discussion.last_page : nil
|
||||
pagination_params(page: default_page)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
class Me::EventsController < Me::BaseController
|
||||
|
||||
#permissions 'events'
|
||||
# permissions 'events'
|
||||
include_controllers 'common/events'
|
||||
|
||||
def index
|
||||
@events = Event.all
|
||||
render template: 'common/events/index'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
class Me::NoticesController < Me::BaseController
|
||||
|
||||
before_filter :fetch_notice, only: [:show, :destroy]
|
||||
before_filter :fetch_notice, only: %i[show destroy]
|
||||
|
||||
def index
|
||||
@notices = Notice.for_user(current_user).
|
||||
dismissed(params[:view] == 'old').
|
||||
includes(:noticable).
|
||||
order('created_at DESC').
|
||||
paginate(pagination_params)
|
||||
@notices = Notice.for_user(current_user)
|
||||
.dismissed(params[:view] == 'old')
|
||||
.includes(:noticable)
|
||||
.order('created_at DESC')
|
||||
.paginate(pagination_params)
|
||||
|
||||
@pages = Page.paginate_by_path '', options_for_me, pagination_params
|
||||
end
|
||||
|
||||
def show
|
||||
url = self.send(@notice.redirect_path, @notice.redirect_object)
|
||||
url = send(@notice.redirect_path, @notice.redirect_object)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to url }
|
||||
format.js { render(:update){|page| page.redirect_to url} }
|
||||
format.js { render(:update) { |page| page.redirect_to url } }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,29 +1,28 @@
|
|||
class Me::PagesController < Me::BaseController
|
||||
|
||||
include_controllers 'common/page_search'
|
||||
|
||||
#
|
||||
# see controller/common/page_search.rb
|
||||
#
|
||||
def index
|
||||
@path = apply_path_modifiers( parsed_path() )
|
||||
@path = apply_path_modifiers(parsed_path)
|
||||
if request.xhr?
|
||||
# note: pagination_params is used just for defaults,
|
||||
# normal pagination is done through @path.
|
||||
@pages = Page.paginate_by_path(@path, options_for_me(method: :sphinx), pagination_params)
|
||||
end
|
||||
render template: 'common/pages/search/index', locals: {columns: :updated_with_owner}
|
||||
render template: 'common/pages/search/index', locals: { columns: :updated_with_owner }
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def setup_navigation(nav)
|
||||
nav[:local] = [
|
||||
{active: false, visible: true, html: {partial: 'common/pages/search/create'}},
|
||||
{active: true, visible: true, html: {partial: 'common/pages/search/controls_active'}},
|
||||
{active: false, visible: true, html: {partial: 'common/pages/search/controls_possible'}}
|
||||
{ active: false, visible: true, html: { partial: 'common/pages/search/create' } },
|
||||
{ active: true, visible: true, html: { partial: 'common/pages/search/controls_active' } },
|
||||
{ active: false, visible: true, html: { partial: 'common/pages/search/controls_possible' } }
|
||||
]
|
||||
return nav
|
||||
nav
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -32,6 +31,4 @@ class Me::PagesController < Me::BaseController
|
|||
def page_search_path(*args)
|
||||
me_pages_path(*args)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
class Me::PasswordsController < Me::BaseController
|
||||
|
||||
rescue_render update: :edit
|
||||
|
||||
def edit
|
||||
end
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if params[:user][:password].empty?
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Me::PermissionsController < Me::BaseController
|
||||
|
||||
helper 'castle_gates'
|
||||
|
||||
def index
|
||||
|
@ -28,5 +27,4 @@ class Me::PermissionsController < Me::BaseController
|
|||
me_permission_path(id, *args)
|
||||
end
|
||||
helper_method :key_holder_path
|
||||
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#
|
||||
|
||||
class Me::PostsController < Me::BaseController
|
||||
|
||||
include_controllers 'common/posts'
|
||||
|
||||
prepend_before_filter :fetch_data
|
||||
|
@ -12,7 +11,7 @@ class Me::PostsController < Me::BaseController
|
|||
permissions 'posts'
|
||||
guard :may_ALIAS_post?
|
||||
guard index: :allow,
|
||||
show: :allow
|
||||
show: :allow
|
||||
|
||||
# /me/discussions/green/posts
|
||||
def index
|
||||
|
@ -50,9 +49,7 @@ class Me::PostsController < Me::BaseController
|
|||
error(:thing_not_found.t(thing: :recipient.t), :later)
|
||||
redirect_to me_discussions_url
|
||||
end
|
||||
if params[:id] && @discussion
|
||||
@post = @discussion.posts.find(params[:id])
|
||||
end
|
||||
@post = @discussion.posts.find(params[:id]) if params[:id] && @discussion
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
class Me::ProfileController < Me::BaseController
|
||||
|
||||
before_filter :fetch_profile
|
||||
helper :profile
|
||||
|
||||
def edit
|
||||
end
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if params[:clear_photo]
|
||||
|
@ -24,7 +22,6 @@ class Me::ProfileController < Me::BaseController
|
|||
|
||||
def profile_params
|
||||
params[:profile].permit :place, :organization, :role, :summary,
|
||||
{:picture => [:upload]}
|
||||
picture: [:upload]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
class Me::RecentPagesController < Me::BaseController
|
||||
def index
|
||||
end
|
||||
def index; end
|
||||
end
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
class Me::RequestsController < Me::BaseController
|
||||
|
||||
include_controllers 'common/requests'
|
||||
|
||||
def index
|
||||
@requests = Request.
|
||||
having_state(current_state).
|
||||
send(current_view, current_user).
|
||||
by_updated_at.
|
||||
paginate(pagination_params)
|
||||
@requests = Request
|
||||
.having_state(current_state)
|
||||
.send(current_view, current_user)
|
||||
.by_updated_at
|
||||
.paginate(pagination_params)
|
||||
render template: 'common/requests/index'
|
||||
end
|
||||
|
||||
|
@ -15,9 +14,9 @@ class Me::RequestsController < Me::BaseController
|
|||
|
||||
def current_view
|
||||
case params[:view]
|
||||
when "incoming" then :to_user;
|
||||
when "outgoing" then :created_by;
|
||||
else :to_or_created_by_user;
|
||||
when 'incoming' then :to_user
|
||||
when 'outgoing' then :created_by
|
||||
else :to_or_created_by_user
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -28,5 +27,4 @@ class Me::RequestsController < Me::BaseController
|
|||
def requests_path(*args)
|
||||
me_requests_path(*args)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
class Me::SettingsController < Me::BaseController
|
||||
|
||||
rescue_render update: :show
|
||||
|
||||
def show
|
||||
end
|
||||
def show; end
|
||||
|
||||
def update
|
||||
current_user.update_attributes!(user_params)
|
||||
if current_user.language
|
||||
session[:language_code] = current_user.language
|
||||
end
|
||||
session[:language_code] = current_user.language if current_user.language
|
||||
success
|
||||
redirect_to me_settings_url
|
||||
end
|
||||
|
@ -18,6 +14,6 @@ class Me::SettingsController < Me::BaseController
|
|||
|
||||
def user_params
|
||||
params.require(:user).permit :login, :display_name,
|
||||
:email, :receive_notifications, :language, :time_zone
|
||||
:email, :receive_notifications, :language, :time_zone
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
class Me::TasksController < Me::BaseController
|
||||
|
||||
def index
|
||||
@pages = pages_with_tasks
|
||||
.not_deleted
|
||||
.order('pages.updated_at DESC')
|
||||
.limit(20)
|
||||
.not_deleted
|
||||
.order('pages.updated_at DESC')
|
||||
.limit(20)
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -24,5 +23,4 @@ class Me::TasksController < Me::BaseController
|
|||
def completed?
|
||||
params[:view] == 'completed'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Page::AssetsController < Page::SidebarsController
|
||||
|
||||
helper 'page/assets'
|
||||
|
||||
def index
|
||||
|
@ -21,13 +20,10 @@ class Page::AssetsController < Page::SidebarsController
|
|||
|
||||
def fetch_page
|
||||
super
|
||||
if @page and params[:id]
|
||||
@asset = @page.assets.find_by_id params[:id]
|
||||
end
|
||||
@asset = @page.assets.find_by_id params[:id] if @page and params[:id]
|
||||
end
|
||||
|
||||
def asset_params
|
||||
params.require(:asset).permit(:uploaded_data)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#
|
||||
|
||||
class Page::AttributesController < Page::SidebarsController
|
||||
|
||||
before_filter :login_required
|
||||
track_actions :update
|
||||
|
||||
|
@ -38,6 +37,4 @@ class Page::AttributesController < Page::SidebarsController
|
|||
Group.where(name: params[:owner]).first!
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#
|
||||
|
||||
class Page::BaseController < ApplicationController
|
||||
|
||||
public
|
||||
|
||||
before_filter :login_required, except: :show
|
||||
|
@ -39,7 +38,7 @@ class Page::BaseController < ApplicationController
|
|||
# ... after all the others
|
||||
after_filter :save_if_needed, except: :create
|
||||
after_filter :update_viewed, only: :show
|
||||
after_filter :update_view_count, only: [:show, :edit, :create]
|
||||
after_filter :update_view_count, only: %i[show edit create]
|
||||
|
||||
include Page::BeforeFilters
|
||||
|
||||
|
@ -56,6 +55,7 @@ class Page::BaseController < ApplicationController
|
|||
|
||||
# to be overridden by subclasses
|
||||
def fetch_data; end
|
||||
|
||||
def setup_options; end
|
||||
|
||||
##
|
||||
|
@ -81,14 +81,12 @@ class Page::BaseController < ApplicationController
|
|||
|
||||
def setup_context
|
||||
if @page and @page.owner
|
||||
if @page.owner == current_user
|
||||
@context = Context::Me.new(current_user)
|
||||
else
|
||||
@context = Context.find(@page.owner)
|
||||
end
|
||||
@context = if @page.owner == current_user
|
||||
Context::Me.new(current_user)
|
||||
else
|
||||
Context.find(@page.owner)
|
||||
end
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#
|
||||
|
||||
module Page::BeforeFilters
|
||||
|
||||
protected
|
||||
|
||||
##
|
||||
|
@ -32,8 +31,8 @@ module Page::BeforeFilters
|
|||
rescue ErrorNotFound => e
|
||||
@exception = e
|
||||
render 'exceptions/show',
|
||||
status: 404,
|
||||
layout: request.xhr? ? nil : 'notice'
|
||||
status: 404,
|
||||
layout: request.xhr? ? nil : 'notice'
|
||||
end
|
||||
|
||||
def default_setup_options
|
||||
|
@ -51,20 +50,20 @@ module Page::BeforeFilters
|
|||
true
|
||||
end
|
||||
|
||||
#def choose_layout
|
||||
# def choose_layout
|
||||
# if action?(:create, :new)
|
||||
# return 'application'
|
||||
# else
|
||||
# return 'page'
|
||||
# end
|
||||
#end
|
||||
# end
|
||||
|
||||
# don't require a login for public pages
|
||||
def login_or_public_page_required
|
||||
if action_name == 'show' and @page and @page.public?
|
||||
true
|
||||
else
|
||||
return login_required
|
||||
login_required
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -72,9 +71,7 @@ module Page::BeforeFilters
|
|||
if @options.show_posts and request.get? and !@page.nil?
|
||||
# use params[:posts] for pagination
|
||||
@posts = @page.posts(page: params[:posts])
|
||||
if @options.show_reply
|
||||
@post = Post.new
|
||||
end
|
||||
@post = Post.new if @options.show_reply
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -83,9 +80,9 @@ module Page::BeforeFilters
|
|||
# adding comments. It's really odd if these disappear when you navigate
|
||||
# back.
|
||||
def bust_cache
|
||||
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
|
||||
response.headers["Pragma"] = "no-cache"
|
||||
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
|
||||
response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
|
||||
response.headers['Pragma'] = 'no-cache'
|
||||
response.headers['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -109,9 +106,9 @@ module Page::BeforeFilters
|
|||
def update_view_count
|
||||
return true unless @page and @page.id
|
||||
action = case params[:action]
|
||||
when 'create' then :edit
|
||||
when 'edit' then :edit
|
||||
when 'show' then :view
|
||||
when 'create' then :edit
|
||||
when 'edit' then :edit
|
||||
when 'show' then :view
|
||||
end
|
||||
return true unless action
|
||||
|
||||
|
@ -123,9 +120,7 @@ module Page::BeforeFilters
|
|||
elsif @page.owner.is_a?(Group)
|
||||
group = @page.owner
|
||||
end
|
||||
if @page.owner.is_a?(User)
|
||||
user = @page.owner
|
||||
end
|
||||
user = @page.owner if @page.owner.is_a?(User)
|
||||
end
|
||||
Tracking::Page.insert(
|
||||
page: @page, current_user: current_user, action: action,
|
||||
|
@ -133,6 +128,4 @@ module Page::BeforeFilters
|
|||
)
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class Page::CreateController < ApplicationController
|
|||
# if the page controller is call by our custom DispatchController,
|
||||
# objects which have already been loaded will be passed to the tool
|
||||
# via this initialize method.
|
||||
def initialize(seed={})
|
||||
def initialize(seed = {})
|
||||
super()
|
||||
@user = seed[:user] # the user context, if any
|
||||
@group = seed[:group] # the group context, if any
|
||||
|
@ -66,9 +66,9 @@ class Page::CreateController < ApplicationController
|
|||
def catch_cancel
|
||||
if params[:cancel]
|
||||
redirect_to new_page_url(params.slice(:owner))
|
||||
return false
|
||||
false
|
||||
else
|
||||
return true
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -76,9 +76,9 @@ class Page::CreateController < ApplicationController
|
|||
# options for the form
|
||||
#
|
||||
def init_options
|
||||
@form_sections = ['title', 'summary', 'tags']
|
||||
@form_sections = %w[title summary tags]
|
||||
@multipart = false
|
||||
return true
|
||||
true
|
||||
end
|
||||
|
||||
def set_owner
|
||||
|
@ -119,30 +119,30 @@ class Page::CreateController < ApplicationController
|
|||
render template: 'page/create/new'
|
||||
end
|
||||
|
||||
# def create_page
|
||||
# begin
|
||||
# # create basic page instance
|
||||
# @page = build_new_page
|
||||
# def create_page
|
||||
# begin
|
||||
# # create basic page instance
|
||||
# @page = build_new_page
|
||||
|
||||
# # setup the data (done by subclasses)
|
||||
# @data = build_page_data
|
||||
# raise ActiveRecord::RecordInvalid.new(@data) if @data and !@data.valid?
|
||||
# # setup the data (done by subclasses)
|
||||
# @data = build_page_data
|
||||
# raise ActiveRecord::RecordInvalid.new(@data) if @data and !@data.valid?
|
||||
|
||||
# # save the page (also saves the data)
|
||||
# @page.data = @data
|
||||
# @page.save!
|
||||
# # save the page (also saves the data)
|
||||
# @page.data = @data
|
||||
# @page.save!
|
||||
|
||||
# # success!
|
||||
# return redirect_to(page_url(@page))
|
||||
# # success!
|
||||
# return redirect_to(page_url(@page))
|
||||
|
||||
# rescue exc
|
||||
# # failure!
|
||||
# destroy_page_data
|
||||
# # in case page gets saved before the exception happens
|
||||
# @page.destroy if @page and !@page.new_record?
|
||||
# raise exc
|
||||
# end
|
||||
# end
|
||||
# rescue exc
|
||||
# # failure!
|
||||
# destroy_page_data
|
||||
# # in case page gets saved before the exception happens
|
||||
# @page.destroy if @page and !@page.new_record?
|
||||
# raise exc
|
||||
# end
|
||||
# end
|
||||
|
||||
#
|
||||
# method to build the unsaved page object, with correct access.
|
||||
|
@ -154,9 +154,9 @@ class Page::CreateController < ApplicationController
|
|||
|
||||
def build_params
|
||||
page_params.merge access: access_param,
|
||||
share_with: params[:recipients],
|
||||
owner: @owner,
|
||||
user: current_user
|
||||
share_with: params[:recipients],
|
||||
owner: @owner,
|
||||
user: current_user
|
||||
end
|
||||
|
||||
def page_params
|
||||
|
@ -165,7 +165,7 @@ class Page::CreateController < ApplicationController
|
|||
|
||||
def access_param
|
||||
access = page_params[:access].to_s
|
||||
if %w/admin edit view/.include?(access)
|
||||
if %w[admin edit view].include?(access)
|
||||
access.to_sym
|
||||
else
|
||||
Conf.default_page_access
|
||||
|
@ -173,35 +173,32 @@ class Page::CreateController < ApplicationController
|
|||
end
|
||||
|
||||
def param_to_page_class(param)
|
||||
if param
|
||||
Page.param_id_to_class(param)
|
||||
end
|
||||
Page.param_id_to_class(param) if param
|
||||
end
|
||||
|
||||
#def extra_form_sections(options)
|
||||
# def extra_form_sections(options)
|
||||
# @extra_form_sections << options[:add] if options[:add]
|
||||
# @extra_form_sections.delete(options[:remove) if options[:remove]
|
||||
#end
|
||||
# end
|
||||
#
|
||||
#def remove_form_section(section)
|
||||
# def remove_form_section(section)
|
||||
# @basic_form_sections.delete(section)
|
||||
#end
|
||||
# end
|
||||
|
||||
# # returns a new data object for page initialization.
|
||||
# # subclasses override this to build their own data objects
|
||||
# def build_page_data
|
||||
# # if something goes terribly wrong with the data do this:
|
||||
# # @page.errors.add :base, I18n.t(:terrible_wrongness)
|
||||
# # raise ActiveRecord::RecordInvalid.new(@page)
|
||||
# # return new data if everything goes well
|
||||
# end
|
||||
|
||||
# # returns a new data object for page initialization.
|
||||
# # subclasses override this to build their own data objects
|
||||
# def build_page_data
|
||||
# # if something goes terribly wrong with the data do this:
|
||||
# # @page.errors.add :base, I18n.t(:terrible_wrongness)
|
||||
# # raise ActiveRecord::RecordInvalid.new(@page)
|
||||
# # return new data if everything goes well
|
||||
# end
|
||||
|
||||
# def destroy_page_data
|
||||
# if @data and !@data.new_record?
|
||||
# @data.destroy
|
||||
# end
|
||||
# end
|
||||
# def destroy_page_data
|
||||
# if @data and !@data.new_record?
|
||||
# @data.destroy
|
||||
# end
|
||||
# end
|
||||
|
||||
def setup_context
|
||||
case @owner
|
||||
|
@ -212,6 +209,4 @@ class Page::CreateController < ApplicationController
|
|||
end
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
class Page::DetailsController < Page::SidebarsController
|
||||
|
||||
# participation and share helpers can be removed if the corresponding
|
||||
# tabs end up getting removed from the details popup.
|
||||
helper 'page/owner', 'page/participation', 'page/share'
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def show; end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
class Page::HistoryController < Page::SidebarsController
|
||||
|
||||
before_filter :login_required
|
||||
|
||||
guard show: :may_edit_page?
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def show; end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,16 +6,14 @@
|
|||
#
|
||||
|
||||
class Page::ParticipationsController < Page::SidebarsController
|
||||
|
||||
guard :may_show_page?, actions: [:update, :create]
|
||||
guard :may_show_page?, actions: %i[update create]
|
||||
helper 'page/participation', 'page/share'
|
||||
|
||||
before_filter :fetch_data
|
||||
track_actions :update
|
||||
|
||||
# this is used for ajax pagination
|
||||
def index
|
||||
end
|
||||
def index; end
|
||||
|
||||
def update
|
||||
if params[:access]
|
||||
|
@ -67,7 +65,7 @@ class Page::ParticipationsController < Page::SidebarsController
|
|||
end
|
||||
end
|
||||
|
||||
def track_action(event = nil, event_options = nil)
|
||||
def track_action(_event = nil, _event_options = nil)
|
||||
super participation: participation
|
||||
end
|
||||
|
||||
|
@ -81,12 +79,10 @@ class Page::ParticipationsController < Page::SidebarsController
|
|||
# watching group participations.
|
||||
def fetch_data
|
||||
return unless params[:access] && params[:id]
|
||||
if params[:group] && params[:group]!= 'false'
|
||||
@part = @page.group_participations.find(params[:id])
|
||||
else
|
||||
@part = @page.user_participations.find(params[:id])
|
||||
end
|
||||
@part = if params[:group] && params[:group] != 'false'
|
||||
@page.group_participations.find(params[:id])
|
||||
else
|
||||
@page.user_participations.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class Page::PostsController < ApplicationController
|
|||
track_actions :create, :update, :destroy
|
||||
|
||||
# if something goes wrong with create, redirect to the page url.
|
||||
rescue_render create: lambda { |controller| redirect_to(page_url(@page)) }
|
||||
rescue_render create: ->(_controller) { redirect_to(page_url(@page)) }
|
||||
|
||||
# do we still want this?...
|
||||
# cache_sweeper :social_activities_sweeper, :only => :create
|
||||
|
@ -62,4 +62,3 @@ class Page::PostsController < ApplicationController
|
|||
super item: @post
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
# the page is private and they already have access.
|
||||
#
|
||||
class Page::SharesController < Page::SidebarsController
|
||||
|
||||
guard update: :may_share_page?
|
||||
|
||||
helper 'page/share', 'page/participation'
|
||||
|
@ -72,7 +71,7 @@ class Page::SharesController < Page::SidebarsController
|
|||
# Main Update Task
|
||||
#
|
||||
def notify_or_share
|
||||
if (params[:share_button] || params[:notify_button])
|
||||
if params[:share_button] || params[:notify_button]
|
||||
share = Page::Share.new(@page, current_user, share_options)
|
||||
@uparts, @gparts = share.with params[:recipients]
|
||||
@page.save!
|
||||
|
@ -97,7 +96,7 @@ class Page::SharesController < Page::SidebarsController
|
|||
|
||||
# we allow for an id of 0 for pages just getting created
|
||||
def fetch_page
|
||||
@page = Page.new if params['page_id'] == "0"
|
||||
@page = Page.new if params['page_id'] == '0'
|
||||
@page || super
|
||||
end
|
||||
|
||||
|
@ -107,7 +106,7 @@ class Page::SharesController < Page::SidebarsController
|
|||
|
||||
def add_recipients
|
||||
@recipients = build_recipient_array
|
||||
render partial: 'page/shares/add_recipient', locals: {alter_access: share?}
|
||||
render partial: 'page/shares/add_recipient', locals: { alter_access: share? }
|
||||
end
|
||||
|
||||
def add_recipients?
|
||||
|
@ -118,14 +117,14 @@ class Page::SharesController < Page::SidebarsController
|
|||
# After Filters
|
||||
#
|
||||
|
||||
def track_action(event = nil, options = {})
|
||||
def track_action(_event = nil, _options = {})
|
||||
@uparts.each do |part|
|
||||
if part.previous_changes.keys.include? "access"
|
||||
if part.previous_changes.keys.include? 'access'
|
||||
super('update_user_access', participation: part)
|
||||
end
|
||||
end
|
||||
@gparts.each do |part|
|
||||
if part.previous_changes.keys.include? "access"
|
||||
if part.previous_changes.keys.include? 'access'
|
||||
super('update_group_access', participation: part)
|
||||
end
|
||||
end
|
||||
|
@ -150,7 +149,7 @@ class Page::SharesController < Page::SidebarsController
|
|||
# a lot can go wrong: the name might not exist, you may not have permission,
|
||||
# the user might already have access, etc.
|
||||
#
|
||||
def find_recipient(recipient_name, action=:share)
|
||||
def find_recipient(recipient_name, action = :share)
|
||||
recipient_name.strip!
|
||||
return nil unless recipient_name.present?
|
||||
recipient = User.find_by_login(recipient_name) || Group.find_by_name(recipient_name)
|
||||
|
@ -172,7 +171,7 @@ class Page::SharesController < Page::SidebarsController
|
|||
end
|
||||
end
|
||||
end
|
||||
return recipient
|
||||
recipient
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -180,7 +179,7 @@ class Page::SharesController < Page::SidebarsController
|
|||
#
|
||||
# Utility Methods
|
||||
#
|
||||
SUCCESS_MESSAGES = { share: :shared_page_success, notify: :notify_success }
|
||||
SUCCESS_MESSAGES = { share: :shared_page_success, notify: :notify_success }.freeze
|
||||
|
||||
def notify_or_share_message
|
||||
SUCCESS_MESSAGES[mode_param]
|
||||
|
@ -188,7 +187,7 @@ class Page::SharesController < Page::SidebarsController
|
|||
|
||||
def mode_param
|
||||
mode = params[:mode]
|
||||
raise ErrorMessage, 'bad mode' unless ['notify', 'share'].include? mode
|
||||
raise ErrorMessage, 'bad mode' unless %w[notify share].include? mode
|
||||
mode.to_sym
|
||||
end
|
||||
|
||||
|
@ -198,7 +197,7 @@ class Page::SharesController < Page::SidebarsController
|
|||
|
||||
# convert {:checkbox => '1'} to {:checkbox => true}
|
||||
def convert_checkbox_boolean(hsh)
|
||||
hsh.each_pair do |key,val|
|
||||
hsh.each_pair do |key, val|
|
||||
if val == '0'
|
||||
hsh[key] = false
|
||||
elsif val == '1'
|
||||
|
@ -206,6 +205,4 @@ class Page::SharesController < Page::SidebarsController
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class Page::SidebarsController < ApplicationController
|
|||
end
|
||||
|
||||
def refresh_sidebar
|
||||
render template: 'page/sidebar/reset'
|
||||
render template: 'page/sidebar/reset'
|
||||
end
|
||||
|
||||
def fetch_page
|
||||
|
@ -35,5 +35,4 @@ class Page::SidebarsController < ApplicationController
|
|||
@upart = @page.participation_for_user(current_user)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Page::TagsController < Page::SidebarsController
|
||||
|
||||
helper 'page/tags'
|
||||
|
||||
def index
|
||||
|
@ -22,5 +21,4 @@ class Page::TagsController < Page::SidebarsController
|
|||
@page.save!
|
||||
refresh_sidebar
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
class Page::TitleController < Page::SidebarsController
|
||||
|
||||
guard :may_edit_page?
|
||||
track_actions :update
|
||||
|
||||
|
||||
# Return the edit title form. This is called by modalbox to load the popup contents.
|
||||
def edit
|
||||
end
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
@old_name = @page.name
|
||||
|
@ -17,6 +14,4 @@ class Page::TitleController < Page::SidebarsController
|
|||
@new_name = @page.name
|
||||
@page.save!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
class Page::TrashController < Page::SidebarsController
|
||||
|
||||
guard :may_admin_page?
|
||||
helper 'page/trash'
|
||||
track_actions :update
|
||||
|
||||
# loads popup
|
||||
def edit
|
||||
end
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if %w/delete destroy undelete/.include? params[:type]
|
||||
if %w[delete destroy undelete].include? params[:type]
|
||||
@page.public_send params[:type]
|
||||
else
|
||||
raise ErrorMessage, 'unknown type'
|
||||
|
@ -39,6 +37,4 @@ class Page::TrashController < Page::SidebarsController
|
|||
end
|
||||
end
|
||||
helper_method :new_url
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Person::BaseController < ApplicationController
|
||||
|
||||
before_filter :fetch_person
|
||||
before_filter :authorization_required
|
||||
|
||||
|
@ -18,6 +17,4 @@ class Person::BaseController < ApplicationController
|
|||
@context = Context.find(@user)
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class Person::DirectoryController < ApplicationController
|
|||
@query = params[:q] || params[:query]
|
||||
if @query.present?
|
||||
self.path += '/' unless path.ends_with? '/'
|
||||
self.path += "search/" unless path.ends_with? 'search/'
|
||||
self.path += 'search/' unless path.ends_with? 'search/'
|
||||
self.path += @query.strip
|
||||
end
|
||||
end
|
||||
|
@ -47,6 +47,4 @@ class Person::DirectoryController < ApplicationController
|
|||
'search'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
class Person::FriendRequestsController < Person::BaseController
|
||||
|
||||
before_filter :login_required
|
||||
|
||||
guard create: :may_request_contact?,
|
||||
new: :may_request_contact?,
|
||||
destroy: :may_remove_contact?
|
||||
new: :may_request_contact?,
|
||||
destroy: :may_remove_contact?
|
||||
|
||||
def new
|
||||
end
|
||||
def new; end
|
||||
|
||||
def create
|
||||
if params[:cancel]
|
||||
redirect_to entity_url(@user)
|
||||
else
|
||||
req = RequestToFriend.create! recipient: @user, created_by: current_user,
|
||||
message: params[:message]
|
||||
message: params[:message]
|
||||
if req.valid?
|
||||
success req
|
||||
create_notice req
|
||||
|
@ -37,5 +35,4 @@ class Person::FriendRequestsController < Person::BaseController
|
|||
def create_notice(request_obj)
|
||||
Notice::RequestNotice.create! request_obj
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
class Person::HomeController < Person::BaseController
|
||||
|
||||
guard :may_show_home?
|
||||
layout 'sidecolumn'
|
||||
|
||||
#
|
||||
# called by DispatchController
|
||||
#
|
||||
def initialize(options={})
|
||||
def initialize(options = {})
|
||||
super()
|
||||
@user = options[:user]
|
||||
end
|
||||
|
@ -15,6 +14,4 @@ class Person::HomeController < Person::BaseController
|
|||
@profile = @user.profiles.public
|
||||
track
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
class Person::PagesController < Person::BaseController
|
||||
|
||||
include_controllers 'common/page_search'
|
||||
guard :may_show_home?
|
||||
|
||||
def index
|
||||
@path = apply_path_modifiers( parsed_path() )
|
||||
@path = apply_path_modifiers(parsed_path)
|
||||
@pages = Page.paginate_by_path(@path, options_for_user(@user), pagination_params)
|
||||
render template: 'common/pages/search/index'
|
||||
end
|
||||
|
@ -13,10 +12,10 @@ class Person::PagesController < Person::BaseController
|
|||
|
||||
def setup_navigation(nav)
|
||||
nav[:local] = [
|
||||
{active: true, visible: true, html: {partial: 'common/pages/search/controls_active'}},
|
||||
{active: false, visible: true, html: {partial: 'common/pages/search/controls_possible'}}
|
||||
{ active: true, visible: true, html: { partial: 'common/pages/search/controls_active' } },
|
||||
{ active: false, visible: true, html: { partial: 'common/pages/search/controls_possible' } }
|
||||
]
|
||||
return nav
|
||||
nav
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -32,6 +31,4 @@ class Person::PagesController < Person::BaseController
|
|||
def show_filter?(filter)
|
||||
filter.section != :my_pages
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#
|
||||
|
||||
class PicturesController < ApplicationController
|
||||
|
||||
before_filter :fetch_picture
|
||||
|
||||
#
|
||||
|
@ -30,6 +29,4 @@ class PicturesController < ApplicationController
|
|||
@picture = Picture.find id.to_i
|
||||
@geometry = Picture::Geometry[params[:geometry]]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
class RootController < ApplicationController
|
||||
|
||||
layout 'notice'
|
||||
|
||||
def index
|
||||
redirect_to me_home_path if logged_in?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#
|
||||
|
||||
class SessionController < ApplicationController
|
||||
|
||||
layout 'notice'
|
||||
skip_before_filter :redirect_unverified_user
|
||||
|
||||
|
@ -21,8 +20,8 @@ class SessionController < ApplicationController
|
|||
def logout
|
||||
if logged_in?
|
||||
# i think the remember me stuff is a security flaw, so it is commented out for now:
|
||||
#self.current_user.forget_me if logged_in?
|
||||
#cookies.delete :auth_token
|
||||
# self.current_user.forget_me if logged_in?
|
||||
# cookies.delete :auth_token
|
||||
logout!
|
||||
success [:logout_success.t, :logout_success_message.t]
|
||||
end
|
||||
|
@ -39,8 +38,8 @@ class SessionController < ApplicationController
|
|||
# used for ajax login form.
|
||||
def login_form
|
||||
render partial: 'common/session/login_form',
|
||||
layout: false,
|
||||
content_type: "text/html"
|
||||
layout: false,
|
||||
content_type: 'text/html'
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -51,7 +50,7 @@ class SessionController < ApplicationController
|
|||
self.current_user = User.authenticate(params[:login], params[:password])
|
||||
|
||||
if current_user.language.present?
|
||||
session[:language_code] = self.current_user.language.to_sym
|
||||
session[:language_code] = current_user.language.to_sym
|
||||
else
|
||||
session[:language_code] = previous_language
|
||||
end
|
||||
|
|
|
@ -50,7 +50,6 @@ class StarsController < ApplicationController
|
|||
|
||||
def track_action
|
||||
super from: current_user, user: @starred.user,
|
||||
noticable: @starred
|
||||
noticable: @starred
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class StaticController < ActionController::Base
|
||||
|
||||
def greencloth
|
||||
# do not send a session cookie.
|
||||
request.session_options[:skip] = true
|
||||
|
|
|
@ -15,15 +15,14 @@
|
|||
# a nice stylesheet specific error message if there is a sass syntax error.
|
||||
#
|
||||
|
||||
|
||||
class ThemeController < ApplicationController
|
||||
include_controllers 'common/always_perform_caching'
|
||||
|
||||
attr_accessor :cache_css
|
||||
caches_page :show, if: Proc.new {|ctrl| ctrl.cache_css}
|
||||
caches_page :show, if: proc { |ctrl| ctrl.cache_css }
|
||||
|
||||
def show
|
||||
if stale?(@theme, file: @file, last_modified: css_last_modified)
|
||||
if stale?(@theme, file: @file, last_modified: css_last_modified)
|
||||
render :show, content_type: 'text/css', formats: [:css]
|
||||
end
|
||||
rescue Sass::SyntaxError => exc
|
||||
|
@ -41,13 +40,13 @@ class ThemeController < ApplicationController
|
|||
self.cache_css = true
|
||||
[params[:name], *params[:file]].each do |param|
|
||||
if param =~ /_refresh/
|
||||
param.sub!('_refresh','')
|
||||
param.sub!('_refresh', '')
|
||||
self.cache_css = false
|
||||
end
|
||||
end
|
||||
@theme = Crabgrass::Theme[params[:name]]
|
||||
@file = File.join(params[:file])
|
||||
@theme.clear_cache(@file) unless self.cache_css
|
||||
@theme.clear_cache(@file) unless cache_css
|
||||
end
|
||||
|
||||
def css_last_modified
|
||||
|
@ -56,7 +55,6 @@ class ThemeController < ApplicationController
|
|||
helper_method :css_last_modified
|
||||
|
||||
def css_updated_at
|
||||
Dir.glob("app/stylesheets/**/*").map{|f| File.mtime(f)}.max
|
||||
Dir.glob('app/stylesheets/**/*').map { |f| File.mtime(f) }.max
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
class Wiki::AssetsController < Wiki::BaseController
|
||||
|
||||
before_filter :fetch_assets, only: :new
|
||||
|
||||
def new
|
||||
end
|
||||
def new; end
|
||||
|
||||
def create
|
||||
asset = Asset.build uploaded_data: params[:asset][:uploaded_data], parent_page: @page
|
||||
|
@ -15,10 +13,9 @@ class Wiki::AssetsController < Wiki::BaseController
|
|||
protected
|
||||
|
||||
def fetch_assets
|
||||
@images = Asset.visible_to(current_user, @wiki.context).
|
||||
media_type(:image).
|
||||
most_recent.
|
||||
paginate(pagination_params(per_page: 3))
|
||||
@images = Asset.visible_to(current_user, @wiki.context)
|
||||
.media_type(:image)
|
||||
.most_recent
|
||||
.paginate(pagination_params(per_page: 3))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Wiki::BaseController < ApplicationController
|
||||
|
||||
before_filter :fetch_wiki
|
||||
|
||||
permissions 'wikis'
|
||||
|
@ -28,5 +27,4 @@ class Wiki::BaseController < ApplicationController
|
|||
@context = Context.find(@wiki.context) if @wiki.context
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Wiki::DiffsController < Wiki::BaseController
|
||||
|
||||
guard show: :may_show_wiki_diff?
|
||||
|
||||
helper 'wikis/versions'
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Wiki::LocksController < Wiki::BaseController
|
||||
|
||||
#
|
||||
# triggered when the user hits the 'cancel' or 'break lock' button
|
||||
# when given the wiki locked error
|
||||
|
@ -25,5 +24,4 @@ class Wiki::LocksController < Wiki::BaseController
|
|||
rescue Wiki::Sections::SectionNotFoundError
|
||||
head :not_found
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
class Wiki::VersionsController < Wiki::BaseController
|
||||
|
||||
guard revert: :may_revert_wiki_version?,
|
||||
destroy: :may_admin_wiki?
|
||||
destroy: :may_admin_wiki?
|
||||
|
||||
def show
|
||||
#unless request.xhr?
|
||||
# unless request.xhr?
|
||||
# params[:page] = @wiki.page_for_version(@version)
|
||||
# @versions = @wiki.versions.most_recent.paginate(pagination_params)
|
||||
#end
|
||||
# end
|
||||
end
|
||||
|
||||
def index
|
||||
|
@ -19,9 +18,9 @@ class Wiki::VersionsController < Wiki::BaseController
|
|||
redirect_to wiki_versions_path(@wiki)
|
||||
end
|
||||
|
||||
#def destroy
|
||||
# def destroy
|
||||
# what happened to this code?
|
||||
#end
|
||||
# end
|
||||
|
||||
protected
|
||||
|
||||
|
@ -30,14 +29,9 @@ class Wiki::VersionsController < Wiki::BaseController
|
|||
super
|
||||
return if action? :index
|
||||
@version = @wiki.find_version(params[:id])
|
||||
if params[:id].to_i > 1
|
||||
@former = @wiki.find_version(params[:id].to_i - 1)
|
||||
end
|
||||
@former = @wiki.find_version(params[:id].to_i - 1) if params[:id].to_i > 1
|
||||
rescue Wiki::VersionNotFoundError => ex
|
||||
error ex
|
||||
redirect_to action: :index
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class Wiki::WikisController < Wiki::BaseController
|
|||
|
||||
def show
|
||||
@wiki.last_seen_at = last_visit if last_visit
|
||||
render template: 'wiki/wikis/show' #, :locals => {:preview => params['preview']}
|
||||
render template: 'wiki/wikis/show' # , :locals => {:preview => params['preview']}
|
||||
end
|
||||
|
||||
def print
|
||||
|
@ -27,7 +27,7 @@ class Wiki::WikisController < Wiki::BaseController
|
|||
if @page.try.discussion
|
||||
@posts = @page.discussion.posts.visible.includes(:user)
|
||||
end
|
||||
render layout: "printer_friendly"
|
||||
render layout: 'printer_friendly'
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -38,7 +38,7 @@ class Wiki::WikisController < Wiki::BaseController
|
|||
Wiki::Lock.transaction do
|
||||
@wiki.lock!(@section, current_user)
|
||||
end
|
||||
render template: "wiki/wikis/edit"
|
||||
render template: 'wiki/wikis/edit'
|
||||
rescue Wiki::LockedError => @error_message
|
||||
render template: 'wiki/wikis/locked'
|
||||
end
|
||||
|
@ -97,6 +97,6 @@ class Wiki::WikisController < Wiki::BaseController
|
|||
end
|
||||
|
||||
def save?
|
||||
!cancel? && ( params[:save] || params[:force_save] )
|
||||
!cancel? && (params[:save] || params[:force_save])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,32 +4,30 @@
|
|||
#
|
||||
|
||||
module ApplicationHelper
|
||||
# include Crabgrass::Hook::Helper
|
||||
|
||||
# include Crabgrass::Hook::Helper
|
||||
# include Utility::CacheHelper
|
||||
# include Utility::GeneralHelper
|
||||
# include Utility::PermissionsHelper
|
||||
# include Utility::RouteHelper
|
||||
# include Utility::RssHelper
|
||||
# include Utility::TimeHelper
|
||||
|
||||
# include Utility::CacheHelper
|
||||
# include Utility::GeneralHelper
|
||||
# include Utility::PermissionsHelper
|
||||
# include Utility::RouteHelper
|
||||
# include Utility::RssHelper
|
||||
# include Utility::TimeHelper
|
||||
# include UI::FlashMessageHelper
|
||||
# include Ui::HelpHelper
|
||||
# include Ui::FormHelper
|
||||
|
||||
# include UI::FlashMessageHelper
|
||||
# include Ui::HelpHelper
|
||||
# include Ui::FormHelper
|
||||
|
||||
# include UI::ImageHelper
|
||||
# include UI::JavascriptHelper
|
||||
# include UI::LayoutHelper
|
||||
# include UI::LinkHelper
|
||||
# include UI::MenuHelper # deprecated
|
||||
# include UI::ModalboxHelper
|
||||
# include UI::PaginationHelper
|
||||
# include UI::PostHelper
|
||||
# include UI::SearchHelper
|
||||
# include UI::TabBarHelper # deprecated
|
||||
# include UI::TaggingHelper
|
||||
|
||||
# include Pages::PageHelper
|
||||
# include UI::ImageHelper
|
||||
# include UI::JavascriptHelper
|
||||
# include UI::LayoutHelper
|
||||
# include UI::LinkHelper
|
||||
# include UI::MenuHelper # deprecated
|
||||
# include UI::ModalboxHelper
|
||||
# include UI::PaginationHelper
|
||||
# include UI::PostHelper
|
||||
# include UI::SearchHelper
|
||||
# include UI::TabBarHelper # deprecated
|
||||
# include UI::TaggingHelper
|
||||
|
||||
# include Pages::PageHelper
|
||||
end
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue