From 91ef195a56304ef59d175e406fb21505bfcd417a Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sat, 31 Aug 2024 00:49:35 +0200 Subject: [PATCH 1/3] Check if article has been published before adding it to RSS feed --- cmd/backend/rss.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/backend/rss.go b/cmd/backend/rss.go index 35927d2..686e8c1 100644 --- a/cmd/backend/rss.go +++ b/cmd/backend/rss.go @@ -23,6 +23,10 @@ func GenerateRSS(c *Config, db *DB) (*string, error) { } for _, article := range articles { + if !article.Published { + continue + } + tags, err := db.GetArticleTags(article.ID) if err != nil { return nil, fmt.Errorf("error getting tags for articles for RSS feed: %v", err) From ab6b9b9a4f0538042ac477d3e7de2ba3b0cfc35b Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sat, 31 Aug 2024 00:52:10 +0200 Subject: [PATCH 2/3] Add port to url of UploadArticleImage() --- cmd/frontend/articles.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/frontend/articles.go b/cmd/frontend/articles.go index fd6bef0..8e6263d 100644 --- a/cmd/frontend/articles.go +++ b/cmd/frontend/articles.go @@ -502,7 +502,7 @@ func UploadArticleImage(c *b.Config, s *b.CookieStore) http.HandlerFunc { return } - url := fmt.Sprint(c.Domain, "/image/serve/", filename) + url := fmt.Sprint(c.Domain, c.Port, "/image/serve/", filename) w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(url) } From bc58b1be44e3635052e620d19f488aad420cecb2 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sat, 31 Aug 2024 01:00:39 +0200 Subject: [PATCH 3/3] Fixed small bug in ServeArticle where it was looking at the link to read the file --- cmd/calls/articles.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/calls/articles.go b/cmd/calls/articles.go index 0c327c0..1568cdd 100644 --- a/cmd/calls/articles.go +++ b/cmd/calls/articles.go @@ -35,7 +35,8 @@ func ServeArticle(c *b.Config, db *b.DB) http.HandlerFunc { return } - contentBytes, err := os.ReadFile(article.Link) + articleAbsName := fmt.Sprint(c.ArticleDir, "/", article.ID, ".md") + contentBytes, err := os.ReadFile(articleAbsName) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError)