allow a random line pull from all corpora
This commit is contained in:
parent
0efd2b41f1
commit
bef5754487
@ -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}`;
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user