Skip to content

Commit

Permalink
improve getting started
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSkovMadsen committed Jan 14, 2024
1 parent 15ba95e commit bf0d6e0
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 41 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ jupyter_execute
builtdocs/
.doit.db

lite/
.jupyterlite.doit.db

# jetbrains settings
Expand Down
41 changes: 1 addition & 40 deletions lite/files/Getting_Started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,46 +121,7 @@
"id": "f4efdeef-e3c5-4cb0-b358-b40f03c59f93",
"metadata": {},
"source": [
"The contents of Panelite are updated on every release, however Jupyterlite caches old edits to files. If you want to reset the storage and **delete all modifications you made to the contents** the click the button below."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6477040-13bc-4cbf-8939-1e893563bc1e",
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display, HTML\n",
"display(HTML(\"\"\"\n",
"<button type=\"button\" id=\"button_for_indexeddb\">Clear JupyterLite local storage</button>\n",
"<script>\n",
"window.button_for_indexeddb.onclick = function(e) {\n",
" window.indexedDB.open('JupyterLite Storage').onsuccess = function(e) {\n",
" // There are also other tables that I'm not clearing:\n",
" // \"counters\", \"settings\", \"local-storage-detect-blob-support\"\n",
" let tables = [\"checkpoints\", \"files\"];\n",
"\n",
" let db = e.target.result;\n",
" let t = db.transaction(tables, \"readwrite\");\n",
"\n",
" function clearTable(tablename) {\n",
" let st = t.objectStore(tablename);\n",
" st.count().onsuccess = function(e) {\n",
" console.log(\"Deleting \" + e.target.result + \" entries from \" + tablename + \"...\");\n",
" st.clear().onsuccess = function(e) {\n",
" console.log(tablename + \" is cleared!\");\n",
" }\n",
" }\n",
" }\n",
"\n",
" for (let tablename of tables) {\n",
" clearTable(tablename);\n",
" }\n",
" }\n",
"};\n",
"</script>\n",
"\"\"\"))"
"The contents of Panelite are updated on every release, however Jupyterlite caches old edits to files. If you want to reset the storage and **delete all modifications you made to the contents** then use the [Reset_Jupyterlite.ipynb](Reset_Jupyterlite.ipynb) notebook."
]
}
],
Expand Down
119 changes: 119 additions & 0 deletions lite/files/Reset_Jupyterlite.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The contents of Panelite are updated on every release, however Jupyterlite caches old edits to files. If you want to reset the storage and **delete all modifications you made to the contents** then run the code below and click the button `Clear JupyterLite local storage` button."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<button type=\"button\" id=\"button_for_indexeddb\">Clear JupyterLite local storage</button>\n",
"<div id=\"clear-storage-message\"></div>\n",
"<script>\n",
"window.button_for_indexeddb.onclick = function(e) {\n",
" message = document.getElementById(\"clear-storage-message\")\n",
" message.innerText=\"Running\"\n",
" window.indexedDB.open('JupyterLite Storage').onsuccess = function(e) {\n",
" // There are also other tables that I'm not clearing:\n",
" // \"counters\", \"settings\", \"local-storage-detect-blob-support\"\n",
" let tables = [\"checkpoints\", \"files\"];\n",
"\n",
" let db = e.target.result;\n",
" let t = db.transaction(tables, \"readwrite\");\n",
"\n",
" function clearTable(tablename) {\n",
" let st = t.objectStore(tablename);\n",
" st.count().onsuccess = function(e) {\n",
" console.log(\"Deleting \" + e.target.result + \" entries from \" + tablename + \"...\");\n",
" st.clear().onsuccess = function(e) {\n",
" console.log(tablename + \" is cleared!\");\n",
" }\n",
" }\n",
" }\n",
"\n",
" for (let tablename of tables) {\n",
" clearTable(tablename);\n",
" }\n",
" }\n",
" message.innerText=\"JupyterLite local storage has successfully been reset\"\n",
"};\n",
"</script>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from IPython.display import display, HTML\n",
"display(HTML(\"\"\"\n",
"<button type=\"button\" id=\"button_for_indexeddb\">Clear JupyterLite local storage</button>\n",
"<div id=\"clear-storage-message\"></div>\n",
"<script>\n",
"window.button_for_indexeddb.onclick = function(e) {\n",
" message = document.getElementById(\"clear-storage-message\")\n",
" message.innerText=\"Running\"\n",
" window.indexedDB.open('JupyterLite Storaage').onsuccess = function(e) {\n",
" // There are also other tables that I'm not clearing:\n",
" // \"counters\", \"settings\", \"local-storage-detect-blob-support\"\n",
" let tables = [\"checkpoints\", \"files\"];\n",
"\n",
" let db = e.target.result;\n",
" let t = db.transaction(tables, \"readwrite\");\n",
"\n",
" function clearTable(tablename) {\n",
" let st = t.objectStore(tablename);\n",
" st.count().onsuccess = function(e) {\n",
" console.log(\"Deleting \" + e.target.result + \" entries from \" + tablename + \"...\");\n",
" st.clear().onsuccess = function(e) {\n",
" console.log(tablename + \" is cleared!\");\n",
" }\n",
" }\n",
" }\n",
"\n",
" for (let tablename of tables) {\n",
" clearTable(tablename);\n",
" }\n",
" }\n",
" message.innerText=\"JupyterLite local storage has successfully been reset\"\n",
"};\n",
"</script>\n",
"\"\"\"))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.10.13"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit bf0d6e0

Please sign in to comment.