repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
ab431cc
parent
f4b4b85
author
Eric Bower
date
2022-08-18 13:27:58 +0000 UTC
fix(all): updated rss feeds to contain more information

I also added aliases to user blog's rss feeds
4 files changed,  +54, -30
M imgs/api.go
+18, -10
 1@@ -734,11 +734,13 @@ func rssBlogHandler(w http.ResponseWriter, r *http.Request) {
 2 		}
 3 
 4 		item := &feeds.Item{
 5-			Id:      realUrl,
 6-			Title:   post.Title,
 7-			Link:    &feeds.Link{Href: realUrl},
 8-			Created: *post.PublishAt,
 9-			Content: tpl.String(),
10+			Id:          realUrl,
11+			Title:       post.Title,
12+			Link:        &feeds.Link{Href: realUrl},
13+			Created:     *post.PublishAt,
14+			Content:     tpl.String(),
15+			Updated:     *post.UpdatedAt,
16+			Description: post.Description,
17 		}
18 
19 		if post.Description != "" {
20@@ -811,11 +813,14 @@ func rssHandler(w http.ResponseWriter, r *http.Request) {
21 		}
22 
23 		item := &feeds.Item{
24-			Id:      realUrl,
25-			Title:   post.Title,
26-			Link:    &feeds.Link{Href: realUrl},
27-			Content: tpl.String(),
28-			Created: *post.PublishAt,
29+			Id:          realUrl,
30+			Title:       post.Title,
31+			Link:        &feeds.Link{Href: realUrl},
32+			Content:     tpl.String(),
33+			Created:     *post.PublishAt,
34+			Updated:     *post.UpdatedAt,
35+			Description: post.Description,
36+			Author:      &feeds.Author{Name: post.Username},
37 		}
38 
39 		if post.Description != "" {
40@@ -876,6 +881,9 @@ func createMainRoutes(staticRoutes []shared.Route) []shared.Route {
41 
42 		shared.NewRoute("GET", "/([^/]+)", blogHandler),
43 		shared.NewRoute("GET", "/([^/]+)/rss", rssBlogHandler),
44+		shared.NewRoute("GET", "/([^/]+)/rss.xml", rssBlogHandler),
45+		shared.NewRoute("GET", "/([^/]+)/atom.xml", rssBlogHandler),
46+		shared.NewRoute("GET", "/([^/]+)/feed.xml", rssBlogHandler),
47 		shared.NewRoute("GET", "/([^/]+)/([^/]+\\..+)", imgHandler),
48 		shared.NewRoute("GET", "/([^/]+)/([^/]+)", postHandler),
49 	)
M imgs/public/card.png
+0, -0
M lists/api.go
+18, -10
 1@@ -535,11 +535,13 @@ func rssBlogHandler(w http.ResponseWriter, r *http.Request) {
 2 		}
 3 
 4 		item := &feeds.Item{
 5-			Id:      cfg.PostURL(post.Username, post.Slug),
 6-			Title:   shared.FilenameToTitle(post.Filename, post.Title),
 7-			Link:    &feeds.Link{Href: cfg.PostURL(post.Username, post.Slug)},
 8-			Content: tpl.String(),
 9-			Created: *post.PublishAt,
10+			Id:          cfg.PostURL(post.Username, post.Slug),
11+			Title:       shared.FilenameToTitle(post.Filename, post.Title),
12+			Link:        &feeds.Link{Href: cfg.PostURL(post.Username, post.Slug)},
13+			Content:     tpl.String(),
14+			Created:     *post.PublishAt,
15+			Updated:     *post.UpdatedAt,
16+			Description: post.Description,
17 		}
18 
19 		if post.Description != "" {
20@@ -607,11 +609,14 @@ func rssHandler(w http.ResponseWriter, r *http.Request) {
21 		}
22 
23 		item := &feeds.Item{
24-			Id:      cfg.PostURL(post.Username, post.Slug),
25-			Title:   post.Title,
26-			Link:    &feeds.Link{Href: cfg.PostURL(post.Username, post.Slug)},
27-			Content: tpl.String(),
28-			Created: *post.PublishAt,
29+			Id:          cfg.PostURL(post.Username, post.Slug),
30+			Title:       post.Title,
31+			Link:        &feeds.Link{Href: cfg.PostURL(post.Username, post.Slug)},
32+			Content:     tpl.String(),
33+			Created:     *post.PublishAt,
34+			Updated:     *post.UpdatedAt,
35+			Description: post.Description,
36+			Author:      &feeds.Author{Name: post.Username},
37 		}
38 
39 		if post.Description != "" {
40@@ -673,6 +678,9 @@ func createMainRoutes(staticRoutes []shared.Route) []shared.Route {
41 
42 		shared.NewRoute("GET", "/([^/]+)", blogHandler),
43 		shared.NewRoute("GET", "/([^/]+)/rss", rssBlogHandler),
44+		shared.NewRoute("GET", "/([^/]+)/rss.xml", rssBlogHandler),
45+		shared.NewRoute("GET", "/([^/]+)/atom.xml", rssBlogHandler),
46+		shared.NewRoute("GET", "/([^/]+)/feed.xml", rssBlogHandler),
47 		shared.NewRoute("GET", "/([^/]+)/([^/]+)", postHandler),
48 		shared.NewRoute("GET", "/raw/([^/]+)/([^/]+)", postRawHandler),
49 	)
M prose/api.go
+18, -10
 1@@ -600,11 +600,13 @@ func rssBlogHandler(w http.ResponseWriter, r *http.Request) {
 2 		}
 3 
 4 		item := &feeds.Item{
 5-			Id:      realUrl,
 6-			Title:   shared.FilenameToTitle(post.Filename, post.Title),
 7-			Link:    &feeds.Link{Href: realUrl},
 8-			Content: tpl.String(),
 9-			Created: *post.PublishAt,
10+			Id:          realUrl,
11+			Title:       shared.FilenameToTitle(post.Filename, post.Title),
12+			Link:        &feeds.Link{Href: realUrl},
13+			Content:     tpl.String(),
14+			Created:     *post.PublishAt,
15+			Updated:     *post.UpdatedAt,
16+			Description: post.Description,
17 		}
18 
19 		if post.Description != "" {
20@@ -682,11 +684,14 @@ func rssHandler(w http.ResponseWriter, r *http.Request) {
21 		}
22 
23 		item := &feeds.Item{
24-			Id:      realUrl,
25-			Title:   post.Title,
26-			Link:    &feeds.Link{Href: realUrl},
27-			Content: tpl.String(),
28-			Created: *post.PublishAt,
29+			Id:          realUrl,
30+			Title:       post.Title,
31+			Link:        &feeds.Link{Href: realUrl},
32+			Content:     tpl.String(),
33+			Created:     *post.PublishAt,
34+			Updated:     *post.UpdatedAt,
35+			Description: post.Description,
36+			Author:      &feeds.Author{Name: post.Username},
37 		}
38 
39 		if post.Description != "" {
40@@ -770,6 +775,9 @@ func createMainRoutes(staticRoutes []shared.Route) []shared.Route {
41 
42 		shared.NewRoute("GET", "/([^/]+)", blogHandler),
43 		shared.NewRoute("GET", "/([^/]+)/rss", rssBlogHandler),
44+		shared.NewRoute("GET", "/([^/]+)/rss.xml", rssBlogHandler),
45+		shared.NewRoute("GET", "/([^/]+)/atom.xml", rssBlogHandler),
46+		shared.NewRoute("GET", "/([^/]+)/feed.xml", rssBlogHandler),
47 		shared.NewRoute("GET", "/([^/]+)/styles.css", blogStyleHandler),
48 		shared.NewRoute("GET", "/([^/]+)/([^/]+)", postHandler),
49 		shared.NewRoute("GET", "/raw/([^/]+)/([^/]+)", postRawHandler),