Skip to content

Commit

Permalink
Add the ES module for datatables.net to the static assets
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed May 11, 2022
1 parent 356219e commit 36ec441
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# A (tentative) Jupyter Lab extension for itables
# A Jupyter Lab extension for itables

This extension exposes the [jquery](https://jquery.com/) and
[datatables.net](https://datatables.net/) libraries
as static libraries in Jupyter Lab.
This extension exposes the [jquery](https://jquery.com/) and [datatables.net](https://datatables.net/) libraries and css as static files in Jupyter Lab.

The purpose of doing this is to allow the
[itables](https://mwouts.github.io/itables) package to have an
[offline mode](https://github.com/mwouts/itables/issues/70) in Jupyter Lab.
The purpose of doing this is to allow the [itables](https://mwouts.github.io/itables) package to have an [offline mode](https://github.com/mwouts/itables/issues/70) in Jupyter Lab.

Install it in the Python environment you use to launch Jupyter Lab with:
```shell
pip install jupyterlab-itables==0.1.0a0
pip install jupyterlab-itables
```

Then relaunch Jupyter Lab with
Expand All @@ -21,7 +17,7 @@ jupyter lab
Assuming that Jupyter Lab is running on port 8888, you will be able to access the static files at e.g.
- http://localhost:8888/static/itables/jquery/dist/jquery.min.js
- http://localhost:8888/static/itables/datatables.net-dt/css/jquery.dataTables.min.css
- http://localhost:8888/static/itables/datatables.net-dt/js/dataTables.dataTables.min.js
- http://localhost:8888/static/itables/datatables.net/js/jquery.dataTables.min.mjs

# How to develop this extension

Expand Down
7 changes: 6 additions & 1 deletion copyAssets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
from shutil import rmtree, copytree
from requests import get

node_modules = Path(__file__).parent / "node_modules"
static = Path(__file__).parent / "jupyterlab_itables" / "static"
Expand All @@ -8,4 +9,8 @@
rmtree(static)

for library in ['jquery', 'datatables.net', 'datatables.net-dt']:
copytree(node_modules / library, static / library)
copytree(node_modules / library, static / library)

# jquery.dataTables.min.mjs will be included in the npm module version 1.12
dt_mjs = get('https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.mjs').content
(static / 'datatables.net' / 'js' / 'jquery.dataTables.min.mjs').write_bytes(dt_mjs)
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies:
- jupyterlab>=3.3
- nodejs
- nb_conda_kernels
- requests
- pip
- twine
- pip:
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "jupyter_packaging>=0.10,<2"]
requires = ["setuptools", "wheel", "jupyter_packaging>=0.10,<2", "requests"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ long_description = file: README.md
long_description_content_type = text/markdown
author = Marc Wouts
author_email = marc.wouts@gmail.com
url = http://github.com/mwouts/jupyterlab-itables3/
url = http://github.com/mwouts/jupyterlab-itables/
platforms = Linux, Mac OS X, Windows
keywords = ipython, jupyter, jupyter-server, datatables
license = BSD 3-Clause License
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@

NAME = "jupyterlab_itables"
here = Path(__file__).absolute().parent
version = "0.1.0b0"
version = "0.1.0c0"

jstargets = [
here.joinpath(NAME, "static", "jquery", "LICENSE.txt"),
here.joinpath(NAME, "static", "jquery", "dist", "jquery.js"),
here.joinpath(NAME, "static", "jquery", "dist", "jquery.min.js"),
here.joinpath(NAME, "static", "datatables.net-dt", "License.txt"),
here.joinpath(NAME, "static", "datatables.net-dt", "css", "jquery.dataTables.min.css"),
here.joinpath(NAME, "static", "datatables.net", "License.txt"),
here.joinpath(NAME, "static", "datatables.net", "js", "jquery.dataTables.min.js"),
here.joinpath(NAME, "static", "datatables.net", "js", 'jquery.dataTables.min.mjs')
]

# Handle datafiles
Expand Down

0 comments on commit 36ec441

Please sign in to comment.