Compare commits

...

7 Commits

Author SHA1 Message Date
vilmibm f9190a8773 link to stuff 2023-07-18 06:39:19 +00:00
vilmibm 46964b5c2b tweak how copying text works 2023-07-18 06:39:12 +00:00
vilmibm ddb1ceb146 make blacked out spans have a grey background when hovering so it is more clear what state they are in 2023-07-18 06:38:53 +00:00
vilmibm 6fa4283e85 ensure that body text defaults to black 2023-07-18 06:38:29 +00:00
vilmibm ef2516fd4d close db connections explicitly
without this, sqlite3 was running out of file handles.
2023-07-18 06:37:56 +00:00
vilmibm 0551fe3ff5 support HEAD 2023-07-18 06:37:37 +00:00
vilmibm 22636ebbd5 lol oops muscle memory 2023-07-14 04:50:59 +00:00
3 changed files with 28 additions and 4 deletions

View File

@ -2,4 +2,4 @@
this is the code for [blackout.tilde.town](https://blackout.tilde.town). this is the code for [blackout.tilde.town](https://blackout.tilde.town).
the database that powers this was made using [gutchunk](https://git.tilde.town/~vilmibm/gutchunk). the database that powers this was made using [gutchunk](https://git.tilde.town/vilmibm/gutchunk).

View File

@ -50,6 +50,9 @@ func main() {
randMax := big.NewInt(maxID) randMax := big.NewInt(maxID)
spaceRE := regexp.MustCompile(`[\t\v\f\r ]+`) spaceRE := regexp.MustCompile(`[\t\v\f\r ]+`)
r.HEAD("/", func(c *gin.Context) {
c.String(http.StatusOK, "")
})
r.GET("/", func(c *gin.Context) { r.GET("/", func(c *gin.Context) {
db, err := connectDB() db, err := connectDB()
@ -58,6 +61,7 @@ func main() {
c.String(http.StatusInternalServerError, "oh no.") c.String(http.StatusInternalServerError, "oh no.")
return return
} }
defer db.Close()
id, err := rand.Int(rand.Reader, randMax) id, err := rand.Int(rand.Reader, randMax)
if err != nil { if err != nil {

View File

@ -7,6 +7,7 @@
<style> <style>
body { body {
background-color: black; background-color: black;
color: black;
} }
.rainbow { .rainbow {
animation-name: rainbow; animation-name: rainbow;
@ -63,6 +64,10 @@
background-color: white; background-color: white;
} }
#paper span.black:hover {
background-color: grey;
}
#aboutToggle { #aboutToggle {
color: white; color: white;
font-weight: bold; font-weight: bold;
@ -97,7 +102,7 @@
--> -->
<center> <center>
<p> <p>
<button id="copy">copy to clipboard</button> <button id="copy">copy text to clipboard</button>
</p> </p>
<p> <p>
<a id="aboutToggle" href="">ABOUT</a> <a id="aboutToggle" href="">ABOUT</a>
@ -112,6 +117,9 @@
<p> <p>
IT IS <strong>#{{.ID}}</strong> OUT OF <strong>{{.MaxID}}</strong> POSSIBLE TEXT CHUNKS. RELOAD FOR ANOTHER. IT IS <strong>#{{.ID}}</strong> OUT OF <strong>{{.MaxID}}</strong> POSSIBLE TEXT CHUNKS. RELOAD FOR ANOTHER.
</p> </p>
<p>
THIS IS A <a href="https://tilde.town/~vilmibm/blog/#blackout">BLOG POST</a>. THIS IS <a href="https://git.tilde.town/vilmibm/gutchunk">SOURCE</a> <a href="https://git.tilde.town/vilmibm/blackout">CODE</a>.
</p>
<p> <p>
THIS IS A PROJECT BY <a href="https://tilde.town/~vilmibm">~VILMIBM</a>. THIS IS A PROJECT BY <a href="https://tilde.town/~vilmibm">~VILMIBM</a>.
</p> </p>
@ -130,6 +138,18 @@
let toCopy = ""; let toCopy = "";
document.querySelectorAll("#paper span").forEach(span => { document.querySelectorAll("#paper span").forEach(span => {
let guts = span.innerHTML; let guts = span.innerHTML;
if (!span.classList.contains("black")) {
toCopy += guts.trim()+" ";
}
if (guts.includes("\n") && toCopy[toCopy.length-1] != "\n") {
toCopy += "\n"
}
/*
// I think this method of converting to plaintext is interesting but
// it's not very practical--it's way too many characters to
// realistically put in a toot or alt text or similar. I may add a
// "copy wide text" button that re-introduces this behavior.
let out = ""; let out = "";
if (span.classList.contains("black")) { if (span.classList.contains("black")) {
for (let i = 0; i < guts.length; i++) { for (let i = 0; i < guts.length; i++) {
@ -142,8 +162,8 @@
} else { } else {
out = guts; out = guts;
} }
toCopy += out
toCopy += out; */
}); });
navigator.clipboard.writeText(toCopy).then(() => { navigator.clipboard.writeText(toCopy).then(() => {