diff --git a/templates/index.tmpl b/templates/index.tmpl index 3ee7569..374a9ad 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -127,6 +127,7 @@ a {

@@ -135,13 +136,19 @@ a {

-
+ +
diff --git a/web/assets/main.js b/web/assets/main.js index 2632a0c..f5b4f6c 100644 --- a/web/assets/main.js +++ b/web/assets/main.js @@ -181,7 +181,13 @@ class PoemLine extends HTMLDivElement { } regen() { - fetch(new Request("/line")).then((resp) => { + let params = new URLSearchParams(document.location.search); + const corpusid = params.get("corpus"); + let p = "/line"; + if (corpusid != "" && corpusid != null) { + p = `/line?corpus=${corpusid}`; + } + fetch(new Request(p)).then((resp) => { if (!resp.ok) { throw new Error(`sadness stalks the land in ${resp.status} ways`); } @@ -191,7 +197,12 @@ class PoemLine extends HTMLDivElement { this.querySelector(".linetext").setAttribute("data-source", payload.Source.Name); this.originalText = payload.Text; const source = payload.Source - const sourceName = source.Name.slice(source.Name.indexOf(' ')); + // hacks for gutenberg name + let sourceName = source.Name; + const space = sourceName.indexOf(' '); + if (space > 0) { + sourceName = sourceName.slice(space); + } this.querySelector(".source").innerText = sourceName; }); } diff --git a/web/web.go b/web/web.go index 97e88bf..1fff2ea 100644 --- a/web/web.go +++ b/web/web.go @@ -111,9 +111,11 @@ func Serve() error { }) r.GET("/", func(c *gin.Context) { + corpusid := c.DefaultQuery("corpus", "c3d8e9") c.HTML(http.StatusOK, "index.tmpl", struct { + SelectedCorpus string Corpora []corpus - }{corpora}) + }{corpusid, corpora}) }) r.GET("/line", func(c *gin.Context) {