Open recoilme opened 6 years ago
I could probably take this on in my free time, I spent some time with the Gorilla feed library (and contributed a bit to it) - this shouldn't be too difficult.
Hello @gmemstr , thank you i use gorilla lib on my last project - http://tggram.com/
as i remember it was very easy on start but hard to add some custom futures like specific to rss tags
because library - universal for rss/atom and so..
So i'm not sure .. May be more easy create it from scratch - think about it please
i found little code snippet - may be it help (may be not)
case "feed":
if urlPart[2] == "rss" {
msgs = tgdb.Messages(host, 0, 10)
var feed feeds.Feed
feed.Created = time.Now()
feed.Title = site.Title
feed.Description = site.Description
feed.Author = &feeds.Author{Name: site.Info.UserName}
feed.Link = &feeds.Link{Href: site.Host}
for _, msg := range msgs {
var item feeds.Item
var link feeds.Link
item.Id = fmt.Sprintf("%s/post/%d", site.Host, msg.MessageID)
item.Title = getTitle(msg.Text)
item.Description = formatTextBr(msg.Text)
link.Href = fmt.Sprintf("%s/post/%d", site.Host, msg.MessageID)
if msg.Caption != "" {
item.Title = getTitle(msg.Caption)
}
if msg.Photo != nil {
var photoSize tgbotapi.PhotoSize
for _, size := range *msg.Photo {
photoSize = size
}
item.Description = fmt.Sprintf(`<figure>
<img src="%s" width="%d" height="%d">
<figcaption>
%s
</figcaption>
</figure>`, msg.Text, photoSize.Width, photoSize.Height, msg.Caption)
link.Href = msg.Text
link.Length = fmt.Sprintf("%d", photoSize.FileSize)
link.Type = mime.TypeByExtension(filepath.Ext(msg.Text)) //"image/jpeg"
}
if msg.Document != nil {
item.Description = fmt.Sprintf(`
<figure>
<div class="video">
<video loop src="%s" controls preload="metadata"></video>
</div>
<p>%s</p>
</figure>
`, msg.Text, msg.Caption)
link.Href = msg.Text
link.Length = fmt.Sprintf("%d", msg.Document.FileSize)
link.Type = msg.Document.MimeType
}
item.Link = &link
item.Author = &feeds.Author{Name: site.Info.UserName}
item.Created = time.Unix(int64(msg.Date), 0)
feed.Add(&item)
}
rssFeed := (&feeds.Rss{Feed: &feed}).RssFeed()
var rss string
var err error
if rssFeed != nil {
rss, err = feeds.ToXML(rssFeed)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
w.Header().Set("Content-Type", "text/xml;charset=UTF-8")
fmt.Fprintln(w, rss)
return
} else {
errorHandler(host, w, r, http.StatusNotFound)
return
}
@gmemstr may i take this?
@recoilme Absolutely, feel free - been pretty busy with work and haven't gotten a chance to do this. Sorry!
no rss/atom feed for author