mirror of
https://github.com/v1k45/pastepass.git
synced 2026-01-05 04:56:16 +00:00
Add static file server
This commit is contained in:
@@ -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
22
web/static/pastepass.js
Normal 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
4
web/static/pico.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user