From 82b6531a07178040bb050926e2b6a273600f2259 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Wed, 7 Aug 2024 19:18:17 +0100 Subject: [PATCH 1/5] Add funding --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..cda2741 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [glanceapp] From c9a2aff6a6c0da29e8903497d9b23abc994166b2 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Tue, 11 Jun 2024 00:35:26 +0100 Subject: [PATCH 2/5] Fix search input color --- internal/assets/static/main.css | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/assets/static/main.css b/internal/assets/static/main.css index 62b4480..ccad001 100644 --- a/internal/assets/static/main.css +++ b/internal/assets/static/main.css @@ -731,6 +731,7 @@ kbd:active { height: 6rem; font: inherit; outline: none; + color: var(--color-text-highlight); } .search-input::placeholder { From b8b90451b6d23d50dedd8bf8f84975cec1160274 Mon Sep 17 00:00:00 2001 From: Wyatt Gill Date: Fri, 7 Jun 2024 16:27:13 -0500 Subject: [PATCH 3/5] Use GitHub's latest release API endpoint The current releases widget uses the releases endpoint to pull the 10 most recent releases and filter them to find the latest release. This causes a problem when a repository's latest release is outside of the 10 most recent (e.g. 10 prereleases): ERROR No live release found repository=cross-seed/cross-seed url="https://api.github.com/repos/cross-seed/cross-seed/releases?per_page=10" This is no longer a problem when using the latest release endpoint which grabs the latest release, ignoring draft releases and prereleases. --- internal/feed/github.go | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/internal/feed/github.go b/internal/feed/github.go index 43a2459..4d7dc73 100644 --- a/internal/feed/github.go +++ b/internal/feed/github.go @@ -8,12 +8,10 @@ import ( "time" ) -type githubReleaseResponseJson struct { +type githubReleaseLatestResponseJson struct { TagName string `json:"tag_name"` PublishedAt string `json:"published_at"` HtmlUrl string `json:"html_url"` - Draft bool `json:"draft"` - PreRelease bool `json:"prerelease"` Reactions struct { Downvotes int `json:"-1"` } `json:"reactions"` @@ -39,7 +37,7 @@ func FetchLatestReleasesFromGithub(repositories []string, token string) (AppRele requests := make([]*http.Request, len(repositories)) for i, repository := range repositories { - request, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/repos/%s/releases?per_page=10", repository), nil) + request, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/repos/%s/releases/latest", repository), nil) if token != "" { request.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token)) @@ -48,7 +46,7 @@ func FetchLatestReleasesFromGithub(repositories []string, token string) (AppRele requests[i] = request } - task := decodeJsonFromRequestTask[[]githubReleaseResponseJson](defaultClient) + task := decodeJsonFromRequestTask[githubReleaseLatestResponseJson](defaultClient) job := newJob(task, requests).withWorkers(15) responses, errs, err := workerPoolDo(job) @@ -65,24 +63,7 @@ func FetchLatestReleasesFromGithub(repositories []string, token string) (AppRele continue } - releases := responses[i] - - if len(releases) < 1 { - failed++ - slog.Error("No releases found", "repository", repositories[i], "url", requests[i].URL) - continue - } - - var liveRelease *githubReleaseResponseJson - - for i := range releases { - release := &releases[i] - - if !release.Draft && !release.PreRelease { - liveRelease = release - break - } - } + liveRelease := &responses[i] if liveRelease == nil { slog.Error("No live release found", "repository", repositories[i], "url", requests[i].URL) From 139937f8874664767f6bdd8d5dead271008fc52c Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sat, 29 Jun 2024 17:17:27 +0100 Subject: [PATCH 4/5] Fix missing RSS thumbnail images --- internal/feed/rss.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/internal/feed/rss.go b/internal/feed/rss.go index 4d22af6..74f064b 100644 --- a/internal/feed/rss.go +++ b/internal/feed/rss.go @@ -12,6 +12,7 @@ import ( "time" "github.com/mmcdole/gofeed" + gofeedext "github.com/mmcdole/gofeed/extensions" ) type RSSFeedItem struct { @@ -145,6 +146,8 @@ func getItemsFromRSSFeedTask(request RSSFeedRequest) ([]RSSFeedItem, error) { if item.Image != nil { rssItem.ImageURL = item.Image.URL + } else if url := findThumbnailInItemExtensions(item); url != "" { + rssItem.ImageURL = url } else if feed.Image != nil { rssItem.ImageURL = feed.Image.URL } @@ -161,6 +164,36 @@ func getItemsFromRSSFeedTask(request RSSFeedRequest) ([]RSSFeedItem, error) { return items, nil } +func recursiveFindThumbnailInExtensions(extensions map[string][]gofeedext.Extension) string { + for _, exts := range extensions { + for _, ext := range exts { + if ext.Name == "thumbnail" || ext.Name == "image" { + if url, ok := ext.Attrs["url"]; ok { + return url + } + } + + if ext.Children != nil { + if url := recursiveFindThumbnailInExtensions(ext.Children); url != "" { + return url + } + } + } + } + + return "" +} + +func findThumbnailInItemExtensions(item *gofeed.Item) string { + media, ok := item.Extensions["media"] + + if !ok { + return "" + } + + return recursiveFindThumbnailInExtensions(media) +} + func GetItemsFromRSSFeeds(requests []RSSFeedRequest) (RSSFeedItems, error) { job := newJob(getItemsFromRSSFeedTask, requests).withWorkers(10) feeds, errs, err := workerPoolDo(job) From 2a3f8eedf605ad8c0b75efc98bd63ae5c6b03cb4 Mon Sep 17 00:00:00 2001 From: ccjjxl Date: Thu, 22 Aug 2024 17:24:00 +0800 Subject: [PATCH 5/5] Fix RSS item link empty --- internal/feed/rss.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/feed/rss.go b/internal/feed/rss.go index 74f064b..7ed2df2 100644 --- a/internal/feed/rss.go +++ b/internal/feed/rss.go @@ -98,7 +98,7 @@ func getItemsFromRSSFeedTask(request RSSFeedRequest) ([]RSSFeedItem, error) { if err == nil { var link string - if item.Link[0] == '/' { + if len(item.Link) > 0 && item.Link[0] == '/' { link = item.Link } else { link = "/" + item.Link