You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-18Lines changed: 30 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
> _**not just sliders!**_
4
4
5
-
Web server to run just the @bind parts of a [Pluto.jl](https://github.com/fonsp/Pluto.jl) notebook.
5
+
Web server to run just the @bind parts of a [Pluto.jl](https://github.com/fonsp/Pluto.jl) notebook.
6
6
7
7
See it in action at [computationalthinking.mit.edu](https://computationalthinking.mit.edu/)! Sliders, buttons and camera inputs work _instantly_, without having to wait for a Julia process. Plutoplutopluto
The main functionality of PlutoSliderServer is to run a ***slider server***. This is a web server that **runs a notebook using Pluto**, and allows visitors to **change the values of `@bind`-ed variables**.
39
+
The main functionality of PlutoSliderServer is to run a ***slider server***. This is a web server that **runs a notebook using Pluto**, and allows visitors to **change the values of `@bind`-ed variables**.
40
40
41
41
The important **differences** between running a *slider server* and running Pluto with public access are:
42
42
- A *slider server* can only set `@bind` values, it is not possible to change the notebook's code.
Many input elements only have a finite number of possible values, for example, `PlutoUI.Slider(5:15)` can only have 11 values. For finite inputs like the slider, PlutoSliderServer can run the slider server **in advance**, and precompute the results to all possible inputs (in other words: precompute the response to all possible requests).
55
+
Many input elements only have a finite number of possible values, for example, `PlutoUI.Slider(5:15)` can only have 11 values. For finite inputs like the slider, PlutoSliderServer can run the slider server **in advance**, and precompute the results to all possible inputs (in other words: precompute the response to all possible requests).
56
56
57
57
This will generate a directory of subdirectories and files, each corresponding to a possible request. You can host this directory along with the generated HTML file (e.g. on GitHub pages), and Pluto will be able to use these pregenerated files as if they are a slider server! **You can get the interactivity of a slider server, without running a Julia server!**
58
58
@@ -71,7 +71,7 @@ See `PlutoSliderServer.export_directory` and `PlutoSliderServer.run_directory`.
71
71
72
72
After scanning a directory for notebook files, you can ask Pluto to continue watching the directory for changes. When notebook files are added/removed, they are also added/removed from the server. When a notebook file changes, the notebook session is restarted.
73
73
74
-
This works especially well when this directory is a git-tracked directory. When running in a git directory, PlutoSliderServer can keep `git pull`ing the directory, updating from the repository automatically.
74
+
This works especially well when this directory is a git-tracked directory. When running in a git directory, PlutoSliderServer can keep `git pull`ing the directory, updating from the repository automatically.
75
75
76
76
See the `SliderServer_watch_dir` option and `PlutoSliderServer.run_git_directory`.
77
77
@@ -157,9 +157,9 @@ There are two ways to change configurations: using keywords arguments, and using
157
157
Our functions can take keyword arguments, for example:
Let's try running it locally before setting up our server:
220
220
```shell
221
221
julia --project="pluto-slider-server-environment" -e "import PlutoSliderServer; PlutoSliderServer.run_git_directory(\".\")"
222
222
```
223
223
224
-
`run_git_directory` will periodically call `git pull`, which requires the `start_dir` to be a repository in which you can `git pull` without password (which means it's either public, or you have the required keys in `~/.ssh/` and your git's provider security page!)
224
+
`run_git_directory` will periodically call `git pull`, which requires the `start_dir` to be a repository in which you can `git pull` without password (which means it's either public, or you have the required keys in `~/.ssh/` and your git's provider security page!)
225
+
226
+
>**Note**
227
+
>Julia by default uses `libgit2` for git operations, [which can be problematic](https://github.com/JuliaLang/Pkg.jl/issues/2679). It is also known to cause issues in cloud environments like AWS's CodeCommit
228
+
>where re-authentication is required at regular intervals.
229
+
>
230
+
> A simple workaround is to set the `JULIA_PKG_USE_CLI_GIT` environment variable to `true`, which will fallback to the system git (the one on the shell).
231
+
> Make sure that this is installed! (`sudo apt-get install git` does the trick in Ubuntu).
232
+
233
+
Also note that `git pull` may fail on the server if you force push the branch from your laptop, so handle history-rewriting commands, like `git push -f`, `git rebase` etc with care!
225
234
226
235
### 4. Set up a server to run PlutoSliderServer
227
236
For this step, we'll assume a very specific but also common setup:
@@ -238,12 +247,12 @@ sudo apt-get upgrade
238
247
239
248
You should run `systemd --version` to verify that we have version 230 or higher.
240
249
241
-
#### 1. Install Julia (run as root)
250
+
#### 1. Install Julia (run as root)
242
251
```shell
243
-
# You can edit me: The Julia version (1.7.3) split into three parts:
252
+
# You can edit me: The Julia version (1.8.0) split into three parts:
# this env var allows us to side step various issues with the Julia-bundled git
301
+
export JULIA_PKG_USE_CLI_GIT=true
302
+
290
303
cd /home/<your-username>/<your-repo> # Make sure to change to the absolute path to your repository. Don't use ~.
291
304
julia --project="pluto-slider-server-environment" -e "import Pkg; Pkg.instantiate(); import PlutoSliderServer; PlutoSliderServer.run_git_directory(\".\")"
292
305
__EOF__
@@ -334,25 +347,24 @@ The most similar project is [PlutoStaticHTML.jl](https://github.com/rikhuijzer/P
334
347
This means that the output of PlutoSliderServer.jl will look exactly the same as what you see while writing the notebook. Output from PlutoStaticHTML.jl is more minimal, which means that it loads faster, it can be styled with CSS, and it can more easily be embedded within other web pages (like Documenter.jl sections).
335
348
336
349
Other Julia packages which export to HTML/PDF, but not necessarily with Pluto notebook files as input, include:
337
-
- Documenter.jl
350
+
- Documenter.jl
338
351
- Franklin.jl
339
352
- Books.jl
340
353
- Weave.jl
341
354
342
355
## Slider server
343
-
PlutoSliderServer is the only package that lets you run a *slider server* for Pluto notebooks (an interactive site to interact with a Pluto notebook through `@bind`).
356
+
PlutoSliderServer is the only package that lets you run a *slider server* for Pluto notebooks (an interactive site to interact with a Pluto notebook through `@bind`).
344
357
345
358
There are alternatives for running a Julia-backed interactive site if your code is *not* a Pluto notebook, including [JSServe.jl](https://github.com/SimonDanisch/JSServe.jl), [Stipple.jl](https://github.com/GenieFramework/Stipple.jl) and [Dash.jl](https://github.com/plotly/Dash.jl), each with their own philosophy and ideal use case. *(Feel free to suggest others!)*
346
359
347
360
## Precomputer slider server
348
361
[PlutoStaticHTML.jl](https://github.com/rikhuijzer/PlutoStaticHTML.jl) should also have this feature in the future, after it is added to PlutoSliderServer (it is still [being worked on](https://github.com/JuliaPluto/PlutoSliderServer.jl/pull/29)).
349
362
350
-
If you code is *not* a Pluto notebook, then [JSServe.jl](https://github.com/SimonDanisch/JSServe.jl) also has precomputing abilities, with a different approach and philosophy.
363
+
If you code is *not* a Pluto notebook, then [JSServe.jl](https://github.com/SimonDanisch/JSServe.jl) also has precomputing abilities, with a different approach and philosophy.
351
364
352
365
# Authentication and security
353
-
Since this server is a new and experimental concept, we highly recommend that you run it inside an isolated environment. While visitors are not able to change the notebook code, it is possible to manipulate the API to set bound values to arbitrary objects. For example, when your notebook uses `@bind x Slider(1:10)`, the API could be used to set the `x` to `9000`, `[10,20,30]` or `"👻"`.
366
+
Since this server is a new and experimental concept, we highly recommend that you run it inside an isolated environment. While visitors are not able to change the notebook code, it is possible to manipulate the API to set bound values to arbitrary objects. For example, when your notebook uses `@bind x Slider(1:10)`, the API could be used to set the `x` to `9000`, `[10,20,30]` or `"👻"`.
354
367
355
368
In the future, we are planning to implement a hook that allows widgets (such as `Slider`) to validate a value before it is run: [`AbstractPlutoDingetjes.Bonds.validate_value`](https://docs.juliahub.com/AbstractPlutoDingetjes/UHbnu/1.1.1/#AbstractPlutoDingetjes.Bonds.validate_value-Tuple{Any,%20Any}).
356
369
357
370
Of course, we are not security experts, and this software does not come with any kind of security guarantee. To be completely safe, assume that someone who can visit the server can execute arbitrary code in the notebook, despite our measures to prevent it. Run PlutoSliderServer in a containerized environment.
0 commit comments