2021-07-12 13:25:57 +00:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/bouncepaw/mycorrhiza/shroom"
|
|
|
|
"github.com/bouncepaw/mycorrhiza/user"
|
|
|
|
"github.com/bouncepaw/mycorrhiza/views"
|
|
|
|
"io"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/bouncepaw/mycorrhiza/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initSearch() {
|
2021-07-12 17:05:50 +00:00
|
|
|
http.HandleFunc("/title-search/", handlerTitleSearch)
|
2021-07-12 13:25:57 +00:00
|
|
|
}
|
|
|
|
|
2021-07-12 17:05:50 +00:00
|
|
|
func handlerTitleSearch(w http.ResponseWriter, rq *http.Request) {
|
2021-07-12 13:25:57 +00:00
|
|
|
util.PrepareRq(rq)
|
2021-07-12 17:01:12 +00:00
|
|
|
_ = rq.ParseForm()
|
2021-07-12 13:25:57 +00:00
|
|
|
var (
|
2021-07-12 17:01:12 +00:00
|
|
|
query = rq.FormValue("q")
|
2021-07-12 13:25:57 +00:00
|
|
|
u = user.FromRequest(rq)
|
|
|
|
)
|
|
|
|
_, _ = io.WriteString(
|
|
|
|
w,
|
|
|
|
views.BaseHTML(
|
|
|
|
"Search: "+query,
|
2021-07-12 17:05:50 +00:00
|
|
|
views.TitleSearchHTML(query, shroom.YieldHyphaNamesContainingString),
|
2021-07-12 13:25:57 +00:00
|
|
|
u,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|