Compare commits
2 Commits
7433947f72
...
cb6bf8fc05
| Author | SHA1 | Date | |
|---|---|---|---|
| cb6bf8fc05 | |||
| 61bdd770f7 |
|
|
@ -138,6 +138,7 @@ 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
|
||||||
|
|
||||||
|
|
@ -299,6 +300,24 @@ 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)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -45,7 +44,6 @@ func getString(fields map[string]interface{}, key, def string) string {
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return def
|
return def
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,18 +67,38 @@ 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
|
||||||
spew.Dump(fields)
|
item.UID = getString(fields, "uid", "")
|
||||||
item.Type = getString(fields, "type", "entry")
|
item.Type = getString(fields, "type", "entry")
|
||||||
item.Name = getString(fields, "name", "")
|
item.Name = getString(fields, "name", "")
|
||||||
item.Content = µsub.Content{}
|
item.Content = µsub.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 = µsub.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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user