mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 17:24:05 +08:00
tce add web.library
This commit is contained in:
parent
419c5487f5
commit
fa8bf1607a
@ -575,9 +575,6 @@ func (m *Message) Assert(e interface{}, msg ...string) bool { // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Log("error", "%s", fmt.Sprintln(e))
|
m.Log("error", "%s", fmt.Sprintln(e))
|
||||||
if m.Confs("debug") {
|
|
||||||
debug.PrintStack()
|
|
||||||
}
|
|
||||||
panic(m.Set("result", "error: ", fmt.Sprintln(e), "\n"))
|
panic(m.Set("result", "error: ", fmt.Sprintln(e), "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +215,7 @@ func (web *WEB) Start(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
web.Configs["library_dir"] = &ctx.Config{Name: "library_dir", Value: "usr", Help: "通用模板路径"}
|
||||||
web.Configs["template_dir"] = &ctx.Config{Name: "template_dir", Value: "usr/template/", Help: "通用模板路径"}
|
web.Configs["template_dir"] = &ctx.Config{Name: "template_dir", Value: "usr/template/", Help: "通用模板路径"}
|
||||||
web.Configs["common_tmpl"] = &ctx.Config{Name: "common_tmpl", Value: "common/*.html", Help: "通用模板路径"}
|
web.Configs["common_tmpl"] = &ctx.Config{Name: "common_tmpl", Value: "common/*.html", Help: "通用模板路径"}
|
||||||
web.Configs["common_main"] = &ctx.Config{Name: "common_main", Value: "main.html", Help: "通用模板框架"}
|
web.Configs["common_main"] = &ctx.Config{Name: "common_main", Value: "main.html", Help: "通用模板框架"}
|
||||||
@ -272,7 +273,8 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
"nroute": &ctx.Cache{Name: "nroute", Value: "0", Help: "路由数量"},
|
"nroute": &ctx.Cache{Name: "nroute", Value: "0", Help: "路由数量"},
|
||||||
},
|
},
|
||||||
Configs: map[string]*ctx.Config{
|
Configs: map[string]*ctx.Config{
|
||||||
"cmd": &ctx.Config{Name: "cmd", Value: "tmux", Help: "路由数量"},
|
"cmd": &ctx.Config{Name: "cmd", Value: "tmux", Help: "路由数量"},
|
||||||
|
"check_right": &ctx.Config{Name: "check_right(true/false)", Value: "false", Help: "路由数量"},
|
||||||
"check": &ctx.Config{Name: "check", Value: map[string]interface{}{
|
"check": &ctx.Config{Name: "check", Value: map[string]interface{}{
|
||||||
"login": []interface{}{
|
"login": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
@ -633,12 +635,21 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
m.Copy(msg, "result")
|
m.Copy(msg, "result")
|
||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
|
"/library/": &ctx.Command{Name: "/library", Help: "网页门户", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
|
r := m.Optionv("request").(*http.Request)
|
||||||
|
w := m.Optionv("response").(http.ResponseWriter)
|
||||||
|
dir := path.Join(m.Conf("library_dir"), m.Option("path"))
|
||||||
|
if s, e := os.Stat(dir); e == nil && !s.IsDir() {
|
||||||
|
http.ServeFile(w, r, dir)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}},
|
||||||
"/index/": &ctx.Command{Name: "/index", Help: "网页门户", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"/index/": &ctx.Command{Name: "/index", Help: "网页门户", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
r := m.Optionv("request").(*http.Request) // {{{
|
r := m.Optionv("request").(*http.Request) // {{{
|
||||||
w := m.Optionv("response").(http.ResponseWriter)
|
w := m.Optionv("response").(http.ResponseWriter)
|
||||||
|
|
||||||
//权限检查
|
//权限检查
|
||||||
dir := path.Join(m.Cap("directory"), m.Option("dir", strings.TrimPrefix(m.Option("path"), "/index")))
|
dir := m.Option("dir", path.Join(m.Cap("directory"), m.Option("dir", strings.TrimPrefix(m.Option("path"), "/index"))))
|
||||||
if check := m.Spawn(c).Cmd("/check", "command", "/index/", "dir", dir); !check.Results(0) {
|
if check := m.Spawn(c).Cmd("/check", "command", "/index/", "dir", dir); !check.Results(0) {
|
||||||
m.Copy(check, "append")
|
m.Copy(check, "append")
|
||||||
return
|
return
|
||||||
@ -646,9 +657,11 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
|
|
||||||
//执行命令
|
//执行命令
|
||||||
if m.Has("details") {
|
if m.Has("details") {
|
||||||
if check := m.Spawn().Cmd("/check", "target", m.Option("module"), "command", m.Option("details")); !check.Results(0) {
|
if m.Confs("check_right") {
|
||||||
m.Copy(check, "append")
|
if check := m.Spawn().Cmd("/check", "target", m.Option("module"), "command", m.Option("details")); !check.Results(0) {
|
||||||
return
|
m.Copy(check, "append")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := m.Find(m.Option("module")).Cmd(m.Option("details"))
|
msg := m.Find(m.Option("module")).Cmd(m.Option("details"))
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
{{define "share"}}
|
{{define "share"}}
|
||||||
<fieldset><legend>share</legend>
|
<fieldset><legend>share</legend>
|
||||||
<form method="POST" onsubmit="return share(event, '{{cap . "directory"}}{{option . "dir"|meta}}')">
|
<form method="POST" onsubmit="return share(event, '{{option . "dir"|meta}}')">
|
||||||
<label>share to:</label><input type="text" name="shareto" required>
|
<label>share to:</label><input type="text" name="shareto" required>
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user