-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7efac2d
commit 23626a5
Showing
10 changed files
with
96 additions
and
49 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module PagesCore | ||
module PageParameters | ||
extend ActiveSupport::Concern | ||
|
||
def page_attachment_attributes | ||
{ page_images_attributes: %i[id position image_id primary _destroy], | ||
page_files_attributes: %i[id position attachment_id _destroy] } | ||
end | ||
|
||
def page_content_attributes | ||
locales = PagesCore.config.locales&.keys || [I18n.default_locale] | ||
[page_static_attributes, | ||
PagesCore::Templates::TemplateConfiguration.all_blocks, | ||
:path_segment, | ||
(PagesCore::Templates::TemplateConfiguration | ||
.localized_blocks + %i[path_segment]) | ||
.index_with { locales }, | ||
page_attachment_attributes] | ||
end | ||
|
||
def page_static_attributes | ||
%i[template user_id status feed_enabled published_at redirect_to | ||
news_page unique_name pinned parent_page_id serialized_tags | ||
meta_image_id starts_at ends_at all_day] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { csrfToken } from "../../lib/request"; | ||
|
||
function buildForm(url: string, body: Record<string, string>) { | ||
const form = document.createElement("form"); | ||
form.action = url; | ||
form.method = "POST"; | ||
form.target = "_blank"; | ||
for (const [name, value] of Object.entries(body)) { | ||
const input = document.createElement("input"); | ||
input.type = "hidden"; | ||
input.name = name; | ||
input.value = value; | ||
form.appendChild(input); | ||
} | ||
return form; | ||
} | ||
|
||
export function openPreview(url: string, body: Record<string, string>) { | ||
const form = buildForm(url, { authenticity_token: csrfToken(), ...body }); | ||
document.body.appendChild(form); | ||
form.submit(); | ||
document.body.removeChild(form); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters