Commit 544f8249 authored by Sebastian's avatar Sebastian

renderjs-extension: update README.md to reflect naming-changes

parent e4c4a70f
......@@ -2,11 +2,10 @@
This repo contains two things:
1. A [jupyter frontend extension](http://jupyter-notebook.readthedocs.io/en/latest/extending/frontend_extensions.html)
also called nbextension containing the javascript and html required to load arbitrary gadgets. See folder
`renderjs_nbextension/`.
also called nbextension containing the javascript and html required to load arbitrary gadgets. See directory *renderjs_nbextension*.
2. An [ipython extension](https://ipython.org/ipython-doc/3/config/extensions/index.html) providing
necessary python commands to initiate renderjs and control the loaded gadgets.
This happens directly from the notebook (cells). See folder *renderjs_ipyextension/*.
This happens directly from the notebook (cells). See directory *renderjs_ipyextension*.
The extension needs both the nbextension and the ipython-extension installed and enabled
in order to function.
......@@ -20,10 +19,10 @@ be used. Instead the ERP5-backend provides the functionality directly.
# Install
## Via slapos
nothing needs to be done, as the extension is shipped with the `ipython-notebook` software.
Nothing needs to be done, as the extension is shipped with the `ipython-notebook` software.
## Manual
the whole directoy */renderjs_nbextension/renderjs_nbextension* needs to be installed
The whole directoy *renderjs_nbextension/renderjs_nbextension* needs to be installed
and enabled as jupyter nbextension. Either use `$ jupyter nbextension [install/enable]`, for instance
```
......@@ -32,7 +31,7 @@ $ jupyter nbextension enable renderjs_nbextension/main --user
```
or copy/symlink manually to the appropriate jupyter directories.
Further, copy the file */renderjs_ipyextension/renderjs_ipyextension/renderjs_extension.py* into the
Further, copy the file *renderjs_ipyextension/renderjs_ipyextension/renderjs_extension.py* into the
ipython directory (usually *~/.ipython* for local install). Note, that the file must be placed directly
into the ipython directory and cannot be contained in a directory.
......@@ -59,12 +58,12 @@ The rest of the functionality is the same from bother Kernels.
## Initialize the extension:
```python
rjs.init_renderjs()
rjs.initRenderJS()
```
## Load a renderjs gadget:
```python
rjs.load_gadget("my_gadget_reference", "https://my.gadget.url/gadget.html")
rjs.loadGadget("my_gadget_reference", "https://my.gadget.url/gadget.html")
```
Note, that you need to assign a unique reference for each gadget. This reference
......@@ -72,7 +71,7 @@ is used when calling declared methods and destroying the gadget.
## Destroy a renderjs gadget:
```python
rjs.destroy("my_gadget_reference")
rjs.destroyGadget("my_gadget_reference")
```
## Call a declared_method of a loaded gadget:
......@@ -81,7 +80,7 @@ arg1 = "Hello"
arg2 = 'World'
arg3 = 2017
arg4 = { "yes": "no!" }
rjs.call_declared_method("my_gadget_reference", "method_name", arg1, arg2, arg3, arg4)
rjs.callDeclaredMethod("my_gadget_reference", "method_name", arg1, arg2, arg3, arg4)
```
The number of arguments can is arbitrary as long as it is python-compatible.
They get converted to js-arguments via pythons `json.dumps`. Keep that in mind
......@@ -89,7 +88,7 @@ when passing more complex arguments.
# Development Notes
The extension is split into a ipython extension and a nbextension für jupyter. This is necessary because both
The extension is split into an ipython extension and a nbextension für jupyter. This is necessary because both
JS in the frontend and python in the backend (client-Kernel/ERP5-backend) are required to
use renderjs gadgets.
......@@ -107,14 +106,14 @@ is in place to respond with `text/html` which contains the inline-javascript cod
## nbextension (Frontend)
Nothing happens on-load of the frontend part. Everything is controlled by the backend
(mostly via events fired from the ipython). Exception to event-based communication is the initial and controller gadget (loading_gadget)
(mostly via events fired from ipython). Exception to event-based communication is the initial and controller gadget (loading_gadget)
which is injected into the page directly and which is initialized by a manual bootstrap of renderjs (since the page is
already loaded; normal bootstrapping happens on-load).
The loading_gadget is responsible for loading other
(actual) gadgets and pass information from the backend to them.
The loading_gadget declares a renderjs service for each possible event which could be fired from the backend
(such as call_declared_method, destroy_gadget, ...).
(such as callDeclaredMethod, destroyGadget, ...).
Multiple gadgets are possible but all are controlled by the same loading_gadget. To differentiate between gadgets
each gadget gets assigned a unique reference
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment