Closed bhaskarvk closed 7 years ago
Once I code up the ability to config the docker instance we can have a /widget
(or something) dir that the widget HTML files get shoved to and then automagically pass a file:///
URI to Splash (assuming it takes file URIs which it should). spiffy idea!
ARGH. It does not support file:// URIs BUT it's prbly doable to fire up another internal web server in the container (or use the existing one) and have it point to a mounted directory.
devd ?
hahahaha. I literally just began to test that
I cld also fire up a local web server (on the host) and point splash to it (just tried that too)
meaning on a non-loopback interface ? Not straightforward to connect to host services running on loopback, no? In any case it would go a long way in being able to do some unit/integration tests on widgets.
ok, so I made a new Docker image that also starts up an internal web server in the image (using python simplehttpserver). It looks for files in an internal mount point. I modified start_splash
and some other functions to automatically mount a local os temp dir into the docker vm. You have to call start_splash()
with add_tempdir=TRUE
for that to work.
You may need to modify:
on macOS to ensure /private
is shared/accessible.
Once all that is done, then you can call the new render_file()
:
render_file <- function(splash_obj, file_path, output=c("html", "png"), wait=0, viewport="1024x768") …
file_path
is the path to the HTML file you want to render. Choose html
to get XML back and png
to get PNG back and modify wait
and viewport
accordingly.
It'll copy the file over to the tempdir and mangle a new URL for Splash
to render.
I tested it with a cpl HTMLs from Rmds and it seems to work fine but this was just hacked together in abt 10m so YMMV.
NOTE: you absolutely need to re-run install_splash()
as it picks up the new image from my docker hub.
Will re-open if it breaks
It would be awesome if we can have
render_widget(widget_instance)
render_*
to acceptfile:///
URLs with a path on the hostFor all these the biggest inhibitor is that splash is running inside a docker container, so need a way to mount local files.
It'll also be nice if
render_*
can connect to host's loopback somehow. So we can also usehttp://localhost:...
URLs, where localhost is the host not the docker image.