Skip to content

Commit

Permalink
Merge pull request #481 from trheyi/main
Browse files Browse the repository at this point in the history
[add] setting api and block layout height, keywords
  • Loading branch information
trheyi authored Oct 19, 2023
2 parents 3c9baec + a072a91 commit 05f7cee
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 5 deletions.
8 changes: 8 additions & 0 deletions sui/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ var dsl = []byte(`
"guard": "-",
"group": "__yao/sui/v1",
"paths": [
{
"path": "/:id/setting",
"method": "GET",
"process": "sui.Setting",
"in": ["$param.id"],
"out": { "status": 200, "type": "application/json" }
},
{
"path": "/:id/template",
"method": "GET",
Expand Down
12 changes: 12 additions & 0 deletions sui/api/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (

func init() {
process.RegisterGroup("sui", map[string]process.Handler{
"setting": Setting,

"template.get": TemplateGet,
"template.find": TemplateFind,
"template.asset": TemplateAsset,
Expand Down Expand Up @@ -51,6 +53,16 @@ func init() {
})
}

// Setting handle the get Template request
func Setting(process *process.Process) interface{} {
sui := get(process)
setting, err := sui.Setting()
if err != nil {
exception.New(err.Error(), 500).Throw()
}
return setting
}

// TemplateGet handle the get Template request
func TemplateGet(process *process.Process) interface{} {
process.ValidateArgNums(1)
Expand Down
1 change: 1 addition & 0 deletions sui/core/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var SUIs = map[string]SUI{}

// SUI is the interface for the SUI
type SUI interface {
Setting() (*Setting, error)
GetTemplates() ([]ITemplate, error)
GetTemplate(name string) (ITemplate, error)
UploadTemplate(src string, dst string) (ITemplate, error)
Expand Down
12 changes: 12 additions & 0 deletions sui/core/sui.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package core

// Setting the struct for the DSL
func (sui *DSL) Setting() (*Setting, error) {
return &Setting{
ID: sui.ID,
Guard: sui.Guard,
Option: map[string]interface{}{
"disableCodeEditor": false,
},
}, nil
}
18 changes: 14 additions & 4 deletions sui/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ package core
type DSL struct {
ID string `json:"-"`
Name string `json:"name,omitempty"`
Guard string `json:"guard,omitempty"`
Storage *Storage `json:"storage,omitempty"`
Public *Public `json:"public,omitempty"`
}

// Setting is the struct for the setting
type Setting struct {
ID string `json:"id,omitempty"`
Guard string `json:"guard,omitempty"`
Option map[string]interface{} `json:"option,omitempty"`
}

// Page is the struct for the page
type Page struct {
Route string `json:"route"`
Expand Down Expand Up @@ -54,10 +62,12 @@ type BlockLayoutItems struct {

// LayoutItem is the struct for the layout it
type LayoutItem struct {
ID string `json:"id"`
Label string `json:"label,omitempty"`
Width int `json:"width,omitempty"`
Blocks []LayoutItem `json:"blocks,omitempty"`
ID string `json:"id"`
Label string `json:"label,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Keywords []string `json:"keywords,omitempty"`
Blocks []LayoutItem `json:"blocks,omitempty"`
}

// Template is the struct for the template
Expand Down
5 changes: 4 additions & 1 deletion sui/storages/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
)

// Azure is the struct for the azure sui
type Azure struct{ url url.URL }
type Azure struct {
url url.URL
*core.DSL
}

// new create a new azure sui
func new() (*Azure, error) {
Expand Down

0 comments on commit 05f7cee

Please sign in to comment.