28 lines
642 B
Go
Executable File
28 lines
642 B
Go
Executable File
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"html"
|
|
"gitea.inhome.blapointe.com/local/notes-server/filetree"
|
|
"net/http"
|
|
)
|
|
|
|
func (s *Server) search(w http.ResponseWriter, r *http.Request) {
|
|
if err := r.ParseForm(); err != nil {
|
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
|
return
|
|
}
|
|
keywords := r.FormValue("keywords")
|
|
keywords = html.UnescapeString(keywords)
|
|
results, err := s.Notes.Search(keywords)
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
head(w, r)
|
|
fmt.Fprintln(w, h2(filetree.NewPathFromURL("/notes").MultiLink()))
|
|
htmlSearch(w)
|
|
fmt.Fprintln(w, h1(keywords), results)
|
|
foot(w, r)
|
|
}
|