Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dom.SendAsDownload #135

Merged
merged 10 commits into from
Oct 9, 2024
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN wget --quiet --output-document=- "https://go.dev/dl/go${GO_VERSION}.linux-am
&& go version

# Install GoNB (https://github.com/janpfeifer/gonb) in the user account
ARG GONB_VERSION="v0.10.4"
ARG GONB_VERSION="v0.10.5"
USER $NB_USER
WORKDIR ${HOME}
RUN export GOPROXY=direct && \
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# GoNB Changelog

## v0.10.5, Added SendAsDownload

* Added `dom.SendAsDownload` to send data from cells to the client by triggering a browser download. #134

## v0.10.4, Fixed #131

* Issue #131: proper handling of tuple variable declarations like `var contents, _ = os.ReadFile(...)`
Expand Down
16 changes: 9 additions & 7 deletions docs/coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ github.com/janpfeifer/gonb/cache/cache.go *Storage.Reset 75.0%
github.com/janpfeifer/gonb/cache/cache.go Reset 0.0%
github.com/janpfeifer/gonb/cache/cache.go CacheWith 91.7%
github.com/janpfeifer/gonb/cache/cache.go Cache 0.0%
github.com/janpfeifer/gonb/cmd/nbexec/nbexec.go main 72.2%
github.com/janpfeifer/gonb/cmd/nbexec/nbexec.go main 74.3%
github.com/janpfeifer/gonb/cmd/nbexec/nbexec.go startJupyterNotebook 73.2%
github.com/janpfeifer/gonb/cmd/nbexec/nbexec.go executeNotebook 78.6%
github.com/janpfeifer/gonb/cmd/nbexec/nbexec.go checkForInputBoxes 95.7%
Expand Down Expand Up @@ -59,8 +59,8 @@ github.com/janpfeifer/gonb/common/common.go *ArrayFlag.String 66.7%
github.com/janpfeifer/gonb/common/common.go *ArrayFlag.Set 0.0%
github.com/janpfeifer/gonb/gonbui/gonbui.go init 100.0%
github.com/janpfeifer/gonb/gonbui/gonbui.go Logf 50.0%
github.com/janpfeifer/gonb/gonbui/gonbui.go Error 100.0%
github.com/janpfeifer/gonb/gonbui/gonbui.go Open 100.0%
github.com/janpfeifer/gonb/gonbui/gonbui.go Error 100.0%
github.com/janpfeifer/gonb/gonbui/gonbui.go Open 100.0%
github.com/janpfeifer/gonb/gonbui/gonbui.go openLocked 67.7%
github.com/janpfeifer/gonb/gonbui/gonbui.go closePipesLocked 0.0%
github.com/janpfeifer/gonb/gonbui/gonbui.go SendData 54.5%
Expand Down Expand Up @@ -107,6 +107,7 @@ github.com/janpfeifer/gonb/gonbui/dom/dom.go SetInnerText 100.0%
github.com/janpfeifer/gonb/gonbui/dom/dom.go GetInnerHtml 83.3%
github.com/janpfeifer/gonb/gonbui/dom/dom.go Remove 100.0%
github.com/janpfeifer/gonb/gonbui/dom/dom.go Persist 66.7%
github.com/janpfeifer/gonb/gonbui/dom/download.go SendAsDownload 0.0%
github.com/janpfeifer/gonb/gonbui/dom/script.go LoadScriptModuleAndRun 0.0%
github.com/janpfeifer/gonb/gonbui/dom/script.go LoadScriptOrRequireJSModuleAndRun 0.0%
github.com/janpfeifer/gonb/gonbui/dom/script.go LoadScriptOrRequireJSModuleAndRunTransient 0.0%
Expand Down Expand Up @@ -180,7 +181,7 @@ github.com/janpfeifer/gonb/internal/goexec/composer.go *WriterWithCursor.Error
github.com/janpfeifer/gonb/internal/goexec/composer.go *WriterWithCursor.Writef 75.0%
github.com/janpfeifer/gonb/internal/goexec/composer.go *WriterWithCursor.Write 76.9%
github.com/janpfeifer/gonb/internal/goexec/composer.go *Declarations.RenderImports 100.0%
github.com/janpfeifer/gonb/internal/goexec/composer.go *Declarations.RenderVariables 92.0%
github.com/janpfeifer/gonb/internal/goexec/composer.go *Declarations.RenderVariables 91.2%
github.com/janpfeifer/gonb/internal/goexec/composer.go *Declarations.RenderFunctions 100.0%
github.com/janpfeifer/gonb/internal/goexec/composer.go *Declarations.RenderTypes 100.0%
github.com/janpfeifer/gonb/internal/goexec/composer.go *Declarations.RenderConstants 100.0%
Expand Down Expand Up @@ -215,6 +216,7 @@ github.com/janpfeifer/gonb/internal/goexec/goexec.go NewDeclarations 100.0
github.com/janpfeifer/gonb/internal/goexec/goexec.go *Declarations.Copy 100.0%
github.com/janpfeifer/gonb/internal/goexec/goexec.go *Declarations.MergeFrom 100.0%
github.com/janpfeifer/gonb/internal/goexec/goexec.go copyMap 100.0%
github.com/janpfeifer/gonb/internal/goexec/goexec.go variablesCopyFrom 100.0%
github.com/janpfeifer/gonb/internal/goexec/goexec.go *Declarations.ClearCursor 100.0%
github.com/janpfeifer/gonb/internal/goexec/goexec.go clearCursor 100.0%
github.com/janpfeifer/gonb/internal/goexec/goexec.go *Declarations.DropFuncInit 100.0%
Expand Down Expand Up @@ -248,7 +250,7 @@ github.com/janpfeifer/gonb/internal/goexec/parser.go *State.parseFromGoCode
github.com/janpfeifer/gonb/internal/goexec/parser.go NewImport 88.9%
github.com/janpfeifer/gonb/internal/goexec/parser.go *parseInfo.ParseImportEntry 100.0%
github.com/janpfeifer/gonb/internal/goexec/parser.go *parseInfo.ParseFuncEntry 100.0%
github.com/janpfeifer/gonb/internal/goexec/parser.go *parseInfo.ParseVarEntry 81.2%
github.com/janpfeifer/gonb/internal/goexec/parser.go *parseInfo.ParseVarEntry 84.6%
github.com/janpfeifer/gonb/internal/goexec/parser.go *parseInfo.ParseConstEntry 100.0%
github.com/janpfeifer/gonb/internal/goexec/parser.go *parseInfo.ParseTypeEntry 100.0%
github.com/janpfeifer/gonb/internal/goexec/parser.go *State.parseLinesAndComposeMain 74.3%
Expand Down Expand Up @@ -404,7 +406,7 @@ github.com/janpfeifer/gonb/internal/specialcmd/definitions.go resetDefinitions
github.com/janpfeifer/gonb/internal/specialcmd/definitions.go displayEnumeration 90.9%
github.com/janpfeifer/gonb/internal/specialcmd/definitions.go listDefinitions 100.0%
github.com/janpfeifer/gonb/internal/specialcmd/definitions.go removeDefinitionImpl 87.5%
github.com/janpfeifer/gonb/internal/specialcmd/definitions.go removeDefinitions 75.0%
github.com/janpfeifer/gonb/internal/specialcmd/definitions.go removeDefinitions 91.7%
github.com/janpfeifer/gonb/internal/specialcmd/specialcmd.go Parse 84.6%
github.com/janpfeifer/gonb/internal/specialcmd/specialcmd.go joinLine 87.5%
github.com/janpfeifer/gonb/internal/specialcmd/specialcmd.go execSpecialConfig 55.3%
Expand All @@ -414,4 +416,4 @@ github.com/janpfeifer/gonb/internal/specialcmd/track.go execTrack 27.3%
github.com/janpfeifer/gonb/internal/specialcmd/track.go execUntrack 54.5%
github.com/janpfeifer/gonb/internal/specialcmd/track.go showTrackedList 91.7%
github.com/janpfeifer/gonb/internal/websocket/websocket.go Javascript 83.3%
total (statements) 64.3%
total (statements) 64.4%
6 changes: 3 additions & 3 deletions examples/tests/bash_script.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"/tmp/gonb_43bd76c8\n"
"/tmp/gonb_b9edd581\n"
]
}
],
Expand All @@ -59,7 +59,7 @@
"output_type": "stream",
"text": [
"/home/janpf/Projects/gonb/examples/tests\n",
"/tmp/gonb_43bd76c8\n",
"/tmp/gonb_b9edd581\n",
"/home/janpf/Projects/gonb\n",
"/home/janpf/Projects/gonb\n"
]
Expand All @@ -86,7 +86,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/comms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/tests/dom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
{
"data": {
"text/html": [
"<div id=\"dom.transient_div_b9910ddd\"></div>"
"<div id=\"dom.transient_div_32726297\"></div>"
]
},
"metadata": {},
Expand Down Expand Up @@ -152,7 +152,7 @@
{
"data": {
"text/html": [
"<div id=\"dom.transient_div_3e8202e0\"></div>"
"<div id=\"dom.transient_div_5b814837\"></div>"
]
},
"metadata": {},
Expand Down Expand Up @@ -197,7 +197,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
10 changes: 5 additions & 5 deletions examples/tests/goflags.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"gonb_d53941d6/main.go:8:\tA\t\t100.0%\n",
"gonb_d53941d6/main.go:12:\tB\t\t0.0%\n",
"gonb_d53941d6/main.go:17:\tmain\t\t100.0%\n",
"gonb_0cdc700f/main.go:8:\tA\t\t100.0%\n",
"gonb_0cdc700f/main.go:12:\tB\t\t0.0%\n",
"gonb_0cdc700f/main.go:17:\tmain\t\t100.0%\n",
"total\t\t\t\t(statements)\t75.0%\n"
]
}
Expand Down Expand Up @@ -238,7 +238,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"# gonb_d53941d6\n",
"# gonb_0cdc700f\n",
"./main.go:10:6: can inline (*Point).ManhattanLen\n",
"./main.go:16:12: inlining call to flag.Parse\n",
"./main.go:18:27: inlining call to (*Point).ManhattanLen\n",
Expand Down Expand Up @@ -267,7 +267,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/gonbui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"output_type": "stream",
"text": [
"%goflags=[\"--cover\" \"--covermode=set\"]\n",
"GOCOVERDIR=/tmp/gonb_test_coverage.eLusFuePYS\n"
"GOCOVERDIR=/tmp/gonb_test_coverage.fmW2jDEhWf\n"
]
}
],
Expand Down Expand Up @@ -133,7 +133,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
14 changes: 7 additions & 7 deletions examples/tests/gotest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@
"text": [
"goos: linux\n",
"goarch: amd64\n",
"pkg: gonb_103d9b0e\n",
"pkg: gonb_a1453c14\n",
"cpu: 12th Gen Intel(R) Core(TM) i9-12900K\n",
"BenchmarkFibonacciA32\n",
"BenchmarkFibonacciA32-24 \t 182\t 6454740 ns/op\n",
"BenchmarkFibonacciA32-24 \t 169\t 7058908 ns/op\n",
"BenchmarkFibonacciB32\n",
"BenchmarkFibonacciB32-24 \t130921929\t 9.613 ns/op\n",
"BenchmarkFibonacciB32-24 \t285643864\t 3.680 ns/op\n",
"PASS\n",
"coverage: [no statements]\n"
]
Expand Down Expand Up @@ -334,10 +334,10 @@
"text": [
"goos: linux\n",
"goarch: amd64\n",
"pkg: gonb_103d9b0e\n",
"pkg: gonb_a1453c14\n",
"cpu: 12th Gen Intel(R) Core(TM) i9-12900K\n",
"BenchmarkFibonacciA32-24 \t 171\t 6435921 ns/op\n",
"BenchmarkFibonacciB32-24 \t121723155\t 9.476 ns/op\n",
"BenchmarkFibonacciA32-24 \t 168\t 7082427 ns/op\n",
"BenchmarkFibonacciB32-24 \t308541147\t 3.901 ns/op\n",
"PASS\n",
"coverage: [no statements]\n"
]
Expand All @@ -361,7 +361,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
18 changes: 9 additions & 9 deletions examples/tests/gowork.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"/tmp/gonb_tests_gowork_D4ZtmNON"
"/tmp/gonb_tests_gowork_IBSuBo7n"
]
}
],
Expand Down Expand Up @@ -64,7 +64,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Temporary test package: /tmp/gonb_tests_gowork_D4ZtmNON\n"
"Temporary test package: /tmp/gonb_tests_gowork_IBSuBo7n\n"
]
}
],
Expand Down Expand Up @@ -136,7 +136,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\t- Added replace rule for module \"a.com/a/pkg\" to local directory \"/tmp/gonb_tests_gowork_D4ZtmNON\".\n"
"\t- Added replace rule for module \"a.com/a/pkg\" to local directory \"/tmp/gonb_tests_gowork_IBSuBo7n\".\n"
]
}
],
Expand All @@ -155,9 +155,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"module gonb_b0524c9c\n",
"module gonb_05a80086\n",
"\n",
"go 1.23.0\n",
"go 1.23.2\n",
"\n",
"replace a.com/a/pkg => TMP_PKG\n"
]
Expand Down Expand Up @@ -186,7 +186,7 @@
"text/html": [
"<b>List of files/directories being tracked:</b>\n",
"<ul>\n",
"<li>/tmp/gonb_tests_gowork_D4ZtmNON</li>\n",
"<li>/tmp/gonb_tests_gowork_IBSuBo7n</li>\n",
"</ul>\n"
]
},
Expand All @@ -208,9 +208,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"module gonb_b0524c9c\n",
"module gonb_05a80086\n",
"\n",
"go 1.23.0\n"
"go 1.23.2\n"
]
}
],
Expand Down Expand Up @@ -280,7 +280,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/hello.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/init.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/input_boxes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"output_type": "stream",
"text": [
"%goflags=[\"--cover\" \"--covermode=set\"]\n",
"GOCOVERDIR=/tmp/gonb_test_coverage.eLusFuePYS\n"
"GOCOVERDIR=/tmp/gonb_test_coverage.fmW2jDEhWf\n"
]
}
],
Expand Down Expand Up @@ -196,7 +196,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/script.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.0"
"version": "go1.23.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/vartuple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"text/html": [
"<h4>Variables</h4>\n",
"<ul>\n",
"<li><pre>_~154179</pre></li>\n",
"<li><pre>_~653277</pre></li>\n",
"<li><pre>a</pre></li>\n",
"<li><pre>c</pre></li>\n",
"</ul>"
Expand Down
Loading
Loading