app/controllers/spotlight/pages_controller.rb in blacklight-spotlight-0.3.1 vs app/controllers/spotlight/pages_controller.rb in blacklight-spotlight-0.4.1
- old
+ new
@@ -1,29 +1,37 @@
module Spotlight
class PagesController < Spotlight::ApplicationController
before_filter :authenticate_user!, except: [:show]
load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
+ helper Openseadragon::OpenseadragonHelper
include Spotlight::Base
include Blacklight::Catalog::SearchContext
include Spotlight::Catalog::AccessControlsEnforcement
- helper_method :get_search_results, :get_solr_response_for_doc_id, :get_solr_response_for_document_ids, :page_collection_name
+ helper_method :get_search_results, :search_results, :fetch, :page_collection_name
# GET /exhibits/1/pages
def index
# set up a model the inline "add a new page" form
@page = CanCan::ControllerResource.new(self).send(:build_resource)
+
+ respond_to do |format|
+ format.html
+ format.json { render json: @pages.published.to_json(methods: [:thumbnail_image_url]) }
+ end
end
# GET /pages/1
def show
fresh_when([@page.exhibit, @page])
end
def preview
- @block = SirTrevorRails::Block.from_hash(JSON.parse(params[:block], symbolize_names: true), "block")
+ @page = current_exhibit.pages.find(params['id'])
+ authorize! :read, @page
+ @block = SirTrevorRails::Block.from_hash(JSON.parse(params[:block], symbolize_names: true), @page)
respond_to do |format|
format.html { render 'preview', layout: false }
end
end
@@ -96,10 +104,14 @@
def page_attributes
[:id, :published, :title, :weight, :display_sidebar, :parent_page_id ]
end
def allowed_page_params
- [:title, :content]
+ [:title, :content, thumbnail_attributes: featured_image_attributes]
+ end
+
+ def featured_image_attributes
+ [:source, :image, :remote_image_url, :document_global_id, :image_crop_x, :image_crop_y, :image_crop_w, :image_crop_h]
end
def human_name
@human_name ||= page_collection_name.humanize
end