From c1251af597ef8f9c5b9e387c41f2340a69d5f3a2 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sun, 11 Aug 2024 14:13:00 +0100 Subject: [PATCH] Tidy up --- internal/assets/templates/forum-posts.html | 2 +- internal/feed/reddit.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/assets/templates/forum-posts.html b/internal/assets/templates/forum-posts.html index 1ada8ec..8a71d22 100644 --- a/internal/assets/templates/forum-posts.html +++ b/internal/assets/templates/forum-posts.html @@ -7,7 +7,7 @@
{{ if $.ShowThumbnails }} {{ if .IsCrosspost }} - + {{ else if ne .ThumbnailUrl "" }} diff --git a/internal/feed/reddit.go b/internal/feed/reddit.go index adeb263..297020c 100644 --- a/internal/feed/reddit.go +++ b/internal/feed/reddit.go @@ -36,7 +36,7 @@ type subredditResponseJson struct { } `json:"data"` } -func templateRedditCommentsUrl(template, subreddit, postId, postPath string) string { +func templateRedditCommentsURL(template, subreddit, postId, postPath string) string { template = strings.ReplaceAll(template, "{SUBREDDIT}", subreddit) template = strings.ReplaceAll(template, "{POST-ID}", postId) template = strings.ReplaceAll(template, "{POST-PATH}", strings.TrimLeft(postPath, "/")) @@ -99,7 +99,7 @@ func FetchSubredditPosts(subreddit, sort, topPeriod, search, commentsUrlTemplate if commentsUrlTemplate == "" { commentsUrl = "https://www.reddit.com" + post.Permalink } else { - commentsUrl = templateRedditCommentsUrl(commentsUrlTemplate, subreddit, post.Id, post.Permalink) + commentsUrl = templateRedditCommentsURL(commentsUrlTemplate, subreddit, post.Id, post.Permalink) } forumPost := ForumPost{ @@ -126,10 +126,16 @@ func FetchSubredditPosts(subreddit, sort, topPeriod, search, commentsUrlTemplate if len(post.ParentList) > 0 { forumPost.IsCrosspost = true forumPost.TargetUrlDomain = "r/" + post.ParentList[0].Subreddit + if commentsUrlTemplate == "" { forumPost.TargetUrl = "https://www.reddit.com" + post.ParentList[0].Permalink } else { - forumPost.TargetUrl = templateRedditCommentsUrl(commentsUrlTemplate, post.ParentList[0].Subreddit, post.ParentList[0].Id, post.ParentList[0].Permalink) + forumPost.TargetUrl = templateRedditCommentsURL( + commentsUrlTemplate, + post.ParentList[0].Subreddit, + post.ParentList[0].Id, + post.ParentList[0].Permalink, + ) } }