Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
API
Commits
4d0a9ad6
Commit
4d0a9ad6
authored
4 months ago
by
moon2
Browse files
Options
Downloads
Plain Diff
Merge branch 'style' into 'main'
Style See merge request
!10
parents
682c4931
7e0c4f38
Branches
Branches containing commit
No related tags found
1 merge request
!10
Style
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server_apps.go
+63
-10
63 additions, 10 deletions
server_apps.go
with
63 additions
and
10 deletions
server_apps.go
+
63
−
10
View file @
4d0a9ad6
...
...
@@ -28,7 +28,18 @@ 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"`
}
type
appPatch
struct
{
version
int
repository
string
zip
[]
byte
targz
[]
byte
...
...
@@ -62,6 +73,7 @@ type appInfo struct {
author
string
description
string
version
int
slug
string
commit
string
stars
int
flow3rSeed
string
...
...
@@ -73,6 +85,7 @@ type appInfo struct {
firstErr
error
tags
[]
string
status
*
appStatus
style
*
appStyle
}
type
GLProject
struct
{
...
...
@@ -296,6 +309,7 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec
Description
string
Version
int
}
Style
map
[
string
]
interface
{}
}
dec
:=
toml
.
NewDecoder
(
reader
)
err
=
dec
.
Decode
(
&
data
)
...
...
@@ -329,7 +343,7 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec
return
nil
,
fmt
.
Errorf
(
"metadata description too long (must be <= 140 chars)"
)
}
ret
urn
&
appInfo
{
ret
:=
appInfo
{
name
:
data
.
App
.
Name
,
author
:
data
.
Metadata
.
Author
,
menu
:
data
.
App
.
Category
,
...
...
@@ -337,7 +351,37 @@ func (s *server) parseAppToml(ctx context.Context, pathInRepo string, obj *objec
version
:
data
.
Metadata
.
Version
,
commit
:
obj
.
Hash
.
String
(),
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
)
{
...
...
@@ -438,6 +482,8 @@ func (s *server) getAppInfo(ctx context.Context, pathInRepo, repo string, slug *
}
app
.
targz
=
tbytes
app
.
slug
=
strings
.
ReplaceAll
(
slug_str
,
"/"
,
"-"
)
// Calculate an 8 digit flow3r seed which can be used to install the
// app. This is based on md5 so ambitious hack3rs can force a certain
// app seed :)
...
...
@@ -617,6 +663,7 @@ func (s *server) getAppRegistry(ctx context.Context) (*appRegistry, error) {
repository
:
patch
,
zip
:
patch_info
.
zip
,
targz
:
patch_info
.
targz
,
version
:
patch_info
.
version
,
}
}
}
...
...
@@ -635,6 +682,7 @@ func (s *server) getAppRegistry(ctx context.Context) (*appRegistry, error) {
}
type
jsonAppPatch
struct
{
Version
int
`json:"version"`
RepoURL
string
`json:"repoUrl"`
DownloadURL
string
`json:"downloadUrl"`
TarDownloadURL
string
`json:"tarDownloadUrl"`
...
...
@@ -657,10 +705,12 @@ type jsonApp struct {
Description
string
`json:"description"`
Version
int
`json:"version"`
Stars
int
`json:"stars"`
Slug
string
`json:"slug"`
Tags
[]
string
`json:"tags"`
Timestamp
time
.
Time
`json:"timestamp"`
Flow3rSeed
string
`json:"flow3rSeed"`
Status
*
jsonAppStatus
`json:"status"`
Style
*
appStyle
`json:"style"`
}
func
makeJsonApp
(
a
*
appDescriptor
)
jsonApp
{
...
...
@@ -678,6 +728,8 @@ func makeJsonApp(a *appDescriptor) jsonApp {
Stars
:
a
.
appInfo
.
stars
,
Flow3rSeed
:
a
.
appInfo
.
flow3rSeed
,
Tags
:
a
.
appInfo
.
tags
,
Slug
:
a
.
appInfo
.
slug
,
Style
:
a
.
appInfo
.
style
,
}
if
a
.
appInfo
.
status
!=
nil
{
ret
.
Status
=
&
jsonAppStatus
{
...
...
@@ -690,6 +742,7 @@ func makeJsonApp(a *appDescriptor) jsonApp {
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
),
Version
:
a
.
appInfo
.
status
.
patch
.
version
,
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment