Sha256: 9fcd31af00347d2f232ad3ae6a0137ab7f7599932e581c6b67fee536526c2cd3

Contents?: true

Size: 1.56 KB

Versions: 12

Compression:

Stored size: 1.56 KB

Contents

module Hyrax
  # Shows the about and help page
  class PagesController < ApplicationController
    load_and_authorize_resource class: ContentBlock, except: :show
    layout :pages_layout

    helper Hyrax::ContentBlockHelper

    def show
      @page = ContentBlock.for(params[:key])
    end

    def edit
      add_breadcrumb t(:'hyrax.controls.home'), root_path
      add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
      add_breadcrumb t(:'hyrax.admin.sidebar.configuration'), '#'
      add_breadcrumb t(:'hyrax.admin.sidebar.pages'), hyrax.edit_pages_path
    end

    def update
      respond_to do |format|
        if @page.update(value: update_value_from_params)
          format.html { redirect_to hyrax.edit_pages_path, notice: t(:'hyrax.pages.updated') }
        else
          format.html { render :edit }
        end
      end
    end

    private

      def permitted_params
        params.require(:content_block).permit(:about,
                                              :agreement,
                                              :help,
                                              :terms)
      end

      # When a request comes to the controller, it will be for one and
      # only one of the content blocks. Params always looks like:
      #   {'about_page' => 'Here is an awesome about page!'}
      # So reach into permitted params and pull out the first value.
      def update_value_from_params
        permitted_params.values.first
      end

      def pages_layout
        action_name == 'show' ? 'homepage' : 'dashboard'
      end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hyrax-2.0.3 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.2 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.1 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.0 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.0.rc3 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.0.rc2 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.0.rc1 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.0.beta5 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.0.beta4 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.0.beta3 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.0.beta2 app/controllers/hyrax/pages_controller.rb
hyrax-2.0.0.beta1 app/controllers/hyrax/pages_controller.rb