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 $$ = document.querySelectorAll.bind(document);
|
||||||
|
|
||||||
const initialLines = 10;
|
const initialLines = 10;
|
||||||
|
const DEFAULT_CORPUS_ID = "c3d8e9";
|
||||||
|
|
||||||
// I am truly sorry
|
// I am truly sorry
|
||||||
function invoker(methodName) {
|
function invoker(methodName) {
|
||||||
@ -203,7 +204,7 @@ class PoemLine extends HTMLDivElement {
|
|||||||
|
|
||||||
regen() {
|
regen() {
|
||||||
let params = new URLSearchParams(document.location.search);
|
let params = new URLSearchParams(document.location.search);
|
||||||
const corpusid = params.get("corpus");
|
const corpusid = params.get("corpus") || DEFAULT_CORPUS_ID;
|
||||||
let p = "/line";
|
let p = "/line";
|
||||||
if (corpusid != "" && corpusid != null) {
|
if (corpusid != "" && corpusid != null) {
|
||||||
p = `/line?corpus=${corpusid}`;
|
p = `/line?corpus=${corpusid}`;
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
mrand "math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -153,7 +154,11 @@ func Serve(opts ServeOpts) error {
|
|||||||
}
|
}
|
||||||
defer conn.Release()
|
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
|
var cpus corpus
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user