Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5 from IllumiDesk/feature/jupyter-integration
Browse files Browse the repository at this point in the history
Feature/jupyter integration
  • Loading branch information
gzuidhof authored May 14, 2021
2 parents 401ba22 + 4b0c579 commit 89776e7
Show file tree
Hide file tree
Showing 19 changed files with 2,175 additions and 748 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 120
}
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,27 @@ npm run build
http-server --port 8080 --cors
```

To connect to a local Jupyter Kernel Gateway, run:

```shell
KG_ALLOW_METHODS="*" \
jupyter kernelgateway \
--KernelGatewayApp.allow_origin="https://unpkg.com" \
--KernelGatewayApp.allow_headers="authorization,content-type,x-xsrftoken" \
--JupyterWebsocketPersonality.list_kernels=True
```


## Development

```
npm run start
```

And in a different tab you can serve the demo:

```
http-server --cors
```

Note that the demo runs in a properly sandboxes iframe, which means that you need to do a full reload to see changes.
19 changes: 9 additions & 10 deletions demo/demo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {convertJupyterStringToStarboardString, convertStarboardStringToJupyterString} from "https://cdn.skypack.dev/jupystar";
import {StarboardNotebookIFrame} from "https://cdn.skypack.dev/starboard-wrap@0.2.5";
import {upgradeNBGraderCells, preprocessGraderCellsForJupystar, prependPluginLoaderCell} from "../dist/converter.js";
import { convertJupyterStringToStarboardString, convertStarboardStringToJupyterString } from "https://cdn.skypack.dev/jupystar";
import { StarboardEmbed } from "https://cdn.skypack.dev/starboard-wrap@0.3.1";
import { upgradeNBGraderCells, preprocessGraderCellsForJupystar, prependPluginLoaderCell } from "../dist/converter.js";

let currentStarboardNotebookContent = `
# %%--- [javascript]
Expand Down Expand Up @@ -161,19 +161,19 @@ function readFileAsText(file) {
resolve(event.target.result);
})
reader.readAsText(file);
})
})
}

function downloadIpynbAsFile() {
var element = document.createElement('a');
element.setAttribute("href", 'data:text/plain;charset=utf-8,' + encodeURIComponent(currentJupyterNotebookContent));
element.setAttribute('download', "starboard-grader-output.ipynb");

element.style.display = 'none';
document.body.appendChild(element);

element.click();

document.body.removeChild(element);
}

Expand All @@ -188,11 +188,11 @@ function createNotebook(content) {
const href = window.location.href;
const baseUrl = href.substring(0, href.lastIndexOf('/')) + "/";

const el = new StarboardNotebookIFrame({
const el = new StarboardEmbed({
// TODO: we should not need to prepend this loader cell like this, starboard-notebook doesn't
// have a clean way to load plugins at runtime level yet, coming soon!
notebookContent: prependPluginLoaderCell(content),
src: "https://unpkg.com/starboard-notebook@0.8.10/dist/index.html",
src: "https://unpkg.com/starboard-notebook@0.9.3/dist/index.html",
// src: "http://localhost:9001/index.html",
baseUrl: baseUrl,

Expand All @@ -204,7 +204,6 @@ function createNotebook(content) {
updateContent(payload.content);
}
});
el.style.width = "100%";
mount.appendChild(el);
}

Expand Down
Loading

0 comments on commit 89776e7

Please sign in to comment.