Commit c28b9f9

Juzexe  ·  2025-07-24 09:43:23 -0400 EDT
parent a34af95
Add copy button to Pastes
2 files changed,  +10, -0
+3, -0
......@@ -53,6 +53,7 @@ type PostPageData struct {
5353 Username string
5454 BlogName string
5555 Contents template.HTML
56+ Text string
5657 PublishAtISO string
5758 PublishAt string
5859 ExpiresAt string
......@@ -219,6 +220,7 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
219220 Username: username,
220221 BlogName: blogName,
221222 Contents: template.HTML(parsedText),
223+ Text: post.Text,
222224 ExpiresAt: expiresAt,
223225 Unlisted: unlisted,
224226 }
......@@ -235,6 +237,7 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
235237 Username: username,
236238 BlogName: blogName,
237239 Contents: "oops! we can't seem to find this post.",
240+ Text: "oops! we can't seem to find this post.",
238241 ExpiresAt: "",
239242 }
240243 }
+7, -0
......@@ -37,6 +37,13 @@
3737 <p class="font-bold m-0">expires: {{.ExpiresAt}}</p>
3838 </header>
3939 <main>
40+<script>
41+function copyText() {
42+ const text = `{{.Text}}`
43+ navigator.clipboard.writeText(text)
44+}
45+</script>
46+ <button onclick="copyText()" class="btn mt inline-block">Copy Paste</button>
4047 <article>
4148 {{.Contents}}
4249 </article>