Skip to content
Snippets Groups Projects
Commit f6c41f9d authored by moon2's avatar moon2 :speech_balloon:
Browse files

Merge branch 'cleanups' into 'main'

apps.json cleanups:

See merge request !11
parents 4d0a9ad6 73ca334f
Branches
No related tags found
1 merge request!11apps.json cleanups:
...@@ -28,14 +28,9 @@ import ( ...@@ -28,14 +28,9 @@ import (
"github.com/pelletier/go-toml/v2" "github.com/pelletier/go-toml/v2"
) )
type appStyleFloatie struct {
Symbol string `json:"symbol"`
Color string `json:"color"`
}
type appStyle struct { type appStyle struct {
Background string `json:"background"` Background string `json:"background",omitempty`
Floaties []appStyleFloatie `json:"floaties"` Color string `json:"color",omitempty`
} }
type appPatch struct{ type appPatch struct{
...@@ -83,7 +78,7 @@ type appInfo struct { ...@@ -83,7 +78,7 @@ type appInfo struct {
targz []byte targz []byte
firstErr error firstErr error
tags []string featured bool
status *appStatus status *appStatus
style *appStyle style *appStyle
} }
...@@ -354,31 +349,17 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec ...@@ -354,31 +349,17 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec
style: nil, style: nil,
} }
if col, ok := data.Style["background"].(string); ok { style := appStyle{}
style := appStyle{ style_exists := false
Background: col, if bg_col, ok := data.Style["background"].(string); ok {
} style.Background = bg_col
if floaties, ok := data.Style["floaties"].([]interface{}); ok { style_exists = true
for x:=0; x<len(floaties); x++ {
floatie, ok := floaties[x].(map[string]interface{})
if !ok {
continue
}
col, ok := floatie["color"].(string)
if !ok {
continue
}
symbol, ok := floatie["symbol"].(string)
if !ok {
symbol = "flow3r"
}
f := appStyleFloatie{
Symbol: symbol,
Color: col,
}
style.Floaties = append(style.Floaties, f)
} }
if col, ok := data.Style["color"].(string); ok {
style.Color = col
style_exists = true
} }
if style_exists {
ret.style = &style ret.style = &style
} }
return &ret, nil return &ret, nil
...@@ -494,8 +475,6 @@ func (s *server) getAppInfo(ctx context.Context, pathInRepo, repo string, slug * ...@@ -494,8 +475,6 @@ func (s *server) getAppInfo(ctx context.Context, pathInRepo, repo string, slug *
} }
app.firstErr = firstErr app.firstErr = firstErr
app.tags = make([]string, 0)
return app, nil return app, nil
} }
...@@ -637,15 +616,11 @@ func (s *server) getAppRegistry(ctx context.Context) (*appRegistry, error) { ...@@ -637,15 +616,11 @@ func (s *server) getAppRegistry(ctx context.Context) (*appRegistry, error) {
}) })
} else if flagmap != nil { } else if flagmap != nil {
if app_flags, ok := (*flagmap)[app.repository].(map[string]interface{}); ok{ if app_flags, ok := (*flagmap)[app.repository].(map[string]interface{}); ok{
info.status = new(appStatus) if feat, ok := app_flags["featured"].(bool); ok {
if tags, ok := app_flags["tags"].([]interface{}); ok { info.featured = feat
for _, tag := range tags{
if tagtxt, ok := tag.(string); ok {
info.tags = append(info.tags, tagtxt)
}
}
} }
if status, ok := app_flags["status"].(map[string]interface{}); ok { if status, ok := app_flags["status"].(map[string]interface{}); ok {
info.status = new(appStatus)
if tested, ok := status["tested_version"].(float64); ok { if tested, ok := status["tested_version"].(float64); ok {
info.status.tested_version = int(math.Round(tested)) info.status.tested_version = int(math.Round(tested))
} }
...@@ -691,7 +666,7 @@ type jsonAppPatch struct{ ...@@ -691,7 +666,7 @@ type jsonAppPatch struct{
type jsonAppStatus struct{ type jsonAppStatus struct{
TestedVersion int `json:"tested_version"` TestedVersion int `json:"tested_version"`
Broken bool `json:"broken"` Broken bool `json:"broken"`
Patch jsonAppPatch `json:"patch"` Patch *jsonAppPatch `json:"patch",omitempty`
} }
type jsonApp struct { type jsonApp struct {
...@@ -706,11 +681,11 @@ type jsonApp struct { ...@@ -706,11 +681,11 @@ type jsonApp struct {
Version int `json:"version"` Version int `json:"version"`
Stars int `json:"stars"` Stars int `json:"stars"`
Slug string `json:"slug"` Slug string `json:"slug"`
Tags []string `json:"tags"` Featured bool `json:"featured"`
Timestamp time.Time `json:"timestamp"` Timestamp time.Time `json:"timestamp"`
Flow3rSeed string `json:"flow3rSeed"` Flow3rSeed string `json:"flow3rSeed"`
Status *jsonAppStatus `json:"status"` Status *jsonAppStatus `json:"status",omitempty`
Style *appStyle `json:"style"` Style *appStyle `json:"style",omitempty`
} }
func makeJsonApp(a *appDescriptor) jsonApp { func makeJsonApp(a *appDescriptor) jsonApp {
...@@ -727,7 +702,7 @@ func makeJsonApp(a *appDescriptor) jsonApp { ...@@ -727,7 +702,7 @@ func makeJsonApp(a *appDescriptor) jsonApp {
Timestamp: a.appInfo.commitObj.Committer.When.UTC(), Timestamp: a.appInfo.commitObj.Committer.When.UTC(),
Stars: a.appInfo.stars, Stars: a.appInfo.stars,
Flow3rSeed: a.appInfo.flow3rSeed, Flow3rSeed: a.appInfo.flow3rSeed,
Tags: a.appInfo.tags, Featured: a.appInfo.featured,
Slug: a.appInfo.slug, Slug: a.appInfo.slug,
Style: a.appInfo.style, Style: a.appInfo.style,
} }
...@@ -738,7 +713,7 @@ func makeJsonApp(a *appDescriptor) jsonApp { ...@@ -738,7 +713,7 @@ func makeJsonApp(a *appDescriptor) jsonApp {
} }
if a.appInfo.status.patch != nil{ if a.appInfo.status.patch != nil{
pa := a.appInfo.status.patch.repository pa := a.appInfo.status.patch.repository
ret.Status.Patch = jsonAppPatch{ ret.Status.Patch = &jsonAppPatch{
RepoURL: "https://git.flow3r.garden/" + pa, RepoURL: "https://git.flow3r.garden/" + pa,
DownloadURL: fmt.Sprintf("%sapps/zip/%s.zip", flagBaseURL, pa), DownloadURL: fmt.Sprintf("%sapps/zip/%s.zip", flagBaseURL, pa),
TarDownloadURL: fmt.Sprintf("%sapps/tar/%s.tar.gz", flagBaseURL, pa), TarDownloadURL: fmt.Sprintf("%sapps/tar/%s.tar.gz", flagBaseURL, pa),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment