Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very early Jupyterlab extension prototype #381

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2aac00e
Push current very experimental and conceptual content, the jupyterlab…
damianavila May 7, 2018
8249713
Update aaplication and notebook dependencies and the README to setup …
damianavila May 7, 2018
661e6b3
Merge commit '7a89959834eae447df8f5119d55edc9bc3359590' into jupyterl…
parmentelat May 28, 2018
08ea93a
Remove unuseful comments and implememts a very basic markupSlides fun…
damianavila Jun 1, 2018
3db691d
Merge branch 'master' into jupyterlab_extension
damianavila Jun 1, 2018
d3d3c00
Merge branch 'jupyterlab_extension' of github.com:damianavila/RISE in…
damianavila Jun 1, 2018
1ea1702
WIP: create classic/ and rise-reveal/ and move stuff in there when ap…
parmentelat Jul 2, 2019
9056946
working split between
parmentelat Jul 2, 2019
191c827
rise-reveal: notes (js + html) get patched instead of being git-added
parmentelat Jul 2, 2019
98b23ed
cleanup
parmentelat Jul 2, 2019
0a77791
preliminary jlab extension
parmentelat Jul 3, 2019
3b1362b
for ts and css, rename files in 'index*' into 'rise*'
parmentelat Jul 3, 2019
89b3acc
tweak rise-reveal packaging so it only contains export; published 380…
parmentelat Jul 3, 2019
376ba3c
trim debug msgs
parmentelat Jul 3, 2019
0fa407b
depend only on rise-reveal, as published on npmjs
parmentelat Jul 3, 2019
f5820c8
pour jquery in the mix
parmentelat Jul 3, 2019
c6b4c5c
protect calls to remove_shortcut()
parmentelat Jul 4, 2019
02475f6
changelog for 5.5.1
parmentelat Jul 5, 2019
a775685
Merge branch 'master' into jupyterlab_extension
damianavila Oct 30, 2020
33607ce
Merge master in and fix conflicts accepting master incoming changes
damianavila Oct 30, 2020
75f95ab
Merge branch 'jlab-redeux' into jupyterlab_extension
damianavila Oct 30, 2020
67ecc68
Add the latest working proto version I worked on
damianavila Nov 1, 2020
b2ac43c
Remove first protoype in favor of the new one under the lab directory
damianavila Nov 1, 2020
7dec34d
Remove jlab directory so we have just once lab devel directory
damianavila Nov 1, 2020
6de9345
Use the patched rise-reveal (shared with classic) local package
damianavila Nov 1, 2020
a127d0c
Import Reveal without requiring it, we were loading from the unpatche…
damianavila Nov 1, 2020
87bca9c
Reorder the definitions and put the button in a more reasonable palce?
damianavila Nov 1, 2020
f4159dc
Add an minimal working notebook
damianavila Nov 1, 2020
b33d8f8
Add the button next to the celltype button/dropdown
damianavila Nov 1, 2020
a71a557
jupyterlab is now 3.*
parmentelat Apr 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions lab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# rise-jupyterlab

A JupyterLab extension to turn your Jupyter Notebooks into a live presentation

## Requirements

* JupyterLab >= 2.0

## Install

```bash
jupyter labextension install rise-jupyterlab
```

## Contributing

### Install

The `jlpm` command is JupyterLab's pinned version of
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
`yarn` or `npm` in lieu of `jlpm` below.

```bash
# Clone the RISE repo to your local environment
# Move to lab directory
# Install dependencies
jlpm
# Build Typescript source
jlpm build
# Install the local rise-reveal patched stuff
jupyter labextension link ../rise-reveal
# Link your development version of the extension with JupyterLab
jupyter labextension link .
# Build JupyterLab
jupyter lab build
# Rebuild Typescript source after making changes
jlpm build
# Rebuild JupyterLab after making any changes
jupyter lab build
```

You can watch the source directory and run JupyterLab in watch mode to watch for changes in the extension's source and automatically rebuild the extension and application.

```bash
# Watch the source directory in another terminal tab
jlpm watch
# Run jupyterlab in watch mode in one terminal tab
jupyter lab --watch
```

### Uninstall

```bash
jupyter labextension uninstall rise-jupyterlab
```

Binary file added lab/commits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions lab/foo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# RISE-jupyterlab (prototype!!!) in JupyterLab 2.2.9!"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I am a WIP PoC again!\n"
]
}
],
"source": [
"print(\"I am a WIP PoC again!\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Let's ride the wave..."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"![commits](commits.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Thank you!"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
62 changes: 62 additions & 0 deletions lab/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "rise-jupyterlab",
"version": "0.1.0",
"description": "A JupyterLab extension to turn your Jupyter Notebooks into a live presentation",
"keywords": [
"jupyter",
"jupyterlab",
"jupyterlab-extension",
"reveal.js",
"RISE",
"slideshow",
"slides"
],
"homepage": "https://github.com/damianavila/RISE/tree/lab/README.md",
"bugs": {
"url": "https://github.com/damianavila/RISE/issues"
},
"license": "BSD-3-Clause",
"author": {
"name": "Damián Avila",
"url": "https://github.com/damianavila"
},
"contributors": [
{
"name": "Thierry Parmentelat",
"url": "https://github.com/parmentelat"
}
],
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
"src/custom.d.ts"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"style": "style/index.css",
"repository": {
"type": "git",
"url": "https://github.com/damianavila/RISE.git"
},
"scripts": {
"build": "tsc",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"prepare": "jlpm run clean && jlpm run build",
"watch": "tsc -w"
},
"dependencies": {
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/notebook": "^3.0.0",
"rise-reveal": "../rise-reveal"
},
"devDependencies": {
"rimraf": "^2.6.1",
"typescript": "~3.7.0"
},
"sideEffects": [
"style/*.css"
],
"jupyterlab": {
"extension": true
}
}
6 changes: 6 additions & 0 deletions lab/src/custom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module "rise-reveal/export/reveal.js";

