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

Add support for page versions #44

Merged
merged 16 commits into from
Mar 5, 2021
Merged

Add support for page versions #44

merged 16 commits into from
Mar 5, 2021

Conversation

tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Mar 1, 2021

This refactors this gem by using page versions of Alchemy v6

This is a breaking change. Older versions of Alchemy are not supported anymore!

It makes some assumptions:

Elements are always loaded from the public version of requested page, besides in the new admin pages controller. Here we always load elements from the draft version of the page. This is meant to be used for the admin page preview.

@tvdeyen tvdeyen marked this pull request as ready for review March 2, 2021 14:53
tvdeyen added 2 commits March 2, 2021 17:32
Decorates a page returning elements from given page_version.
Since we now use a eager loaded elements collection on the page,
we do not need this any more.
@tvdeyen tvdeyen force-pushed the page-versions branch 2 times, most recently from 39cf89f to cd34e8b Compare March 3, 2021 13:48
@tvdeyen tvdeyen marked this pull request as draft March 3, 2021 17:01
@tvdeyen tvdeyen marked this pull request as ready for review March 5, 2021 13:15
@tvdeyen tvdeyen requested a review from mamhoff March 5, 2021 13:20
@tvdeyen
Copy link
Member Author

tvdeyen commented Mar 5, 2021

@mamhoff ready for re-review

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE

app/serializers/alchemy/json_api/element_serializer.rb Outdated Show resolved Hide resolved
tvdeyen added 11 commits March 5, 2021 14:31
The element has a page through its page version now.
Uses our page with eager loaded elements collection in our controllers
Page versions has been introduced with Alchemy 6.0
We only support Alchemy v6 for now
This is meant to be used from the admin pages preview frame
and always returns elements from the draft version.
We do not need the parent_element relation in element
serializer because usually you render top to bottom.
Somehow CanCanCan is not always able to get the correct class
We sometimes use the pages urlname in the preview window as
well. For instance if using a static site generator.
The only difference is the page version we want to load
elements for.
tvdeyen added 3 commits March 5, 2021 14:32
You might want to preview layoutpages as well.
The former version returned a draft version of a public page
even for not admin users. Lets lock this route down completely.
Unauthentiated users must not see unpublished layoutpages.
@tvdeyen tvdeyen merged commit 194f781 into main Mar 5, 2021
@tvdeyen tvdeyen deleted the page-versions branch March 5, 2021 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants