forked from x/ContextOS
add some
This commit is contained in:
parent
148e8a3846
commit
0e44340ceb
@ -1,4 +1,6 @@
|
|||||||
# 应用配置
|
# 应用配置
|
||||||
|
~chat
|
||||||
|
config save var/tmp/share.json share
|
||||||
~wiki
|
~wiki
|
||||||
config save var/tmp/story.json story
|
config save var/tmp/story.json story
|
||||||
~code
|
~code
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
~ssh
|
~ssh
|
||||||
config load data/work.json work
|
config load data/work.json work
|
||||||
config load data/flow.json flow
|
config load data/flow.json flow
|
||||||
|
|
||||||
# 服务配置
|
# 服务配置
|
||||||
~nfs
|
~nfs
|
||||||
source etc/common.shy
|
source etc/common.shy
|
||||||
@ -23,9 +22,12 @@
|
|||||||
config load tmp/vim/vim.json vim
|
config load tmp/vim/vim.json vim
|
||||||
~wiki
|
~wiki
|
||||||
config load tmp/story.json story
|
config load tmp/story.json story
|
||||||
|
~chat
|
||||||
|
config load tmp/share.json share
|
||||||
|
|
||||||
# 终端配置
|
# 终端配置
|
||||||
~cli
|
~cli
|
||||||
|
|
||||||
~wiki
|
|
||||||
~code
|
~code
|
||||||
|
~wiki
|
||||||
|
~chat
|
||||||
|
@ -506,6 +506,9 @@ func (m *Message) ToHTML(style string) string {
|
|||||||
|
|
||||||
func (m *Message) Grow(key string, args interface{}, data interface{}) interface{} {
|
func (m *Message) Grow(key string, args interface{}, data interface{}) interface{} {
|
||||||
cache := m.Confm(key, args)
|
cache := m.Confm(key, args)
|
||||||
|
if args == nil {
|
||||||
|
cache = m.Confm(key)
|
||||||
|
}
|
||||||
if cache == nil {
|
if cache == nil {
|
||||||
cache = map[string]interface{}{}
|
cache = map[string]interface{}{}
|
||||||
}
|
}
|
||||||
@ -579,11 +582,18 @@ func (m *Message) Grow(key string, args interface{}, data interface{}) interface
|
|||||||
}
|
}
|
||||||
cache["meta"] = meta
|
cache["meta"] = meta
|
||||||
cache["list"] = list
|
cache["list"] = list
|
||||||
m.Conf(key, args, cache)
|
if args == nil {
|
||||||
|
m.Conf(key, cache)
|
||||||
|
} else {
|
||||||
|
m.Conf(key, args, cache)
|
||||||
|
}
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
func (m *Message) Grows(key string, args interface{}, cb interface{}) map[string]interface{} {
|
func (m *Message) Grows(key string, args interface{}, cb interface{}) map[string]interface{} {
|
||||||
cache := m.Confm(key, args)
|
cache := m.Confm(key, args)
|
||||||
|
if args == nil {
|
||||||
|
cache = m.Confm(key)
|
||||||
|
}
|
||||||
if cache == nil {
|
if cache == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -967,11 +967,6 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
|
|
||||||
kind := h.Header.Get("Content-Type")
|
kind := h.Header.Get("Content-Type")
|
||||||
kind = strings.Split(kind, "/")[0]
|
kind = strings.Split(kind, "/")[0]
|
||||||
if m.Options("river") {
|
|
||||||
prefix := []string{"ssh._route", m.Option("dream"), "ssh.data", "insert"}
|
|
||||||
m.Cmd(prefix, kit.Select(kind, m.Option("table")), "name", h.Filename, "kind", kind, "hash", name, "size", n)
|
|
||||||
m.Cmd(prefix, "file", "name", h.Filename, "kind", kind, "hash", name, "size", n)
|
|
||||||
}
|
|
||||||
|
|
||||||
buf := bytes.NewBuffer(make([]byte, 0, 1024))
|
buf := bytes.NewBuffer(make([]byte, 0, 1024))
|
||||||
fmt.Fprintf(buf, "create_time: %s\n", m.Time("2006-01-02 15:04"))
|
fmt.Fprintf(buf, "create_time: %s\n", m.Time("2006-01-02 15:04"))
|
||||||
@ -983,6 +978,12 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
b := buf.Bytes()
|
b := buf.Bytes()
|
||||||
|
|
||||||
code := kit.Hashs(string(b))
|
code := kit.Hashs(string(b))
|
||||||
|
if m.Options("river") {
|
||||||
|
prefix := []string{"ssh._route", m.Option("dream"), "ssh.data", "insert"}
|
||||||
|
m.Cmd(prefix, kit.Select(kind, m.Option("table")), "name", h.Filename, "kind", kind, "hash", name, "size", n)
|
||||||
|
m.Cmd(prefix, "file", "name", h.Filename, "kind", kind, "hash", name, "size", n, "code", code)
|
||||||
|
}
|
||||||
|
|
||||||
if o, p, e := kit.Create(path.Join(m.Conf("web.upload", "path"), "meta", code)); m.Assert(e) {
|
if o, p, e := kit.Create(path.Join(m.Conf("web.upload", "path"), "meta", code)); m.Assert(e) {
|
||||||
defer o.Close()
|
defer o.Close()
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"contexts/web"
|
"contexts/web"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"toolkit"
|
"toolkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -97,6 +98,15 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, Help: "组件列表"},
|
}, Help: "组件列表"},
|
||||||
|
"share": &ctx.Config{Name: "share", Value: map[string]interface{}{
|
||||||
|
"meta": map[string]interface{}{
|
||||||
|
"fields": "id time share type code remote_ip",
|
||||||
|
"store": "var/tmp/share.csv",
|
||||||
|
"limit": 30, "least": 10,
|
||||||
|
},
|
||||||
|
"hash": map[string]interface{}{},
|
||||||
|
"list": []interface{}{},
|
||||||
|
}, Help: "共享链接"},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
"login": &ctx.Command{Name: "login [username password]", Help: "登录", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"login": &ctx.Command{Name: "login [username password]", Help: "登录", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
@ -462,6 +472,49 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
"/share/": &ctx.Command{Name: "/share/", Help: "共享链接", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
h := strings.TrimPrefix(key, "/share/")
|
||||||
|
m.Confm("share", []string{"hash", h}, func(value map[string]interface{}) {
|
||||||
|
switch kit.Format(value["type"]) {
|
||||||
|
case "file":
|
||||||
|
m.Cmdy("/download/" + h)
|
||||||
|
case "wiki":
|
||||||
|
m.Cmdy("web.wiki.note", kit.Format(value["code"]))
|
||||||
|
}
|
||||||
|
m.Grow("share", nil, map[string]interface{}{
|
||||||
|
"time": m.Time(),
|
||||||
|
"share": h,
|
||||||
|
"type": value["type"],
|
||||||
|
"code": value["code"],
|
||||||
|
"sid": m.Option("sid"),
|
||||||
|
"agent": m.Option("agent"),
|
||||||
|
"sessid": m.Option("sessid"),
|
||||||
|
"username": m.Option("username"),
|
||||||
|
"remote_ip": m.Option("remote_ip"),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}},
|
||||||
|
"share": &ctx.Command{Name: "share type code", Help: "共享链接", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
if len(arg) == 0 {
|
||||||
|
fields := strings.Split(m.Conf("share", "meta.fields"), " ")
|
||||||
|
m.Grows("share", nil, func(meta map[string]interface{}, index int, value map[string]interface{}) {
|
||||||
|
m.Push(fields, value)
|
||||||
|
})
|
||||||
|
m.Table()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h := kit.Hashs("uniq")
|
||||||
|
m.Confv("share", []string{"hash", h}, map[string]interface{}{
|
||||||
|
"from": m.Option("username"),
|
||||||
|
"time": m.Time(),
|
||||||
|
"type": arg[0],
|
||||||
|
"code": arg[1],
|
||||||
|
})
|
||||||
|
m.Echo(h)
|
||||||
|
return
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,10 +346,11 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
// 文件列表
|
// 文件列表
|
||||||
m.Cmd("ssh.data", "show", arg[1]).Table(func(index int, value map[string]string) {
|
m.Cmd("ssh.data", "show", arg[1]).Table(func(index int, value map[string]string) {
|
||||||
m.Push("id", value["id"])
|
m.Push("id", value["id"])
|
||||||
|
m.Push("time", value["create_time"])
|
||||||
m.Push("kind", value["kind"])
|
m.Push("kind", value["kind"])
|
||||||
m.Push("name", value["name"])
|
m.Push("name", value["name"])
|
||||||
m.Push("size", kit.FmtSize(int64(kit.Int(value["size"]))))
|
m.Push("size", kit.FmtSize(int64(kit.Int(value["size"]))))
|
||||||
m.Push("file", fmt.Sprintf(`<a href="/download/%s" target="_blank">%s</a>`, value["hash"], value["name"]))
|
m.Push("file", fmt.Sprintf(`<a href="/download/%s" target="_blank">%s</a>`, kit.Select(value["hash"], value["code"]), value["name"]))
|
||||||
m.Push("hash", value["hash"])
|
m.Push("hash", value["hash"])
|
||||||
})
|
})
|
||||||
m.Table()
|
m.Table()
|
||||||
|
@ -64,7 +64,6 @@ var page = Page({
|
|||||||
page.action.Action["最大"](event)
|
page.action.Action["最大"](event)
|
||||||
|
|
||||||
}
|
}
|
||||||
break
|
|
||||||
} else {
|
} else {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case " ":
|
case " ":
|
||||||
@ -75,7 +74,6 @@ var page = Page({
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Action: {
|
Action: {
|
||||||
|
@ -139,7 +139,7 @@ function Page(page) {
|
|||||||
// Event入口 0
|
// Event入口 0
|
||||||
if (page.Event(event, {}) && page.check && !ctx.Cookie("sessid")) {
|
if (page.Event(event, {}) && page.check && !ctx.Cookie("sessid")) {
|
||||||
// 用户登录
|
// 用户登录
|
||||||
document.querySelectorAll("body>fieldset.Login").forEach(function(field) {
|
kit.Selector(document, "body>fieldset.Login", function(field) {
|
||||||
page.Pane(page, field)
|
page.Pane(page, field)
|
||||||
}), page.login.Pane.Dialog(1, 1)
|
}), page.login.Pane.Dialog(1, 1)
|
||||||
} else {
|
} else {
|
||||||
@ -1479,7 +1479,7 @@ function Output(plugin, type, msg, cb, target, option) {
|
|||||||
onimport: shy("导入数据", {
|
onimport: shy("导入数据", {
|
||||||
_table: function(msg, list) {
|
_table: function(msg, list) {
|
||||||
return list && list.length > 0 && kit.OrderTable(kit.AppendTable(kit.AppendChild(target, "table"), msg.Table(), list), "", output.onexport, function(event, value, name, line, index) {
|
return list && list.length > 0 && kit.OrderTable(kit.AppendTable(kit.AppendChild(target, "table"), msg.Table(), list), "", output.onexport, function(event, value, name, line, index) {
|
||||||
var td = event.target
|
var td = event.target;
|
||||||
plugin.oncarte(event, shy("菜单列表", {
|
plugin.oncarte(event, shy("菜单列表", {
|
||||||
"修改": "modify",
|
"修改": "modify",
|
||||||
"删除": "delete",
|
"删除": "delete",
|
||||||
@ -1528,7 +1528,7 @@ function Output(plugin, type, msg, cb, target, option) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -262,7 +262,7 @@ kit = toolkit = (function() {var kit = {__proto__: document,
|
|||||||
child.list && kit.AppendChild(node, child.list, subs)
|
child.list && kit.AppendChild(node, child.list, subs)
|
||||||
subs.first || (subs.first = node), subs.last = node
|
subs.first || (subs.first = node), subs.last = node
|
||||||
name && (subs[name] = node)
|
name && (subs[name] = node)
|
||||||
parent.append(node)
|
parent && parent.append && parent.append(node)
|
||||||
})
|
})
|
||||||
return subs
|
return subs
|
||||||
},
|
},
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<link rel="shortcut icon" type="image/ico" href="/static/librarys/{{options . "favicon"}}">
|
<link rel="shortcut icon" type="image/ico" href="/static/librarys/{{options . "favicon"}}">
|
||||||
{{range $index, $lib := option . "styles"}}
|
{{range $index, $lib := option . "styles"}}
|
||||||
<link rel="stylesheet" type="text/css" href="/static/librarys/{{$lib}}"></link>
|
<link rel="stylesheet" type="text/css" href="/static/librarys/{{$lib}}">
|
||||||
{{end}}
|
{{end}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
{{define "fieldset"}}
|
{{define "fieldset"}}
|
||||||
<fieldset class="{{options . "view"}}" data-init="{{options . "init"}}">
|
<fieldset class="{{options . "view"}}" data-init="{{options . "init"}}">
|
||||||
<form class="option" data-names="{{options . "name"}}" data-group="{{options . "group"}}">
|
<form class="option" data-names="{{options . "name"}}" data-group="{{options . "group"}}">
|
||||||
<input style="display:none"></input>
|
<input style="display:none">
|
||||||
</form>
|
</form>
|
||||||
<div class="action"></div>
|
<div class="action"></div>
|
||||||
<div class="output"></div>
|
<div class="output"></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user