diff --git a/server_apps.go b/server_apps.go index ddedd333bb490ec602857af0b406ca8b8617658d..9f5f0a6d1a1aff765fe70c6c07da71d577ab684d 100644 --- a/server_apps.go +++ b/server_apps.go @@ -28,14 +28,9 @@ import ( "github.com/pelletier/go-toml/v2" ) -type appStyleFloatie struct { - Symbol string `json:"symbol"` - Color string `json:"color"` -} - type appStyle struct { - Background string `json:"background"` - Floaties []appStyleFloatie `json:"floaties"` + Background string `json:"background",omitempty` + Color string `json:"color",omitempty` } type appPatch struct{ @@ -83,7 +78,7 @@ type appInfo struct { targz []byte firstErr error - tags []string + featured bool status *appStatus style *appStyle } @@ -354,33 +349,19 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec style: nil, } - if col, ok := data.Style["background"].(string); ok { - style := appStyle{ - Background: col, - } - if floaties, ok := data.Style["floaties"].([]interface{}); ok { - 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) - } - } - ret.style = &style - } + style := appStyle{} + style_exists := false + if bg_col, ok := data.Style["background"].(string); ok { + style.Background = bg_col + style_exists = true + } + if col, ok := data.Style["color"].(string); ok { + style.Color = col + style_exists = true + } + if style_exists { + ret.style = &style + } return &ret, nil } @@ -494,8 +475,6 @@ func (s *server) getAppInfo(ctx context.Context, pathInRepo, repo string, slug * } app.firstErr = firstErr - - app.tags = make([]string, 0) return app, nil } @@ -637,15 +616,11 @@ func (s *server) getAppRegistry(ctx context.Context) (*appRegistry, error) { }) } else if flagmap != nil { if app_flags, ok := (*flagmap)[app.repository].(map[string]interface{}); ok{ - info.status = new(appStatus) - if tags, ok := app_flags["tags"].([]interface{}); ok { - for _, tag := range tags{ - if tagtxt, ok := tag.(string); ok { - info.tags = append(info.tags, tagtxt) - } - } + if feat, ok := app_flags["featured"].(bool); ok { + info.featured = feat } if status, ok := app_flags["status"].(map[string]interface{}); ok { + info.status = new(appStatus) if tested, ok := status["tested_version"].(float64); ok { info.status.tested_version = int(math.Round(tested)) } @@ -691,7 +666,7 @@ type jsonAppPatch struct{ type jsonAppStatus struct{ TestedVersion int `json:"tested_version"` Broken bool `json:"broken"` - Patch jsonAppPatch `json:"patch"` + Patch *jsonAppPatch `json:"patch",omitempty` } type jsonApp struct { @@ -706,11 +681,11 @@ type jsonApp struct { Version int `json:"version"` Stars int `json:"stars"` Slug string `json:"slug"` - Tags []string `json:"tags"` + Featured bool `json:"featured"` Timestamp time.Time `json:"timestamp"` Flow3rSeed string `json:"flow3rSeed"` - Status *jsonAppStatus `json:"status"` - Style *appStyle `json:"style"` + Status *jsonAppStatus `json:"status",omitempty` + Style *appStyle `json:"style",omitempty` } func makeJsonApp(a *appDescriptor) jsonApp { @@ -727,7 +702,7 @@ func makeJsonApp(a *appDescriptor) jsonApp { Timestamp: a.appInfo.commitObj.Committer.When.UTC(), Stars: a.appInfo.stars, Flow3rSeed: a.appInfo.flow3rSeed, - Tags: a.appInfo.tags, + Featured: a.appInfo.featured, Slug: a.appInfo.slug, Style: a.appInfo.style, } @@ -738,7 +713,7 @@ func makeJsonApp(a *appDescriptor) jsonApp { } if a.appInfo.status.patch != nil{ pa := a.appInfo.status.patch.repository - ret.Status.Patch = jsonAppPatch{ + ret.Status.Patch = &jsonAppPatch{ RepoURL: "https://git.flow3r.garden/" + pa, DownloadURL: fmt.Sprintf("%sapps/zip/%s.zip", flagBaseURL, pa), TarDownloadURL: fmt.Sprintf("%sapps/tar/%s.tar.gz", flagBaseURL, pa),