Extension for creating jupyter notebooks from urls.
Project description
nblink 🔗
A JupyterLab Extension for Sharing Notebooks via URL
nblink is a JupyterLab extension that allows you to easily share your Jupyter notebooks by encoding their content into a URL. This enables quick sharing and collaboration without the need for file transfers or cloud storage.
Features
- Save to URL: Compress and encode your notebook content into a shareable URL with a single click.
- Configurable Settings: Choose whether to include cell outputs and select the appropriate URL path for your Jupyter environment.
- Easy Sharing: The generated URL is automatically copied to your clipboard for immediate sharing.
Installation
To install the extension, run the following command in your environment:
pip install nblink
Installation on Jupyterlite
If you are deploying your own jupyterlite instance, you can install nblink by adding it to your requirements.txt. See adding additional requirements to the deployment.
- Follow the instructions here to deploy your own jupyterlite instance: Deploying JupyterLite.
- Add
nblink
to your requirements.txt file. - Push your changes to github, triggering a new deployment containing the nblink extension.
- Confirm the extension is installed by opening a notebook and looking for the "Save to URL" button in the notebook toolbar.
Usage
- Open a Jupyter notebook in JupyterLab.
- Look for the "Save to URL" button in the notebook toolbar.
- Click the main button to save the current content of your notebook to a URL.
- Use the settings icon (gear) next to the main button to configure options:
- Toggle including cell outputs
- Select the appropriate URL path for your Jupyter environment or enter a custom path
- Share the generated URL.
Architecture
nblink is composed of two main components: compression and decompression.
Compression
The compression mechanism, implemented in the urlUtils.ts
file, is responsible for taking the current state of a Jupyter notebook and encoding it into a compact URL format. This process involves serializing the notebook's content, including cells, outputs (if specified), and metadata, then compressing this data using the LZ-string algorithm. The resulting compressed string is then embedded into a URL, along with additional parameters such as the desired view mode (lab or notebook) and other settings. This compressed URL serves as a portable representation of the notebook, allowing users to easily share their work.
Decompression
On the receiving end, the decompression routes, primarily handled in the notebookRoute.ts
file, manage the process of reconstructing a notebook from a compressed URL. When a user navigates to a URL containing compressed notebook data, the extension intercepts this request, extracts the compressed content, and decompresses it back into a full notebook structure. It then creates a new temporary notebook in the Jupyter environment, populates it with the decompressed content, and opens it for the user. This process effectively allows notebooks to be shared and opened without needing to save or transfer actual notebook files.
Configuration
The extension provides two main configuration options:
- Copy Notebook Output: When enabled, cell outputs are included in the generated URL. This is disabled by default to keep URLs shorter but will require the recipient to run the notebook to see the outputs. Modern notebook
- URL Path: Choose the appropriate path based on your Jupyter environment:
/lab/index.html
for JupyterLab/retro/notebooks/index.html
for Jupyter Notebook
Inspiration
This project draws inspiration from the Vega Editor's "Save to URL" feature and PyCafe's goal to simplify sharing python data apps. We've adapted these ideas to the Jupyter ecosystem, aiming to make notebook sharing as easy as passing along a URL. While our approach differs, we're all working towards making collaboration in the coding world more accessible. We encourage you to check out these awesome projects too: Vega Editor (https://vega.github.io/editor/) and PyCafe (https://py.cafe/).
Contributing
We don't have a formal contributing process right now, but we're open to feedback and suggestions. Feel free to open an issue or reach out to us directly if you have any ideas or improvements in mind.
License
This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nblink-0.1.10.tar.gz
.
File metadata
- Download URL: nblink-0.1.10.tar.gz
- Upload date:
- Size: 240.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6051ac7b16926d42748842ba4f7a1047205c60fca773d929567db9d20a05e2a9 |
|
MD5 | 6e84fe403488e7453d49c9e4d9bafb86 |
|
BLAKE2b-256 | dfaddc6c35593f5252d6395d1b5eba989a03436d7de43bdeba5899f7363146b3 |
File details
Details for the file nblink-0.1.10-py3-none-any.whl
.
File metadata
- Download URL: nblink-0.1.10-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81acac4d566346bd16126fd289ae5886e459df419057296caed9d807d9351aa7 |
|
MD5 | 0990ea9cdaa55bf0553e065df8b4300a |
|
BLAKE2b-256 | 68661d63c5517ef19c603487f4ee9af8d6c71cf85d9ffd67aa983c648d26f2ba |