diff options
| author | xengineering <me@xengineering.eu> | 2026-08-11 11:14:54 +0200 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-08-11 11:22:48 +0200 |
| commit | 40b3272f5660517a4c97f97afcc9c3ed787465a4 (patch) | |
| tree | 76b9e2c31ab655ef097f19735d4a693d6787ea0b | |
| parent | 99cff9a3102c64cd146d524524001bd6ecb246c4 (diff) | |
| download | ceres-40b3272f5660517a4c97f97afcc9c3ed787465a4.tar ceres-40b3272f5660517a4c97f97afcc9c3ed787465a4.tar.zst ceres-40b3272f5660517a4c97f97afcc9c3ed787465a4.zip | |
Introduce Dart infrastructure for frontend
The Dart programming language is excellent for frontend use. It is
suitable to write command line programs, web interfaces with the builtin
JavaScript transpiler and cross-platform applications with Flutter.
To focus on a small number of languages Dart should now be used for
frontend purposes as Go is used for backend purposes.
Thus it is a valid option to start the migration for Ceres from Go +
JavaScript to Go + Dart.
This commit sets up the infrastructure. A `view/dart/ceres.dart` file is
added together with tooling to transpile to JavaScript, embed it into
the Go executable and serve it. Furthermore the script which just prints
a message to the console is added to every page.
Further commits can move existing code to Dart or add new code in Dart.
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | server.go | 3 | ||||
| -rw-r--r-- | view/dart/.gitignore | 3 | ||||
| -rw-r--r-- | view/dart/ceres.dart | 3 | ||||
| -rwxr-xr-x | view/dart/dart2js.sh | 11 | ||||
| -rw-r--r-- | view/html/head.html | 1 |
6 files changed, 23 insertions, 2 deletions
@@ -12,9 +12,10 @@ cd ceres git submodule update --init ``` -Only the [Go][4] tool is required to build ceres. +Only the [Go][4] and [Dart][7] tools are required to build ceres. ``` +go generate go build ``` @@ -69,3 +70,4 @@ As soon as version 1.0.0 is reached these aspects are stable. [4]: https://go.dev [5]: https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping [6]: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete +[7]: https://dart.dev/ @@ -13,7 +13,8 @@ import ( type Server http.Server -//go:embed view/static/simple.css/simple.css view/static/ceres.js +//go:generate ./view/dart/dart2js.sh +//go:embed view/static/simple.css/simple.css view/static/ceres.js view/dart/ceres.dart.js view/dart/ceres.dart.js.map var static embed.FS func NewServer(addr string, db *model.DB) *Server { diff --git a/view/dart/.gitignore b/view/dart/.gitignore new file mode 100644 index 0000000..8b613fb --- /dev/null +++ b/view/dart/.gitignore @@ -0,0 +1,3 @@ +*.js +*.js.deps +*.js.map diff --git a/view/dart/ceres.dart b/view/dart/ceres.dart new file mode 100644 index 0000000..596fbe4 --- /dev/null +++ b/view/dart/ceres.dart @@ -0,0 +1,3 @@ +void main() { + print("Dart infrastructure is available."); +} diff --git a/view/dart/dart2js.sh b/view/dart/dart2js.sh new file mode 100755 index 0000000..8d53fda --- /dev/null +++ b/view/dart/dart2js.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -euf + +SCRIPT="$0" +DART="$(dirname "$SCRIPT")" +CERES_DART="${DART}/ceres.dart" +CERES_DART_JS="${CERES_DART}.js" + +set -x +dart compile js -O2 --output "$CERES_DART_JS" "$CERES_DART" diff --git a/view/html/head.html b/view/html/head.html index 91ae004..cebfa0f 100644 --- a/view/html/head.html +++ b/view/html/head.html @@ -4,5 +4,6 @@ <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="/static/view/static/simple.css/simple.css" type="text/css"> + <script defer src="/static/view/dart/ceres.dart.js"></script> </head> {{end}} |
