Sha256: 22cc2e85b6f796c9cea95234fa211849e76c25d4cc560d2325c6fa3d545bc5f4

Contents?: true

Size: 1.43 KB

Versions: 13

Compression:

Stored size: 1.43 KB

Contents

module Spotlight
  ##
  # CRUD actions for exhibit resources
  class ResourcesController < Spotlight::ApplicationController
    before_action :authenticate_user!, except: [:show]

    load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
    before_action :build_resource, only: [:create]

    load_and_authorize_resource through: :exhibit

    def new
      add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), exhibit_root_path(@exhibit)
      add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
      add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_path(@exhibit)
      add_breadcrumb t(:'spotlight.resources.new.header'), new_exhibit_resource_path(@exhibit)

      render
    end

    def create
      if @resource.save_and_index
        redirect_to admin_exhibit_catalog_path(@resource.exhibit, sort: :timestamp)
      else
        render action: 'new'
      end
    end

    def monitor
      render json: current_exhibit.reindex_progress
    end

    def reindex_all
      @exhibit.reindex_later

      redirect_to admin_exhibit_catalog_path(@exhibit), notice: t(:'spotlight.resources.reindexing_in_progress')
    end

    protected

    def resource_params
      params.require(:resource).permit(:url, data: params[:resource][:data].try(:keys))
    end

    def build_resource
      @resource ||= @exhibit.resources.build(resource_params)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
blacklight-spotlight-0.25.0 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.24.0 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.23.0 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.22.0 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.21.0 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.20.3 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.20.2 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.20.1 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.20.0 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.19.2 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.19.1 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.19.0 app/controllers/spotlight/resources_controller.rb
blacklight-spotlight-0.18.0 app/controllers/spotlight/resources_controller.rb