Skip to content

Commit 0731084

Browse files
committed
layer show call, to allow for custom script urls
1 parent 98b7a05 commit 0731084

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/providers/generic_http.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,26 @@ can be used in the following way to create a generic display method for webio:
191191
```
192192
The above example enables display code & webio code that doesn't rely on any
193193
provider dependencies.
194+
If you want to host the bundle + websocket script somewhere else, you can also call:
195+
```example
196+
function Base.display(d::MyWebDisplay, m::MIME"application/webio", app)
197+
println(d.io, "outer html")
198+
show(io, m, app, bundle_url, websocket_url)
199+
println(d.io, "close outer html")
200+
end
201+
```
194202
"""
195-
function Base.show(io::IO, ::MIME"application/webio", app::Union{Scope, Node})
196-
# Make sure we run a server
197-
c = global_server_config()
198-
WebIOServer(routing_callback[], baseurl = c.url, http_port = c.http_port)
199-
203+
function Base.show(io::IO, m::MIME"application/webio", app::Union{Scope, Node})
200204
webio_script = wio_asseturl("/webio/dist/bundle.js")
201205
ws_script = wio_asseturl("/providers/websocket_connection.js")
206+
show(io, m, app, webio_script, ws_script)
207+
return
208+
end
202209

210+
function Base.show(io::IO, ::MIME"application/webio", app::Union{Scope, Node}, webio_script, ws_script)
211+
# Make sure we run a server
212+
c = global_server_config()
213+
WebIOServer(routing_callback[], baseurl = c.url, http_port = c.http_port)
203214
println(io, "<script> var websocket_url = $(repr(c.ws_url)) </script>")
204215
println(io, "<script src=$(repr(webio_script))></script>")
205216
println(io, "<script src=$(repr(ws_script)) ></script>")

0 commit comments

Comments
 (0)