Add static file server

This commit is contained in:
Vikas
2024-06-02 12:45:17 +05:30
parent a124c1b0be
commit f67ceb3d8e
3 changed files with 34 additions and 1 deletions

View File

@@ -1,6 +1,12 @@
package web
import "net/http"
import (
"embed"
"net/http"
)
//go:embed static
var staticFs embed.FS
func (h *Handler) Router() http.Handler {
router := http.NewServeMux()
@@ -8,5 +14,6 @@ func (h *Handler) Router() http.Handler {
router.HandleFunc("POST /", h.Paste)
router.HandleFunc("GET /p/{id}/{key}", h.View)
router.HandleFunc("POST /p/{id}/{key}", h.Decrypt)
router.Handle("GET /static/", http.FileServer(http.FS(staticFs)))
return router
}

22
web/static/pastepass.js Normal file
View File

@@ -0,0 +1,22 @@
function copyText(event, selector) {
var pastedContent = document.querySelector(selector);
// Create a range and select the text
var range = document.createRange();
range.selectNode(pastedContent);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
// Copy the selected text
if (navigator.clipboard) {
navigator.clipboard.writeText(pastedContent.innerText).then(function () {
event.dataset.tooltip = 'Copied!';
event.innerText = 'Copied!';
setTimeout(function () {
event.innerText = 'Copy content';
event.dataset.tooltip = 'Click to copy';
event.blur();
}, 1000);
});
}
}

4
web/static/pico.min.css vendored Normal file

File diff suppressed because one or more lines are too long