generated from ElnuDev/go-project
Proper go.work implementation
This commit is contained in:
parent
1036ea930f
commit
f8ccf62570
9 changed files with 15 additions and 4 deletions
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"git.elnu.com/ElnuDev/jichanorg/httputils"
|
||||
. "git.elnu.com/ElnuDev/jichanorg/shiritori"
|
||||
. "git.elnu.com/ElnuDev/jichanorg/shiritori/clients"
|
||||
)
|
||||
|
||||
func GenerateApiEvents(clients *ClientSet) httputils.Handler {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"git.elnu.com/ElnuDev/jichanorg/httputils"
|
||||
. "git.elnu.com/ElnuDev/jichanorg/shiritori"
|
||||
. "git.elnu.com/ElnuDev/jichanorg/shiritori/clients"
|
||||
)
|
||||
|
||||
func GenerateApiSubmit(clients *ClientSet) httputils.Handler {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package shiritori
|
||||
package clients
|
||||
|
||||
import (
|
||||
"fmt"
|
3
shiritori/go.mod
Normal file
3
shiritori/go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module git.elnu.com/ElnuDev/jichanorg/shiritori
|
||||
|
||||
go 1.20
|
17
shiritori/main.go
Normal file
17
shiritori/main.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"git.elnu.com/ElnuDev/jichanorg/shiritori/api"
|
||||
. "git.elnu.com/ElnuDev/jichanorg/shiritori/clients"
|
||||
)
|
||||
|
||||
func main() {
|
||||
clients := NewClientSet()
|
||||
http.Handle("/", http.FileServer(http.Dir("static")))
|
||||
http.HandleFunc("/api/events", api.GenerateApiEvents(&clients))
|
||||
http.HandleFunc("/api/submit", api.GenerateApiSubmit(&clients))
|
||||
log.Fatal(http.ListenAndServe(":3333", nil))
|
||||
}
|
36
shiritori/static/index.html
Normal file
36
shiritori/static/index.html
Normal file
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Shiritori</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
||||
</head>
|
||||
<body hx-sse="connect:/api/events">
|
||||
<div id="content">
|
||||
<div id="split">
|
||||
<div>
|
||||
<div id="shiritori"
|
||||
hx-sse="swap:word"
|
||||
hx-swap="beforeend"
|
||||
hx-on::sse-message="this.scrollTop = this.scrollHeight">
|
||||
</div>
|
||||
<form
|
||||
hx-post="/api/submit"
|
||||
hx-swap="none"
|
||||
hx-on::after-request="this.querySelector('input[name=word]').value = ''">
|
||||
<input id="shiritori-input" type="text" name="word">
|
||||
</form>
|
||||
</div>
|
||||
<iframe
|
||||
hx-sse="swap:navigate"
|
||||
hx-on::sse-message="this.src = event.detail.data">
|
||||
</iframe>
|
||||
</div>
|
||||
<p id="shiritori-players"
|
||||
hx-sse="swap:players">
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
92
shiritori/static/style.css
Normal file
92
shiritori/static/style.css
Normal file
|
@ -0,0 +1,92 @@
|
|||
* {
|
||||
font-family: sans-serif;
|
||||
color: ghostwhite;
|
||||
}
|
||||
body {
|
||||
background: slategrey;
|
||||
font-size: 1.75em;
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
div#content {
|
||||
width: 32em;
|
||||
max-width: 100%;
|
||||
}
|
||||
div#shiritori p {
|
||||
margin: 0;
|
||||
animation-duration: 1s;
|
||||
animation-name: slidein;
|
||||
animation-fill-mode: forwards;
|
||||
opacity: 0;
|
||||
}
|
||||
@keyframes slidein {
|
||||
from {
|
||||
transform: translateX(-32px);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
to {
|
||||
transform: none;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
div#shiritori {
|
||||
padding: 2px;
|
||||
height: 24em;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
div#shiritori, input#shiritori-input, #split > :last-child {
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
border: 1px solid;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
div#shiritori, input#shiritori-input {
|
||||
padding: 0.25em;
|
||||
}
|
||||
input {
|
||||
font-size: 1em;
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
border: none;
|
||||
padding: 0.25em;
|
||||
}
|
||||
input#shiritori-input {
|
||||
width: 100%;
|
||||
|
||||
border-top: none;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
input#shiritori-input:focus {
|
||||
outline: none;
|
||||
background: rgba(0, 0, 0, 0.125);
|
||||
}
|
||||
div#shiritori {
|
||||
border-bottom: none;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
#split {
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
flex-direction: row;
|
||||
}
|
||||
#split > * {
|
||||
width: 16em;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
border-bottom: 2px solid;
|
||||
}
|
||||
button {
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
font-size: inherit;
|
||||
cursor: pointer;
|
||||
padding: 1em;
|
||||
border: 0;
|
||||
}
|
Reference in a new issue