diff --git a/.travis.yml b/.travis.yml index 8baba4031..3f217b6be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: ruby rvm: - - "2.0.0" + - "2.3.0" # - "1.9.2" # uncomment this line if your project needs to run something other than `rake`: # script: bundle exec rspec spec before_script: - - mysql -e 'create database browsercms_test;' \ No newline at end of file + - mysql -e 'create database browsercms_test;' diff --git a/Gemfile b/Gemfile index ef339913c..1c0a38e06 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -ruby '2.3.3' +ruby '2.5.8' # Load this project as a gem. gemspec @@ -25,16 +25,17 @@ end group :development do gem 'rake' # gem 'debugger' - gem 'quiet_assets' + # gem 'quiet_assets' gem 'better_errors' gem 'binding_of_caller' gem 'pry' end group :test, :development do - gem 'minitest', '~>5.3.3' + gem 'minitest' gem "test-unit", "~> 3.0" - gem 'minitest-rails', '~>2.0.0' + gem 'minitest-rails' gem 'minitest-reporters', '~>1.0.0' + gem 'rails-controller-testing' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index d098f844b..e7ce4303f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,20 +1,21 @@ PATH remote: . specs: - browsercms (4.2.8.rc1) - actionpack-page_caching (~> 1.2.4) + browsercms (5.0.2.rc1) + actionpack-page_caching (~> 1.0) ancestry (~> 2.0.0) bootstrap-sass + ckeditor_rails compass-rails (~> 3.0.0) - devise (~> 4.7.1) - jquery-rails - jquery-ui-rails + devise (~> 4.7.0) + jquery-rails (~> 4.3.1) + jquery-ui-rails (= 6.0.1) panoramic - paperclip - rails (~> 4.2.0) + paperclip (= 6.0.0) + rails (~> 5.0.2) sass-rails sassc (~> 2.1.0) - simple_form (~> 3.1.0) + simple_form (~> 3.3.0) term-ansicolor underscore-rails (~> 1.4) will_paginate (~> 3.0.0) @@ -22,48 +23,51 @@ PATH GEM remote: http://rubygems.org/ specs: - actionmailer (4.2.8) - actionpack (= 4.2.8) - actionview (= 4.2.8) - activejob (= 4.2.8) + actioncable (5.0.7.2) + actionpack (= 5.0.7.2) + nio4r (>= 1.2, < 3.0) + websocket-driver (~> 0.6.1) + actionmailer (5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.8) - actionview (= 4.2.8) - activesupport (= 4.2.8) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.0.7.2) + actionview (= 5.0.7.2) + activesupport (= 5.0.7.2) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) actionpack-page_caching (1.2.4) actionpack (>= 4.0.0) - actionview (4.2.8) - activesupport (= 4.2.8) + actionview (5.0.7.2) + activesupport (= 5.0.7.2) builder (~> 3.1) erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.8) - activesupport (= 4.2.8) - globalid (>= 0.3.0) - activemodel (4.2.8) - activesupport (= 4.2.8) - builder (~> 3.1) - activerecord (4.2.8) - activemodel (= 4.2.8) - activesupport (= 4.2.8) - arel (~> 6.0) - activesupport (4.2.8) - i18n (~> 0.7) + activejob (5.0.7.2) + activesupport (= 5.0.7.2) + globalid (>= 0.3.6) + activemodel (5.0.7.2) + activesupport (= 5.0.7.2) + activerecord (5.0.7.2) + activemodel (= 5.0.7.2) + activesupport (= 5.0.7.2) + arel (~> 7.0) + activesupport (5.0.7.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.5.0) public_suffix (~> 2.0, >= 2.0.2) ancestry (2.0.0) activerecord (>= 3.0.0) ansi (1.5.0) - arel (6.0.4) + arel (7.1.4) aruba (0.14.2) childprocess (~> 0.5.6) contracts (~> 0.9) @@ -71,8 +75,8 @@ GEM ffi (~> 1.9.10) rspec-expectations (>= 2.99) thor (~> 0.19) - autoprefixer-rails (9.8.6) - execjs + autoprefixer-rails (10.3.3.0) + execjs (~> 2) bcrypt (3.1.16) better_errors (2.1.1) coderay (>= 1.0.0) @@ -84,7 +88,7 @@ GEM bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) - builder (3.2.3) + builder (3.2.4) capybara (2.13.0) addressable mime-types (>= 1.16) @@ -95,6 +99,8 @@ GEM childprocess (0.5.9) ffi (~> 1.0, >= 1.0.11) chunky_png (1.4.0) + ckeditor_rails (4.10.0) + railties (>= 3.0) climate_control (0.2.0) cliver (0.3.2) coderay (1.1.1) @@ -114,8 +120,9 @@ GEM compass (~> 1.0.0) sass-rails (< 5.1) sprockets (< 4.0) - concurrent-ruby (1.0.5) + concurrent-ruby (1.1.9) contracts (0.15.0) + crass (1.0.6) cucumber (2.4.0) builder (>= 2.1.2) cucumber-core (~> 1.5.0) @@ -153,10 +160,11 @@ GEM railties (>= 3.0.0) ffi (1.9.18) gherkin (4.1.1) - globalid (0.4.2) - activesupport (>= 4.2.0) - i18n (0.8.1) - jquery-rails (4.4.0) + globalid (0.5.2) + activesupport (>= 5.0) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) @@ -164,7 +172,8 @@ GEM railties (>= 3.2.16) launchy (2.4.3) addressable (~> 2.3) - loofah (2.0.3) + loofah (2.12.0) + crass (~> 1.0.2) nokogiri (>= 1.5.9) m (1.5.0) method_source (>= 0.6.7) @@ -180,11 +189,11 @@ GEM nokogiri (~> 1) rake mini_mime (1.1.1) - mini_portile2 (2.1.0) - minitest (5.3.5) - minitest-rails (2.0.3) - minitest (>= 5.3.3, < 6.0) - railties (~> 4.1) + mini_portile2 (2.6.1) + minitest (5.14.4) + minitest-rails (3.0.0) + minitest (~> 5.8) + railties (~> 5.0) minitest-reporters (1.0.20) ansi builder @@ -195,12 +204,14 @@ GEM multi_json (1.12.1) multi_test (0.1.2) mysql2 (0.4.5) - nokogiri (1.6.8.1) - mini_portile2 (~> 2.1.0) + nio4r (2.5.8) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) + racc (~> 1.4) orm_adapter (0.5.0) - panoramic (0.0.7) - rails (~> 4) - paperclip (6.1.0) + panoramic (0.0.6) + rails (>= 3.0.7) + paperclip (6.0.0) activemodel (>= 4.2.0) activesupport (>= 4.2.0) mime-types @@ -216,42 +227,44 @@ GEM method_source (~> 0.8.1) slop (~> 3.4) public_suffix (2.0.5) - quiet_assets (1.1.0) - railties (>= 3.1, < 5.0) - rack (1.6.5) + racc (1.5.2) + rack (2.2.3) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.8) - actionmailer (= 4.2.8) - actionpack (= 4.2.8) - actionview (= 4.2.8) - activejob (= 4.2.8) - activemodel (= 4.2.8) - activerecord (= 4.2.8) - activesupport (= 4.2.8) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.8) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.8) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - railties (4.2.8) - actionpack (= 4.2.8) - activesupport (= 4.2.8) + rails (5.0.7.2) + actioncable (= 5.0.7.2) + actionmailer (= 5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) + activemodel (= 5.0.7.2) + activerecord (= 5.0.7.2) + activesupport (= 5.0.7.2) + bundler (>= 1.3.0) + railties (= 5.0.7.2) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.1) + actionpack (~> 5.x) + actionview (~> 5.x) + activesupport (~> 5.x) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.4.2) + loofah (~> 2.3) + railties (5.0.7.2) + actionpack (= 5.0.7.2) + activesupport (= 5.0.7.2) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (12.0.0) + rake (13.0.6) rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) - responders (2.4.1) - actionpack (>= 4.2.0, < 6.0) - railties (>= 4.2.0, < 6.0) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) rspec-expectations (3.5.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.5.0) @@ -267,9 +280,9 @@ GEM tilt (>= 1.1, < 3) sassc (2.1.0) ffi (~> 1.9) - simple_form (3.1.1) - actionpack (~> 4.0) - activemodel (~> 4.0) + simple_form (3.3.1) + actionpack (> 4, < 5.1) + activemodel (> 4, < 5.1) single_test (0.6.0) rake slop (3.6.0) @@ -294,18 +307,18 @@ GEM daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (0.19.4) + thor (0.20.3) thread_safe (0.3.6) tilt (2.0.7) tins (1.29.1) sync - tzinfo (1.2.2) + tzinfo (1.2.9) thread_safe (~> 0.1) uglifier (3.1.9) execjs (>= 0.3.0, < 3) underscore-rails (1.8.3) - warden (1.2.7) - rack (>= 1.0) + warden (1.2.9) + rack (>= 2.0.9) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) @@ -330,14 +343,14 @@ DEPENDENCIES factory_girl_rails (= 3.3.0) launchy m (~> 1.2) - minitest (~> 5.3.3) - minitest-rails (~> 2.0.0) + minitest + minitest-rails minitest-reporters (~> 1.0.0) mocha mysql2 poltergeist pry - quiet_assets + rails-controller-testing rake ruby-prof sass-rails (~> 5.0.0) @@ -350,7 +363,7 @@ DEPENDENCIES yard RUBY VERSION - ruby 2.3.3p222 + ruby 2.5.8p224 BUNDLED WITH 1.17.3 diff --git a/Rakefile b/Rakefile index 1c5d548a8..687c5c5a4 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ #!/usr/bin/env rake begin + $arel_silence_type_casting_deprecation=true require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' @@ -104,7 +105,7 @@ def run_tests(tests_to_run) end # Build and run against MySQL. -task 'ci:test' => ['project:setup:mysql', 'db:drop', 'db:create:all', 'db:install', 'test'] +task 'ci:test' => [ 'project:setup:mysql', 'db:drop', 'db:create:all', 'db:install', 'test'] task :default => 'ci:test' require 'yard' diff --git a/app/assets/javascripts/bcms/ckeditor.js b/app/assets/javascripts/bcms/ckeditor.js index ef3c57562..baca3b703 100644 --- a/app/assets/javascripts/bcms/ckeditor.js +++ b/app/assets/javascripts/bcms/ckeditor.js @@ -3,4 +3,7 @@ // See /assets/ckeditor/config.js for default configuration. // //= require rich +//= require ckeditor-jquery +//= require bcms/ckeditor_load +//= require bcms/ckeditor_standard_config diff --git a/app/assets/stylesheets/cms/application.scss b/app/assets/stylesheets/cms/application.scss index a2ee1524f..f3e570448 100644 --- a/app/assets/stylesheets/cms/application.scss +++ b/app/assets/stylesheets/cms/application.scss @@ -1,6 +1,11 @@ @charset "utf-8"; $experimental-support-for-khtml: false; +@import "compass/reset"; +@import "compass/css3"; +@import "compass/typography"; +@import "compass/css3/box"; + // Basic items for making modals work @import "bootstrap/mixins"; @import "bootstrap/variables"; @@ -27,6 +32,12 @@ $experimental-support-for-khtml: false; @import 'cms/styles/_glyph'; +/* IMPORTS JQUERY-UI CSS FROM GEM */ +@import "/assets/jquery.ui.core.css"; +@import "/assets/jquery.ui.datepicker.css"; +@import "/assets/jquery.ui.theme.css"; + + /* PAGE STYLE & LAYOUT IMPORTS */ diff --git a/app/assets/stylesheets/cms/style.scss b/app/assets/stylesheets/cms/style.scss index eada1e886..8685cce6b 100644 --- a/app/assets/stylesheets/cms/style.scss +++ b/app/assets/stylesheets/cms/style.scss @@ -1,9 +1,15 @@ @charset "utf-8"; $experimental-support-for-khtml: false; +@import "compass/reset"; +@import "compass/css3"; +@import "compass/typography"; +@import "compass/css3/box"; + @import "includes/_rem.scss"; @import "includes/_animation.scss"; + /* COLORS & MIX-INS */ @mixin breakpoint($point) { @if $point == large { diff --git a/app/controllers/cms/base_controller.rb b/app/controllers/cms/base_controller.rb index 690eedaa2..6bc067fb8 100644 --- a/app/controllers/cms/base_controller.rb +++ b/app/controllers/cms/base_controller.rb @@ -1,9 +1,9 @@ module Cms class BaseController < Cms::ApplicationController - before_filter :redirect_to_cms_site + before_action :redirect_to_cms_site before_action :authenticate_cms_user! - before_filter :cms_access_required + before_action :cms_access_required layout 'cms/application' @@ -19,4 +19,4 @@ def self.allow_guests_to(methods) end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/connectors_controller.rb b/app/controllers/cms/connectors_controller.rb index 140d5dabe..7b9d50886 100644 --- a/app/controllers/cms/connectors_controller.rb +++ b/app/controllers/cms/connectors_controller.rb @@ -1,7 +1,7 @@ module Cms class ConnectorsController < Cms::BaseController - - before_filter :load_page, :only => [:new, :create] + + before_action :load_page, :only => [:new, :create] def new @block_type = ContentType.find_by_key(params[:block_type] || session[:last_block_type] || 'html_block') @@ -67,4 +67,4 @@ def load_page end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/content_block_controller.rb b/app/controllers/cms/content_block_controller.rb index e88dfa168..4525efb3d 100644 --- a/app/controllers/cms/content_block_controller.rb +++ b/app/controllers/cms/content_block_controller.rb @@ -166,9 +166,8 @@ def resource end # methods for loading one or a collection of blocks - def load_blocks - @search_filter = SearchFilter.build(params[:search_filter], model_class) + @search_filter = SearchFilter.build(search_params, model_class) options = {} @@ -184,11 +183,15 @@ def load_blocks scope = scope.with_parent_id(params[:section_id]) end @total_number_of_items = scope.count - @blocks = scope.paginate(options) + @blocks = scope.paginate(:page=>options[:page]).order(options[:order]) check_permissions end + def search_params + params[:search_filter].permit(:term) if params[:search_filter].present? + end + def load_block find_block check_permissions @@ -269,7 +272,7 @@ def update_block def model_params defaults = {"publish_on_save" => false} model_params = params[model_form_name] - defaults.merge(model_params) + defaults.merge(model_params.to_unsafe_h) end def after_update_on_success diff --git a/app/controllers/cms/content_controller.rb b/app/controllers/cms/content_controller.rb index 58bed6dcb..4d5add839 100644 --- a/app/controllers/cms/content_controller.rb +++ b/app/controllers/cms/content_controller.rb @@ -8,15 +8,15 @@ class ContentController < Cms::ApplicationController include Cms::MobileAware helper MobileHelper - skip_before_filter :redirect_to_cms_site - before_filter :redirect_non_cms_users_to_public_site, :only => [:show, :show_page_route] - before_filter :construct_path, :only => [:show] - before_filter :construct_path_from_route, :only => [:show_page_route] - before_filter :try_to_redirect, :only => [:show] - before_filter :try_to_stream_file, :only => [:show] - before_filter :load_page, :only => [:show, :show_page_route] - before_filter :check_access_to_page, :except => [:edit, :preview] - before_filter :select_cache_directory + #skip_before_filter :redirect_to_cms_site + before_action :redirect_non_cms_users_to_public_site, :only => [:show, :show_page_route] + before_action :construct_path, :only => [:show] + before_action :construct_path_from_route, :only => [:show_page_route] + before_action :try_to_redirect, :only => [:show] + before_action :try_to_stream_file, :only => [:show] + before_action :load_page, :only => [:show, :show_page_route] + before_action :check_access_to_page, :except => [:edit, :preview] + before_action :select_cache_directory self.responder = Cms::ContentResponder @@ -64,12 +64,11 @@ def assign(key, value) end private - def render_editing_frame @page_title = @page.page_title # Adds all provided parameters to the iframe - @edit_page_path = ActionDispatch::Http::URL.url_for(path: edit_content_path(current_page), params: params.except(:controller, :action, :path), only_path: true) + @edit_page_path = edit_content_path(current_page, params.except(:controller, :action, :path).permit! ) render 'editing_frame', :layout => 'cms/page_editor' end diff --git a/app/controllers/cms/dynamic_views_controller.rb b/app/controllers/cms/dynamic_views_controller.rb index 90aab2c69..f91fa648f 100644 --- a/app/controllers/cms/dynamic_views_controller.rb +++ b/app/controllers/cms/dynamic_views_controller.rb @@ -4,7 +4,7 @@ class DynamicViewsController < Cms::BaseController include Cms::AdminTab check_permissions :administrate - before_filter :load_view, :only => [:show, :edit, :update, :destroy] + before_action :load_view, :only => [:show, :edit, :update, :destroy] helper_method :dynamic_view_type diff --git a/app/controllers/cms/form_entries_controller.rb b/app/controllers/cms/form_entries_controller.rb index a73000f77..428170018 100644 --- a/app/controllers/cms/form_entries_controller.rb +++ b/app/controllers/cms/form_entries_controller.rb @@ -55,7 +55,7 @@ def index # Allows us to use the content_block/index view @content_type = FauxContentType.new(@form) - @search_filter = SearchFilter.build(params[:search_filter], Cms::FormEntry) + @search_filter = SearchFilter.build(search_params, Cms::FormEntry) @blocks = Cms::FormEntry.where(form_id: params[:id]).search(@search_filter.term).paginate({page: params[:page], order: params[:order]}) @entry = Cms::FormEntry.for(@form) @@ -100,6 +100,10 @@ def save_entry_failure protected + def search_params + params[:search_filter].permit(:term) if params[:search_filter].present? + end + def find_form_and_populate_entry @form = Cms::Form.find(params[:form_id]) @entry = Cms::FormEntry.for(@form) @@ -137,4 +141,4 @@ def content_type end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/forms_controller.rb b/app/controllers/cms/forms_controller.rb index 797be0139..6aaf3af9c 100644 --- a/app/controllers/cms/forms_controller.rb +++ b/app/controllers/cms/forms_controller.rb @@ -1,7 +1,7 @@ class Cms::FormsController < Cms::ContentBlockController - before_filter :associate_form_fields, only: [:create, :update] - before_filter :strip_new_entry_params, only: [:create, :update] + before_action :associate_form_fields, only: [:create, :update] + before_action :strip_new_entry_params, only: [:create, :update] helper do # For new forms, if the user doesn't complete and save them, we need to delete them from the database. diff --git a/app/controllers/cms/links_controller.rb b/app/controllers/cms/links_controller.rb index ea668b59b..b35b53f3a 100644 --- a/app/controllers/cms/links_controller.rb +++ b/app/controllers/cms/links_controller.rb @@ -1,9 +1,9 @@ module Cms class LinksController < Cms::BaseController - before_filter :load_section, :only => [:new, :create, :move_to] - before_filter :load_link, :only => [:destroy, :update] - before_filter :load_draft_link, :only => [:edit] + before_action :load_section, :only => [:new, :create, :move_to] + before_action :load_link, :only => [:destroy, :update] + before_action :load_draft_link, :only => [:edit] include Cms::PublishWorkflow @@ -78,4 +78,4 @@ def load_draft_link end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/page_components_controller.rb b/app/controllers/cms/page_components_controller.rb index ce0a326ce..71d1f4717 100644 --- a/app/controllers/cms/page_components_controller.rb +++ b/app/controllers/cms/page_components_controller.rb @@ -2,7 +2,6 @@ module Cms class PageComponentsController < Cms::ApplicationController layout false respond_to :json - def new @default_type = Cms::ContentType.default @content_types = Cms::ContentType.other_connectables @@ -17,4 +16,4 @@ def update end end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/page_route_options_controller.rb b/app/controllers/cms/page_route_options_controller.rb index 6ff5f9c7e..363e1a8b6 100644 --- a/app/controllers/cms/page_route_options_controller.rb +++ b/app/controllers/cms/page_route_options_controller.rb @@ -1,8 +1,8 @@ module Cms class PageRouteOptionsController < Cms::BaseController - before_filter :load_page_route - before_filter :load_model, :only => [:edit, :update, :destroy] + before_action :load_page_route + before_action :load_model, :only => [:edit, :update, :destroy] def new @model = resource.new @@ -55,4 +55,4 @@ def object_name end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/page_routes_controller.rb b/app/controllers/cms/page_routes_controller.rb index f394bfdfb..fe2b0248d 100644 --- a/app/controllers/cms/page_routes_controller.rb +++ b/app/controllers/cms/page_routes_controller.rb @@ -1,7 +1,7 @@ module Cms class PageRoutesController < Cms::BaseController - before_filter :load_page_route, :only => [:edit, :update, :destroy] + before_action :load_page_route, :only => [:edit, :update, :destroy] def index @page_routes = PageRoute.paginate(:page => params[:page]).order("name") @@ -48,4 +48,4 @@ def page_route_params end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/pages_controller.rb b/app/controllers/cms/pages_controller.rb index 375435096..26c9c710c 100644 --- a/app/controllers/cms/pages_controller.rb +++ b/app/controllers/cms/pages_controller.rb @@ -3,10 +3,10 @@ class PagesController < Cms::BaseController helper Cms::RenderingHelper - before_filter :load_section, :only => [:new, :create] - before_filter :load_page, :only => [:versions, :version, :revert_to, :destroy] - before_filter :load_draft_page, :only => [:edit, :update] - before_filter :hide_toolbar, :only => [:new, :create] + before_action :load_section, :only => [:new, :create] + before_action :load_page, :only => [:versions, :version, :revert_to, :destroy] + before_action :load_draft_page, :only => [:edit, :update] + before_action :hide_toolbar, :only => [:new, :create] before_action :strip_visibility_params, :only => [:create, :update] include Cms::PublishWorkflow @@ -148,4 +148,4 @@ def load_templates end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/portlet_controller.rb b/app/controllers/cms/portlet_controller.rb index 150ddc56b..285bd221d 100644 --- a/app/controllers/cms/portlet_controller.rb +++ b/app/controllers/cms/portlet_controller.rb @@ -1,7 +1,7 @@ module Cms class PortletController < Cms::ApplicationController - skip_before_filter :redirect_to_cms_site + skip_before_action :redirect_to_cms_site if self.respond_to?(:redirect_to_cms_site) def execute_handler @portlet = Portlet.find(params[:id]) @@ -16,6 +16,14 @@ def execute_handler end + # Adding this here temporarily to get tests to pass. Makes little sense as this is skipping this method + # but for some reason this method is not defined within the portlet controller. + def redirect_to_cms_site + if using_cms_subdomains? && !request_is_for_cms_subdomain? + redirect_to(url_with_cms_domain_prefix) + end + end + end end diff --git a/app/controllers/cms/sections_controller.rb b/app/controllers/cms/sections_controller.rb index adcf8f0ae..395c64f4a 100644 --- a/app/controllers/cms/sections_controller.rb +++ b/app/controllers/cms/sections_controller.rb @@ -1,8 +1,8 @@ module Cms class SectionsController < Cms::BaseController - before_filter :load_parent, :only => [:new, :create] - before_filter :load_section, :only => [:edit, :update, :destroy, :move] + before_action :load_parent, :only => [:new, :create] + before_action :load_section, :only => [:edit, :update, :destroy, :move] helper_method :public_groups helper_method :cms_groups @@ -97,4 +97,4 @@ def cms_groups end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/sessions_controller.rb b/app/controllers/cms/sessions_controller.rb index 05990530c..3171b302f 100644 --- a/app/controllers/cms/sessions_controller.rb +++ b/app/controllers/cms/sessions_controller.rb @@ -2,7 +2,7 @@ module Cms # Handles the login/logout function of the site. class SessionsController < Devise::SessionsController include Cms::AdminController - before_filter :redirect_to_cms_site, :only => [:new] + before_action :redirect_to_cms_site, :only => [:new] layout 'cms/application' @@ -12,4 +12,4 @@ def new end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/tasks_controller.rb b/app/controllers/cms/tasks_controller.rb index ae41a922f..85c73ff47 100644 --- a/app/controllers/cms/tasks_controller.rb +++ b/app/controllers/cms/tasks_controller.rb @@ -1,7 +1,7 @@ module Cms class TasksController < Cms::BaseController - before_filter :load_page, :only => [:new, :create] + before_action :load_page, :only => [:new, :create] def new @task = @page.tasks.build(:assigned_by => current_user) @@ -53,4 +53,4 @@ def load_page end end -end \ No newline at end of file +end diff --git a/app/controllers/cms/users_controller.rb b/app/controllers/cms/users_controller.rb index 80adee0f3..3d8a825a4 100644 --- a/app/controllers/cms/users_controller.rb +++ b/app/controllers/cms/users_controller.rb @@ -3,26 +3,25 @@ class UsersController < Cms::ResourceController include Cms::AdminTab check_permissions :administrate, :except => [:change_password, :update_password] - before_filter :only_self_or_administrator, :only => [:change_password, :update_password] - after_filter :update_flash, :only => [:update] - + before_action :only_self_or_administrator, :only => [:change_password, :update_password] + after_action :update_flash, :only => [:update] def index @have_external_users = Cms::ExternalUser.count > 0 query, conditions = [], [] - unless params[:show_expired] + if params[:show_expired] != "yes" query << "expires_at IS NULL OR expires_at >= ?" conditions << Time.now.utc end - unless params[:key_word].blank? + if !params[:key_word].blank? query << %w(login email first_name last_name).collect { |f| "lower(#{f}) LIKE lower(?)" }.join(" OR ") 4.times { conditions << "%#{params[:key_word]}%" } end - unless params[:group_id].to_i == 0 + if params[:group_id].present? && params[:group_id] != 0 query << "#{UserGroupMembership.table_name}.group_id = ?" conditions << params[:group_id] end @@ -32,7 +31,11 @@ def index per_page = params[:per_page] || 10 page_num = params[:page] ? params[:page].to_i : 1 - @users = PersistentUser.where(conditions).paginate(page: page_num, per_page: per_page).includes(:user_group_memberships).references(:user_group_memberships).order("first_name, last_name, email") + if conditions.count==1 && conditions.first.blank? + @users = PersistentUser.all.paginate(page: page_num, per_page: per_page).includes(:user_group_memberships).references(:user_group_memberships).order("first_name, last_name, email") + else + @users = PersistentUser.where(conditions).paginate(page: page_num, per_page: per_page).includes(:user_group_memberships).references(:user_group_memberships).order("first_name, last_name, email") + end end def new @@ -122,4 +125,4 @@ def only_self_or_administrator raise Cms::Errors::AccessDenied if !current_user.able_to?(:administrate) && params[:id].to_i != current_user.id end end -end \ No newline at end of file +end diff --git a/app/controllers/tests/pretend_controller.rb b/app/controllers/tests/pretend_controller.rb index 4839efad9..3d0c4f2bd 100644 --- a/app/controllers/tests/pretend_controller.rb +++ b/app/controllers/tests/pretend_controller.rb @@ -11,11 +11,11 @@ class Tests::PretendController < ApplicationController RESTRICTED_H1 = "Restricted" def restricted - render :text =>"

#{RESTRICTED_H1}

You can see this restricted page." + render plain: "

#{RESTRICTED_H1}

You can see this restricted page." end def open - render :text =>"

Open Page

You can see this public page." + render plain: "

Open Page

You can see this public page." end def error diff --git a/app/helpers/cms/page_helper.rb b/app/helpers/cms/page_helper.rb index bcd7edd7c..eb980ea8f 100644 --- a/app/helpers/cms/page_helper.rb +++ b/app/helpers/cms/page_helper.rb @@ -28,7 +28,7 @@ module PageHelper # Ideally, this could be improved if sprockets allows for dynamically determining which js library to use. # @return [String] Names of the JS file needed to load the editor. def cms_content_editor - "bcms/#{Cms.content_editor}" + "/assets/bcms/#{Cms.content_editor}" end # Outputs the title for this page. Used by both internal CMS pages, as well as page templates. Call use_page_title to diff --git a/app/helpers/cms/path_helper.rb b/app/helpers/cms/path_helper.rb index 3ef192b25..59ae12a9f 100644 --- a/app/helpers/cms/path_helper.rb +++ b/app/helpers/cms/path_helper.rb @@ -34,7 +34,7 @@ def sortable_column_path(content_type, column_to_sort) filtered_params.delete(:action) filtered_params.delete(:controller) filtered_params.merge!(:order => determine_order(filtered_params[:order], column_to_sort)) - polymorphic_path(engine_aware_path(content_type.model_class), filtered_params) + polymorphic_path(engine_aware_path(content_type.model_class), filtered_params.to_unsafe_h) end def link_to_usages(block) diff --git a/app/models/cms/guest_user.rb b/app/models/cms/guest_user.rb index f25338afd..0fd9bbd91 100644 --- a/app/models/cms/guest_user.rb +++ b/app/models/cms/guest_user.rb @@ -13,7 +13,7 @@ def initialize(attributes={}) end def able_to?(*name) - group && group.permissions.where("name in (?)", name.map(&:to_s)).count > 0 + group && group&.permissions&.collect(&:name).include?(name) end # Guests never get access to the CMS. @@ -54,4 +54,4 @@ def save(perform_validation=true) end end -end \ No newline at end of file +end diff --git a/app/models/cms/page.rb b/app/models/cms/page.rb index 03e95673f..912bcaf68 100644 --- a/app/models/cms/page.rb +++ b/app/models/cms/page.rb @@ -302,11 +302,10 @@ def append_leading_slash_to_path self.path = "/#{path}" end end - # remove trailing slash, unless the path is only a slash. uses capture and # substition because ruby regex engine does not support lookbehind def remove_trailing_slash_from_path - self.path.sub!(/(.+)\/+$/, '\1') + self.path = self.path.sub(/(.+)\/+$/, '\1') end def path_not_reserved diff --git a/app/models/cms/persistent_user.rb b/app/models/cms/persistent_user.rb index b2fb449bb..c0aee9752 100644 --- a/app/models/cms/persistent_user.rb +++ b/app/models/cms/persistent_user.rb @@ -25,7 +25,7 @@ class PersistentUser < ActiveRecord::Base validates_presence_of :login validates_uniqueness_of :login, :case_sensitive => false - validates_format_of :login, :with => /\A\w[\w\.\-_@]+\z/, :message => "use only letters, numbers, and .-_@ please.", unless: proc { |c| c.is_a? Member } + validates_format_of :login, :with => /\A\w[\w\.\-_@]+\z/, :message => "use only letters, numbers, and .-_@ please." # Class Methods class << self @@ -206,4 +206,4 @@ def able_to_edit_or_publish_content? end end -end \ No newline at end of file +end diff --git a/app/models/cms/search_filter.rb b/app/models/cms/search_filter.rb index 353697f77..d294135ae 100644 --- a/app/models/cms/search_filter.rb +++ b/app/models/cms/search_filter.rb @@ -4,7 +4,6 @@ class SearchFilter include ::ActiveModel::Model attr_accessor :model_class, :term - def self.build(params_hash, model_class) model = self.new(params_hash) model.model_class = model_class @@ -15,4 +14,4 @@ def path model_class end end -end \ No newline at end of file +end diff --git a/app/models/cms/view_context.rb b/app/models/cms/view_context.rb index 8030759e9..c98f162d8 100644 --- a/app/models/cms/view_context.rb +++ b/app/models/cms/view_context.rb @@ -39,7 +39,7 @@ def initialize(controller, attributes_to_assign) # We want content_for to be called on the controller's view, not this inner view def content_for(name, content=nil, &block) - Rails.logger.info "content_for(#{name}, #{content}, block) called." + Rails.logger.warn "content_for(#{name}, #{content}, block) called." @controller.instance_variable_get("@template").content_for(name, content, &block) end diff --git a/app/portlets/dynamic_portlet.rb b/app/portlets/dynamic_portlet.rb index c6de2d723..1d16827ad 100644 --- a/app/portlets/dynamic_portlet.rb +++ b/app/portlets/dynamic_portlet.rb @@ -4,4 +4,8 @@ def render eval(@portlet.code) unless @portlet.code.blank? end + def attributes=(new_attributes, guard_protected_attributes = true) + self.assign_attributes(new_attributes) + end + end diff --git a/app/views/cms/attachments/_attachment.html.erb b/app/views/cms/attachments/_attachment.html.erb index 1f2aca4a8..3a5445cf9 100644 --- a/app/views/cms/attachments/_attachment.html.erb +++ b/app/views/cms/attachments/_attachment.html.erb @@ -6,11 +6,11 @@ <% if attachment.is_image? %> <%= link_to(image_tag(attachment_path_for(attachment), :size => '60x60', :data => {:purpose => 'attachment'}), attachment_path_for(attachment), target: "_blank") %> <% else %> - <%= image_tag "cms/icons/file_types/#{attachment.icon}.png" %> + <%= image_tag "cms/icons/file_types/#{attachment.icon}.png", :style => "width:18px;height:18px;" %> <% end %> <%= attachment.attachment_name.singularize.capitalize %> <%= number_to_human_size(attachment.size) %> <%= link_to("Delete", '#', data: {purpose: 'delete-attachment', id: attachment.id}, class: 'btn btn-mini btn-danger') if show_delete %> - \ No newline at end of file + diff --git a/app/views/cms/content/show.html.erb b/app/views/cms/content/show.html.erb index 618df6d0b..da3a93b5b 100644 --- a/app/views/cms/content/show.html.erb +++ b/app/views/cms/content/show.html.erb @@ -1,12 +1,13 @@ <%= content_for :html_head do %> <%# JQuery is required both for page_editor and cms/user. But it needs to be included only once. %> + <%= javascript_include_tag 'jquery' %> <% if @show_toolbar %> - <%= javascript_include_tag 'cms/page_editor' %> - <%= stylesheet_link_tag 'cms/page_content_editing' %> + <%= javascript_include_tag '/assets/cms/page_editor' %> + <%= stylesheet_link_tag '/assets/cms/page_content_editing' %> <%= csrf_meta_tags %> <% end %> - <%= javascript_include_tag 'cms/site' %> + <%= javascript_include_tag '/assets/cms/site' %> <% end %> <% if @show_toolbar %> <% flash.keep %> diff --git a/app/views/cms/file_blocks/render.html.erb b/app/views/cms/file_blocks/render.html.erb index db78a7a23..bb868a129 100644 --- a/app/views/cms/file_blocks/render.html.erb +++ b/app/views/cms/file_blocks/render.html.erb @@ -1,5 +1,5 @@
- <%= image_tag "cms/icons/file_types/#{@content_block.file.icon}.png", :alt=>@content_block.file.icon %> + <%= image_tag "cms/icons/file_types/#{@content_block.file.icon}.png", :style => "width:18px;height:18px;", :alt=>@content_block.file.icon %> <%= link_to @content_block.name, attachment_path_for(@content_block.file) %> <%= @content_block.file_size %>
diff --git a/app/views/cms/html_blocks/_form.html.erb b/app/views/cms/html_blocks/_form.html.erb index 7afe23808..52f7fdf31 100644 --- a/app/views/cms/html_blocks/_form.html.erb +++ b/app/views/cms/html_blocks/_form.html.erb @@ -1,3 +1,3 @@ <%= f.input :name %> -<%= f.input :content, as: :rich_simple_form %> -<%= f.cms_tag_list %> \ No newline at end of file +<%= f.input :content, as: :text_editor %> +<%= f.cms_tag_list %> diff --git a/app/views/cms/pages/_simple_container.html.erb b/app/views/cms/pages/_simple_container.html.erb index 752dbec46..369c14dd8 100644 --- a/app/views/cms/pages/_simple_container.html.erb +++ b/app/views/cms/pages/_simple_container.html.erb @@ -1,5 +1,4 @@
-
<%= name %>
<%= content %> <%= image_tag "cms/plus.png", :class => 'cms-add-content', diff --git a/app/views/layouts/cms/_content_types.html.erb b/app/views/layouts/cms/_content_types.html.erb index b9bdeb391..4b842dc5f 100644 --- a/app/views/layouts/cms/_content_types.html.erb +++ b/app/views/layouts/cms/_content_types.html.erb @@ -4,10 +4,10 @@ <%= divider_tag %> <% end %> <% modules = Cms::ContentType.available_by_module - modules.keys.sort.each_with_index do |module_name, i| %> + modules.keys.compact.sort.each_with_index do |module_name, i| %> <%= divider_tag(i) %> <% modules[module_name].each do |type| %> <%= nav_link_to h(type.display_name), engine_aware_path(type) %> <% end -%> <% end %> - \ No newline at end of file + diff --git a/app/views/layouts/cms/_main_menu.html.erb b/app/views/layouts/cms/_main_menu.html.erb index 25b171f2a..ceda6e866 100644 --- a/app/views/layouts/cms/_main_menu.html.erb +++ b/app/views/layouts/cms/_main_menu.html.erb @@ -64,7 +64,7 @@