Skip to main content

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

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.

Usage

An image demonstrating the Save to URL and customization options.

  1. Open a Jupyter notebook in JupyterLab.
  2. Look for the "Save to URL" button in the notebook toolbar.
  3. Click the main button to save the current content of your notebook to a URL.
  4. 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
  5. 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:

  1. 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
  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nblink-0.1.1.tar.gz (275.6 kB view details)

Uploaded Source

Built Distribution

nblink-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page