Add web support
This commit is contained in:
35
templates/index.gohtml
Normal file
35
templates/index.gohtml
Normal file
@@ -0,0 +1,35 @@
|
||||
{{- /*gotype:llamachat.WebPageModel*/ -}}
|
||||
{{define "index"}}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Llamachat</title>
|
||||
<link rel="stylesheet" href="static/style.css">
|
||||
<script src="static/script.js" type="application/javascript"></script>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.3"></script>
|
||||
<script src="https://unpkg.com/htmx-ext-ws@2.0.1/ws.js"></script>
|
||||
</head>
|
||||
<body hx-ext="ws">
|
||||
|
||||
<div class="content-box" id="conversation" ws-connect="/ws" hx-on::ws-after-message="scrollToBottom();">
|
||||
<div id="conversation">
|
||||
{{range .Conversation}}
|
||||
{{- /*gotype:llamachat.WebMessage*/ -}}
|
||||
{{block "message-frag" .}}
|
||||
<div class="message" id="message-{{.Id}}">
|
||||
<span class="content">{{ .Content }}</span>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<form class="message-box" id="message-box" ws-send>
|
||||
<input id="message-input" name="message" type="text" placeholder="Type a message">
|
||||
<input type="submit" value="Send">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
||||
9
templates/message.gohtml
Normal file
9
templates/message.gohtml
Normal file
@@ -0,0 +1,9 @@
|
||||
{{- /*gotype:llamachat.WebMessage*/ -}}
|
||||
{{define "message"}}
|
||||
<div
|
||||
{{if .New}} hx-swap-oob="beforebegin" id="message-box"
|
||||
{{else if .Replace}} hx-swap-oob="outerHTML" id="message-{{.Id}}"
|
||||
{{end}}>
|
||||
{{template "message-frag" .}}
|
||||
</div>
|
||||
{{end}}
|
||||
Reference in New Issue
Block a user