diff options
| author | Christine Dodrill <me@christine.website> | 2018-11-07 06:55:08 -0800 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-11-07 06:56:03 -0800 |
| commit | a8bc837d3858b82d9b65ca7f1718bc44ab1311fd (patch) | |
| tree | 78da119e407fb120481cbe5658babb7503ac2db8 /jbo | |
| parent | 3d17521a6df46dcad08c78c89a9fb682760fb7da (diff) | |
| download | x-a8bc837d3858b82d9b65ca7f1718bc44ab1311fd.tar.xz x-a8bc837d3858b82d9b65ca7f1718bc44ab1311fd.zip | |
ilo-kesi: restore cadeybot markov behavior
Diffstat (limited to 'jbo')
| -rw-r--r-- | jbo/la-banbixsicns/build.go | 39 | ||||
| -rw-r--r-- | jbo/la-banbixsicns/main.go | 46 |
2 files changed, 85 insertions, 0 deletions
diff --git a/jbo/la-banbixsicns/build.go b/jbo/la-banbixsicns/build.go new file mode 100644 index 0000000..82dcfa8 --- /dev/null +++ b/jbo/la-banbixsicns/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 := "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 new file mode 100644 index 0000000..07cd77d --- /dev/null +++ b/jbo/la-banbixsicns/main.go @@ -0,0 +1,46 @@ +package main + +import ( + "encoding/json" + "io/ioutil" + "log" + "net/http" + "os" + + "github.com/eaburns/johaus/parser" + _ "github.com/eaburns/johaus/parser/camxes" + _ "github.com/joho/godotenv/autoload" +) + +const dialect = "camxes" + +func main() { + p := os.Getenv("PORT") + if p == "" { + p = "9001" + } + + log.Printf("Listening on http://0.0.0.0:%s", p) + http.ListenAndServe(":"+p, http.HandlerFunc(handle)) +} + +func handle(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) +} |
