MCPcopy
hub / github.com/writefreely/writefreely / viewLocalTimelineFeed

Function viewLocalTimelineFeed

read.go:291–340  ·  view source on GitHub ↗
(app *App, w http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

289}
290
291func viewLocalTimelineFeed(app *App, w http.ResponseWriter, req *http.Request) error {
292 if !app.cfg.App.LocalTimeline {
293 return impart.HTTPError{http.StatusNotFound, "Page doesn't exist."}
294 }
295
296 updateTimelineCache(app.timeline, false)
297
298 feed := &Feed{
299 Title: app.cfg.App.SiteName + " Reader",
300 Link: &Link{Href: app.cfg.App.Host},
301 Description: "Read the latest posts from " + app.cfg.App.SiteName + ".",
302 Created: time.Now(),
303 }
304
305 c := 0
306 var title, permalink, author string
307 for _, p := range *app.timeline.posts {
308 if c == tlFeedLimit {
309 break
310 }
311
312 title = p.PlainDisplayTitle()
313 permalink = p.CanonicalURL(app.cfg.App.Host)
314 if p.Collection != nil {
315 author = p.Collection.Title
316 } else {
317 author = "Anonymous"
318 }
319 i := &Item{
320 Id: app.cfg.App.Host + "/read/a/" + p.ID,
321 Title: title,
322 Link: &Link{Href: permalink},
323 Description: "<![CDATA[" + stripmd.Strip(p.Content) + "]]>",
324 Content: applyMarkdown([]byte(p.Content), "", app.cfg),
325 Author: &Author{author, ""},
326 Created: p.Created,
327 Updated: p.Updated,
328 }
329 feed.Items = append(feed.Items, i)
330 c++
331 }
332
333 rss, err := feed.ToRss()
334 if err != nil {
335 return err
336 }
337
338 fmt.Fprint(w, rss)
339 return nil
340}

Callers

nothing calls this directly

Calls 4

updateTimelineCacheFunction · 0.85
applyMarkdownFunction · 0.85
PlainDisplayTitleMethod · 0.80
CanonicalURLMethod · 0.45

Tested by

no test coverage detected