Skip to content

Commit e726bfa

Browse files
committed
Restore demo
1 parent 29c32b0 commit e726bfa

File tree

13 files changed

+1520
-5
lines changed

13 files changed

+1520
-5
lines changed

.github/workflows/build.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,69 @@ jobs:
157157
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
158158
with:
159159
ignore_links: https://github.com/TileDB-Inc/jupyter-iframe-commands/.*
160+
161+
build-lite:
162+
name: Build JupyterLite
163+
needs: build
164+
runs-on: ubuntu-latest
165+
steps:
166+
- name: Checkout
167+
uses: actions/checkout@v4
168+
169+
- name: Setup Python
170+
uses: actions/setup-python@v5
171+
with:
172+
python-version: '3.12'
173+
174+
- name: Set up Node
175+
uses: actions/setup-node@v4
176+
with:
177+
node-version: 20
178+
cache: 'yarn'
179+
180+
- name: Install the dependencies
181+
run: |
182+
set -eux
183+
python -m pip install -r requirements.txt
184+
jlpm
185+
jlpm build
186+
python -m pip install .
187+
188+
- name: Build the JupyterLite assets
189+
working-directory: demo
190+
run: |
191+
jlpm clean:lite
192+
jlpm build:lite
193+
194+
- name: Install and build Vite dependencies
195+
working-directory: demo
196+
run: |
197+
jlpm
198+
jlpm build:ghpages
199+
200+
- name: Setup Pages
201+
uses: actions/configure-pages@v4
202+
203+
- name: Upload artifact
204+
id: deployment
205+
uses: actions/upload-pages-artifact@v3
206+
with:
207+
path: ./demo/dist
208+
209+
deploy:
210+
needs: build-lite
211+
if: github.ref == 'refs/heads/main'
212+
permissions:
213+
contents: read
214+
pages: write
215+
id-token: write
216+
217+
environment:
218+
name: github-pages
219+
url: ${{ steps.deployment.outputs.page_url }}
220+
221+
runs-on: ubuntu-latest
222+
steps:
223+
- name: Deploy to GitHub Pages
224+
id: deployment
225+
uses: actions/deploy-pages@v4

demo/config/jupyter-lite.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"jupyter-lite-schema-version": 0,
3+
"jupyter-config-data": {
4+
"disabledExtensions": [
5+
"@jupyterlab/mainmenu-extension",
6+
"@jupyterlite/application-extension:logo",
7+
"@jupyterlab/help-extension:resources",
8+
"@jupyter-notebook/lab-extension"
9+
]
10+
}
11+
}

demo/config/overrides.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@jupyter-notebook/application-extension:top": {
3+
"visible": "no"
4+
}
5+
}

demo/example.ipynb

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Example Notebook\n",
8+
"\n",
9+
"This is a simple example notebook that demonstrates basic Python functionality."
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": null,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"# Create a simple list of numbers\n",
19+
"numbers = list(range(1, 6))\n",
20+
"print(f\"Numbers: {numbers}\")"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": null,
26+
"metadata": {},
27+
"outputs": [],
28+
"source": [
29+
"# Calculate the sum and average\n",
30+
"total = sum(numbers)\n",
31+
"average = total / len(numbers)\n",
32+
"\n",
33+
"print(f\"Sum: {total}\")\n",
34+
"print(f\"Average: {average}\")"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": null,
40+
"metadata": {},
41+
"outputs": [],
42+
"source": [
43+
"# Create a simple multiplication table\n",
44+
"n = 5\n",
45+
"for i in range(1, n + 1):\n",
46+
" for j in range(1, n + 1):\n",
47+
" print(f\"{i * j:3}\", end=\" \")\n",
48+
" print()"
49+
]
50+
}
51+
],
52+
"metadata": {
53+
"kernelspec": {
54+
"display_name": "Python 3 (ipykernel)",
55+
"language": "python",
56+
"name": "python3"
57+
},
58+
"language_info": {
59+
"codemirror_mode": {
60+
"name": "ipython",
61+
"version": 3
62+
},
63+
"file_extension": ".py",
64+
"mimetype": "text/x-python",
65+
"name": "python",
66+
"nbconvert_exporter": "python",
67+
"pygments_lexer": "ipython3",
68+
"version": "3.12.8"
69+
}
70+
},
71+
"nbformat": 4,
72+
"nbformat_minor": 4
73+
}

