Sha256: 2612ae9a5d1700efe421df287fd026e590404fdaf5705f8fdd669ca4940de90d

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Maglev
  class PagePreviewController < ApplicationController
    include Maglev::RenderingConcern
    include Maglev::JsonConcern
    include Maglev::ContentLocaleConcern

    before_action :fetch_maglev_site
    before_action :extract_content_locale

    def index
      render_maglev_page
    end

    def create
      render_maglev_page
    end

    private

    def fetch_maglev_site
      super.tap do |site|
        raise ActiveRecord::RecordNotFound if site.nil?

        site.style = JSON.parse(params[:style]) if params[:style]
      end
    end

    def fetch_maglev_page_sections
      return super if action_name == 'index'

      super(JSON.parse(params[:page_sections]))
    end

    def maglev_rendering_mode
      params[:rendering_mode] || super
    end

    def use_engine_vite?
      false
    end

    def extract_content_locale
      _, locale = maglev_services.extract_locale.call(params: params, locales: maglev_site.locale_prefixes)
      ::I18n.locale = locale
    end

    def fallback_to_default_locale
      maglev_rendering_mode == :editor
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
maglevcms-1.5.1 app/controllers/maglev/page_preview_controller.rb
maglevcms-1.4.0 app/controllers/maglev/page_preview_controller.rb
maglevcms-1.3.0 app/controllers/maglev/page_preview_controller.rb
maglevcms-1.2.2 app/controllers/maglev/page_preview_controller.rb
maglevcms-1.2.1 app/controllers/maglev/page_preview_controller.rb
maglevcms-1.2.0 app/controllers/maglev/page_preview_controller.rb
maglevcms-1.1.7 app/controllers/maglev/page_preview_controller.rb
maglevcms-1.1.6 app/controllers/maglev/page_preview_controller.rb
maglevcms-1.1.5 app/controllers/maglev/page_preview_controller.rb
maglevcms-1.1.4 app/controllers/maglev/page_preview_controller.rb