Compare commits
No commits in common. "8bad2d1a88874ee86b23697d804b6d4f908e971c" and "453b69590118541c0df68d6db454e9511c8d3adc" have entirely different histories.
8bad2d1a88
...
453b695901
|
|
@ -24,9 +24,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gilliek/go-opml/opml"
|
|
||||||
"p83.nl/go/ekster/pkg/client"
|
"p83.nl/go/ekster/pkg/client"
|
||||||
"p83.nl/go/ekster/pkg/indieauth"
|
"p83.nl/go/ekster/pkg/indieauth"
|
||||||
"p83.nl/go/ekster/pkg/microsub"
|
"p83.nl/go/ekster/pkg/microsub"
|
||||||
|
|
@ -140,8 +138,6 @@ Commands:
|
||||||
|
|
||||||
unfollow UID URL unfollow URL on channel UID
|
unfollow UID URL unfollow URL on channel UID
|
||||||
|
|
||||||
export opml export feeds as OPML
|
|
||||||
|
|
||||||
Global arguments:
|
Global arguments:
|
||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
@ -330,53 +326,6 @@ func performCommands(sub microsub.Microsub, commands []string) {
|
||||||
log.Fatalf("An error occurred: %s\n", err)
|
log.Fatalf("An error occurred: %s\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(commands) == 2 && commands[0] == "export" {
|
|
||||||
filetype := commands[1]
|
|
||||||
if filetype == "opml" {
|
|
||||||
output := opml.OPML{}
|
|
||||||
output.Head.Title = "Microsub channels and feeds"
|
|
||||||
output.Head.DateCreated = time.Now().Format(time.RFC3339)
|
|
||||||
output.Version = "1.0"
|
|
||||||
|
|
||||||
channels, err := sub.ChannelsGetList()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("An error occurred: %s\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, c := range channels {
|
|
||||||
var feeds []opml.Outline
|
|
||||||
list, err := sub.FollowGetList(c.UID)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("An error occurred: %s\n", err)
|
|
||||||
}
|
|
||||||
for _, f := range list {
|
|
||||||
feeds = append(feeds, opml.Outline{
|
|
||||||
Title: f.Name,
|
|
||||||
Text: f.Name,
|
|
||||||
Type: f.Type,
|
|
||||||
URL: f.URL,
|
|
||||||
HTMLURL: f.URL,
|
|
||||||
XMLURL: f.URL,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
output.Body.Outlines = append(output.Body.Outlines, opml.Outline{
|
|
||||||
Text: c.Name,
|
|
||||||
Title: c.Name,
|
|
||||||
Outlines: feeds,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
xml, err := output.XML()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("An error occurred: %s\n", err)
|
|
||||||
}
|
|
||||||
os.Stdout.WriteString(xml)
|
|
||||||
} else {
|
|
||||||
log.Fatalf("unsupported filetype %q", filetype)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func showItem(item *microsub.Item) {
|
func showItem(item *microsub.Item) {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == http.MethodOptions {
|
if r.Method == http.MethodOptions {
|
||||||
w.Header().Add("Access-Control-Allow-Origin", "*")
|
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||||
w.Header().Add("Access-Control-Allow-Methods", "GET, POST")
|
w.Header().Add("Access-Control-Allow-Methods", "GET, POST")
|
||||||
w.Header().Add("Access-Control-Allow-Headers", "Authorization")
|
w.Header().Add("Access-Control-Allow-Headers", "Authorization, Cache-Control")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user