Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Oct 16, 2024
0 parents commit 4d3380a
Show file tree
Hide file tree
Showing 111 changed files with 34,724 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 5255abc07ec372c185ebac0c40b91438
tags: 645f666f9bcd5a90fca523b33c5a78b7
1 change: 1 addition & 0 deletions .extra_resources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"/home/runner/work/nbsite/nbsite/site/doc/playground/pyodide/index.md": {"css": [], "js": ["https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js", "https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js", "https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js"], "js_exports": {}, "js_modules": {}}, "/home/runner/work/nbsite/nbsite/site/doc/playground/pyodide/holoviz.md": {"css": [], "js": ["https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js", "https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js", "https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js"], "js_exports": {}, "js_modules": {}}}
Empty file added .nojekyll
Empty file.
1 change: 1 addition & 0 deletions .pyodide/682b1f02dcb0c227011060c4b16acacd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"e73b48e8e00d36304ea7204a0683c814": [null, null, "hello\n", "", ["https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js", "https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js", "https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js"], {}, {}, [], []]}
1 change: 1 addition & 0 deletions .pyodide/76abbd8056ddd6e9cb44cf3e1c838598.json

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions PyodideServiceWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const appName = 'nbsite'
const appCacheName = 'nbsite-0.8.6rc10';

const preCacheFiles = [];

const cachePatterns = ['https://cdn.holoviz.org/panel/1.5.2/dist/', 'https://cdn.bokeh.org/bokeh/', 'https://cdn.jsdelivr.net/pyodide/', 'https://files.pythonhosted.org/packages/', 'https://pypi.org/pypi/'];

self.addEventListener('install', (e) => {
console.log('[Service Worker] Install');
self.skipWaiting();
e.waitUntil((async () => {
const cacheNames = await caches.keys();
for (const cacheName of cacheNames) {
if (cacheName.startsWith(appName) && cacheName !== appCacheName) {
console.log(`[Service Worker] Delete old cache ${cacheName}`);
caches.delete(cacheName);
}
}
const cache = await caches.open(appCacheName);
if (preCacheFiles.length) {
console.log('[Service Worker] Precaching ');
}
preCacheFiles.forEach(async (cacheFile) => {
const request = new Request(cacheFile);
const response = await fetch(request);
if (response.ok || response.type == 'opaque') {
cache.put(request, response);
}
})
})());
});

self.addEventListener('activate', (event) => {
console.log('[Service Worker] Activating');
return self.clients.claim();
});

self.addEventListener('fetch', (e) => {
if (e.request.method !== 'GET') {
return
}
e.respondWith((async () => {
const cache = await caches.open(appCacheName);
let response = await cache.match(e.request);
console.log(`[Service Worker] Fetching resource: ${e.request.url}`);
if (response) {
return response;
}
response = await fetch(e.request);
if (!response.ok && !(response.type == 'opaque')) {
throw Error(`[Service Worker] Fetching resource ${e.request.url} failed with response: ${response.status}`);
}
console.log(`[Service Worker] Caching new resource: ${e.request.url}`);
if (e.request.mode !== 'no-cors') {
cache.put(e.request, response.clone());
}
return response;
})());
});
Binary file added _images/example1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/example2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/thing1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/thing2.png
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 _rediraffe_redirected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
101 changes: 101 additions & 0 deletions _sphinx_design_static/design-tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// @ts-check

// Extra JS capability for selected tabs to be synced
// The selection is stored in local storage so that it persists across page loads.

/**
* @type {Record<string, HTMLElement[]>}
*/
let sd_id_to_elements = {};
const storageKeyPrefix = "sphinx-design-tab-id-";

/**
* Create a key for a tab element.
* @param {HTMLElement} el - The tab element.
* @returns {[string, string, string] | null} - The key.
*
*/
function create_key(el) {
let syncId = el.getAttribute("data-sync-id");
let syncGroup = el.getAttribute("data-sync-group");
if (!syncId || !syncGroup) return null;
return [syncGroup, syncId, syncGroup + "--" + syncId];
}

/**
* Initialize the tab selection.
*
*/
function ready() {
// Find all tabs with sync data

/** @type {string[]} */
let groups = [];

document.querySelectorAll(".sd-tab-label").forEach((label) => {
if (label instanceof HTMLElement) {
let data = create_key(label);
if (data) {
let [group, id, key] = data;

// add click event listener
// @ts-ignore
label.onclick = onSDLabelClick;

// store map of key to elements
if (!sd_id_to_elements[key]) {
sd_id_to_elements[key] = [];
}
sd_id_to_elements[key].push(label);

if (groups.indexOf(group) === -1) {
groups.push(group);
// Check if a specific tab has been selected via URL parameter
const tabParam = new URLSearchParams(window.location.search).get(
group
);
if (tabParam) {
console.log(
"sphinx-design: Selecting tab id for group '" +
group +
"' from URL parameter: " +
tabParam
);
window.sessionStorage.setItem(storageKeyPrefix + group, tabParam);
}
}

// Check is a specific tab has been selected previously
let previousId = window.sessionStorage.getItem(
storageKeyPrefix + group
);
if (previousId === id) {
// console.log(
// "sphinx-design: Selecting tab from session storage: " + id
// );
// @ts-ignore
label.previousElementSibling.checked = true;
}
}
}
});
}

/**
* Activate other tabs with the same sync id.
*
* @this {HTMLElement} - The element that was clicked.
*/
function onSDLabelClick() {
let data = create_key(this);
if (!data) return;
let [group, id, key] = data;
for (const label of sd_id_to_elements[key]) {
if (label === this) continue;
// @ts-ignore
label.previousElementSibling.checked = true;
}
window.sessionStorage.setItem(storageKeyPrefix + group, id);
}

document.addEventListener("DOMContentLoaded", ready, false);
1 change: 1 addition & 0 deletions _sphinx_design_static/sphinx-design.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 4d3380a

Please sign in to comment.