From 40b3272f5660517a4c97f97afcc9c3ed787465a4 Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 11 Aug 2026 11:14:54 +0200 Subject: 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. --- README.md | 4 +++- server.go | 3 ++- view/dart/.gitignore | 3 +++ view/dart/ceres.dart | 3 +++ view/dart/dart2js.sh | 11 +++++++++++ view/html/head.html | 1 + 6 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 view/dart/.gitignore create mode 100644 view/dart/ceres.dart create mode 100755 view/dart/dart2js.sh diff --git a/README.md b/README.md index 560dd4f..659a230 100644 --- a/README.md +++ b/README.md @@ -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/ diff --git a/server.go b/server.go index 3b17227..3868315 100644 --- a/server.go +++ b/server.go @@ -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 @@ + {{end}} -- cgit v1.3.1