Skip to content

Commit

Permalink
Rename notebook extension
Browse files Browse the repository at this point in the history
  • Loading branch information
lwindolf committed Sep 6, 2023
1 parent 1b503c7 commit b4d7eb1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<select id='notebook-name'>
<!-- FIXME load list automatically -->
<option default>default</option>
<option>df</option>
<option>systemd</option>
<option>arp</option>
</select>
Expand Down
15 changes: 12 additions & 3 deletions frontend/js/notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@ function registerStarboardShellCellType() {
}
}

runtime.definitions.cellTypes.map.delete('esm');
runtime.definitions.cellTypes.map.delete('js');
runtime.definitions.cellTypes.map.delete('javascript');
runtime.definitions.cellTypes.map.delete('css');
runtime.definitions.cellTypes.map.delete('html');
runtime.definitions.cellTypes.map.delete('python');
runtime.definitions.cellTypes.map.delete('python3');
runtime.definitions.cellTypes.map.delete('ipython3');
Expand All @@ -107,7 +105,7 @@ async function setupNotebook(host, name) {
$('#notebook-name').val(name);
$('#notebook-host').val(host);

let response = await fetch(`/notebooks/${name}.md`);
let response = await fetch(`/notebooks/${name}.nb`);
window.initialNotebookContent = await response.text();

/* Async module load to ensure we have loaded the initial notebook markdown above */
Expand All @@ -118,4 +116,15 @@ async function setupNotebook(host, name) {
$('#notebook-host').on('change', reloadNotebook);
}

// Helper function to allow JS notebook cells to get output of other cells
window.getCellOutput = (cellNr) => {
if(undefined === runtime.content.cells[cellNr]) {
console.error(`No cell with index ${cellNr} found!`);
return "";
}

let id = runtime.content.cells[cellNr].id;
return $(`starboard-cell#${id} .starboard-console-output-inner`).get(0).innerText;
};

export { setupNotebook };
7 changes: 4 additions & 3 deletions frontend/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ var filesToCache = [
'/js/renderer/netmap.js',
'/js/renderer/perf-flamegraph.js',

'/notebooks/default.md',
'/notebooks/arp.md',
'/notebooks/systemd.md',
'/notebooks/default.nb',
'/notebooks/df.nb',
'/notebooks/arp.nb',
'/notebooks/systemd.nb',
'default.json'
];

Expand Down

0 comments on commit b4d7eb1

Please sign in to comment.