bskyweb: iterate on RSS format, based on feedback (#2269)
Thanks to Dave Winer (@scripting)!zio/stable
parent
64dc8ff342
commit
a5c151c041
|
@ -1,8 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
appbsky "github.com/bluesky-social/indigo/api/bsky"
|
appbsky "github.com/bluesky-social/indigo/api/bsky"
|
||||||
"github.com/bluesky-social/indigo/atproto/syntax"
|
"github.com/bluesky-social/indigo/atproto/syntax"
|
||||||
|
@ -10,6 +12,12 @@ import (
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ItemGUID struct {
|
||||||
|
XMLName xml.Name `xml:"guid"`
|
||||||
|
Value string `xml:",chardata"`
|
||||||
|
IsPerma bool `xml:"isPermalink,attr"`
|
||||||
|
}
|
||||||
|
|
||||||
// We don't actually populate the title for "posts".
|
// We don't actually populate the title for "posts".
|
||||||
// Some background: https://book.micro.blog/rss-for-microblogs/
|
// Some background: https://book.micro.blog/rss-for-microblogs/
|
||||||
type Item struct {
|
type Item struct {
|
||||||
|
@ -17,8 +25,7 @@ type Item struct {
|
||||||
Link string `xml:"link,omitempty"`
|
Link string `xml:"link,omitempty"`
|
||||||
Description string `xml:"description,omitempty"`
|
Description string `xml:"description,omitempty"`
|
||||||
PubDate string `xml:"pubDate,omitempty"`
|
PubDate string `xml:"pubDate,omitempty"`
|
||||||
Author string `xml:"author,omitempty"`
|
GUID ItemGUID
|
||||||
GUID string `xml:"guid,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type rss struct {
|
type rss struct {
|
||||||
|
@ -71,12 +78,19 @@ func (srv *Server) WebProfileRSS(c echo.Context) error {
|
||||||
if rec.Reply != nil {
|
if rec.Reply != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
pubDate := ""
|
||||||
|
createdAt, err := syntax.ParseDatetimeLenient(rec.CreatedAt)
|
||||||
|
if nil == err {
|
||||||
|
pubDate = createdAt.Time().Format(time.RFC822Z)
|
||||||
|
}
|
||||||
posts = append(posts, Item{
|
posts = append(posts, Item{
|
||||||
Link: fmt.Sprintf("https://bsky.app/profile/%s/post/%s", pv.Handle, aturi.RecordKey().String()),
|
Link: fmt.Sprintf("https://bsky.app/profile/%s/post/%s", pv.Handle, aturi.RecordKey().String()),
|
||||||
Description: rec.Text,
|
Description: rec.Text,
|
||||||
PubDate: rec.CreatedAt,
|
PubDate: pubDate,
|
||||||
Author: "@" + pv.Handle,
|
GUID: ItemGUID{
|
||||||
GUID: aturi.String(),
|
Value: aturi.String(),
|
||||||
|
IsPerma: false,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue