forked from x/icebergs
add image
This commit is contained in:
parent
1c9b74c2b9
commit
5d6a489bd4
@ -264,7 +264,7 @@ func _story_catch(m *ice.Message, arg ...string) {
|
||||
_story_add(m, arg...)
|
||||
}
|
||||
func _story_add(m *ice.Message, arg ...string) {
|
||||
if m.Richs(ice.WEB_CACHE, nil, kit.Select("", arg, 3), func(key string, value map[string]interface{}) {
|
||||
if arg[3] == "" || m.Richs(ice.WEB_CACHE, nil, arg[3], func(key string, value map[string]interface{}) {
|
||||
// 复用缓存
|
||||
arg[3] = key
|
||||
}) == nil {
|
||||
@ -277,18 +277,19 @@ func _story_add(m *ice.Message, arg ...string) {
|
||||
head, prev, value, count := "", "", map[string]interface{}{}, 0
|
||||
m.Richs(ice.WEB_STORY, "head", arg[2], func(key string, val map[string]interface{}) {
|
||||
head, prev, value, count = key, kit.Format(val["list"]), val, kit.Int(val["count"])
|
||||
m.Log("info", "head: %v prev: %v count: %v", head, prev, count)
|
||||
m.Logs("info", "head", head, "prev", prev, "count", count)
|
||||
})
|
||||
|
||||
if last := m.Richs(ice.WEB_STORY, nil, prev, nil); prev != "" && last != nil && last["data"] == arg[3] {
|
||||
// 重复提交
|
||||
m.Logs("info", "file", "exists")
|
||||
m.Echo(prev)
|
||||
} else {
|
||||
// 添加节点
|
||||
list := m.Rich(ice.WEB_STORY, nil, kit.Dict(
|
||||
"scene", arg[1], "story", arg[2], "count", count+1, "data", arg[3], "prev", prev,
|
||||
))
|
||||
m.Log(ice.LOG_CREATE, "story: %s %s: %s", list, arg[1], arg[2])
|
||||
m.Log_CREATE("story", list, "type", arg[1], "name", arg[2])
|
||||
m.Push("list", list)
|
||||
|
||||
if head == "" {
|
||||
@ -328,8 +329,10 @@ func _story_index(m *ice.Message, name string) {
|
||||
// 查询数据
|
||||
m.Push("data", key)
|
||||
m.Push(key, value, []string{"text", "time", "size", "type", "name", "file"})
|
||||
if value["file"] != "" {
|
||||
if kit.Format(value["file"]) != "" {
|
||||
m.Echo("%s", m.Cmdx("nfs.cat", value["file"]))
|
||||
} else {
|
||||
m.Echo("%s", kit.Format(value["text"]))
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -367,7 +370,10 @@ func StoryIndex(m *ice.Message, name string) { _story_index(m, nam
|
||||
func StoryHistory(m *ice.Message, name string) { _story_history(m, name) }
|
||||
func StoryWatch(m *ice.Message, index string, file string) { _story_watch(m, index, file) }
|
||||
func StoryCatch(m *ice.Message, mime string, file string) {
|
||||
_story_catch(m, "catch", kit.Select(mime, strings.TrimPrefix(path.Ext(file), ".")), file)
|
||||
_story_catch(m, "catch", kit.Select(mime, strings.TrimPrefix(path.Ext(file), ".")), file, "")
|
||||
}
|
||||
func StoryAdd(m *ice.Message, mime string, name string, text string, arg ...string) {
|
||||
_story_add(m, kit.Simple("add", mime, name, text, arg)...)
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
22
core/wiki/image.go
Normal file
22
core/wiki/image.go
Normal file
@ -0,0 +1,22 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
Index.Register(&ice.Context{Name: "jpg", Help: "图片",
|
||||
Configs: map[string]*ice.Config{},
|
||||
Commands: map[string]*ice.Command{
|
||||
"list": {Name: "list name", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Echo(arg[0])
|
||||
}},
|
||||
"save": {Name: "save name text", Help: "保存", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
}},
|
||||
"show": {Name: "show name", Help: "渲染", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
|
||||
}
|
@ -15,7 +15,7 @@ const QRCODE = "qrcode"
|
||||
const VEDIO = "vedio"
|
||||
|
||||
func _inner_ext(name string) string {
|
||||
return kit.Select(path.Base(name), strings.TrimPrefix(path.Ext(name), "."))
|
||||
return strings.ToLower(kit.Select(path.Base(name), strings.TrimPrefix(path.Ext(name), ".")))
|
||||
}
|
||||
func _inner_binary(m *ice.Message, name string) bool {
|
||||
p := _inner_ext(name)
|
||||
@ -107,6 +107,13 @@ func _inner_show(m *ice.Message, name string) {
|
||||
m.Echo(strings.ReplaceAll(strings.Join(m.Cmd("web.wiki.word", name).Resultv(), ""), "\n", " "))
|
||||
}
|
||||
}
|
||||
func _inner_main(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 2 && arg[2] != "" {
|
||||
web.StoryIndex(m, arg[2])
|
||||
return
|
||||
}
|
||||
_inner_list(m, path.Join(arg...))
|
||||
}
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
@ -133,14 +140,27 @@ func init() {
|
||||
"display": "/plugin/inner.js", "style": "editor",
|
||||
}, Action: map[string]*ice.Action{
|
||||
"history": {Name: "history path name", Help: "历史", Hand: func(m *ice.Message, arg ...string) {
|
||||
web.StoryHistory(m, path.Join("./", arg[0], arg[1]))
|
||||
if len(arg) > 2 && arg[2] != "" {
|
||||
m.Echo(m.Cmdx(ice.WEB_STORY, "index", arg[2]))
|
||||
}
|
||||
msg := m.Spawn()
|
||||
web.StoryHistory(msg, path.Join("./", arg[0], arg[1]))
|
||||
m.Copy(msg, ice.MSG_APPEND, "time", "key", "count", "data")
|
||||
msg = m.Spawn()
|
||||
_inner_main(msg, arg...)
|
||||
m.Echo(msg.Result())
|
||||
}},
|
||||
"commit": {Name: "commit path name", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||
web.StoryCatch(m, "", path.Join("./", arg[0], arg[1]))
|
||||
}},
|
||||
"record": {Name: "record", Help: "记录", Hand: func(m *ice.Message, arg ...string) {
|
||||
web.StoryAdd(m, "display", path.Join("./", m.Option("path"), m.Option("name"))+".display", m.Option("display"))
|
||||
}},
|
||||
"recover": {Name: "recover", Help: "复盘", Hand: func(m *ice.Message, arg ...string) {
|
||||
msg := m.Spawn()
|
||||
web.StoryHistory(msg, path.Join("./", arg[0], arg[1])+".display")
|
||||
m.Copy(msg, ice.MSG_APPEND, "time", "key", "count", "drama")
|
||||
msg = m.Spawn()
|
||||
_inner_main(msg, arg...)
|
||||
m.Echo(msg.Result())
|
||||
}},
|
||||
|
||||
"run": {Name: "run path name", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||
_inner_show(m, path.Join("./", arg[0], arg[1]))
|
||||
@ -165,11 +185,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
if len(arg) > 2 && arg[2] != "" {
|
||||
m.Echo(m.Cmdx(ice.WEB_STORY, "index", arg[2]))
|
||||
return
|
||||
}
|
||||
_inner_list(m, path.Join(arg...))
|
||||
_inner_main(m, arg...)
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
|
3
info.go
3
info.go
@ -115,3 +115,6 @@ func (m *Message) Log_MODIFY(arg ...interface{}) *Message {
|
||||
func (m *Message) Log_REMOVE(arg ...interface{}) *Message {
|
||||
return m.log(LOG_REMOVE, log_fields(arg...))
|
||||
}
|
||||
func (m *Message) Log_CREATE(arg ...interface{}) *Message {
|
||||
return m.log(LOG_CREATE, log_fields(arg...))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user