Sha256: e1ef2abd2244ef0d15e5bc1e8e90f1245616431c56b38809a6f9f5ae6cc325bb

Contents?: true

Size: 1.14 KB

Versions: 18

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Spotlight
  ##
  # Global site configuration
  class SitesController < Spotlight::ApplicationController
    before_action :authenticate_user!
    before_action :load_site
    load_and_authorize_resource

    def edit; end

    def edit_exhibits; end

    def update
      if @site.update(site_params)
        redirect_to exhibits_path, notice: t(:'helpers.submit.site.updated', model: @site.class.model_name.human.downcase)
      else
        flash[:alert] = @site.errors.full_messages.join('<br>'.html_safe)
        render action: :edit
      end
    end

    def tags
      authorize! :tag, @site

      respond_to do |format|
        format.json { render json: Spotlight::Exhibit.all_tags.map(&:name) }
      end
    end

    private

    def load_site
      @site ||= Spotlight::Site.instance
    end

    def site_params
      params.require(:site).permit(
        :title,
        :subtitle,
        masthead_attributes: masthead_params,
        exhibits_attributes: [:id, :weight]
      )
    end

    def masthead_params
      [
        :display,
        :iiif_region,
        :iiif_tilesource
      ]
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-3.0.0.alpha.1 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.13.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.12.1 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.12.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.11.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.10.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.9.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.8.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.7.2 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.7.1 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.7.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.6.1.1 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.6.1 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.6.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.5.2 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.5.1 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-2.5.0 app/controllers/spotlight/sites_controller.rb