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

apps.json: add style and patch version fields

parent 682c4931
No related branches found
No related tags found
1 merge request!10Style
...@@ -28,7 +28,18 @@ import ( ...@@ -28,7 +28,18 @@ 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 {
Background string `json:"background"`
Floaties []appStyleFloatie `json:"floaties"`
}
type appPatch struct{ type appPatch struct{
version int
repository string repository string
zip []byte zip []byte
targz []byte targz []byte
...@@ -73,6 +84,7 @@ type appInfo struct { ...@@ -73,6 +84,7 @@ type appInfo struct {
firstErr error firstErr error
tags []string tags []string
status *appStatus status *appStatus
style *appStyle
} }
type GLProject struct { type GLProject struct {
...@@ -296,6 +308,7 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec ...@@ -296,6 +308,7 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec
Description string Description string
Version int Version int
} }
Style map[string]interface{}
} }
dec := toml.NewDecoder(reader) dec := toml.NewDecoder(reader)
err = dec.Decode(&data) err = dec.Decode(&data)
...@@ -329,7 +342,7 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec ...@@ -329,7 +342,7 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec
return nil, fmt.Errorf("metadata description too long (must be <= 140 chars)") return nil, fmt.Errorf("metadata description too long (must be <= 140 chars)")
} }
return &appInfo{ ret := appInfo{
name: data.App.Name, name: data.App.Name,
author: data.Metadata.Author, author: data.Metadata.Author,
menu: data.App.Category, menu: data.App.Category,
...@@ -337,7 +350,37 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec ...@@ -337,7 +350,37 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec
version: data.Metadata.Version, version: data.Metadata.Version,
commit: obj.Hash.String(), commit: obj.Hash.String(),
commitObj: obj, commitObj: obj,
}, nil 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
}
return &ret, nil
} }
func (s *server) getAppInfo(ctx context.Context, pathInRepo, repo string, slug *string) (*appInfo, error) { func (s *server) getAppInfo(ctx context.Context, pathInRepo, repo string, slug *string) (*appInfo, error) {
...@@ -617,6 +660,7 @@ func (s *server) getAppRegistry(ctx context.Context) (*appRegistry, error) { ...@@ -617,6 +660,7 @@ func (s *server) getAppRegistry(ctx context.Context) (*appRegistry, error) {
repository: patch, repository: patch,
zip: patch_info.zip, zip: patch_info.zip,
targz: patch_info.targz, targz: patch_info.targz,
version: patch_info.version,
} }
} }
} }
...@@ -635,6 +679,7 @@ func (s *server) getAppRegistry(ctx context.Context) (*appRegistry, error) { ...@@ -635,6 +679,7 @@ func (s *server) getAppRegistry(ctx context.Context) (*appRegistry, error) {
} }
type jsonAppPatch struct{ type jsonAppPatch struct{
Version int `json:"version"`
RepoURL string `json:"repoUrl"` RepoURL string `json:"repoUrl"`
DownloadURL string `json:"downloadUrl"` DownloadURL string `json:"downloadUrl"`
TarDownloadURL string `json:"tarDownloadUrl"` TarDownloadURL string `json:"tarDownloadUrl"`
...@@ -661,6 +706,7 @@ type jsonApp struct { ...@@ -661,6 +706,7 @@ type jsonApp struct {
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"`
Style *appStyle `json:"style"`
} }
func makeJsonApp(a *appDescriptor) jsonApp { func makeJsonApp(a *appDescriptor) jsonApp {
...@@ -678,6 +724,7 @@ func makeJsonApp(a *appDescriptor) jsonApp { ...@@ -678,6 +724,7 @@ func makeJsonApp(a *appDescriptor) jsonApp {
Stars: a.appInfo.stars, Stars: a.appInfo.stars,
Flow3rSeed: a.appInfo.flow3rSeed, Flow3rSeed: a.appInfo.flow3rSeed,
Tags: a.appInfo.tags, Tags: a.appInfo.tags,
Style: a.appInfo.style,
} }
if a.appInfo.status != nil{ if a.appInfo.status != nil{
ret.Status = &jsonAppStatus{ ret.Status = &jsonAppStatus{
...@@ -690,6 +737,7 @@ func makeJsonApp(a *appDescriptor) jsonApp { ...@@ -690,6 +737,7 @@ func makeJsonApp(a *appDescriptor) jsonApp {
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),
Version: a.appInfo.status.patch.version,
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment