From a0ccb5341b04c83f8569d4ef2ea51ce96c26e060 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Tue, 12 Mar 2019 18:23:19 -0700 Subject: johaus --- jbo/johaus/build.go | 39 ++++++++++++++++++++++++ jbo/johaus/main.go | 72 +++++++++++++++++++++++++++++++++++++++++++++ jbo/la-banbixsicns/build.go | 39 ------------------------ jbo/la-banbixsicns/main.go | 72 --------------------------------------------- 4 files changed, 111 insertions(+), 111 deletions(-) create mode 100644 jbo/johaus/build.go create mode 100644 jbo/johaus/main.go delete mode 100644 jbo/la-banbixsicns/build.go delete mode 100644 jbo/la-banbixsicns/main.go diff --git a/jbo/johaus/build.go b/jbo/johaus/build.go new file mode 100644 index 0000000..07e8489 --- /dev/null +++ b/jbo/johaus/build.go @@ -0,0 +1,39 @@ +//+build ignore + +// Builds and deploys the application to minipaas. +package main + +import ( + "context" + "log" + "os" + + "github.com/Xe/x/internal/greedo" + "github.com/Xe/x/internal/minipaas" + "github.com/Xe/x/internal/yeet" +) + +func main() { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + env := append(os.Environ(), []string{"CGO_ENABLED=0", "GOOS=linux"}...) + yeet.ShouldWork(ctx, env, yeet.WD, "vgo", "build", "-o=web") + yeet.ShouldWork(ctx, env, yeet.WD, "appsluggr", "-web=web") + fin, err := os.Open("slug.tar.gz") + if err != nil { + log.Fatal(err) + } + defer fin.Close() + + fname := "johaus-" + yeet.DateTag + ".tar.gz" + pubURL, err := greedo.CopyFile(fname, fin) + if err != nil { + log.Fatal(err) + } + + err = minipaas.Exec("tar:from johaus " + pubURL) + if err != nil { + log.Fatal(err) + } +} diff --git a/jbo/johaus/main.go b/jbo/johaus/main.go new file mode 100644 index 0000000..5c9c59e --- /dev/null +++ b/jbo/johaus/main.go @@ -0,0 +1,72 @@ +package main + +import ( + "encoding/json" + "flag" + "io/ioutil" + "log" + "net/http" + + "github.com/Xe/x/internal" + "within.website/johaus/parser" + _ "within.website/johaus/parser/camxes" + "within.website/johaus/pretty" +) + +const dialect = "camxes" + +var ( + port = flag.String("port", "9001", "TCP port to bind on for HTTP") +) + +func main() { + internal.HandleStartup() + + log.Printf("Listening on http://0.0.0.0:%s", *port) + + http.DefaultServeMux.HandleFunc("/tree", tree) + http.DefaultServeMux.HandleFunc("/braces", braces) + + http.ListenAndServe(":"+*port, nil) +} + +func braces(w http.ResponseWriter, r *http.Request) { + data, err := ioutil.ReadAll(r.Body) + if err != nil { + http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) + return + } + + tree, err := parser.Parse(dialect, string(data)) + if err != nil { + http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) + return + } + + parser.RemoveMorphology(tree) + parser.AddElidedTerminators(tree) + parser.RemoveSpace(tree) + parser.CollapseLists(tree) + + pretty.Braces(w, tree) +} +func tree(w http.ResponseWriter, r *http.Request) { + data, err := ioutil.ReadAll(r.Body) + if err != nil { + http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) + return + } + + tree, err := parser.Parse(dialect, string(data)) + if err != nil { + http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) + return + } + + parser.RemoveMorphology(tree) + parser.AddElidedTerminators(tree) + parser.RemoveSpace(tree) + parser.CollapseLists(tree) + + json.NewEncoder(w).Encode(tree) +} diff --git a/jbo/la-banbixsicns/build.go b/jbo/la-banbixsicns/build.go deleted file mode 100644 index 82dcfa8..0000000 --- a/jbo/la-banbixsicns/build.go +++ /dev/null @@ -1,39 +0,0 @@ -//+build ignore - -// Builds and deploys the application to minipaas. -package main - -import ( - "context" - "log" - "os" - - "github.com/Xe/x/internal/greedo" - "github.com/Xe/x/internal/minipaas" - "github.com/Xe/x/internal/yeet" -) - -func main() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - env := append(os.Environ(), []string{"CGO_ENABLED=0", "GOOS=linux"}...) - yeet.ShouldWork(ctx, env, yeet.WD, "vgo", "build", "-o=web") - yeet.ShouldWork(ctx, env, yeet.WD, "appsluggr", "-web=web") - fin, err := os.Open("slug.tar.gz") - if err != nil { - log.Fatal(err) - } - defer fin.Close() - - fname := "la-banbixsicns-" + yeet.DateTag + ".tar.gz" - pubURL, err := greedo.CopyFile(fname, fin) - if err != nil { - log.Fatal(err) - } - - err = minipaas.Exec("tar:from la-banbixsicns " + pubURL) - if err != nil { - log.Fatal(err) - } -} diff --git a/jbo/la-banbixsicns/main.go b/jbo/la-banbixsicns/main.go deleted file mode 100644 index 5c9c59e..0000000 --- a/jbo/la-banbixsicns/main.go +++ /dev/null @@ -1,72 +0,0 @@ -package main - -import ( - "encoding/json" - "flag" - "io/ioutil" - "log" - "net/http" - - "github.com/Xe/x/internal" - "within.website/johaus/parser" - _ "within.website/johaus/parser/camxes" - "within.website/johaus/pretty" -) - -const dialect = "camxes" - -var ( - port = flag.String("port", "9001", "TCP port to bind on for HTTP") -) - -func main() { - internal.HandleStartup() - - log.Printf("Listening on http://0.0.0.0:%s", *port) - - http.DefaultServeMux.HandleFunc("/tree", tree) - http.DefaultServeMux.HandleFunc("/braces", braces) - - http.ListenAndServe(":"+*port, nil) -} - -func braces(w http.ResponseWriter, r *http.Request) { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) - return - } - - tree, err := parser.Parse(dialect, string(data)) - if err != nil { - http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) - return - } - - parser.RemoveMorphology(tree) - parser.AddElidedTerminators(tree) - parser.RemoveSpace(tree) - parser.CollapseLists(tree) - - pretty.Braces(w, tree) -} -func tree(w http.ResponseWriter, r *http.Request) { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) - return - } - - tree, err := parser.Parse(dialect, string(data)) - if err != nil { - http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) - return - } - - parser.RemoveMorphology(tree) - parser.AddElidedTerminators(tree) - parser.RemoveSpace(tree) - parser.CollapseLists(tree) - - json.NewEncoder(w).Encode(tree) -} -- cgit v1.2.3