Merge pull request #481 from trheyi/main

[add] setting api and block layout height, keywords
This commit is contained in:
Max 2023-10-19 05:58:21 -05:00 committed by GitHub
commit 05f7cee40f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 5 deletions

View file

@ -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",

View file

@ -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,
@ -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)

View file

@ -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)

12
sui/core/sui.go Normal file
View file

@ -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
}

View file

@ -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"`
@ -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

View file

@ -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) {