It works (but it sucks0
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"git.mills.io/prologic/spyda"
|
"git.mills.io/prologic/spyda"
|
||||||
"git.mills.io/prologic/spyda/internal/session"
|
"git.mills.io/prologic/spyda/internal/session"
|
||||||
"git.mills.io/prologic/spyda/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Meta struct {
|
type Meta struct {
|
||||||
@@ -52,7 +51,7 @@ type Context struct {
|
|||||||
Title string
|
Title string
|
||||||
Meta Meta
|
Meta Meta
|
||||||
|
|
||||||
Results types.Results
|
Results Results
|
||||||
Pager *paginator.Paginator
|
Pager *paginator.Paginator
|
||||||
|
|
||||||
// Report abuse
|
// Report abuse
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ func (s *Server) SearchHandler() httprouter.Handle {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
results, err := s.indexer.Search(q)
|
searchResults, err := s.indexer.Search(q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("error performing search")
|
log.WithError(err).Error("error performing search")
|
||||||
ctx.Error = true
|
ctx.Error = true
|
||||||
@@ -160,7 +160,22 @@ func (s *Server) SearchHandler() httprouter.Handle {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug(results)
|
log.Debug(searchResults)
|
||||||
|
|
||||||
|
var results []Result
|
||||||
|
|
||||||
|
for _, searchResult := range searchResults.Hits {
|
||||||
|
result := Result{
|
||||||
|
ID: searchResult.ID,
|
||||||
|
Title: searchResult.Fields["Title"].(string),
|
||||||
|
Summary: searchResult.Fields["Summary"].(string),
|
||||||
|
URL: searchResult.Fields["URL"].(string),
|
||||||
|
Length: int(searchResult.Fields["Length"].(float64)),
|
||||||
|
}
|
||||||
|
results = append(results, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Results = results
|
||||||
|
|
||||||
s.render("search", w, ctx)
|
s.render("search", w, ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
11
internal/results.go
Normal file
11
internal/results.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
type Result struct {
|
||||||
|
ID string
|
||||||
|
URL string
|
||||||
|
Title string
|
||||||
|
Summary string
|
||||||
|
Length int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Results []Result
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
type Item struct {
|
|
||||||
ID int
|
|
||||||
Length int
|
|
||||||
|
|
||||||
URL string
|
|
||||||
Title string
|
|
||||||
Author string
|
|
||||||
Summary string
|
|
||||||
Content string
|
|
||||||
HTMLContent string
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
type Results []Item
|
|
||||||
Reference in New Issue
Block a user