add regen button for line
This commit is contained in:
부모
fc03a3ca39
커밋
e40f12085b
@ -1,43 +0,0 @@
|
||||
/*
|
||||
Given a project gutenberg plaintext book on STDIN, this program prints just its content (ie with header and footer stripped)
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := bufio.NewScanner(os.Stdin)
|
||||
inHeader := true
|
||||
inFooter := false
|
||||
skippedAll := true
|
||||
for s.Scan() {
|
||||
text := strings.TrimSpace(s.Text())
|
||||
if inFooter {
|
||||
break
|
||||
}
|
||||
if strings.HasPrefix(text, "*** START") {
|
||||
inHeader = false
|
||||
continue
|
||||
}
|
||||
if inHeader {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(text, "*** END") {
|
||||
inFooter = true
|
||||
continue
|
||||
}
|
||||
fmt.Println(text)
|
||||
if skippedAll {
|
||||
skippedAll = false
|
||||
}
|
||||
}
|
||||
if skippedAll {
|
||||
fmt.Fprintln(os.Stderr, "warning: found no text to print")
|
||||
}
|
||||
}
|
@ -110,7 +110,7 @@ a {
|
||||
<span class="linetext"></span>
|
||||
</div>
|
||||
<div class="linectrl">
|
||||
<button is="line-pinner">PIN</button><button is="line-editor">EDIT</button><button is="line-remover">KILL</button>
|
||||
<button is="line-pinner">PIN</button><button is="line-regenner">REGEN</button><button is="line-editor">EDIT</button><button is="line-remover">KILL</button>
|
||||
</div>
|
||||
</div>
|
||||
<div is="source-text" class="source"></div>
|
||||
|
@ -33,14 +33,12 @@ class LineRemover extends Button {
|
||||
|
||||
class LinePinner extends Button {
|
||||
connectedCallback() {
|
||||
//this.innerText = "lock";
|
||||
this.setAttribute("title", "pin line in place");
|
||||
}
|
||||
click() {
|
||||
const l = this.closest("div.line");
|
||||
l.classList.toggle("unpinned");
|
||||
if (l.classList.contains("unpinned")) {
|
||||
// this.innerText = "lock";
|
||||
this.classList.remove("pinned");
|
||||
this.setAttribute("title", "lock line in place");
|
||||
} else {
|
||||
@ -50,6 +48,19 @@ class LinePinner extends Button {
|
||||
}
|
||||
}
|
||||
|
||||
class LineRegenner extends Button {
|
||||
connectedCallback() {
|
||||
this.setAttribute("title", "regenerate just this line");
|
||||
}
|
||||
click() {
|
||||
const l = this.closest("div.line");
|
||||
if (!l.classList.contains("unpinned")) {
|
||||
return;
|
||||
}
|
||||
l.regen()
|
||||
}
|
||||
}
|
||||
|
||||
class LineEditor extends Button {
|
||||
connected = false
|
||||
connectedCallback() {
|
||||
@ -233,7 +244,6 @@ class SourceText extends HTMLDivElement {
|
||||
edited() {
|
||||
const line = this.parentElement;
|
||||
const text = line.querySelector(".linetext").innerText;
|
||||
console.log(text);
|
||||
const orig = line.originalText;
|
||||
if (text == "" || (text != orig && !orig.includes(text))) {
|
||||
this.update({"Name": "original"});
|
||||
@ -411,6 +421,7 @@ customElements.define("theme-toggler", ThemeToggler, { extends: "a" });
|
||||
customElements.define("source-text", SourceText, { extends: "div" });
|
||||
customElements.define("line-remover", LineRemover, { extends: "button" });
|
||||
customElements.define("line-pinner", LinePinner, { extends: "button" });
|
||||
customElements.define("line-regenner", LineRegenner, { extends: "button" });
|
||||
customElements.define("line-editor", LineEditor, { extends: "button" });
|
||||
customElements.define("line-adder", LineAdder, { extends: "button" });
|
||||
customElements.define("poem-regenner", PoemRegenner, {extends: "button"});
|
||||
|
@ -12,6 +12,8 @@ import (
|
||||
"github.com/vilmibm/trunkless/db"
|
||||
)
|
||||
|
||||
// TODO detect max id on startup
|
||||
|
||||
type source struct {
|
||||
ID int64
|
||||
Name string
|
||||
|
불러오는 중...
x
Reference in New Issue
Block a user