declare module "*.svg" {
const content: string;
export default content;
}
158 changes: 158 additions & 0 deletions lab/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
declare let require:(moduleId:string) => any;
//let Reveal = require('reveal.js');
import Reveal from 'rise-reveal/export/reveal.js';

import {
JupyterFrontEnd, JupyterFrontEndPlugin
} from '@jupyterlab/application';

import {
IDisposable, DisposableDelegate
} from '@lumino/disposable';

import {
ToolbarButton
} from '@jupyterlab/apputils';

import {
DocumentRegistry
} from '@jupyterlab/docregistry';

import {
NotebookPanel, INotebookModel
} from '@jupyterlab/notebook';

import {
JSONObject
} from '@lumino/coreutils';

import {
LabIcon
} from '@jupyterlab/ui-components';

import '../style/index.css';

import riseIconStr from '../style/icons/assessment.svg';

/**
* Initialization data for the rise-lab extension.
*/
const extension: JupyterFrontEndPlugin<void> = {
id: 'rise-lab',
autoStart: true,
activate
};

/**
* A notebook widget extension that adds a RISE button to the toolbar.
*/
export
class RiseExtension implements DocumentRegistry.IWidgetExtension<NotebookPanel, INotebookModel> {
/**
* Create a new extension object.
*/
createNew(panel: NotebookPanel, context: DocumentRegistry.IContext<INotebookModel>): IDisposable {
let callback = () => {

function get_slide_type(cell: any) {
let slideshow = (cell.metadata.get("slideshow") || {});
let slide_type = (slideshow as JSONObject)['slide_type'];
//console.log(slide_type);
return ((slide_type === undefined) || (slide_type == '-')) ? '' : slide_type;
}

// function is_slide(cell: any) {return get_slide_type(cell) == 'slide';}
// function is_subslide(cell: any) {return get_slide_type(cell) == 'subslide';}
// function is_fragment(cell: any) {return get_slide_type(cell) == 'fragment';}
// function is_regular(cell: any) {return get_slide_type(cell) == '';

function markupSlides(container: any) {
let slide_section;
let slide_counter = 0;
let cells = container.model.cells;

for (let i=0; i < cells.length; i++) {
let cell = cells.get(i);
let slide_type = get_slide_type(cell);

let cell_node = container.node.children[slide_counter];
let prev_slide_section = slide_section;

if (slide_type === 'slide') {
// Start new slide
slide_section = document.createElement('section');
slide_section.appendChild(cell_node);
if (i === 0) {
container.node.insertBefore(slide_section, container.node.firstChild);
} else {
container.node.insertBefore(slide_section, prev_slide_section.nextSibling);
}
slide_counter++;
console.log("Sep slide", i);
} else {
slide_section.appendChild(cell_node);
console.log("Nop slide", i);
}
console.log(container.node);
}
}

let notebook = panel.content;
markupSlides(notebook);

let panel_container = document.getElementsByClassName("jp-NotebookPanel")[0];
panel_container.classList.add("reveal");
//console.log("panel_container");

let notebook_container = document.getElementsByClassName("jp-Notebook")[0];
notebook_container.classList.add("slides");
//console.log("notebook_container");

let revealCSS = require('../../rise-reveal/export/reveal.js/css/reveal.css');
console.log(revealCSS);
let customCSS = require('../style/rise.css');
console.log(customCSS);
//let revealTheme = require('reveal.js/css/theme/simple.css');

Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,

transition: 'slide', // none/fade/slide/convex/concave/zoom
//make codemirror works as expected
minScale: 1.0,
maxScale: 1.0
});
};

const riseIcon = new LabIcon({ name: 'rise:slideshow', svgstr: riseIconStr });

let button = new ToolbarButton({
icon: riseIcon,
onClick: callback,
tooltip: 'RISE me'
});

// Getting the index iteratively is less resource consuming, but this is far more readable
// and we only need to get the index at the loading of the extension...
let cellTypeButton = panel.toolbar.node.getElementsByClassName("jp-Notebook-toolbarCellType")[0]
let index = Array.from(cellTypeButton.parentNode.children).indexOf(cellTypeButton)

panel.toolbar.insertItem(index + 1,'rise', button);
return new DisposableDelegate(() => {
button.dispose();
});
}
}

/**
* Activate the extension.
*/
function activate(app: JupyterFrontEnd) {
app.docRegistry.addWidgetExtension('Notebook', new RiseExtension());
console.log('JupyterLab extension rise-lab is activated!');
};

export default extension;
Binary file added lab/style/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions lab/style/icons/assessment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lab/style/icons/insert_chart_outlined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added lab/style/index.css
Empty file.
3 changes: 3 additions & 0 deletions lab/style/rise.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.reveal .slides {
text-align: left;
}
Loading