mirror of
https://github.com/glanceapp/glance.git
synced 2024-11-22 00:13:55 +01:00
Merge pull request #210 from micash545/main
releases: Add support for Codeberg
This commit is contained in:
commit
aa74c00fd4
@ -1114,7 +1114,7 @@ Whether to ignore invalid/self-signed certificates.
|
|||||||
Whether to open the link in the same or a new tab.
|
Whether to open the link in the same or a new tab.
|
||||||
|
|
||||||
### Releases
|
### Releases
|
||||||
Display a list of latest releases for specific repositories on Github, GitLab or Docker Hub.
|
Display a list of latest releases for specific repositories on Github, GitLab, Codeberg or Docker Hub.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -1125,6 +1125,7 @@ Example:
|
|||||||
- go-gitea/gitea
|
- go-gitea/gitea
|
||||||
- jellyfin/jellyfin
|
- jellyfin/jellyfin
|
||||||
- glanceapp/glance
|
- glanceapp/glance
|
||||||
|
- codeberg:redict/redict
|
||||||
- gitlab:fdroid/fdroidclient
|
- gitlab:fdroid/fdroidclient
|
||||||
- dockerhub:gotify/server
|
- dockerhub:gotify/server
|
||||||
```
|
```
|
||||||
@ -1145,12 +1146,13 @@ Preview:
|
|||||||
| collapse-after | integer | no | 5 |
|
| collapse-after | integer | no | 5 |
|
||||||
|
|
||||||
##### `repositories`
|
##### `repositories`
|
||||||
A list of repositores to fetch the latest release for. Only the name/repo is required, not the full URL. A prefix can be specified for repositories hosted elsewhere such as GitLab and Docker Hub. Example:
|
A list of repositores to fetch the latest release for. Only the name/repo is required, not the full URL. A prefix can be specified for repositories hosted elsewhere such as GitLab, Codeberg and Docker Hub. Example:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
repositories:
|
repositories:
|
||||||
- gitlab:inkscape/inkscape
|
- gitlab:inkscape/inkscape
|
||||||
- dockerhub:glanceapp/glance
|
- dockerhub:glanceapp/glance
|
||||||
|
- codeberg:redict/redict
|
||||||
```
|
```
|
||||||
|
|
||||||
Official images on Docker Hub can be specified by ommiting the owner:
|
Official images on Docker Hub can be specified by ommiting the owner:
|
||||||
@ -1172,7 +1174,7 @@ repositories:
|
|||||||
|
|
||||||
|
|
||||||
##### `show-source-icon`
|
##### `show-source-icon`
|
||||||
Shows an icon of the source (GitHub/GitLab/Docker Hub) next to the repository name when set to `true`.
|
Shows an icon of the source (GitHub/GitLab/Codeberg/Docker Hub) next to the repository name when set to `true`.
|
||||||
|
|
||||||
##### `token`
|
##### `token`
|
||||||
Without authentication Github allows for up to 60 requests per hour. You can easily exceed this limit and start seeing errors if you're tracking lots of repositories or your cache time is low. To circumvent this you can [create a read only token from your Github account](https://github.com/settings/personal-access-tokens/new) and provide it here.
|
Without authentication Github allows for up to 60 requests per hour. You can easily exceed this limit and start seeing errors if you're tracking lots of repositories or your cache time is low. To circumvent this you can [create a read only token from your Github account](https://github.com/settings/personal-access-tokens/new) and provide it here.
|
||||||
|
1
internal/assets/static/icons/codeberg.svg
Normal file
1
internal/assets/static/icons/codeberg.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M11.955.49A12 12 0 0 0 0 12.49a12 12 0 0 0 1.832 6.373L11.838 5.928a.187.14 0 0 1 .324 0l10.006 12.935A12 12 0 0 0 24 12.49a12 12 0 0 0-12-12 12 12 0 0 0-.045 0zm.375 6.467l4.416 16.553a12 12 0 0 0 5.137-4.213z"/></svg>
|
After Width: | Height: | Size: 300 B |
39
internal/feed/codeberg.go
Normal file
39
internal/feed/codeberg.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package feed
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type codebergReleaseResponseJson struct {
|
||||||
|
TagName string `json:"tag_name"`
|
||||||
|
PublishedAt string `json:"published_at"`
|
||||||
|
HtmlUrl string `json:"html_url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func fetchLatestCodebergRelease(request *ReleaseRequest) (*AppRelease, error) {
|
||||||
|
httpRequest, err := http.NewRequest(
|
||||||
|
"GET",
|
||||||
|
fmt.Sprintf(
|
||||||
|
"https://codeberg.org/api/v1/repos/%s/releases/latest",
|
||||||
|
request.Repository,
|
||||||
|
),
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := decodeJsonFromRequest[codebergReleaseResponseJson](defaultClient, httpRequest)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &AppRelease{
|
||||||
|
Source: ReleaseSourceCodeberg,
|
||||||
|
Name: request.Repository,
|
||||||
|
Version: normalizeVersionFormat(response.TagName),
|
||||||
|
NotesUrl: response.HtmlUrl,
|
||||||
|
TimeReleased: parseRFC3339Time(response.PublishedAt),
|
||||||
|
}, nil
|
||||||
|
}
|
@ -9,6 +9,7 @@ import (
|
|||||||
type ReleaseSource string
|
type ReleaseSource string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
ReleaseSourceCodeberg ReleaseSource = "codeberg"
|
||||||
ReleaseSourceGithub ReleaseSource = "github"
|
ReleaseSourceGithub ReleaseSource = "github"
|
||||||
ReleaseSourceGitlab ReleaseSource = "gitlab"
|
ReleaseSourceGitlab ReleaseSource = "gitlab"
|
||||||
ReleaseSourceDockerHub ReleaseSource = "dockerhub"
|
ReleaseSourceDockerHub ReleaseSource = "dockerhub"
|
||||||
@ -57,6 +58,8 @@ func FetchLatestReleases(requests []*ReleaseRequest) (AppReleases, error) {
|
|||||||
|
|
||||||
func fetchLatestReleaseTask(request *ReleaseRequest) (*AppRelease, error) {
|
func fetchLatestReleaseTask(request *ReleaseRequest) (*AppRelease, error) {
|
||||||
switch request.Source {
|
switch request.Source {
|
||||||
|
case ReleaseSourceCodeberg:
|
||||||
|
return fetchLatestCodebergRelease(request)
|
||||||
case ReleaseSourceGithub:
|
case ReleaseSourceGithub:
|
||||||
return fetchLatestGithubRelease(request)
|
return fetchLatestGithubRelease(request)
|
||||||
case ReleaseSourceGitlab:
|
case ReleaseSourceGitlab:
|
||||||
|
@ -40,7 +40,6 @@ func (widget *Releases) Initialize() error {
|
|||||||
for _, repository := range widget.Repositories {
|
for _, repository := range widget.Repositories {
|
||||||
parts := strings.SplitN(repository, ":", 2)
|
parts := strings.SplitN(repository, ":", 2)
|
||||||
var request *feed.ReleaseRequest
|
var request *feed.ReleaseRequest
|
||||||
|
|
||||||
if len(parts) == 1 {
|
if len(parts) == 1 {
|
||||||
request = &feed.ReleaseRequest{
|
request = &feed.ReleaseRequest{
|
||||||
Source: feed.ReleaseSourceGithub,
|
Source: feed.ReleaseSourceGithub,
|
||||||
@ -65,6 +64,11 @@ func (widget *Releases) Initialize() error {
|
|||||||
Source: feed.ReleaseSourceDockerHub,
|
Source: feed.ReleaseSourceDockerHub,
|
||||||
Repository: parts[1],
|
Repository: parts[1],
|
||||||
}
|
}
|
||||||
|
} else if parts[0] == string(feed.ReleaseSourceCodeberg) {
|
||||||
|
request = &feed.ReleaseRequest{
|
||||||
|
Source: feed.ReleaseSourceCodeberg,
|
||||||
|
Repository: parts[1],
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return errors.New("invalid repository source " + parts[0])
|
return errors.New("invalid repository source " + parts[0])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user