Sha256: 5b4a1d4393415aef2e73bbe35dc624d42cde70c8031eed0a5ec87b037766d8dc

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 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: %i[id weight]
      )
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.7 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-3.0.0.alpha.6 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-3.0.0.alpha.5 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-3.0.0.alpha.4 app/controllers/spotlight/sites_controller.rb
blacklight-spotlight-3.0.0.alpha.3 app/controllers/spotlight/sites_controller.rb