A social RSS reader built on the AT Protocol. glean.at
glean atproto atmosphere rss feed social app
14
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support Favicon URLs and auto-discovery

+38 -6
+1
internal/db/store.go
··· 29 29 SiteURL: df.SiteURL.String, 30 30 Description: df.Description.String, 31 31 Type: df.FeedType.String, 32 + FaviconURL: df.FaviconURL.String, 32 33 ETag: df.Etag.String, 33 34 LastModified: df.LastModified.String, 34 35 })
+8 -2
internal/feed/fetcher.go
··· 182 182 s.logger.Error("failed to update feed fetch result", "error", err, "feed", feed.URL) 183 183 } 184 184 185 - if feed.SiteURL != "" { 185 + if result != nil && result.Feed.FaviconURL != "" { 186 + _ = s.store.UpdateFeedFavicon(ctx, feed.URL, result.Feed.FaviconURL) 187 + } else if feed.FaviconURL == "" { 188 + siteURL := feed.SiteURL 189 + if siteURL == "" { 190 + siteURL = feed.URL 191 + } 186 192 go func() { 187 - discResult, err := Discover(context.Background(), feed.SiteURL) 193 + discResult, err := Discover(context.Background(), siteURL) 188 194 if err == nil && discResult.Favicon != "" { 189 195 _ = s.store.UpdateFeedFavicon(context.Background(), feed.URL, discResult.Favicon) 190 196 }
+16 -1
internal/feed/parser.go
··· 17 17 SiteURL string 18 18 Description string 19 19 Type string 20 + FaviconURL string 20 21 ETag string 21 22 LastModified string 22 23 } ··· 44 45 Title string `xml:"title"` 45 46 Link string `xml:"link"` 46 47 Description string `xml:"description"` 47 - Items []struct { 48 + Image struct { 49 + URL string `xml:"url"` 50 + } `xml:"image"` 51 + Items []struct { 48 52 Title string `xml:"title"` 49 53 Link string `xml:"link"` 50 54 GUID string `xml:"guid"` ··· 65 69 XMLName xml.Name `xml:"feed"` 66 70 Title string `xml:"title"` 67 71 Link []atomLink `xml:"link"` 72 + Icon string `xml:"icon"` 73 + Logo string `xml:"logo"` 68 74 Subtitle string `xml:"subtitle"` 69 75 Entry []struct { 70 76 Title string `xml:"title"` ··· 103 109 Title string `json:"title"` 104 110 HomePageURL string `json:"home_page_url"` 105 111 Description string `json:"description"` 112 + Favicon string `json:"favicon"` 106 113 Items []struct { 107 114 ID string `json:"id"` 108 115 URL string `json:"url"` ··· 144 151 Title: jf.Title, 145 152 SiteURL: jf.HomePageURL, 146 153 Description: jf.Description, 154 + FaviconURL: jf.Favicon, 147 155 Type: "json", 148 156 }, 149 157 } ··· 214 222 Title: rss.Channel.Title, 215 223 SiteURL: rss.Channel.Link, 216 224 Description: rss.Channel.Description, 225 + FaviconURL: rss.Channel.Image.URL, 217 226 Type: "rss", 218 227 }, 219 228 } ··· 272 281 } 273 282 274 283 func convertAtom(atom *atomFeed, feedURL string) *ParseResult { 284 + favicon := atom.Icon 285 + if favicon == "" { 286 + favicon = atom.Logo 287 + } 288 + 275 289 result := &ParseResult{ 276 290 Feed: Feed{ 277 291 URL: feedURL, 278 292 Title: atom.Title, 279 293 SiteURL: pickAtomLink(atom.Link), 280 294 Description: atom.Subtitle, 295 + FaviconURL: favicon, 281 296 Type: "atom", 282 297 }, 283 298 }
+13 -3
internal/server/feeds_handler.go
··· 87 87 return 88 88 } 89 89 90 - siteURL := result.Feed.SiteURL 91 - if siteURL != "" { 90 + if result.Feed.FaviconURL != "" { 91 + _ = s.db.UpdateFeedFavicon(r.Context(), feedURL, result.Feed.FaviconURL) 92 + } else if result.Feed.SiteURL != "" { 92 93 go func() { 93 - discResult, err := feed.Discover(context.Background(), siteURL) 94 + discResult, err := feed.Discover(context.Background(), result.Feed.SiteURL) 94 95 if err == nil && discResult.Favicon != "" { 95 96 _ = s.db.UpdateFeedFavicon(context.Background(), feedURL, discResult.Favicon) 96 97 } ··· 237 238 if upsertErr := s.db.UpsertFeed(r.Context(), f); upsertErr != nil { 238 239 s.logger.Error("failed to upsert feed", "error", upsertErr) 239 240 continue 241 + } 242 + 243 + if fu.SiteURL != "" { 244 + go func(feedURL, siteURL string) { 245 + discResult, err := feed.Discover(context.Background(), siteURL) 246 + if err == nil && discResult.Favicon != "" { 247 + _ = s.db.UpdateFeedFavicon(context.Background(), feedURL, discResult.Favicon) 248 + } 249 + }(fu.URL, fu.SiteURL) 240 250 } 241 251 242 252 var subURI, subCID string