summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/login.html.template1
-rw-r--r--templates/note.html.template25
-rw-r--r--templates/upload.html.template7
-rw-r--r--templates/wormhole-send.html.template14
4 files changed, 18 insertions, 29 deletions
diff --git a/templates/login.html.template b/templates/login.html.template
index 8d1ec9b..a197e8e 100644
--- a/templates/login.html.template
+++ b/templates/login.html.template
@@ -5,6 +5,7 @@
<p class="login-error">Incorrect password</p>
{{end}}
<form class="password-form" action="/login" method="post">
+ <input type="hidden" name="csrf-token" value="{{.CSRFToken}}">
<input type="hidden" name="redirect" value="{{.Redirect}}">
<label class="password-label" for="password">Enter password</label>
<input id="password" class="password" type="password" name="password" autofocus>
diff --git a/templates/note.html.template b/templates/note.html.template
index fe6d073..07c2d8e 100644
--- a/templates/note.html.template
+++ b/templates/note.html.template
@@ -1,5 +1,5 @@
{{define "head"}}
- <script src="/static/note.js"></script>
+ <script src="/static/htmx.min.js"></script>
<title>Notepad</title>
<meta name="viewport" content="interactive-widget=resizes-content"> <!-- https://stackoverflow.com/q/76026292 -->
@@ -8,15 +8,24 @@
<form id="form" method="post">
<input type="hidden" name="csrf-token" value="{{.CSRFToken}}">
<div class="save-indicator-container">
- <div id="save-indicator-wrapper">
- {{block "saveIndicator" ""}}
- <span id="save-indicator">{{.}}</span>
- {{end}}
- </div>
- <noscript><input type="submit" value="Save"></noscript>
+ {{block "saveIndicator" ""}}
+ <span id="save-indicator">{{.}}</span>
+ {{end}}
</div>
<div class="content-container">
- <textarea id="content" name="content" oninput="autosave()" autofocus>
+ <textarea
+ name="content"
+ hx-post="/notepad"
+ hx-on:input="
+ const indicator = htmx.find('#save-indicator');
+ htmx.addClass(indicator, 'htmx-indicator');
+ indicator.innerHTML = 'Saving...';
+ "
+ hx-trigger="input delay:1s"
+ hx-indicator="#save-indicator"
+ hx-target="#save-indicator"
+ hx-swap="outerHTML"
+ autofocus>
{{- .Content -}}
</textarea>
</div>
diff --git a/templates/upload.html.template b/templates/upload.html.template
deleted file mode 100644
index f920f23..0000000
--- a/templates/upload.html.template
+++ /dev/null
@@ -1,7 +0,0 @@
-{{define "head"}}<title>Upload</title>{{end}}
-
-<form method="POST" enctype="multipart/form-data">
- <input type="hidden" name="csrf-token" value="{{.CSRFToken}}">
- <input type="file" name="content">
- <input type="submit" value="Upload">
-</form>
diff --git a/templates/wormhole-send.html.template b/templates/wormhole-send.html.template
deleted file mode 100644
index 5b06c5f..0000000
--- a/templates/wormhole-send.html.template
+++ /dev/null
@@ -1,14 +0,0 @@
-{{define "head"}}
- <script src="/static/htmx.min.js"></script>
- <script src="/static/htmx-ext-sse.js"></script>
- <title>Wormhole</title>
-{{end}}
-
-<form
- hx-ext="sse"
- sse-connect="/wormhole/{{.Hole}}/ready"
- hx-post="/wormhole/{{.Hole}}"
- hx-trigger="sse:receiver-ready"
- enctype="multipart/form-data">
- <input type="file" name="file">
-</form>