better search view and admin user reset
This commit is contained in:
parent
c8adfd2ef9
commit
4812a60367
7 changed files with 54 additions and 14 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
"git.giftfish.de/ston1th/godrop/v2"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/render"
|
||||
"github.com/blevesearch/bleve"
|
||||
"github.com/blevesearch/bleve/mapping"
|
||||
"html/template"
|
||||
|
|
@ -32,7 +33,7 @@ type Index struct {
|
|||
i bleve.Index
|
||||
}
|
||||
|
||||
func NewIndex(path string) (i *Index, err error) {
|
||||
func New(path string) (i *Index, err error) {
|
||||
var bi bleve.Index
|
||||
err = godrop.Unveil(path, "rwc")
|
||||
if err != nil {
|
||||
|
|
@ -102,16 +103,11 @@ func (i *Index) Search(search string) (results []core.Result, err error) {
|
|||
continue
|
||||
}
|
||||
r := core.Result{StoreTitle: hit.ID}
|
||||
r.Section, r.Title = render.SplitStoreTitle(hit.ID)
|
||||
d, err := i.i.Document(hit.ID)
|
||||
if d == nil || err != nil {
|
||||
continue
|
||||
}
|
||||
for _, v := range d.Fields {
|
||||
if v.Name() == "title" {
|
||||
r.Title = string(v.Value())
|
||||
break
|
||||
}
|
||||
}
|
||||
for fragField, frags := range hit.Fragments {
|
||||
if fragField == "title" || fragField == "search" {
|
||||
for _, f := range frags {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue