diff --git a/Gemfile.lock b/Gemfile.lock index 7edd38f7f..f381c3893 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,12 +6,12 @@ PATH ancestry (~> 2.0.0) bootstrap-sass ckeditor_rails (~> 4.3.0) - compass-rails (~> 1.1.3) + compass-rails (~> 2.0.4) devise (~> 3.0) jquery-rails (~> 3.1) jquery-ui-rails (~> 4.1) panoramic - paperclip (~> 3.4) + paperclip (~> 4.3) rails (~> 4.0.0) sass-rails simple_form (>= 3.0.0.rc, < 3.1) @@ -57,10 +57,14 @@ GEM childprocess (>= 0.3.6) cucumber (>= 1.1.1) rspec-expectations (>= 2.7.0) - bcrypt (3.1.7) + autoprefixer-rails (6.1.0.1) + execjs + json + bcrypt (3.1.10) bluecloth (2.2.0) - bootstrap-sass (3.2.0.2) - sass (~> 3.2) + bootstrap-sass (3.3.5.1) + autoprefixer-rails (>= 5.0.0.1) + sass (>= 3.3.0) builder (3.1.4) capybara (2.1.0) mime-types (>= 1.16) @@ -70,28 +74,29 @@ GEM xpath (~> 2.0) childprocess (0.3.9) ffi (~> 1.0, >= 1.0.11) - chunky_png (1.3.1) + chunky_png (1.3.5) ckeditor_rails (4.3.4) railties (>= 3.0) climate_control (0.0.3) activesupport (>= 3.0) - cocaine (0.5.4) + cocaine (0.5.7) climate_control (>= 0.0.3, < 1.0) - compass (1.0.1) + compass (1.0.3) chunky_png (~> 1.2) - compass-core (~> 1.0.1) + compass-core (~> 1.0.2) compass-import-once (~> 1.0.5) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) sass (>= 3.3.13, < 3.5) - compass-core (1.0.1) + compass-core (1.0.3) multi_json (~> 1.0) sass (>= 3.3.0, < 3.5) compass-import-once (1.0.5) sass (>= 3.2, < 3.5) - compass-rails (1.1.7) - compass (>= 0.12.2) - sprockets (<= 2.11.0) + compass-rails (2.0.5) + compass (~> 1.0.0) + sass-rails (< 5.1) + sprockets (< 2.13) cucumber (1.3.6) builder (>= 2.1.2) diff-lcs (>= 1.1.3) @@ -104,10 +109,11 @@ GEM nokogiri (>= 1.5.0) daemons (1.1.9) database_cleaner (1.2.0) - devise (3.3.0) + devise (3.5.2) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) + responders thread_safe (~> 0.1) warden (~> 1.2.3) diff-lcs (1.2.4) @@ -122,18 +128,19 @@ GEM railties (>= 3.0.0) faye-websocket (0.4.7) eventmachine (>= 0.12.0) - ffi (1.9.0) + ffi (1.9.10) gherkin (2.12.1) multi_json (~> 1.3) hashie (2.0.5) hike (1.2.3) http_parser.rb (0.5.3) - i18n (0.6.11) - jquery-rails (3.1.2) + i18n (0.7.0) + jquery-rails (3.1.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) jquery-ui-rails (4.2.1) railties (>= 3.2.16) + json (1.8.3) launchy (2.3.0) addressable (~> 2.3) m (1.3.2) @@ -145,6 +152,7 @@ GEM metaclass (0.0.1) method_source (0.8.2) mime-types (1.25.1) + mimemagic (0.3.0) mini_portile (0.5.1) minitest (4.7.5) minitest-rails (0.9.2) @@ -165,11 +173,12 @@ GEM orm_adapter (0.5.0) panoramic (0.0.4) rails (>= 3.0.7) - paperclip (3.5.4) - activemodel (>= 3.0.0) - activesupport (>= 3.0.0) - cocaine (~> 0.5.3) + paperclip (4.3.1) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + cocaine (~> 0.5.5) mime-types + mimemagic (= 0.3.0) poltergeist (1.3.0) capybara (~> 2.1.0) faye-websocket (>= 0.4.4, < 0.5.0) @@ -180,8 +189,8 @@ GEM hashie (>= 1.1.0) quiet_assets (1.0.2) railties (>= 3.1, < 5.0) - rack (1.5.2) - rack-test (0.6.2) + rack (1.5.5) + rack-test (0.6.3) rack (>= 1.0) rails (4.0.2) actionmailer (= 4.0.2) @@ -196,24 +205,28 @@ GEM activesupport (= 4.0.2) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.1.1) - rb-fsevent (0.9.4) + rake (10.4.2) + rb-fsevent (0.9.6) rb-inotify (0.9.5) ffi (>= 0.5.0) + responders (1.1.2) + railties (>= 3.2, < 4.2) rspec-expectations (2.14.1) diff-lcs (>= 1.1.3, < 2.0) ruby-prof (0.13.0) - sass (3.4.5) - sass-rails (4.0.1) + sass (3.4.19) + sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) - sass (>= 3.1.10) - sprockets-rails (~> 2.0.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) simple_form (3.1.0.rc2) actionpack (~> 4.0) activemodel (~> 4.0) single_test (0.6.0) rake - sprockets (2.10.1) + sprockets (2.12.4) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) @@ -225,24 +238,24 @@ GEM sqlite3 (1.3.7) sqlite3-ruby (1.3.3) sqlite3 (>= 1.3.3) - term-ansicolor (1.3.0) + term-ansicolor (1.3.2) tins (~> 1.0) thin (1.5.1) daemons (>= 1.0.9) eventmachine (>= 0.12.6) rack (>= 1.0.0) - thor (0.18.1) - thread_safe (0.3.4) + thor (0.19.1) + thread_safe (0.3.5) tilt (1.4.1) - tins (1.3.3) + tins (1.7.0) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.41) + tzinfo (0.3.45) uglifier (2.1.2) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) - underscore-rails (1.7.0) + underscore-rails (1.8.3) warden (1.2.3) rack (>= 1.0) will_paginate (3.0.7) @@ -278,3 +291,6 @@ DEPENDENCIES thin uglifier yard + +BUNDLED WITH + 1.10.6 diff --git a/app/assets/javascripts/bcms/ckeditor_load.js b/app/assets/javascripts/bcms/ckeditor_load.js index 111dd5e6c..9e71b1178 100644 --- a/app/assets/javascripts/bcms/ckeditor_load.js +++ b/app/assets/javascripts/bcms/ckeditor_load.js @@ -3,21 +3,21 @@ // Note: Uses noConflict version of jquery to avoid possible issues with loading ckeditor. jQuery(function ($) { $('textarea.editor').each(function (e) { - if (editorEnabled()) { + if (editorEnabled(this.id)) { loadEditor(this.id); } }); }); -function editorEnabled() { - return $.cookie('editorEnabled') ? $.cookie('editorEnabled') == "true" : true; +function editorEnabled(id) { + return $.cookie(cookieName(id)) ? $.cookie(cookieName(id)) == "true" : false; } function disableEditor(id) { if (typeof(CKEDITOR) != "undefined" && CKEDITOR.instances[id] != null) { $('#' + id).val(CKEDITOR.instances[id].getData()).show(); CKEDITOR.instances[id].destroy(); - $.cookie('editorEnabled', false, { expires:90, path:'/' }); + $.cookie(cookieName(id), false, { expires:90, path:'/' }); } } @@ -25,7 +25,7 @@ function enableEditor(id) { if (typeof(CKEDITOR) != "undefined" && CKEDITOR.instances[id] != null) { CKEDITOR.instances[id].setData($('#' + id).val()); $('#' + id).hide(); - $.cookie('editorEnabled', true, { expires:90, path:'/' }); + $.cookie(cookieName(id), true, { expires:90, path:'/' }); } } @@ -46,9 +46,13 @@ function loadEditor(id) { editor.config.width = '100%'; editor.config.height = 400; } - $.cookie('editorEnabled', true, { expires:90, path:'/' }); + $.cookie(cookieName(id), true, { expires:90, path:'/' }); return true; } else { return false; } -} \ No newline at end of file +} + +function cookieName(id) { + return 'editorEnabled_' + id + '_' + $('#' + id).data('path') +} diff --git a/app/assets/javascripts/cms/form_builder.js b/app/assets/javascripts/cms/form_builder.js index 02e529164..f81015046 100644 --- a/app/assets/javascripts/cms/form_builder.js +++ b/app/assets/javascripts/cms/form_builder.js @@ -55,6 +55,7 @@ FormBuilder.prototype.confirmDeleteFormField = function() { FormBuilder.prototype.editFormField = function() { // This is the overall container for the entire field. formBuilder.field_being_editted = $(this).parents('.control-group'); + $('#modal-edit-field').find('.modal-content').load($(this).attr('data-edit-path')); $('#modal-edit-field').modal({ show: true, remote: $(this).attr('data-edit-path') diff --git a/app/controllers/cms/content_block_controller.rb b/app/controllers/cms/content_block_controller.rb index e88dfa168..277e34115 100644 --- a/app/controllers/cms/content_block_controller.rb +++ b/app/controllers/cms/content_block_controller.rb @@ -319,9 +319,9 @@ def check_permissions when "index", "show", "new", "create", "version", "versions" # Allow when "edit", "update", "inline" - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@block) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@block) when "destroy", "publish", "revert_to" - raise Cms::Errors::AccessDenied unless current_user.able_to_publish?(@block) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_publish?(@block) else raise Cms::Errors::AccessDenied end @@ -330,7 +330,7 @@ def check_permissions private def render_block_in_main_container - ensure_current_user_can_view(@block) + ensure_current_cms_user_can_view(@block) show_content_as_page(@block) render 'render_block_in_main_container', layout: @block.class.layout end @@ -341,7 +341,7 @@ def render_block_in_content_library def render_editing_frame_or_block_in_main_container if @block.class.addressable? - if current_user.able_to_edit?(@block) + if current_cms_user.able_to_edit?(@block) render_toolbar_and_iframe else render_block_in_main_container diff --git a/app/controllers/cms/content_controller.rb b/app/controllers/cms/content_controller.rb index 58bed6dcb..cc32f1e04 100644 --- a/app/controllers/cms/content_controller.rb +++ b/app/controllers/cms/content_controller.rb @@ -47,7 +47,7 @@ def edit def preview @mode = "view" @page = Page.find_draft(params[:id].to_i) - ensure_current_user_can_view(@page) + ensure_current_cms_user_can_view(@page) render_page end @@ -114,7 +114,7 @@ def redirect_non_cms_users_to_public_site logger.debug "Using cms subdomain is enabled" if request_is_for_cms_subdomain? logger.debug "User has required a page on the cms subdomain." - if current_user.able_to?(:edit_content, :publish_content, :administrate) + if current_cms_user.able_to?(:edit_content, :publish_content, :administrate) logger.debug "User has access to cms" @show_toolbar = true else @@ -126,7 +126,7 @@ def redirect_non_cms_users_to_public_site end else logger.debug "Using cms subdomain is disabled" - if current_user.able_to?(:edit_content, :publish_content, :administrate) + if current_cms_user.able_to?(:edit_content, :publish_content, :administrate) @show_toolbar = true end end @@ -157,7 +157,7 @@ def try_to_stream_file end def load_page - if current_user.able_to?(:edit_content, :publish_content, :administrate) + if current_cms_user.able_to?(:edit_content, :publish_content, :administrate) logger.debug "Displaying draft version of page" @page = Page.find_draft(@path) else @@ -167,7 +167,7 @@ def load_page end def check_access_to_page - ensure_current_user_can_view(@page) + ensure_current_cms_user_can_view(@page) end end end diff --git a/app/controllers/cms/dashboard_controller.rb b/app/controllers/cms/dashboard_controller.rb index e58912840..9e105d241 100644 --- a/app/controllers/cms/dashboard_controller.rb +++ b/app/controllers/cms/dashboard_controller.rb @@ -3,8 +3,8 @@ class DashboardController < Cms::BaseController def index @unpublished_pages = Page.unpublished.order("updated_at desc") - @unpublished_pages = @unpublished_pages.select { |page| current_user.able_to_publish?(page) } - @incomplete_tasks = current_user.tasks.incomplete. + @unpublished_pages = @unpublished_pages.select { |page| current_cms_user.able_to_publish?(page) } + @incomplete_tasks = current_cms_user.tasks.incomplete. includes(:page). order("#{Task.table_name}.due_date desc, #{Page.table_name}.name"). references(:page) diff --git a/app/controllers/cms/links_controller.rb b/app/controllers/cms/links_controller.rb index ea668b59b..8d5099507 100644 --- a/app/controllers/cms/links_controller.rb +++ b/app/controllers/cms/links_controller.rb @@ -64,12 +64,12 @@ def link_params def load_section @section = Section.find(params[:section_id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@section) end def load_link @link = Link.find(params[:id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@link) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@link) end def load_draft_link diff --git a/app/controllers/cms/pages_controller.rb b/app/controllers/cms/pages_controller.rb index 375435096..6cffad6e4 100644 --- a/app/controllers/cms/pages_controller.rb +++ b/app/controllers/cms/pages_controller.rb @@ -73,7 +73,7 @@ def destroy define_method status do if params[:page_ids] @pages = params[:page_ids].map { |id| Page.find(id) } - raise Cms::Errors::AccessDenied unless @pages.all? { |page| current_user.able_to_edit?(page) } + raise Cms::Errors::AccessDenied unless @pages.all? { |page| current_cms_user.able_to_edit?(page) } @pages.each { |page| page.send(status) } flash[:notice] = "#{params[:page_ids].size} pages #{verb}" redirect_to dashboard_url @@ -117,7 +117,7 @@ def page_params end def strip_visibility_params - unless current_user.able_to?(:publish_content) + unless current_cms_user.able_to?(:publish_content) params[:page].delete :hidden params[:page].delete :archived params[:page].delete :visibility @@ -126,7 +126,7 @@ def strip_visibility_params def load_page @page = Page.find(params[:id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@page) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@page) end def load_draft_page @@ -136,7 +136,7 @@ def load_draft_page def load_section @section = Section.find(params[:section_id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@section) end def hide_toolbar diff --git a/app/controllers/cms/section_nodes_controller.rb b/app/controllers/cms/section_nodes_controller.rb index d8135c3bb..e469b8d0a 100644 --- a/app/controllers/cms/section_nodes_controller.rb +++ b/app/controllers/cms/section_nodes_controller.rb @@ -4,7 +4,7 @@ class SectionNodesController < Cms::BaseController check_permissions :publish_content, :except => [:index] def index - @modifiable_sections = current_user.modifiable_sections + @modifiable_sections = current_cms_user.modifiable_sections @public_sections = Group.guest.sections.to_a # Load once here so that every section doesn't need to. @sitemap = Section.sitemap diff --git a/app/controllers/cms/sections_controller.rb b/app/controllers/cms/sections_controller.rb index c47d360ba..a743d7242 100644 --- a/app/controllers/cms/sections_controller.rb +++ b/app/controllers/cms/sections_controller.rb @@ -27,7 +27,7 @@ def new def create @section = Cms::Section.new(section_params) @section.parent = @parent - @section.groups = @section.parent.groups unless current_user.able_to?(:administrate) + @section.groups = @section.parent.groups unless current_cms_user.able_to?(:administrate) if @section.save flash[:notice] = "Section '#{@section.name}' was created" redirect_to @section @@ -40,7 +40,7 @@ def edit end def update - params[:section].delete('group_ids') if params[:section] && !current_user.able_to?(:administrate) + params[:section].delete('group_ids') if params[:section] && !current_cms_user.able_to?(:administrate) @section.attributes = section_params() if @section.save flash[:notice] = "Section '#{@section.name}' was updated" @@ -80,12 +80,12 @@ def section_params def load_parent @parent = Cms::Section.find(params[:section_id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@parent) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@parent) end def load_section @section = Cms::Section.find(params[:id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@section) end def public_groups diff --git a/app/controllers/cms/tasks_controller.rb b/app/controllers/cms/tasks_controller.rb index ae41a922f..c593a195f 100644 --- a/app/controllers/cms/tasks_controller.rb +++ b/app/controllers/cms/tasks_controller.rb @@ -4,12 +4,12 @@ class TasksController < Cms::BaseController before_filter :load_page, :only => [:new, :create] def new - @task = @page.tasks.build(:assigned_by => current_user) + @task = @page.tasks.build(:assigned_by => current_cms_user) end def create @task = @page.tasks.build(task_params()) - @task.assigned_by = current_user + @task.assigned_by = current_cms_user if @task.save flash[:notice] = "Page was assigned to '#{@task.assigned_to.login}'" redirect_to @page.path @@ -21,7 +21,7 @@ def create def complete if params[:task_ids] Task.where(["id in (?)", params[:task_ids]]).each do |t| - if t.assigned_to == current_user + if t.assigned_to == current_cms_user t.mark_as_complete! end end @@ -29,7 +29,7 @@ def complete redirect_to dashboard_path else @task = Task.find(params[:id]) - if @task.assigned_to == current_user + if @task.assigned_to == current_cms_user if @task.mark_as_complete! flash[:notice] = "Task was marked as complete" end diff --git a/app/controllers/cms/user_controller.rb b/app/controllers/cms/user_controller.rb index aa8f85f8a..4754470b9 100644 --- a/app/controllers/cms/user_controller.rb +++ b/app/controllers/cms/user_controller.rb @@ -2,7 +2,7 @@ module Cms class UserController < Cms::ApplicationController # Return information about the current user as json. Can be used by cached html pages do create interactive elements. def show - render json: Cms::UserPresenter.new(current_user) + render json: Cms::UserPresenter.new(current_cms_user) end end end diff --git a/app/controllers/cms/users_controller.rb b/app/controllers/cms/users_controller.rb index 80adee0f3..860906362 100644 --- a/app/controllers/cms/users_controller.rb +++ b/app/controllers/cms/users_controller.rb @@ -56,7 +56,7 @@ def change_password def update_password if user.update(cms_user_params) flash[:notice] = "Password for '#{user.login}' was changed" - redirect_to(current_user.able_to?(:administrate) ? users_path : "/") + redirect_to(current_cms_user.able_to?(:administrate) ? users_path : "/") else render :action => 'change_password' end @@ -119,7 +119,7 @@ def set_menu_section end def only_self_or_administrator - raise Cms::Errors::AccessDenied if !current_user.able_to?(:administrate) && params[:id].to_i != current_user.id + raise Cms::Errors::AccessDenied if !current_cms_user.able_to?(:administrate) && params[:id].to_i != current_cms_user.id end end end \ No newline at end of file diff --git a/app/helpers/cms/content_block_helper.rb b/app/helpers/cms/content_block_helper.rb index 84c0c26e5..c08b9dfcb 100644 --- a/app/helpers/cms/content_block_helper.rb +++ b/app/helpers/cms/content_block_helper.rb @@ -10,15 +10,15 @@ module ContentBlockHelper # * If the user can edit/publish it def block_row_tag(block) cname = class_name_for(block) - can_modify = current_user.able_to_modify?(block) + can_modify = current_cms_user.able_to_modify?(block) options = { :id => "#{cname}_#{block.id}", :class => cname } options[:class] += block.class.publishable? && !block.published? ? ' draft' : ' published' - options[:class] += ' non-editable' unless can_modify && current_user.able_to?(:edit_content) - options[:class] += ' non-publishable' unless can_modify && current_user.able_to?(:publish_content) + options[:class] += ' non-editable' unless can_modify && current_cms_user.able_to?(:edit_content) + options[:class] += ' non-publishable' unless can_modify && current_cms_user.able_to?(:publish_content) tag "tr", options, true end @@ -28,7 +28,7 @@ def block_row_tag(block) # We use 'data-' elements here to avoid duplication of path calculations. def content_block_tr_tag(block) cname = class_name_for(block) - can_modify = current_user.able_to_modify?(block) + can_modify = current_cms_user.able_to_modify?(block) options = {} data = options[:data] = {} @@ -36,8 +36,8 @@ def content_block_tr_tag(block) options[:id] = "#{cname}_#{block.id}" options[:class] = [cname] - options[:class] << 'non-editable' unless can_modify && current_user.able_to?(:edit_content) - options[:class] << 'non-publishable' unless can_modify && current_user.able_to?(:publish_content) + options[:class] << 'non-editable' unless can_modify && current_cms_user.able_to?(:edit_content) + options[:class] << 'non-publishable' unless can_modify && current_cms_user.able_to?(:publish_content) options['data-new_path'] = url_for(new_engine_aware_path(block)) options['data-view_path'] = url_for(engine_aware_path(block, nil)) options['data-edit_path'] = url_for(edit_engine_aware_path(block)) diff --git a/app/helpers/cms/page_helper.rb b/app/helpers/cms/page_helper.rb index bcd7edd7c..ba724b51d 100644 --- a/app/helpers/cms/page_helper.rb +++ b/app/helpers/cms/page_helper.rb @@ -157,7 +157,7 @@ def render_portlet(name) # Determines if the current_user is able to do specific permissions. def able_to?(*perms, &block) - block.call if current_user.able_to?(*perms) + block.call if current_cms_user.able_to?(*perms) return '' end diff --git a/app/helpers/cms/path_helper.rb b/app/helpers/cms/path_helper.rb index 3ef192b25..0622e307f 100644 --- a/app/helpers/cms/path_helper.rb +++ b/app/helpers/cms/path_helper.rb @@ -18,7 +18,7 @@ def link_to_addressable_content(name, content) # Content editors will see exact specific version path, while other users will see the 'public' url for the path. def attachment_path_for(attachment) return "" unless attachment - if current_user.able_to?(:edit_content) + if current_cms_user.able_to?(:edit_content) attachment.attachment_version_path else attachment.url diff --git a/app/helpers/cms/rendering_helper.rb b/app/helpers/cms/rendering_helper.rb index 24ee21f07..525555138 100644 --- a/app/helpers/cms/rendering_helper.rb +++ b/app/helpers/cms/rendering_helper.rb @@ -55,7 +55,7 @@ def attachment_viewer(content) # Determines if the current user can edit and is currently editing this content. def is_current_user_able_to_edit_this_content?(content) - content && logged_in? && edit_mode? && current_user.able_to_edit?(content) + content && logged_in? && edit_mode? && current_cms_user.able_to_edit?(content) end # @deprecated diff --git a/app/helpers/cms/ui_elements_helper.rb b/app/helpers/cms/ui_elements_helper.rb index 0f99ba19e..703ce93cd 100644 --- a/app/helpers/cms/ui_elements_helper.rb +++ b/app/helpers/cms/ui_elements_helper.rb @@ -32,7 +32,7 @@ def bottom_buttons(form, partial_name="buttons") # 1. Current User has publish rights # 2. Block is publishable def save_and_publish_button(block, content_type) - if current_user.able_to?(:publish_content) && block.publishable? + if current_cms_user.able_to?(:publish_content) && block.publishable? html = %Q{} html.html_safe end @@ -50,7 +50,7 @@ def publish_button(type) def publish_menu_button(content_item) options = {class: ["btn", "btn-primary", "http_put"], id: "publish_button"} path = "#" - if current_user.able_to?(:publish_content) && !content_item.new_record? && content_item.respond_to?(:live?) && !content_item.live? + if current_cms_user.able_to?(:publish_content) && !content_item.new_record? && content_item.respond_to?(:live?) && !content_item.live? path = engine(@block).polymorphic_path([:publish, @block]) else options[:class] << "disabled" @@ -118,7 +118,7 @@ def versions_menu_button(content_item) # def delete_menu_button(content_item=nil, opts={class: []}) classes = ["btn", "http_delete", "confirm_with_title"] - if current_user.able_to_publish?(content_item) + if current_cms_user.able_to_publish?(content_item) classes << 'btn-primary' else classes << 'disabled' diff --git a/app/inputs/attachments_input.rb b/app/inputs/attachments_input.rb index 61499e392..ee121b327 100644 --- a/app/inputs/attachments_input.rb +++ b/app/inputs/attachments_input.rb @@ -1,6 +1,6 @@ class AttachmentsInput < SimpleForm::Inputs::Base - def input + def input(wrapper_options = nil) definitions = Cms::Attachment.definitions_for(object.class.name, :multiple) if definitions.empty? template.render(partial: 'cms/attachments/no_attachments_defined', locals: {object: object}) @@ -11,4 +11,4 @@ def input end end -end \ No newline at end of file +end diff --git a/app/inputs/cms_text_area_input.rb b/app/inputs/cms_text_area_input.rb index 0157bf4d7..f0ef80921 100644 --- a/app/inputs/cms_text_area_input.rb +++ b/app/inputs/cms_text_area_input.rb @@ -3,8 +3,8 @@ class CmsTextAreaInput < SimpleForm::Inputs::TextInput include Cms::FormBuilder::DefaultInput - def input + def input(wrapper_options = nil) extract_default @builder.text_area(attribute_name, input_html_options).html_safe end -end \ No newline at end of file +end diff --git a/app/inputs/date_picker_input.rb b/app/inputs/date_picker_input.rb index db6a59730..fdee10473 100644 --- a/app/inputs/date_picker_input.rb +++ b/app/inputs/date_picker_input.rb @@ -2,7 +2,7 @@ # 1. Allows for empty dates (i.e. no date) class DatePickerInput < SimpleForm::Inputs::TextInput - def input + def input(wrapper_options = nil) @builder.text_field(attribute_name, input_html_options).html_safe end -end \ No newline at end of file +end diff --git a/app/inputs/file_picker_input.rb b/app/inputs/file_picker_input.rb index cd1a91ff6..6661d56e1 100644 --- a/app/inputs/file_picker_input.rb +++ b/app/inputs/file_picker_input.rb @@ -6,7 +6,7 @@ # @option options [String] :hint (blank) Helpful tips for the person entering the field, appears blank if nothing is specified. class FilePickerInput < SimpleForm::Inputs::Base - def input + def input(wrapper_options = nil) # New blocks will not have their attachments created yet. object.ensure_attachment_exists if object.respond_to?(:ensure_attachment_exists) @@ -72,4 +72,4 @@ def sections_with_full_paths sections end -end \ No newline at end of file +end diff --git a/app/inputs/name_input.rb b/app/inputs/name_input.rb index 73bf5da1a..2444b04de 100644 --- a/app/inputs/name_input.rb +++ b/app/inputs/name_input.rb @@ -14,7 +14,7 @@ def initialize(*args) options[:placeholder] = "Name" if options[:placeholder].nil? end - def input + def input(wrapper_options = nil) add_slug_source_for_content_that_needs_it unless options[:label] @@ -39,4 +39,4 @@ def should_autogenerate_slug? def content_requires_slug_field? object.class.requires_slug? end -end \ No newline at end of file +end diff --git a/app/inputs/path_input.rb b/app/inputs/path_input.rb index 3e98937d1..ca12f5fc8 100644 --- a/app/inputs/path_input.rb +++ b/app/inputs/path_input.rb @@ -1,6 +1,6 @@ class PathInput < SimpleForm::Inputs::TextInput - def input + def input(wrapper_options = nil) if forecasting_a_new_section? options[:hint] = "Forecast: Saving this first #{object.class.display_name} will create a new section at #{object.class.path}." end @@ -15,4 +15,4 @@ def forecasting_a_new_section? Cms::Section.with_path(object.class.path).first.nil? end -end \ No newline at end of file +end diff --git a/app/inputs/template_editor_input.rb b/app/inputs/template_editor_input.rb index 55e7959c1..bf34c3166 100644 --- a/app/inputs/template_editor_input.rb +++ b/app/inputs/template_editor_input.rb @@ -2,11 +2,11 @@ class TemplateEditorInput < SimpleForm::Inputs::TextInput include Cms::FormBuilder::DefaultInput - def label + def label(wrapper_options = nil) super if render_template_input? end - def input + def input(wrapper_options = nil) if render_template_input? options[:default] = object.class.default_template options[:default_handler] = "erb" unless options[:default_handler] @@ -21,4 +21,4 @@ def input def render_template_input? object.class.render_inline end -end \ No newline at end of file +end diff --git a/app/inputs/text_editor_input.rb b/app/inputs/text_editor_input.rb index b72bf26de..35e992cf6 100644 --- a/app/inputs/text_editor_input.rb +++ b/app/inputs/text_editor_input.rb @@ -1,13 +1,15 @@ class TextEditorInput < SimpleForm::Inputs::TextInput - def input + def input(wrapper_options = nil) tag_id = "#{object_name}_#{attribute_name}" + path = input_html_options.fetch(:data, {})[:path] s = template.select_tag(:dhtml_selector, - template.options_for_select([["Rich Text", ""],["Simple Text", "disabled"]], - template.cookies[:editorEnabled] == 'true' ? "" : "disabled"), - :class => "#{object_name}_#{attribute_name}_dhtml_selector", - :tabindex => '-1', - :onchange => "toggleEditor('#{tag_id}', this)".html_safe) + template.options_for_select([["Rich Text", ""],["Simple Text", "disabled"]], + template.cookies["editorEnabled_#{tag_id}_#{path}"] == 'true' ? "" : "disabled"), + :class => "#{object_name}_#{attribute_name}_dhtml_selector", + :tabindex => '-1', + :onchange => "toggleEditor('#{tag_id}', this)".html_safe, + :data => input_html_options[:data]) s += template.content_tag(:div, super, class: 'editor') end @@ -16,4 +18,4 @@ def input def input_html_classes super.push('editor') end -end \ No newline at end of file +end diff --git a/app/models/cms/attachment.rb b/app/models/cms/attachment.rb index 6c6d38acf..6f5fc1a47 100644 --- a/app/models/cms/attachment.rb +++ b/app/models/cms/attachment.rb @@ -62,10 +62,10 @@ def configuration # Paperclip can handle a :styles parameter which responds to :call(Paperclip::Attachment) def dynamically_return_styles lambda do |paperclip_attachment| - cms_attachment = paperclip_attachment.instance + cms_attachment = paperclip_attachment.try(:instance) # Look up the style for the given block - if cms_attachment.has_assigned_content_type? + if cms_attachment && cms_attachment.has_assigned_content_type? configuration_value(cms_attachment.content_block_class, cms_attachment.attachment_name, :styles) else # New attachments that aren't associated with an Attaching type yet have no styles {} @@ -100,7 +100,7 @@ def configure_paperclip :bucket => rail_config(:s3_bucket), :s3_host_name => rail_config(:s3_host_name), :s3_host_alias => rail_config(:s3_host_alias) - + do_not_validate_attachment_file_type :data end # Looks up a value from Rails config diff --git a/app/models/cms/email_message.rb b/app/models/cms/email_message.rb index 5b909af7b..ea7001a2f 100644 --- a/app/models/cms/email_message.rb +++ b/app/models/cms/email_message.rb @@ -31,8 +31,8 @@ def self.normalize_domain(domain) # @param [String] path A relative path (i.e. /cms/your-page) # @return [String] (i.e http://cms.example.com/cms/your-page) def self.absolute_cms_url(path) - host = normalize_domain(Rails.configuration.cms.site_domain) - "http://#{cms_domain_prefix}.#{host}#{path}" + host = [cms_domain_prefix, normalize_domain(Rails.configuration.cms.site_domain)].compact.join(".") + "http://#{host}#{path}" end # Returns a default address that mail will be sent from. (i.e. mailbot@example.com) @@ -60,4 +60,4 @@ def deliver! end end -end \ No newline at end of file +end diff --git a/app/models/cms/guest_user.rb b/app/models/cms/guest_user.rb index 1ef1d8d2e..eca8141e1 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.count(:conditions => ["name in (?)", name.map(&:to_s)]) > 0 + group && group.permissions.where(name: name.map(&:to_s)).exists? end # Guests never get access to the CMS. diff --git a/app/models/cms/page.rb b/app/models/cms/page.rb index bfb7cf085..c0f42cf81 100644 --- a/app/models/cms/page.rb +++ b/app/models/cms/page.rb @@ -204,6 +204,11 @@ def copy_connectors(options={}) true end + def main_attributes + draft.attributes.slice("description", "archived", "cacheable", "hidden", "keywords", "language", "name", + "template_file_name", "title") + end + # Adds a Content block to this page. # # @param [ContentBlock] connectable The content block to be added @@ -216,9 +221,9 @@ def add_content(connectable, container=:main) # connectable.connected_page && # (connectable.class.publishable? ? connectable.published? : true) should_publish = false - update_attributes( + update_attributes({ :version_comment => "#{connectable} was added to the '#{container}' container", - :publish_on_save => should_publish + :publish_on_save => should_publish }.merge(main_attributes) ) connectors.create( :page_version => draft.version, @@ -237,7 +242,7 @@ def move_connector(connector, direction) raise "Connector is nil" unless connector raise "Direction is nil" unless direction orientation = direction[/_/] ? "#{direction.sub('_', ' the ')} of" : "#{direction} within" - update_attributes(:version_comment => "#{connector.connectable} was moved #{orientation} the '#{connector.container}' container", :publish_on_save => false) + update_attributes({:version_comment => "#{connector.connectable} was moved #{orientation} the '#{connector.container}' container", :publish_on_save => false}.merge(main_attributes)) connectors.for_page_version(draft.version).like(connector).first.send("move_#{direction}") end end @@ -251,7 +256,7 @@ def move_connector(connector, direction) def remove_connector(connector) transaction do raise "Connector is nil" unless connector - update_attributes(version_comment: "#{connector.connectable} was removed from the '#{connector.container}' container", publish_on_save: false) + update_attributes({version_comment: "#{connector.connectable} was removed from the '#{connector.container}' container", publish_on_save: false}.merge(main_attributes)) #The logic of this is to go ahead and let the container get copied forward, then delete the new connector if new_connector = connectors.for_page_version(draft.version).like(connector).first diff --git a/app/models/cms/portlet.rb b/app/models/cms/portlet.rb index 03057599c..201a99487 100644 --- a/app/models/cms/portlet.rb +++ b/app/models/cms/portlet.rb @@ -25,7 +25,7 @@ def self.description(description="") delegate :request, :response, :session, :flash, :params, :cookies, - :current_user, :logged_in?, + :current_cms_user, :logged_in?, :to => :controller def self.inherited(subclass) diff --git a/app/views/cms/content_block/render_block_in_main_container.html.erb b/app/views/cms/content_block/render_block_in_main_container.html.erb index b6963a8d0..4330829ea 100644 --- a/app/views/cms/content_block/render_block_in_main_container.html.erb +++ b/app/views/cms/content_block/render_block_in_main_container.html.erb @@ -1,4 +1,4 @@ -<% if current_user.able_to_edit?(@block) %> +<% if current_cms_user.able_to_edit?(@block) %> <% content_for :html_head do %> <%= javascript_include_tag 'cms/page_editor' %> <%= stylesheet_link_tag 'cms/page_content_editing' %> diff --git a/app/views/cms/pages/_form.html.erb b/app/views/cms/pages/_form.html.erb index 194edc09e..66a4e7b48 100644 --- a/app/views/cms/pages/_form.html.erb +++ b/app/views/cms/pages/_form.html.erb @@ -6,7 +6,7 @@ <% content_for :sidebar do %>