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
|
// Render the page
|
||||||
request := NewRequestMock(page.Config.Mock)
|
request := NewRequestMock(page.Config.Mock)
|
||||||
|
|
||||||
|
// Set Default Sid
|
||||||
|
if request.Sid == "" {
|
||||||
|
request.Sid, _ = page.Sid()
|
||||||
|
}
|
||||||
|
|
||||||
// Render tools
|
// Render tools
|
||||||
// res.Scripts = append(res.Scripts, filepath.Join("@assets", "__render.js"))
|
// res.Scripts = append(res.Scripts, filepath.Join("@assets", "__render.js"))
|
||||||
// res.Styles = append(res.Styles, filepath.Join("@assets", "__render.css"))
|
// res.Styles = append(res.Styles, filepath.Join("@assets", "__render.css"))
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ type SUI interface {
|
||||||
GetTemplate(name string) (ITemplate, error)
|
GetTemplate(name string) (ITemplate, error)
|
||||||
UploadTemplate(src string, dst string) (ITemplate, error)
|
UploadTemplate(src string, dst string) (ITemplate, error)
|
||||||
WithSid(sid string)
|
WithSid(sid string)
|
||||||
|
GetSid() string
|
||||||
PublicRootMatcher() *Matcher
|
PublicRootMatcher() *Matcher
|
||||||
GetPublic() *Public
|
GetPublic() *Public
|
||||||
PublicRootWithSid(sid string) (string, error)
|
PublicRootWithSid(sid string) (string, error)
|
||||||
|
|
@ -65,6 +66,9 @@ type ITemplate interface {
|
||||||
type IPage interface {
|
type IPage interface {
|
||||||
Load() error
|
Load() error
|
||||||
|
|
||||||
|
SUI() (SUI, error)
|
||||||
|
Sid() (string, error)
|
||||||
|
|
||||||
Get() *Page
|
Get() *Page
|
||||||
GetConfig() *PageConfig
|
GetConfig() *PageConfig
|
||||||
Save(request *RequestSource) error
|
Save(request *RequestSource) error
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -14,6 +15,24 @@ func (page *Page) Get() *Page {
|
||||||
return 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
|
// GetConfig get the config
|
||||||
func (page *Page) GetConfig() *PageConfig {
|
func (page *Page) GetConfig() *PageConfig {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@ func (sui *DSL) WithSid(sid string) {
|
||||||
sui.Sid = sid
|
sui.Sid = sid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetSid returns the sid
|
||||||
|
func (sui *DSL) GetSid() string {
|
||||||
|
return sui.Sid
|
||||||
|
}
|
||||||
|
|
||||||
// PublicRootMatcher returns the public root matcher
|
// PublicRootMatcher returns the public root matcher
|
||||||
func (sui *DSL) PublicRootMatcher() *Matcher {
|
func (sui *DSL) PublicRootMatcher() *Matcher {
|
||||||
pub := sui.GetPublic()
|
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")
|
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)
|
html, err := page.Page.Compile(option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue