From f4e9c04228e6b5a8c84a73da077b179dc33b6a24 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 29 Sep 2019 18:45:20 +0800 Subject: [PATCH] add web.serve.open --- src/contexts/cli/version.go | 2 +- src/contexts/ctx/cgi.go | 16 ++++++++++++++++ src/contexts/web/web.go | 1 + usr/template/common.tmpl | 4 +++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index b1598c19..608a15d4 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -7,5 +7,5 @@ var version = struct { self int }{ []string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"}, - `2019-09-29 17:30:47`, `centos`, 612, + `2019-09-29 18:40:19`, `centos`, 617, } diff --git a/src/contexts/ctx/cgi.go b/src/contexts/ctx/cgi.go index 4d6d7988..ee5ddb60 100644 --- a/src/contexts/ctx/cgi.go +++ b/src/contexts/ctx/cgi.go @@ -2,6 +2,7 @@ package ctx import ( "html/template" + "io" "path" "strings" @@ -74,6 +75,21 @@ func index(name string, arg ...interface{}) interface{} { } var CGI = template.FuncMap{ + "conf": func(arg ...interface{}) interface{} { + switch m := arg[0].(type) { + case *Message: + switch c := arg[1].(type) { + case string: + if len(arg) == 2 { + return m.Confv(c) + } + if len(arg) == 3 { + return m.Confv(c, arg[2]) + } + } + } + return nil + }, "option": func(arg ...interface{}) interface{} { return index("option", arg...) }, diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index ead219fe..93a89fc4 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -404,6 +404,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", "key": "etc/key.pem", "site": "", "index": "/chat/", + "open": []interface{}{}, }, Help: "服务配置"}, "route": &ctx.Config{Name: "route", Value: map[string]interface{}{ "index": "/render", diff --git a/usr/template/common.tmpl b/usr/template/common.tmpl index 8dbf5654..4136b86e 100644 --- a/usr/template/common.tmpl +++ b/usr/template/common.tmpl @@ -30,7 +30,9 @@ {{range $index, $lib := option . "scripts"}} {{end}} - + {{range $index, $lib := conf . "serve" "open"}} + + {{end}} {{end}}