demo/index.html

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!-- parent.html -->
2+
<!doctype html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta
8+
name="description"
9+
content="Demo for Jupyter iframe commands - Control JupyterLab through iframe messages"
10+
/>
11+
<link rel="stylesheet" href="/src/style.css" />
12+
<title>Jupyter IFrame Commands Demo</title>
13+
<script type="module" src="src/main.js"></script>
14+
</head>
15+
<body>
16+
<div class="demo-top">
17+
<h1>%VITE_TITLE% Demo</h1>
18+
<div class="button-row">
19+
<button id="instructions" aria-label="Show instructions">
20+
<span>📖 Instructions</span>
21+
</button>
22+
<button id="list-commands" aria-label="Show available commands">
23+
List Available Commands
24+
</button>
25+
<div class="mode-toggle">
26+
<label>
27+
<input type="radio" name="mode" value="lab" checked />
28+
<span>JupyterLab</span>
29+
</label>
30+
<label>
31+
<input type="radio" name="mode" value="notebook" />
32+
<span>Jupyter Notebook</span>
33+
</label>
34+
</div>
35+
</div>
36+
<div class="input-area">
37+
<form id="commands" autocomplete="off">
38+
<input
39+
type="text"
40+
name="command"
41+
placeholder="Enter a command"
42+
aria-label="Command input"
43+
required
44+
/>
45+
<input
46+
type="text"
47+
name="args"
48+
placeholder="Enter args (optional)"
49+
aria-label="Command arguments"
50+
/>
51+
<button type="submit">Submit Command</button>
52+
</form>
53+
</div>
54+
</div>
55+
56+
<iframe
57+
id="jupyterlab"
58+
src="%VITE_DEMO_SRC%"
59+
sandbox="allow-scripts allow-same-origin"
60+
title="JupyterLab Instance"
61+
loading="lazy"
62+
></iframe>
63+
</body>
64+
</html>

demo/jupyter_server_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# do not open JupyterLab in a browser after starting
2+
c.ServerApp.open_browser = False
3+
4+
# disable the token for easier testing in an IFrame
5+
c.ServerApp.token = ""
6+
7+
# Allow embedding JupyterLab in an IFrame from a specific host
8+
c.ServerApp.tornado_settings = {
9+
"headers": {
10+
"Content-Security-Policy": "frame-ancestors 'self' http://localhost:8080 http://127.0.0.1:8080"
11+
}
12+
}
13+
c.ServerApp.allow_origin = "http://localhost:8080"
14+
15+
c.ServerApp.disable_check_xsrf = True

demo/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "jupyter-iframe-commands-demo",
3+
"private": true,
4+
"version": "0.1.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "VITE_DEMO_SRC='./lite/index.html' VITE_TITLE='Lite' vite",
8+
"build": "tsc && VITE_DEMO_SRC='http://localhost:8888' VITE_TITLE='Local' vite build --base=./",
9+
"build:ghpages": "tsc && VITE_DEMO_SRC='./lite/index.html' VITE_TITLE='Lite' vite build --base=./",
10+
"build:lite": "jlpm clean:lite && jupyter lite build --contents ../README.md --contents ./example.ipynb --lite-dir ./config --output-dir ./public/lite",
11+
"clean:lite": "rm -rf public/lite",
12+
"preview": "VITE_DEMO_SRC='./lite/index.html' VITE_TITLE='Lite' vite preview",
13+
"start:lab": "jupyter lab --config jupyter_server_config.py",
14+
"start:lite": "jlpm dev",
15+
"start:local": "VITE_DEMO_SRC='http://localhost:8888' VITE_TITLE='Local' vite --port 8080"
16+
},
17+
"dependencies": {
18+
"jupyter-iframe-commands-host": "^0.1.0"
19+
},
20+
"devDependencies": {
21+
"typescript": "~5.6.2",
22+
"vite": "^6.0.1"
23+
}
24+
}

0 commit comments

Comments
 (0)