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

Turbo hotwired #1365

Merged
merged 34 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
139f0ce
Added support for 'type' attribute on a script tag
May 14, 2023
f83c4a6
Added support for turbo frames and responding to turbo actions with r…
Jun 6, 2023
fb5d0c0
turbolinks: do not redirect + turbo frames should render only once
Jul 2, 2023
be898ae
added first version of turbo frame navigation and turbostream rendering
Aug 14, 2023
953b080
redirect turbo frame navigation response on POST; always use replace …
Aug 14, 2023
c826a3b
Convenience method for rendering Javascript from a String
Aug 20, 2023
76d2474
Fix callback priority for turbostream callback to make sure it's the …
Aug 20, 2023
c971b5c
Added the WAPluggablePresenter class that allows to instantiate a pre…
Aug 20, 2023
b414e02
Changed todo demo to basic seaside app and moved the jquery version t…
Aug 23, 2023
86cadb9
Added jQuery-Examples
Aug 23, 2023
45517c0
Cleanup class checks
Aug 23, 2023
76e1f14
turbo callback via a javascript callback
Aug 23, 2023
e06d397
Turbolinks examples: multicounter and todo app
Aug 23, 2023
e39829f
Fix registration of Turbo examples
Aug 23, 2023
064b4dc
more convenient turbocallback names
Aug 23, 2023
cdf44af
small improvements to the turbo todo example
Aug 23, 2023
dbce514
Added comments to some turbo attributes
Aug 23, 2023
8c6a615
Added titles for todo app
Aug 24, 2023
bdcb561
add edit anchor on todo item and clean up code examples
Aug 24, 2023
334aa15
add convenience method to the turbostreambuilder to remove a componen…
Aug 26, 2023
8b4131d
drop the WATurboActionCallback and use a (regular) WAActionCallback i…
Aug 26, 2023
9f07adf
also move the turbostream rendering to the redirected rendering conti…
Aug 26, 2023
22b5cd1
disable evaluation of WATurboStreamCallback outside of the rendering …
Aug 26, 2023
f1be9fe
Merge branch 'master' into turbo
Aug 28, 2023
62827f1
remove canvas>>javascript: as it's not conform the paradigm of the ca…
Sep 17, 2023
8847e1e
Merge f1be9fed9621529fa63e0c99add6320b17a93499
Sep 17, 2023
ed6d22a
Merge branch 'master' into turbo
Sep 17, 2023
1628752
added test for script type, re-added WARenderer>>javascript: shorthan…
Sep 17, 2023
a013724
code style
Sep 17, 2023
2aab196
tests for data attributes
Sep 17, 2023
a95d816
remove merge artefacts: packages got re-added
Sep 17, 2023
6cf0891
include 'Seaside-HotwireTurbo' in baselineof
Sep 17, 2023
1502245
Merge a95d816f96c172878e51e8f1eec9a120d218016d
Sep 17, 2023
b9587b4
correct dependencies
Sep 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ baselinecommon: spec
package: 'Seaside-Tools-Core' with: [
spec requires: #('Seaside-Core' 'Seaside-Component' 'Seaside-RenderLoop' 'Seaside-Session' ). ];
package: 'Seaside-Tools-Web' with: [
spec requires: #('Seaside-Tools-Core' 'Seaside-RenderLoop' 'Seaside-Widgets' ). ];
spec requires: #('Seaside-Tools-Core' 'Seaside-RenderLoop' 'Seaside-Widgets' ) ];
package: 'Seaside-Widgets' with: [
spec requires: #('Seaside-Component' 'Seaside-Canvas' ). ];
spec requires: #('Seaside-Component' 'Seaside-Canvas' ) ];
package: 'Seaside-HotwireTurbo' with: [
spec requires: #('Seaside-Core' 'Seaside-Component' 'Seaside-Canvas') ];
package: 'Seaside-HotwireTurbo-Examples' with: [
spec requires: #('Seaside-HotwireTurbo') ];
package: 'Seaside-Tests-Canvas' with: [
spec requires: #('Seaside-Tests-Core' 'Seaside-Canvas' ). ];
package: 'Seaside-Tests-Component' with: [
Expand Down Expand Up @@ -96,11 +100,12 @@ baselinecommon: spec
spec
group: 'default' with: #('Core' 'JSON' 'Email' 'Javascript' 'JQuery' 'JQueryUI' 'Seaside-Examples' 'Seaside-Welcome');
group: 'OneClick' with: #('Tests' 'Development' 'Zinc');
group: 'CI' with: #('Tests' 'Development Tests');
group: 'CI' with: #('Tests' 'Development Tests' 'Seaside-HotwireTurbo');
group: 'Core' with: #('Seaside-Core' 'Seaside-Continuation' 'Seaside-Canvas' 'Seaside-Session' 'Seaside-Component' 'Seaside-RenderLoop' 'Seaside-Tools-Core' 'Seaside-Flow' 'Seaside-Environment' 'Seaside-Widgets' );
group: 'Tests' with: #('Core' 'Seaside-Tests-Core' 'Seaside-Tests-Canvas' 'Seaside-Tests-Session' 'Seaside-Tests-Component' 'Seaside-Tests-RenderLoop' 'Seaside-Tests-Environment' 'Seaside-Tests-Flow' 'Seaside-Tests-UTF8' 'Seaside-Tests-InternetExplorer' 'Seaside-Tests-Email' 'Seaside-Tests-Examples' 'RSS Tests' 'Welcome Tests' 'REST Tests' 'Swagger Tests' 'Seaside-Tests-Parasol');
group: 'Development' with: #('Core' 'Seaside-Development' );
group: 'Development Tests' with: #('Development' 'Core' 'Seaside-Tests-Development' );
group: 'Hotwired' with: #('Seaside-HotwireTurbo');
group: 'Development' with: #('Core' 'Seaside-Development');
group: 'Development Tests' with: #('Development' 'Core' 'Seaside-Tests-Development');
group: 'Email' with: #('Seaside-Email');
group: 'Examples' with: #('Core' 'Seaside-Examples' 'Seaside-REST-Examples');
group: 'Examples' with: #('Core' 'Seaside-Examples' 'Seaside-REST-Examples' 'Seaside-HotwireTurbo-Examples');
group: 'Base' with: #('Core') ].
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ baselinejquery: spec
spec requires: #('Javascript-Core' ) ];
package: 'JQuery-Tests-Core' with: [
spec requires: #('JQuery-Core' 'Javascript-Tests-Core' 'Seaside-Development' 'Seaside-Tests-Functional' 'Seaside-Ajaxifier-Core') ];
package: 'JQuery-Examples' with: [
spec requires: #('JQuery-Core') ];
package: 'JQuery-JSON' with: [
spec requires: #('JQuery-Core' 'Seaside-JSON-Core') ];
package: 'JQuery-Tests-JSON' with: [
Expand All @@ -16,4 +18,5 @@ baselinejquery: spec
spec
group: 'JQuery' with: #('JQuery-Core' 'JQuery-JSON');
group: 'JQuery Tests' with: #('JQuery-Tests-Core' 'JQuery-Tests-JSON');
group: 'Examples' with: #('JQuery-Examples');
group: 'Tests' with: #( 'JQuery Tests' ) ]
5 changes: 5 additions & 0 deletions repository/JQuery-Examples.package/.filetree
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"separateMethodMetaAndSource" : false,
"noMethodMetaData" : true,
"useCypressPropertiesFile" : true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialization
initialize
(WAAdmin register: self asApplicationAt: '/examples/todo-jquery')
exceptionHandler: WADebugErrorHandler;
addLibrary: WAExamplesLibrary
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
actions
addTodo: aString
| newTodo |
newTodo := WATodoWithJQueryItem newWithDescription: aString in: todos.
todos add: newTodo.
^ newTodo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
children
^ self todos
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
initialization
initialize
super initialize.
todos := OrderedCollection new.
1 to: 5000 do: [ :index |
self addTodo: 'Task ', index greaseString ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rendering
renderAddNewTodoOn: html
| newTodo |
html header
id: #header;
with: [
html heading
level: 1;
with: 'todos'.
html textInput
id: #'new-todo';
autofocus;
attributeAt: 'autocomplete' put: 'off';
callback: [ :value | newTodo := self addTodo: value ];
onChange: (html jQuery ajax
serializeThis;
script: [ :s | s << ((s jQuery id: 'todo-list') append: newTodo) ];
onComplete: ((html jQuery id: #'new-todo') value: ''));
placeholder: 'What needs to be done?' ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rendering
renderContentOn: html
html section
id: #todoapp;
with: [
self renderAddNewTodoOn: html.
self renderTodosOn: html ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rendering
renderTodosOn: html

html section
id: 'main';
with: [
html checkbox
id: 'toggle-all'.
html label
for: 'toggle-all';
with: 'Mark all as complete'.
html unorderedList
id: 'todo-list';
script: (self scriptToTriggerCheckboxToggleOn: html);
script: (self scriptToTriggerRenameOn: html);
script: (self scriptToTriggerEditOn: html);
script: (self scriptToSerializeEditOn: html);
with: [
self todos do: [ :todoItem | todoItem renderOn: html ] ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rendering
scriptToSerializeEditOn: html

| currentItem itemId |
^ html jQuery this
on: 'change'
selector:'.edit'
do: ((
html jQuery ajax
serialize: (html jQuery expression: (JSStream on:'event.target'));
callback: [ :passengers | currentItem := passengers first ]
passengers: ((html jQuery expression: (JSStream on:'event.target')) closest:'li');
callback: [ :id | itemId := id ]
value: (JSStream on:'$(event.target).closest("li").get(0).id');
script: [ :s | s << (((s jQuery id: itemId) find: 'label') html: currentItem description) ];
onComplete: ((((html jQuery expression: (JSStream on: 'event.target')) closest:'li') find: '.edit') hide, (((html jQuery expression: (JSStream on: 'event.target')) closest:'li') find: 'label') show))
asFunction: #(event))
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rendering
scriptToTriggerCheckboxToggleOn: html

^ html jQuery this
on: 'click'
selector: '.toggle'
do: ((html jQuery ajax serializeWithHidden: (html jQuery expression: (JSStream on: 'event.target'))) asFunction: #(event))
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rendering
scriptToTriggerEditOn: html

^ html jQuery this
on: 'click'
selector: '.view>label'
do: (((((html jQuery expression: (JSStream on: 'event.target')) hide closest:'li') find: '.edit') show) asFunction:#(event))
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rendering
scriptToTriggerRenameOn: html

^ html jQuery this
on: 'click'
selector: '.destroy'
do: ((html jQuery ajax
callback: [ :passengers | passengers first remove ]
passengers: (((html jQuery expression: (JSStream on:'event.target')) closest: 'li'));
onComplete: (((html jQuery expression: (JSStream on:'event.target')) closest: 'li') remove)) asFunction: #(event))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
todos
^ todos
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rendering
updateRoot: aRoot

super updateRoot: aRoot.
aRoot title: 'Seaside-JQuery Todo Demo'.
aRoot stylesheet url: WAExamplesLibrary / #todoCss.
aRoot javascript url: JQDeploymentLibrary / #jQueryJs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"commentStamp" : "",
"super" : "WAExampleComponent",
"category" : "JQuery-Examples",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"todos"
],
"name" : "WATodoWithJQuery",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
newWithDescription: aString in: aCollection
^ self new initializeWithDescription: aString in: aCollection
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
description: anObject
description := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
description
^ description
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
done: anObject
done := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
done
^ done
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
initialization
initializeWithDescription: aString in: aCollection
self initialize.
self done: false.
self description: aString.
todos := aCollection
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
remove
todos remove: self
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
rendering
renderContentOn: html
html listItem
passenger: self;
with: [
html div
class: 'view';
with:[
html checkbox
class: 'toggle';
callback: [ :value | self done: value ];
value: done.
html label: description.
html button
class: 'destroy' ].
html textInput
class: 'edit';
style: 'display:none';
callback: [ :value | self description: value ];
value: description ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"commentStamp" : "",
"super" : "WAComponent",
"category" : "JQuery-Examples",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"todos",
"description",
"done"
],
"name" : "WATodoWithJQueryItem",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SystemOrganization addCategory: #'JQuery-Examples'!
Empty file.
1 change: 1 addition & 0 deletions repository/JQuery-Examples.package/monticello.meta/package
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(name 'JQuery-Examples')
1 change: 1 addition & 0 deletions repository/JQuery-Examples.package/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*javascript-core
javascript: aString

^ JSStream on: aString
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
attributes
defer
"When set, this boolean attribute provides a hint to the user agent that the script is not going to generate any document content (e.g., no 'document.write' in javascript) and thus, the user agent can continue parsing and rendering."

self attributes at: 'defer' put: true
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
attributes
resourceUrl: aString

self url: (canvas absoluteUrlForResource: aString)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessing
tag

^ 'script'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
attributes
type: aString

self attributeAt: 'type' put: aString
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
attributes
url: aString

self attributes at: 'src' put: aString
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
public
with: aString
self attributes
with: aString

self attributes
at: 'type'
ifAbsentPut: [ 'text/javascript' ].
super with: [
aString isNil ifFalse: [
aString ifNotNil: [
self document nextPutAll: aString greaseString ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
attributes
dataAttributeAt: aString put: aValue

self attributeAt: 'data-',aString put: aValue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
attributes
dataAttributeAt: aString put: aValue if: aBoolean

aBoolean ifTrue:[ self dataAttributeAt: aString put: aValue ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
block: aBlock
block := aBlock
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rendering
renderContentOn: html
block value: html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"commentStamp" : "",
"super" : "WAComponent",
"category" : "Seaside-Component-Base",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"block"
],
"name" : "WAPluggablePresenter",
"type" : "normal"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ handle: aRequestContext
callbacks at: key ifPresent: [ :callback |
(callback isEnabledFor: aRequestContext)
ifTrue: [ set add: callback ] ] ].
"Process the callbacks in order of priority"
set sorted do: [ :callback |
callback evaluateWithFieldValues:
(fields allAt: callback key) ]
Loading