Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set preview mode earlier #2307

Merged
merged 2 commits into from
Apr 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions app/controllers/alchemy/admin/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class PagesController < ResourcesController
before_action :set_root_page,
only: [:index, :show, :order]

before_action :run_on_page_layout_callbacks,
if: :run_on_page_layout_callbacks?,
only: [:show]
before_action :set_preview_mode, only: [:show]

before_action :load_languages_and_layouts,
unless: -> { @page_root },
Expand All @@ -35,6 +33,10 @@ class PagesController < ResourcesController

before_action :set_page_version, only: [:show, :edit]

before_action :run_on_page_layout_callbacks,
if: :run_on_page_layout_callbacks?,
only: [:show]

def index
@query = @current_language.pages.contentpages.ransack(search_filter_params[:q])

Expand Down Expand Up @@ -64,7 +66,6 @@ def tree
# Used by page preview iframe in Page#edit view.
#
def show
@preview_mode = true
Page.current_preview = @page
# Setting the locale to pages language, so the page content has it's correct translations.
::I18n.locale = @page.language.locale
Expand Down Expand Up @@ -397,6 +398,10 @@ def load_languages_and_layouts
@languages_with_page_tree = Language.on_current_site.with_root_page
@page_layouts = PageLayout.layouts_for_select(@language.id)
end

def set_preview_mode
@preview_mode = true
end
end
end
end