From b8f5b992b6f43ee1f9a2ec4dd1bd05460ef91b76 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Fri, 8 Jan 2021 18:50:11 -0800 Subject: [PATCH] Adding website deploy. --- ueforth/Makefile | 31 +++++++++++++++---- ueforth/site/app.yaml | 27 +++++++++++++++++ ueforth/site/deploy.sh | 3 ++ ueforth/site/eforth.go | 30 +++++++++++++++++++ ueforth/site/static/index.html | 55 ++++++++++++++++++++++++++++++++++ ueforth/site/static/robots.txt | 9 ++++++ 6 files changed, 150 insertions(+), 5 deletions(-) create mode 100644 ueforth/site/app.yaml create mode 100644 ueforth/site/deploy.sh create mode 100644 ueforth/site/eforth.go create mode 100644 ueforth/site/static/index.html create mode 100644 ueforth/site/static/robots.txt diff --git a/ueforth/Makefile b/ueforth/Makefile index 016f952..2c3e964 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -5,6 +5,7 @@ WEB = $(OUT)/web POSIX = $(OUT)/posix WINDOWS = $(OUT)/windows ARDUINO = $(OUT)/arduino/ueforth +DEPLOY = $(OUT)/deploy CFLAGS = -Wall -Werror \ -O2 \ @@ -37,7 +38,7 @@ endif TARGETS = $(WEB)/terminal.html \ $(WEB)/ueforth.js \ $(POSIX)/ueforth \ - $(ARDUINO)/ueforth.ino + $(ARDUINO)/ueforth/ueforth.ino # Selectively enable windows if tools available ifneq (, $(shell which $(WIN_ARCH)-w64-mingw32-windres)) @@ -50,7 +51,7 @@ else $(warning "Missing $(WIN_ARCH)-w64-mingw32-windres skipping Windows.") endif -all: $(TARGETS) tests +all: $(TARGETS) tests $(DEPLOY)/app.yaml clean: rm -rf $(OUT) @@ -171,14 +172,34 @@ $(WINDOWS)/uEforth.exe: \ # ---- ARDUINO ---- -$(ARDUINO): +$(ARDUINO)/ueforth: mkdir -p $@ -$(ARDUINO)/ueforth.ino: \ +$(ARDUINO)/ueforth/ueforth.ino: \ arduino/fuse_ino.js \ arduino/arduino.template.ino \ common/opcodes.h \ common/core.h \ - $(GEN)/arduino_boot.h | $(ARDUINO) + $(GEN)/arduino_boot.h | $(ARDUINO)/ueforth $^ >$@ +# ---- PACKAGE ---- + +$(ARDUINO)/ueforth-arduino-esp32.zip: $(ARDUINO)/ueforth/ueforth.ino + cd $(ARDUINO) && zip -r ueforth-arduino-esp32.zip ueforth + +# ---- DEPLOY ---- + +$(DEPLOY): + mkdir -p $@ + +$(DEPLOY)/app.yaml: $(ARDUINO)/ueforth-arduino-esp32.zip $(TARGETS) | $(DEPLOY) + mkdir -p $(DEPLOY)/static + cp -r $(ARDUINO)/ueforth-arduino-esp32.zip $(DEPLOY)/static + cp -r $(POSIX)/ueforth $(DEPLOY)/static/ueforth.linux + cp -r $(WINDOWS)/uEforth.exe $(DEPLOY)/static + cp -r $(RES)/eforth.ico $(DEPLOY)/static/favicon.ico + cp -r site/* $(DEPLOY) + +deploy: + cd $(DEPLOY) && ./deploy.sh diff --git a/ueforth/site/app.yaml b/ueforth/site/app.yaml new file mode 100644 index 0000000..2d3c24a --- /dev/null +++ b/ueforth/site/app.yaml @@ -0,0 +1,27 @@ +runtime: go115 + +default_expiration: "1m" + +handlers: +- url: /robots.txt + static_files: static/robots.txt + upload: static/robots.txt + secure: always + +- url: /favicon(.*) + static_files: static/favicon\1 + upload: static/favicon.* + secure: always + +- url: / + static_files: static/index.html + upload: static/index.html + secure: always + +- url: /static + static_dir: static + secure: always + +- url: /.* + script: auto + secure: always diff --git a/ueforth/site/deploy.sh b/ueforth/site/deploy.sh new file mode 100644 index 0000000..36a2d20 --- /dev/null +++ b/ueforth/site/deploy.sh @@ -0,0 +1,3 @@ +#! /bin/bash +export CLOUDSDK_PYTHON=/usr/bin/python +gcloud app deploy --project eforth *.yaml diff --git a/ueforth/site/eforth.go b/ueforth/site/eforth.go new file mode 100644 index 0000000..b82e53d --- /dev/null +++ b/ueforth/site/eforth.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "log" + "net/http" + "os" +) + +func main() { + http.HandleFunc("/test", indexHandler) + + port := os.Getenv("PORT") + if port == "" { + port = "8080" + log.Printf("Defaulting to port %s", port) + } + log.Printf("Listening on port %s", port) + if err := http.ListenAndServe(":"+port, nil); err != nil { + log.Fatal(err) + } +} + +func indexHandler(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/test" { + http.NotFound(w, r) + return + } + fmt.Fprint(w, "Hello") +} diff --git a/ueforth/site/static/index.html b/ueforth/site/static/index.html new file mode 100644 index 0000000..24fed7c --- /dev/null +++ b/ueforth/site/static/index.html @@ -0,0 +1,55 @@ + + +

EForth

+ +

+EForth is delightfully minimalist approach to Forth originated by Bill Muench and Dr. C. H. Ting. +

+ +

+In its original form metacompilation is avoided. +

+ +

Download

+

+

+

+ +

EForth Quirks

+ +

+EForth uses FOR..NEXT in favor of DO..LOOP. +Details +

+ +

+This construct has the odd property that it iterates one "extra" time for zero. +

+ +
+: FOO 10 FOR R@ . NEXT ; FOO
+ 10 9 8 7 6 5 4 3 2 1 0  ok
+
+ +

+To permit a more ordinary loop the AFT word is used in the sequence +FOR..AFT..THEN..NEXT. +

+ +
+: FOO 10 FOR ( 1st time only ) AFT R@ . THEN NEXT ; FOO
+ 9 8 7 6 5 4 3 2 1 0  ok
+
+ +

+The even more enigmatic FOR..WHILE..NEXT..ELSE..THEN +is used in place of DO..LEAVE..LOOP. +It allows a while condition to early out of a counted loop. +

+ diff --git a/ueforth/site/static/robots.txt b/ueforth/site/static/robots.txt new file mode 100644 index 0000000..f9642bd --- /dev/null +++ b/ueforth/site/static/robots.txt @@ -0,0 +1,9 @@ +User-agent: * +Disallow: /haiku-editor +Disallow: /haiku-submit +Disallow: /haiku-view +Disallow: /haiku-print +Disallow: /haiku-vote +Disallow: /haiku-bare +Disallow: /haiku-search +Disallow: /haiku-slideshow