mirror of
https://shylinux.com/x/icebergs
synced 2025-04-27 01:48:27 +08:00
add vimer
This commit is contained in:
parent
ee043fd1c5
commit
98e018df6d
@ -23,6 +23,17 @@ func _hash_insert(m *ice.Message, prefix, key string, arg ...string) string {
|
|||||||
return m.Rich(prefix, key, kit.Dict(arg))
|
return m.Rich(prefix, key, kit.Dict(arg))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
func _hash_inputs(m *ice.Message, prefix, key string, field, value string) {
|
||||||
|
list := map[string]int{}
|
||||||
|
m.Richs(prefix, key, kit.MDB_FOREACH, func(key string, val map[string]interface{}) {
|
||||||
|
list[kit.Format(val[field])]++
|
||||||
|
})
|
||||||
|
for k, i := range list {
|
||||||
|
m.Push("key", k)
|
||||||
|
m.Push("count", i)
|
||||||
|
}
|
||||||
|
m.Sort("count", "int_r")
|
||||||
|
}
|
||||||
func _hash_modify(m *ice.Message, prefix, key string, field, value string, arg ...string) {
|
func _hash_modify(m *ice.Message, prefix, key string, field, value string, arg ...string) {
|
||||||
m.Richs(prefix, key, value, func(key string, value map[string]interface{}) {
|
m.Richs(prefix, key, value, func(key string, value map[string]interface{}) {
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
for i := 0; i < len(arg)-1; i += 2 {
|
||||||
@ -84,9 +95,7 @@ func _hash_import(m *ice.Message, prefix, key, file string) {
|
|||||||
}
|
}
|
||||||
func _hash_select(m *ice.Message, prefix, key, field, value string) {
|
func _hash_select(m *ice.Message, prefix, key, field, value string) {
|
||||||
fields := strings.Split(kit.Select("time,name", m.Option("fields")), ",")
|
fields := strings.Split(kit.Select("time,name", m.Option("fields")), ",")
|
||||||
m.Debug("what %v %v", prefix, key, value)
|
|
||||||
m.Richs(prefix, key, value, func(key string, val map[string]interface{}) {
|
m.Richs(prefix, key, value, func(key string, val map[string]interface{}) {
|
||||||
m.Debug("what %v %v", prefix, key)
|
|
||||||
if value == kit.MDB_FOREACH {
|
if value == kit.MDB_FOREACH {
|
||||||
m.Push(key, val, fields)
|
m.Push(key, val, fields)
|
||||||
return
|
return
|
||||||
@ -279,6 +288,8 @@ const (
|
|||||||
IMPORT = "import"
|
IMPORT = "import"
|
||||||
EXPORT = "export"
|
EXPORT = "export"
|
||||||
|
|
||||||
|
INPUTS = "inputs"
|
||||||
|
|
||||||
INSERT = "insert"
|
INSERT = "insert"
|
||||||
MODIFY = "modify"
|
MODIFY = "modify"
|
||||||
DELETE = "delete"
|
DELETE = "delete"
|
||||||
@ -338,6 +349,13 @@ var Index = &ice.Context{Name: "mdb", Help: "数据模块",
|
|||||||
_list_import(m, arg[0], arg[1], file)
|
_list_import(m, arg[0], arg[1], file)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
INPUTS: {Name: "inputs conf key type field value", Help: "输入补全", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
switch arg[2] {
|
||||||
|
case HASH:
|
||||||
|
_hash_inputs(m, arg[0], arg[1], arg[3], kit.Select("", arg, 4))
|
||||||
|
case LIST:
|
||||||
|
}
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,5 +364,6 @@ func init() {
|
|||||||
IMPORT, EXPORT, SELECT,
|
IMPORT, EXPORT, SELECT,
|
||||||
PLUGIN, ENGINE, SEARCH, RENDER,
|
PLUGIN, ENGINE, SEARCH, RENDER,
|
||||||
INSERT, MODIFY, DELETE,
|
INSERT, MODIFY, DELETE,
|
||||||
|
INPUTS,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
68
core/chat/study.go
Normal file
68
core/chat/study.go
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package chat
|
||||||
|
|
||||||
|
import (
|
||||||
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
kit "github.com/shylinux/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _target_insert = kit.List(
|
||||||
|
"_input", "text", "name", "type", "value", "@key",
|
||||||
|
"_input", "text", "name", "name", "value", "@key",
|
||||||
|
"_input", "text", "name", "text", "value", "@key",
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
STUDY = "study"
|
||||||
|
TARGET = "target"
|
||||||
|
// ACTION = "action"
|
||||||
|
ASSESS = "assess"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.Register(&ice.Context{Name: STUDY, Help: "study",
|
||||||
|
Configs: map[string]*ice.Config{
|
||||||
|
TARGET: {Name: "target", Help: "大纲", Value: kit.Data()},
|
||||||
|
ACTION: {Name: "action", Help: "互动", Value: kit.Data()},
|
||||||
|
ASSESS: {Name: "assess", Help: "评测", Value: kit.Data()},
|
||||||
|
},
|
||||||
|
Commands: map[string]*ice.Command{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }},
|
||||||
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }},
|
||||||
|
|
||||||
|
TARGET: {Name: "target hash=auto auto 添加:button 导出:button 导入:button", Help: "大纲", Meta: kit.Dict(
|
||||||
|
"添加", _target_insert,
|
||||||
|
), Action: map[string]*ice.Action{
|
||||||
|
mdb.INSERT: {Name: "insert [key value]...", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(mdb.INSERT, m.Prefix(TARGET), m.Option(ice.MSG_DOMAIN), mdb.HASH, arg)
|
||||||
|
}},
|
||||||
|
mdb.MODIFY: {Name: "modify key value", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(mdb.MODIFY, m.Prefix(TARGET), m.Option(ice.MSG_DOMAIN), mdb.HASH, "", m.Option("hash"), arg[0], arg[1])
|
||||||
|
}},
|
||||||
|
mdb.DELETE: {Name: "delete", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(mdb.DELETE, m.Prefix(TARGET), m.Option(ice.MSG_DOMAIN), mdb.HASH, "", m.Option("hash"))
|
||||||
|
}},
|
||||||
|
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(mdb.EXPORT, m.Prefix(TARGET), m.Option(ice.MSG_DOMAIN), mdb.HASH)
|
||||||
|
}},
|
||||||
|
mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(mdb.IMPORT, m.Prefix(TARGET), m.Option(ice.MSG_DOMAIN), mdb.HASH)
|
||||||
|
}},
|
||||||
|
|
||||||
|
mdb.INPUTS: {Name: "inputs key value", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(mdb.INPUTS, m.Prefix(TARGET), m.Option(ice.MSG_DOMAIN), mdb.HASH, arg)
|
||||||
|
}},
|
||||||
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Option("fields", "time,hash,type,name,text")
|
||||||
|
m.Cmdy(mdb.SELECT, m.Prefix(TARGET), m.Option(ice.MSG_DOMAIN), mdb.HASH, "", kit.Select(kit.MDB_FOREACH, arg, 0))
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.PushAction("备课", "学习", "测试", "删除")
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
ACTION: {Name: "action", Help: "互动", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
}},
|
||||||
|
ASSESS: {Name: "assess", Help: "评测", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
}, nil)
|
||||||
|
}
|
@ -25,7 +25,7 @@ func _c_find(m *ice.Message, key string) {
|
|||||||
}
|
}
|
||||||
func _c_grep(m *ice.Message, key string) {
|
func _c_grep(m *ice.Message, key string) {
|
||||||
m.Split(m.Cmd(cli.SYSTEM, GREP, "--exclude-dir=.git", "--exclude-dir=pluged", "--exclude=.[a-z]*",
|
m.Split(m.Cmd(cli.SYSTEM, GREP, "--exclude-dir=.git", "--exclude-dir=pluged", "--exclude=.[a-z]*",
|
||||||
"-rn", key, ".").Append(cli.CMD_OUT), "file:line:text", ":", "\n")
|
"-rn", "\\<"+key+"\\>", ".").Append(cli.CMD_OUT), "file:line:text", ":", "\n")
|
||||||
}
|
}
|
||||||
func _c_tags(m *ice.Message, key string) {
|
func _c_tags(m *ice.Message, key string) {
|
||||||
if _, e := os.Stat(path.Join(m.Option("_path"), m.Conf(C, "meta.tags"))); e != nil {
|
if _, e := os.Stat(path.Join(m.Option("_path"), m.Conf(C, "meta.tags"))); e != nil {
|
||||||
|
@ -17,6 +17,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VEDIO = "vedio"
|
||||||
|
QRCODE = "qrcode"
|
||||||
|
)
|
||||||
|
|
||||||
const ( // CODE
|
const ( // CODE
|
||||||
INSTALL = "_install"
|
INSTALL = "_install"
|
||||||
PREPARE = "_prepare"
|
PREPARE = "_prepare"
|
||||||
|
@ -146,6 +146,7 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
m.Cmdy(cli.SYSTEM, GO, "run", "./"+arg[1])
|
m.Cmdy(cli.SYSTEM, GO, "run", "./"+arg[1])
|
||||||
}
|
}
|
||||||
|
m.Set(ice.MSG_APPEND)
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||||
},
|
},
|
||||||
|
@ -12,30 +12,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
INNER = "inner"
|
|
||||||
VEDIO = "vedio"
|
|
||||||
QRCODE = "qrcode"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
LIST = "list"
|
|
||||||
PLUG = "plug"
|
|
||||||
SHOW = "show"
|
|
||||||
SAVE = "save"
|
|
||||||
)
|
|
||||||
|
|
||||||
func _inner_ext(name string) string {
|
func _inner_ext(name string) string {
|
||||||
return strings.ToLower(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_show(m *ice.Message, ext, file, dir string, arg ...string) {
|
|
||||||
if m.Cmdy(mdb.ENGINE, ext, file, dir, arg); m.Result() == "" {
|
|
||||||
if ls := kit.Simple(m.Confv(INNER, kit.Keys("meta.show", ext))); len(ls) > 0 {
|
|
||||||
m.Cmdy(cli.SYSTEM, ls, path.Join(dir, file)).Set(ice.MSG_APPEND)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func _inner_list(m *ice.Message, ext, file, dir string, arg ...string) {
|
func _inner_list(m *ice.Message, ext, file, dir string, arg ...string) {
|
||||||
if !m.Right(strings.Split(dir, "/"), file) {
|
if !m.Right(strings.Split(dir, "/"), file) {
|
||||||
return
|
return
|
||||||
@ -48,11 +28,30 @@ func _inner_list(m *ice.Message, ext, file, dir string, arg ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func _inner_show(m *ice.Message, ext, file, dir string, arg ...string) {
|
||||||
|
if m.Cmdy(mdb.ENGINE, ext, file, dir, arg); m.Result() == "" {
|
||||||
|
if ls := kit.Simple(m.Confv(INNER, kit.Keys("meta.show", ext))); len(ls) > 0 {
|
||||||
|
m.Cmdy(cli.SYSTEM, ls, path.Join(dir, file)).Set(ice.MSG_APPEND)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
LIST = "list"
|
||||||
|
PLUG = "plug"
|
||||||
|
SHOW = "show"
|
||||||
|
SAVE = "save"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
INNER = "inner"
|
||||||
|
VIMER = "vimer"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
INNER: {Name: "inner path=usr/demo file=hi.sh line=1 auto", Help: "编辑器", Meta: kit.Dict(
|
INNER: {Name: "inner path=usr/demo file=hi.sh line=1 auto", Help: "阅读器", Meta: kit.Dict(
|
||||||
"display", "/plugin/local/code/inner.js", "style", "editor",
|
"display", "/plugin/local/code/inner.js", "style", "editor",
|
||||||
), Action: map[string]*ice.Action{
|
), Action: map[string]*ice.Action{
|
||||||
web.UPLOAD: {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
web.UPLOAD: {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -83,9 +82,14 @@ func init() {
|
|||||||
}
|
}
|
||||||
_inner_list(m, _inner_ext(arg[1]), arg[1], arg[0])
|
_inner_list(m, _inner_ext(arg[1]), arg[1], arg[0])
|
||||||
}},
|
}},
|
||||||
|
VIMER: {Name: "vimer path=usr/demo file=hi.sh line=1 auto", Help: "编辑器", Meta: kit.Dict(
|
||||||
|
"display", "/plugin/local/code/vimer.js", "style", "editor",
|
||||||
|
), Action: map[string]*ice.Action{}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Cmdy(INNER, arg)
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
INNER: {Name: "inner", Help: "编辑器", Value: kit.Data(
|
INNER: {Name: "inner", Help: "阅读器", Value: kit.Data(
|
||||||
"source", kit.Dict(
|
"source", kit.Dict(
|
||||||
"license", "true",
|
"license", "true",
|
||||||
"makefile", "true",
|
"makefile", "true",
|
||||||
|
@ -19,6 +19,7 @@ func init() {
|
|||||||
m.Cmd(mdb.SEARCH, mdb.CREATE, SH, SH, c.Cap(ice.CTX_FOLLOW))
|
m.Cmd(mdb.SEARCH, mdb.CREATE, SH, SH, c.Cap(ice.CTX_FOLLOW))
|
||||||
m.Cmd(mdb.PLUGIN, mdb.CREATE, SH, SH, c.Cap(ice.CTX_FOLLOW))
|
m.Cmd(mdb.PLUGIN, mdb.CREATE, SH, SH, c.Cap(ice.CTX_FOLLOW))
|
||||||
m.Cmd(mdb.RENDER, mdb.CREATE, SH, SH, c.Cap(ice.CTX_FOLLOW))
|
m.Cmd(mdb.RENDER, mdb.CREATE, SH, SH, c.Cap(ice.CTX_FOLLOW))
|
||||||
|
m.Cmd(mdb.ENGINE, mdb.CREATE, SH, SH, c.Cap(ice.CTX_FOLLOW))
|
||||||
}},
|
}},
|
||||||
SH: {Name: SH, Help: "sh", Action: map[string]*ice.Action{
|
SH: {Name: SH, Help: "sh", Action: map[string]*ice.Action{
|
||||||
mdb.SEARCH: {Name: "search type name text", Hand: func(m *ice.Message, arg ...string) {
|
mdb.SEARCH: {Name: "search type name text", Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -37,7 +38,9 @@ func init() {
|
|||||||
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
|
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
|
||||||
}},
|
}},
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(cli.SYSTEM, path.Join(arg[2], arg[1]))
|
m.Option(cli.CMD_DIR, arg[2])
|
||||||
|
m.Cmdy(cli.SYSTEM, arg[1])
|
||||||
|
m.Set(ice.MSG_APPEND)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"man": {Hand: func(m *ice.Message, arg ...string) {
|
"man": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
2
meta.go
2
meta.go
@ -83,7 +83,7 @@ func (m *Message) Push(key string, value interface{}, arg ...interface{}) *Messa
|
|||||||
// 查找数据
|
// 查找数据
|
||||||
var v interface{}
|
var v interface{}
|
||||||
switch k {
|
switch k {
|
||||||
case kit.MDB_KEY, kit.MDB_ZONE:
|
case kit.MDB_KEY, kit.MDB_ZONE, kit.MDB_HASH:
|
||||||
if key != "" {
|
if key != "" {
|
||||||
v = key
|
v = key
|
||||||
break
|
break
|
||||||
|
5
misc.go
5
misc.go
@ -13,6 +13,11 @@ func (m *Message) Prefix(arg ...string) string {
|
|||||||
}
|
}
|
||||||
func (m *Message) Save(arg ...string) *Message {
|
func (m *Message) Save(arg ...string) *Message {
|
||||||
list := []string{}
|
list := []string{}
|
||||||
|
if len(arg) == 0 {
|
||||||
|
for k := range m.target.Configs {
|
||||||
|
arg = append(arg, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, k := range arg {
|
for _, k := range arg {
|
||||||
list = append(list, kit.Keys(m.Cap(CTX_FOLLOW), k))
|
list = append(list, kit.Keys(m.Cap(CTX_FOLLOW), k))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user