Add quick bookmarklet

This commit is contained in:
James Mills
2021-02-02 17:25:01 +10:00
parent e34e331101
commit 867b7b141d
4 changed files with 421 additions and 39 deletions

View File

@@ -110,12 +110,13 @@ func (s *Server) AddHandler() httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := NewContext(s.config, s.db, r)
if r.Method == http.MethodGet {
url := NormalizeURL(strings.TrimSpace(r.FormValue("url")))
if url == "" && r.Method == http.MethodGet {
s.render("add", w, ctx)
return
}
url := NormalizeURL(strings.TrimSpace(r.FormValue("url")))
if url == "" {
ctx.Error = true
ctx.Message = "Invalid URL"