Sha256: cadcba04b7323be5fd0d60d151db812a3b451ade2c2fd6ca12a5b6e652fb1a45

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Maglev
  class EditorController < ApplicationController
    include Maglev::AuthenticationConcern
    include Maglev::FetchersConcern
    include Maglev::BackActionConcern
    include Maglev::UiLocaleConcern
    include Maglev::ContentLocaleConcern

    before_action :fetch_maglev_site, only: :show
    before_action :ensure_path_and_content_locale, only: :show
    before_action :set_content_locale, only: :show

    helper_method :maglev_home_page_id

    def show
      fetch_maglev_page_content
      render layout: nil
    end

    def destroy
      call_back_action
    end

    private

    def ensure_path_and_content_locale
      return unless params[:path].blank? || params[:locale].blank?

      redirect_to default_maglev_editor_path
    end

    def maglev_home_page_id
      @maglev_home_page_id ||=
        maglev_pages_collection.home.pick(:id) ||
        maglev_pages_collection.home(default_content_locale).pick(:id)
    end

    def maglev_pages_collection
      ::Maglev::Page
    end

    def fallback_to_default_locale
      true
    end

    def maglev_rendering_mode
      :editor
    end

    def default_maglev_editor_path
      editor_path(
        params[:path] || 'index',
        locale: params[:locale] || default_content_locale
      )
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
maglevcms-1.7.3 app/controllers/maglev/editor_controller.rb
maglevcms-1.7.2 app/controllers/maglev/editor_controller.rb
maglevcms-1.7.1 app/controllers/maglev/editor_controller.rb
maglevcms-1.7.0 app/controllers/maglev/editor_controller.rb
maglevcms-1.6.1 app/controllers/maglev/editor_controller.rb
maglevcms-1.6.0 app/controllers/maglev/editor_controller.rb
maglevcms-1.5.1 app/controllers/maglev/editor_controller.rb