-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Use Rails' CurrentAttributes to store globals #2701
Merged
Merged
Conversation
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
tvdeyen
force-pushed
the
use-current-attributes
branch
from
January 22, 2024 07:49
2579240
to
776fa38
Compare
Sweet - would this allow us to remove the |
@mamhoff yes, thats why its still WIP |
tvdeyen
force-pushed
the
use-current-attributes
branch
2 times, most recently
from
January 24, 2024 11:17
8a0d153
to
f7cc9a6
Compare
tvdeyen
force-pushed
the
main
branch
3 times, most recently
from
February 19, 2024 14:11
4ea5c7d
to
19e4094
Compare
tvdeyen
commented
Feb 28, 2024
tvdeyen
force-pushed
the
use-current-attributes
branch
2 times, most recently
from
March 2, 2024 19:45
a696479
to
322bea8
Compare
This deprecates - `Alchemy::Site.current` - `Alchemy::Language.current` in favor of `Alchemy::Current.site` `Alchemy::Current.language` Also introduces - `Alchemy::Current.preview_page`
This is an alias for `Site.first`. Use that instead.
We use Alchemy::Current now, that uses Rails' built in CurrentAttributes instead.
tvdeyen
force-pushed
the
use-current-attributes
branch
from
March 2, 2024 19:55
322bea8
to
654e9e9
Compare
tvdeyen
changed the title
Use Rails' CurrentAttributes
Use Rails' CurrentAttributes to store globals
Mar 2, 2024
tvdeyen
force-pushed
the
use-current-attributes
branch
from
March 2, 2024 20:36
654e9e9
to
2cf2ff0
Compare
@mamhoff ready for review |
mamhoff
reviewed
Mar 5, 2024
mamhoff
approved these changes
Mar 5, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! :)
tvdeyen
added a commit
to tvdeyen/alchemy_cms
that referenced
this pull request
Sep 3, 2024
With Alchemy 7.2 (AlchemyCMS#2701) we started to use `Alchemy::Current.page` for rendering elements of current page. If one has a custom controller to render Alchemy content with: render(template: "alchemy/pages/show") it is now empty if `Alchemy::Current.page` is not set. Someday we might deprecate the `@page` instance variable, but until then we need to fall back to it.
3 tasks
tvdeyen
added a commit
to tvdeyen/alchemy_cms
that referenced
this pull request
Sep 3, 2024
Since Alchemy 7.2 (AlchemyCMS#2701) we need to set `Alchemy::Page.current` if we want to render a page from another controller.
3 tasks
tvdeyen
added a commit
that referenced
this pull request
Sep 4, 2024
With Alchemy 7.2 (#2701) we started to use `Alchemy::Current.page` for rendering elements of current page. If one has a custom controller to render Alchemy content with: render(template: "alchemy/pages/show") it is now empty if `Alchemy::Current.page` is not set. Someday we might deprecate the `@page` instance variable, but until then we need to fall back to it. (cherry picked from commit 26072ab)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this pull request for?
Instead of our own custom implementation for Alchemy globals that
use the
request_store
gem, we use Rails' built in Current Attributes.Notable changes
Alchemy::Page.current_preview
,Alchemy::Language.current
andAlchemy::Site.current
are now deprecatedand replaced by
Alchemy::Current.preview_page
,Alchemy::Current.language
andAlchemy::Current.site
.We also introduced a new global
Alchemy::Current.preview_page?
that returnstrue
if the current rendered pageis also the page currently previewed in page editor. You should use that instead of
@preview_mode
.Checklist