Compare commits

..

No commits in common. "cb6bf8fc05822dd051179308bf6cb2d72838c244" and "7433947f72ff4fbeabda2bf420ef9d48610486b7" have entirely different histories.

2 changed files with 3 additions and 40 deletions

View File

@ -138,7 +138,6 @@ Commands:
timeline UID -before BEFORE show posts for channel UID ending at BEFORE timeline UID -before BEFORE show posts for channel UID ending at BEFORE
search QUERY search for feeds from QUERY search QUERY search for feeds from QUERY
query QUERY CHANNEL search for items matching QUERY in CHANNEL
preview URL show items from the feed at URL preview URL show items from the feed at URL
@ -300,24 +299,6 @@ func performCommands(sub microsub.Microsub, commands []string) {
} }
} }
if len(commands) >= 2 && len(commands) <= 3 && commands[0] == "query" {
query := commands[1]
var channel string
if len(commands) == 3 {
channel = commands[2]
} else {
channel = "global"
}
items, err := sub.ItemSearch(channel, query)
if err != nil {
log.Fatalf("An error occurred: %s\n", err)
}
for _, item := range items {
showItem(&item)
}
}
if len(commands) == 2 && commands[0] == "preview" { if len(commands) == 2 && commands[0] == "preview" {
u := commands[1] u := commands[1]
timeline, err := sub.PreviewURL(u) timeline, err := sub.PreviewURL(u)

View File

@ -5,6 +5,7 @@ import (
"os" "os"
"github.com/blevesearch/bleve/v2" "github.com/blevesearch/bleve/v2"
"github.com/davecgh/go-spew/spew"
"p83.nl/go/ekster/pkg/microsub" "p83.nl/go/ekster/pkg/microsub"
) )
@ -44,6 +45,7 @@ func getString(fields map[string]interface{}, key, def string) string {
return str return str
} }
} }
return def return def
} }
@ -67,38 +69,18 @@ func querySearch(channel, query string) ([]microsub.Item, error) {
items := []microsub.Item{} items := []microsub.Item{}
/*
web_1 | (string) (len=19) "author.country-name": (string) "",
web_1 | (string) (len=15) "author.latitude": (string) "",
web_1 | (string) (len=13) "author.region": (string) ""
web_1 | (string) (len=15) "author.locality": (string) "",
web_1 | (string) (len=16) "author.longitude": (string) "",
*/
hits := res.Hits hits := res.Hits
for _, hit := range hits { for _, hit := range hits {
fields := hit.Fields fields := hit.Fields
var item microsub.Item var item microsub.Item
item.UID = getString(fields, "uid", "") spew.Dump(fields)
item.Type = getString(fields, "type", "entry") item.Type = getString(fields, "type", "entry")
item.Name = getString(fields, "name", "") item.Name = getString(fields, "name", "")
item.Content = &microsub.Content{} item.Content = &microsub.Content{}
item.Content.HTML = getString(fields, "content.html", "") item.Content.HTML = getString(fields, "content.html", "")
item.Content.Text = getString(fields, "content.text", "") item.Content.Text = getString(fields, "content.text", "")
item.Summary = getString(fields, "summary", "")
item.URL = getString(fields, "url", "") item.URL = getString(fields, "url", "")
item.Name = getString(fields, "name", "") item.Name = getString(fields, "name", "")
item.Longitude = getString(fields, "longitude", "")
item.Latitude = getString(fields, "latitude", "")
item.Published = getString(fields, "published", "")
item.Updated = getString(fields, "updated", "")
item.Read = false
item.Author = &microsub.Card{
Type: getString(fields, "author.type", ""),
Name: getString(fields, "author.name", ""),
URL: getString(fields, "author.url", ""),
Photo: getString(fields, "author.photo", ""),
}
items = append(items, item) items = append(items, item)
} }