corpus selection
This commit is contained in:
parent
9031c268c9
commit
e152494484
@ -127,6 +127,7 @@ a {
|
|||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>gutenberg</code>, THE ENTIRE ENGLISH CONTENT OF <a href="https://gutenberg.org">PROJECT GUTENBERG</a>. IT IS UNABRIDGED: BE WARNED.</li>
|
<li><code>gutenberg</code>, THE ENTIRE ENGLISH CONTENT OF <a href="https://gutenberg.org">PROJECT GUTENBERG</a>. IT IS UNABRIDGED: BE WARNED.</li>
|
||||||
|
<li><code>gamefaqs</code>, TWENTY YEARS WORTH OF PLAINTEXT FAQS/GUIDES FROM <a href="https://gamefaqs.com">GAMEFAQS</a>.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -135,13 +136,19 @@ a {
|
|||||||
</div>
|
</div>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button is="poem-resetter"></button>
|
<button is="poem-resetter"></button>
|
||||||
<form is="corpus-picker" style="display:inline">
|
<form method="GET" action="/" style="display:inline">
|
||||||
<label for="corpus-select">corpus:</label>
|
<label for="corpus-select">corpus:</label>
|
||||||
<select name="corpus" id="corpus-select">
|
<select name="corpus" id="corpus-select">
|
||||||
|
{{$selected := .SelectedCorpus}}
|
||||||
{{range .Corpora}}
|
{{range .Corpora}}
|
||||||
<option value="{{.ID}}">{{.Name}} ({{.MaxID}} possible lines)</option>
|
{{if eq $selected .ID}}
|
||||||
|
<option selected="selected" value="{{.ID}}">{{.Name}} ({{.MaxID}} possible lines)</option>
|
||||||
|
{{else}}
|
||||||
|
<option value="{{.ID}}">{{.Name}} ({{.MaxID}} possible lines)</option>
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</select>
|
</select>
|
||||||
|
<button type="submit">go</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form is="poem-saver" style="border: 1px solid grey; display:inline; padding:4px;">
|
<form is="poem-saver" style="border: 1px solid grey; display:inline; padding:4px;">
|
||||||
|
@ -181,7 +181,13 @@ class PoemLine extends HTMLDivElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
regen() {
|
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) {
|
if (!resp.ok) {
|
||||||
throw new Error(`sadness stalks the land in ${resp.status} ways`);
|
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.querySelector(".linetext").setAttribute("data-source", payload.Source.Name);
|
||||||
this.originalText = payload.Text;
|
this.originalText = payload.Text;
|
||||||
const source = payload.Source
|
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;
|
this.querySelector(".source").innerText = sourceName;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -111,9 +111,11 @@ func Serve() error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
r.GET("/", func(c *gin.Context) {
|
r.GET("/", func(c *gin.Context) {
|
||||||
|
corpusid := c.DefaultQuery("corpus", "c3d8e9")
|
||||||
c.HTML(http.StatusOK, "index.tmpl", struct {
|
c.HTML(http.StatusOK, "index.tmpl", struct {
|
||||||
|
SelectedCorpus string
|
||||||
Corpora []corpus
|
Corpora []corpus
|
||||||
}{corpora})
|
}{corpusid, corpora})
|
||||||
})
|
})
|
||||||
|
|
||||||
r.GET("/line", func(c *gin.Context) {
|
r.GET("/line", func(c *gin.Context) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user