forked from psmb/Psmb.Ajaxify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: dynamic ajaxify identifiers for content-nodes
* `Psmb.Ajaxify:Ajaxify` can configure the identifier for out-of-band rendered content with runtime values to discriminate by content-nodes and more. * The URI builder receives an additional argument `contentNode` with the contextPath of the current content-node and hydrates it as context node `node` when rendering. * The prototype implementations relax their hardcoded dependance on "Psmb.Ajaxify:Ajaxify" for ease of extensibility. This change introduces `@apply` and `Neos.Fusion:Component`, so we break support with neos/neos < 4.2. While this addresses psmb#7, it doesn't further cachable context values that might be required for other use-cases.
- Loading branch information
Showing
5 changed files
with
108 additions
and
18 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
prototype(Neos.Fusion:GlobalCacheIdentifiers).ajaxPathKey = ${request.arguments.ajaxPathKey} | ||
prototype(Neos.Fusion:GlobalCacheIdentifiers) { | ||
ajaxPathKey = ${request.arguments.ajaxPathKey} | ||
contentNode = ${request.arguments.contentNode} | ||
} |
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 |
---|---|---|
@@ -1,30 +1,55 @@ | ||
include: Override.fusion | ||
|
||
# TODO: Watch out, this is hardcoded to be used with Psmb.Ajaxify:Ajaxify | ||
prototype(Psmb.Ajaxify:RenderPath) { | ||
@class = 'Psmb\\Ajaxify\\Fusion\\RenderPathImplementation' | ||
# every path resolution is relative to the Ajaxify prototype, so if you | ||
# overwrite it, make sure to adjust this property | ||
prototypeName = 'Psmb.Ajaxify:Ajaxify' | ||
entryIdentifier = Neos.Fusion:Join { | ||
key = ${key} | ||
@process.hash { | ||
expression = ${String.sha1(value)} | ||
@position = 'end' | ||
} | ||
} | ||
} | ||
|
||
prototype(Psmb.Ajaxify:Loader) < prototype(Neos.Fusion:Value) { | ||
value = ${'<div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>'} | ||
} | ||
|
||
# Use this object as a processor on any path | ||
prototype(Psmb.Ajaxify:Ajaxify) < prototype(Neos.Fusion:Tag) { | ||
prototype(Psmb.Ajaxify:Ajaxify) < prototype(Neos.Fusion:Component) { | ||
# The processor is disabled in BE or when rendering the AJAX request | ||
@if.disableProcessor = ${!request.arguments.ajaxPathKey && !documentNode.context.inBackend} | ||
tagName = 'a' | ||
attributes.data-ajaxify = ${true} | ||
attributes.href = Neos.Neos:NodeUri { | ||
node = ${documentNode} | ||
additionalParams.ajaxPathKey = Psmb.Ajaxify:RenderPath | ||
|
||
entryIdentifier = Neos.Fusion:DataStructure | ||
|
||
renderer = Neos.Fusion:Tag { | ||
tagName = 'a' | ||
attributes.data-ajaxify = ${true} | ||
attributes.href = Neos.Neos:NodeUri { | ||
node = ${documentNode} | ||
additionalParams { | ||
# The argument "node" is already used by the uri builder | ||
contentNode = ${node.contextPath} | ||
ajaxPathKey = Psmb.Ajaxify:RenderPath { | ||
[email protected] = ${props.entryIdentifier} | ||
context = ${props.context} | ||
} | ||
} | ||
} | ||
content = Psmb.Ajaxify:Loader | ||
} | ||
content = Psmb.Ajaxify:Loader | ||
} | ||
|
||
prototype(Psmb.Ajaxify:Renderer) { | ||
@class = 'Psmb\\Ajaxify\\Fusion\\RendererImplementation' | ||
node = ${documentNode} | ||
# The argument "node" is already used | ||
# We receive a context-path and need to find the respective node | ||
contentNode = ${String.split(request.arguments.contentNode || '', '@')[0]} | ||
[email protected] = ${q(documentNode).find(value).get(0) || documentNode} | ||
node = ${this.contentNode} | ||
pathKey = ${request.arguments.ajaxPathKey} | ||
@cache { | ||
mode = 'uncached' | ||
|
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