diff --git a/web/assets/main.js b/web/assets/main.js index e092efd..b324a43 100644 --- a/web/assets/main.js +++ b/web/assets/main.js @@ -3,6 +3,7 @@ const $ = document.querySelector.bind(document); const $$ = document.querySelectorAll.bind(document); const initialLines = 10; +const DEFAULT_CORPUS_ID = "c3d8e9"; // I am truly sorry function invoker(methodName) { @@ -203,7 +204,7 @@ class PoemLine extends HTMLDivElement { regen() { let params = new URLSearchParams(document.location.search); - const corpusid = params.get("corpus"); + const corpusid = params.get("corpus") || DEFAULT_CORPUS_ID; let p = "/line"; if (corpusid != "" && corpusid != null) { p = `/line?corpus=${corpusid}`; diff --git a/web/web.go b/web/web.go index 805dec1..52d6af3 100644 --- a/web/web.go +++ b/web/web.go @@ -7,6 +7,7 @@ import ( "html/template" "log" "math/big" + mrand "math/rand" "net/http" "strings" @@ -153,7 +154,11 @@ func Serve(opts ServeOpts) error { } defer conn.Release() - corpusid := c.DefaultQuery("corpus", "c3d8e9") + corpusid := c.DefaultQuery("corpus", "") + if corpusid == "" { + ix := mrand.Intn(len(corpora)) + corpusid = corpora[ix].ID + } var cpus corpus