From 334aa151cbde7fac58b5630e023f77988e6806e3 Mon Sep 17 00:00:00 2001 From: Johan Brichau Date: Sat, 26 Aug 2023 08:46:25 +0200 Subject: [PATCH] add convenience method to the turbostreambuilder to remove a component such that you do not need to care about the id --- .../instance/after.with..st | 1 + .../instance/append.with..st | 1 + .../instance/before.with..st | 1 + .../instance/prepend.with..st | 1 + .../instance/remove..st | 1 + .../instance/removeComponent..st | 4 ++++ .../instance/replace.with..st | 1 + .../instance/turboStreamAction.target.with..st | 1 + .../instance/update.with..st | 1 + .../README.md | 0 .../instance/processRendering..st | 10 ++++++++++ .../instance/renderContext..st | 4 ++++ .../instance/renderTurboFrameResponseOn..st | 18 ++++++++++++++++++ .../properties.json | 13 +++++++++++++ 14 files changed, 57 insertions(+) create mode 100644 repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/removeComponent..st create mode 100644 repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/README.md create mode 100644 repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/processRendering..st create mode 100644 repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderContext..st create mode 100644 repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderTurboFrameResponseOn..st create mode 100644 repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/properties.json diff --git a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/after.with..st b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/after.with..st index 64936c319..2cb922140 100644 --- a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/after.with..st +++ b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/after.with..st @@ -1,3 +1,4 @@ actions after: anId with: aRenderable + self turboStreamAction: 'after' target: anId with: aRenderable \ No newline at end of file diff --git a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/append.with..st b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/append.with..st index a3e8c4a17..c03c0d824 100644 --- a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/append.with..st +++ b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/append.with..st @@ -1,3 +1,4 @@ actions append: anId with: aRenderable + self turboStreamAction: 'append' target: anId with: aRenderable \ No newline at end of file diff --git a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/before.with..st b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/before.with..st index dc6121ebc..76b6403df 100644 --- a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/before.with..st +++ b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/before.with..st @@ -1,3 +1,4 @@ actions before: anId with: aRenderable + self turboStreamAction: 'before' target: anId with: aRenderable \ No newline at end of file diff --git a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/prepend.with..st b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/prepend.with..st index e3b7f7429..2d4463036 100644 --- a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/prepend.with..st +++ b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/prepend.with..st @@ -1,3 +1,4 @@ actions prepend: anId with: aRenderable + self turboStreamAction: 'prepend' target: anId with: aRenderable \ No newline at end of file diff --git a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/remove..st b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/remove..st index 7616c45d3..3085e1340 100644 --- a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/remove..st +++ b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/remove..st @@ -1,3 +1,4 @@ actions remove: anId + self turboStreamAction: 'remove' target: anId with: nil \ No newline at end of file diff --git a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/removeComponent..st b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/removeComponent..st new file mode 100644 index 000000000..c652862ca --- /dev/null +++ b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/removeComponent..st @@ -0,0 +1,4 @@ +convenience +removeComponent: aComponent + + self remove: aComponent turboframeDecoration id \ No newline at end of file diff --git a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/replace.with..st b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/replace.with..st index 44091d5fd..56034e8a0 100644 --- a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/replace.with..st +++ b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/replace.with..st @@ -1,3 +1,4 @@ actions replace: anId with: aRenderable + self turboStreamAction: 'replace' target: anId with: aRenderable \ No newline at end of file diff --git a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/turboStreamAction.target.with..st b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/turboStreamAction.target.with..st index 737a0ba85..ecfe69649 100644 --- a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/turboStreamAction.target.with..st +++ b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/turboStreamAction.target.with..st @@ -1,5 +1,6 @@ private turboStreamAction: aName target: anId with: aRenderable + (canvas tag: 'turbo-stream') attributeAt: 'action' put: aName; attributeAt: 'target' put: anId; diff --git a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/update.with..st b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/update.with..st index 34d2b3c32..59ec5458b 100644 --- a/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/update.with..st +++ b/repository/Seaside-HotwireTurbo.package/WATurboStreamBuilder.class/instance/update.with..st @@ -1,3 +1,4 @@ actions update: anId with: aRenderable + self turboStreamAction: 'update' target: anId with: aRenderable \ No newline at end of file diff --git a/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/README.md b/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/processRendering..st b/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/processRendering..st new file mode 100644 index 000000000..75cacd96e --- /dev/null +++ b/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/processRendering..st @@ -0,0 +1,10 @@ +processing +processRendering: aResponse + + self requestContext request isTurboFrameRequest + ifTrue: [ + aResponse + doNotCache; + contentType: self application contentType. + self renderTurboFrameResponseOn: aResponse stream ] + ifFalse: [ super processRendering: aResponse ] \ No newline at end of file diff --git a/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderContext..st b/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderContext..st new file mode 100644 index 000000000..78775772b --- /dev/null +++ b/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderContext..st @@ -0,0 +1,4 @@ +accessing +renderContext: anObject + + renderContext := anObject \ No newline at end of file diff --git a/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderTurboFrameResponseOn..st b/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderTurboFrameResponseOn..st new file mode 100644 index 000000000..a4386244e --- /dev/null +++ b/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/instance/renderTurboFrameResponseOn..st @@ -0,0 +1,18 @@ +rendering +renderTurboFrameResponseOn: aStream + "Render aRenderable on aStream." + + | document turboframeId | + turboframeId := self requestContext request headerAt: 'turbo-frame'. + document := (WAHtmlDocument on: aStream codec: self requestContext codec) + scriptGenerator: self requestContext handler scriptGeneratorClass new; + yourself. + renderContext + document: document + during: [ + renderContext + visitor: ((WATurboFramePresenterGuide client: (WARenderVisitor context: renderContext)) id: turboframeId) + during: [ + self presenter renderWithContext: renderContext ] + "self presenter allPresentersDo: [ :p | ((p isKindOf: WATurboFrame) and: [ turboframeId = p id ]) ifTrue:[ self halt. p renderWithContext: renderContext ] ]" ]. + document scriptGenerator closeOn: document \ No newline at end of file diff --git a/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/properties.json b/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/properties.json new file mode 100644 index 000000000..d7e498c5e --- /dev/null +++ b/repository/Seaside-RenderLoop.package/WATurboRenderPhaseContinuation.class/properties.json @@ -0,0 +1,13 @@ +{ + "commentStamp" : "", + "super" : "WARenderPhaseContinuation", + "category" : "Seaside-RenderLoop-Continuations", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ + "renderContext" + ], + "name" : "WATurboRenderPhaseContinuation", + "type" : "normal" +} \ No newline at end of file