Sha256: 73830892a5b2c43a22ab904ce594d3a66628ed0f58afe9e3ffb92ba588e5a97f

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 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
      add_breadcrumb(t(:'spotlight.sites.home'), root_url)
      add_breadcrumb(t(:'spotlight.sites.edit.page_title'))
    end

    def edit_exhibits
      add_breadcrumb(t(:'spotlight.sites.home'), root_url)
      add_breadcrumb(t(:'spotlight.sites.edit_exhibits.page_title'))
    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: %i[id weight]
      )
    end

    def masthead_params
      %i[
        display
        iiif_region
        iiif_tilesource
      ]
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
blacklight-spotlight-4.7.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.6.1 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.6.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.5.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.4.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.3.6 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.3.5 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.3.4 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.3.3 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.3.2 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.3.1 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.3.0 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-4.2.0 app/controllers/spotlight/sites_controller.rb