Merge pull request #509 from trheyi/main
[add] sui page build Add default Sid if not set
This commit is contained in:
commit
03f63b7edd
5 changed files with 34 additions and 0 deletions
|
|
@ -35,6 +35,11 @@ func (page *Page) EditorRender() (*ResponseEditorRender, error) {
|
|||
// Render the page
|
||||
request := NewRequestMock(page.Config.Mock)
|
||||
|
||||
// Set Default Sid
|
||||
if request.Sid == "" {
|
||||
request.Sid, _ = page.Sid()
|
||||
}
|
||||
|
||||
// Render tools
|
||||
// res.Scripts = append(res.Scripts, filepath.Join("@assets", "__render.js"))
|
||||
// res.Styles = append(res.Styles, filepath.Join("@assets", "__render.css"))
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ type SUI interface {
|
|||
GetTemplate(name string) (ITemplate, error)
|
||||
UploadTemplate(src string, dst string) (ITemplate, error)
|
||||
WithSid(sid string)
|
||||
GetSid() string
|
||||
PublicRootMatcher() *Matcher
|
||||
GetPublic() *Public
|
||||
PublicRootWithSid(sid string) (string, error)
|
||||
|
|
@ -65,6 +66,9 @@ type ITemplate interface {
|
|||
type IPage interface {
|
||||
Load() error
|
||||
|
||||
SUI() (SUI, error)
|
||||
Sid() (string, error)
|
||||
|
||||
Get() *Page
|
||||
GetConfig() *PageConfig
|
||||
Save(request *RequestSource) error
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
|
@ -14,6 +15,24 @@ func (page *Page) Get() *Page {
|
|||
return page
|
||||
}
|
||||
|
||||
// SUI get the sui
|
||||
func (page *Page) SUI() (SUI, error) {
|
||||
sui, has := SUIs[page.SuiID]
|
||||
if !has {
|
||||
return nil, fmt.Errorf("[sui] get page sui %s not found", page.SuiID)
|
||||
}
|
||||
return sui, nil
|
||||
}
|
||||
|
||||
// Sid get the sid
|
||||
func (page *Page) Sid() (string, error) {
|
||||
sui, err := page.SUI()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return sui.GetSid(), nil
|
||||
}
|
||||
|
||||
// GetConfig get the config
|
||||
func (page *Page) GetConfig() *PageConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ func (sui *DSL) WithSid(sid string) {
|
|||
sui.Sid = sid
|
||||
}
|
||||
|
||||
// GetSid returns the sid
|
||||
func (sui *DSL) GetSid() string {
|
||||
return sui.Sid
|
||||
}
|
||||
|
||||
// PublicRootMatcher returns the public root matcher
|
||||
func (sui *DSL) PublicRootMatcher() *Matcher {
|
||||
pub := sui.GetPublic()
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ func (page *Page) Build(option *core.BuildOption) error {
|
|||
option.AssetRoot = filepath.Join(page.tmpl.local.DSL.Public.Root, "assets")
|
||||
}
|
||||
|
||||
log.Trace("Build the page %s AssetRoot: %s", page.Route, option.AssetRoot)
|
||||
html, err := page.Page.Compile(option)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue