forked from x/icebergs
opt word
This commit is contained in:
parent
33a485dee2
commit
1a1a53db00
@ -202,6 +202,8 @@ func _space_search(m *ice.Message, kind, name, text string, arg ...string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch value[kit.MDB_TYPE] {
|
switch value[kit.MDB_TYPE] {
|
||||||
|
case CHROME:
|
||||||
|
|
||||||
case MASTER:
|
case MASTER:
|
||||||
m.PushSearch(cli.CMD, SPACE, kit.MDB_TYPE, value[kit.MDB_TYPE], kit.MDB_NAME, value[kit.MDB_NAME],
|
m.PushSearch(cli.CMD, SPACE, kit.MDB_TYPE, value[kit.MDB_TYPE], kit.MDB_NAME, value[kit.MDB_NAME],
|
||||||
kit.MDB_TEXT, m.Cmd(SPIDE, value[kit.MDB_NAME], ice.OptionFields("client.url")).Append("client.url"), value)
|
kit.MDB_TEXT, m.Cmd(SPIDE, value[kit.MDB_NAME], ice.OptionFields("client.url")).Append("client.url"), value)
|
||||||
|
@ -64,7 +64,7 @@ func init() {
|
|||||||
kit.MDB_PATH, ice.USR_LOCAL_RIVER,
|
kit.MDB_PATH, ice.USR_LOCAL_RIVER,
|
||||||
MENUS, `["river",
|
MENUS, `["river",
|
||||||
["添加", "创建群组", "添加应用", "添加工具", "添加用户", "添加设备", "创建空间"],
|
["添加", "创建群组", "添加应用", "添加工具", "添加用户", "添加设备", "创建空间"],
|
||||||
["共享", "共享群组", "共享应用", "共享工具", "共享主机"]
|
["共享", "共享群组", "共享应用", "共享工具", "共享主机", "访问空间"]
|
||||||
]`,
|
]`,
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
|
@ -35,6 +35,10 @@ func init() {
|
|||||||
AUTOGEN: {Name: "create main=src/main.go@key key= zone= type=Zone,Hash,List,Data name=hi list= help=", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
AUTOGEN: {Name: "create main=src/main.go@key key= zone= type=Zone,Hash,List,Data name=hi list= help=", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(AUTOGEN, mdb.CREATE, arg)
|
m.Cmdy(AUTOGEN, mdb.CREATE, arg)
|
||||||
}},
|
}},
|
||||||
|
COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(cli.SYSTEM, cli.MAKE)
|
||||||
|
m.ProcessInner()
|
||||||
|
}},
|
||||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(AUTOGEN, mdb.INPUTS, arg)
|
m.Cmdy(AUTOGEN, mdb.INPUTS, arg)
|
||||||
}},
|
}},
|
||||||
|
@ -1,12 +1,61 @@
|
|||||||
package wiki
|
package wiki
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func _title_deep(str string) int {
|
||||||
|
for i, c := range str {
|
||||||
|
if c != ' ' {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
func _title_parse(m *ice.Message, root map[string]interface{}, list []string) int {
|
||||||
|
var last map[string]interface{}
|
||||||
|
deep := _title_deep(list[0])
|
||||||
|
for i := 0; i < len(list); i++ {
|
||||||
|
if d := _title_deep(list[i]); d < deep {
|
||||||
|
return i
|
||||||
|
} else if d > deep {
|
||||||
|
i += _title_parse(m, last, list[i:]) - 1
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
ls := kit.Split(list[i])
|
||||||
|
switch len(ls) {
|
||||||
|
case 0:
|
||||||
|
continue
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
meta := kit.Dict(
|
||||||
|
"name", kit.Select("", ls, 0),
|
||||||
|
"link", kit.Select("", ls, 1),
|
||||||
|
)
|
||||||
|
for i := 2; i < len(ls); i += 2 {
|
||||||
|
meta[ls[i]] = ls[i+1]
|
||||||
|
}
|
||||||
|
last = kit.Dict("meta", meta, "list", kit.List())
|
||||||
|
kit.Value(root, "list.-2", last)
|
||||||
|
}
|
||||||
|
return len(list)
|
||||||
|
}
|
||||||
|
|
||||||
func _title_show(m *ice.Message, kind, text string, arg ...string) {
|
func _title_show(m *ice.Message, kind, text string, arg ...string) {
|
||||||
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
|
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
|
||||||
|
case NAVMENU: // 导航目录
|
||||||
|
_option(m, kind, "", text, arg...)
|
||||||
|
data := kit.Dict("meta", kit.Dict(), "list", kit.List())
|
||||||
|
_title_parse(m, data, strings.Split(text, ice.NL))
|
||||||
|
m.RenderTemplate(kit.Format("<div {{.OptionTemplate}} data-data='%s'></div>", kit.Format(data)))
|
||||||
|
return
|
||||||
|
|
||||||
case PREMENU: // 前置目录
|
case PREMENU: // 前置目录
|
||||||
_option(m, kind, "", "", arg...)
|
_option(m, kind, "", "", arg...)
|
||||||
m.RenderTemplate(m.Conf(TITLE, kit.Keym(kind)))
|
m.RenderTemplate(m.Conf(TITLE, kit.Keym(kind)))
|
||||||
@ -42,6 +91,7 @@ func _title_show(m *ice.Message, kind, text string, arg ...string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
NAVMENU = "navmenu"
|
||||||
PREMENU = "premenu"
|
PREMENU = "premenu"
|
||||||
CHAPTER = "chapter"
|
CHAPTER = "chapter"
|
||||||
SECTION = "section"
|
SECTION = "section"
|
||||||
@ -58,6 +108,8 @@ func init() {
|
|||||||
arg = append(arg, ns[len(ns)-1])
|
arg = append(arg, ns[len(ns)-1])
|
||||||
}
|
}
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
|
case NAVMENU:
|
||||||
|
_title_show(m, arg[0], arg[1], arg[2:]...)
|
||||||
case PREMENU, ENDMENU:
|
case PREMENU, ENDMENU:
|
||||||
_title_show(m, arg[0], "", arg[1:]...)
|
_title_show(m, arg[0], "", arg[1:]...)
|
||||||
case CHAPTER, SECTION:
|
case CHAPTER, SECTION:
|
||||||
|
@ -52,16 +52,14 @@ func _wiki_template(m *ice.Message, cmd string, name, text string, arg ...string
|
|||||||
|
|
||||||
const WIKI = "wiki"
|
const WIKI = "wiki"
|
||||||
|
|
||||||
var Index = &ice.Context{Name: WIKI, Help: "文档中心",
|
var Index = &ice.Context{Name: WIKI, Help: "文档中心", Commands: map[string]*ice.Command{
|
||||||
Commands: map[string]*ice.Command{
|
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Load()
|
m.Load()
|
||||||
}},
|
}},
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Save()
|
m.Save()
|
||||||
}},
|
}},
|
||||||
},
|
}}
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
web.Index.Register(Index, &web.Frame{},
|
web.Index.Register(Index, &web.Frame{},
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package wiki
|
package wiki
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
@ -48,10 +51,10 @@ func _word_template(m *ice.Message, cmd string, arg ...string) {
|
|||||||
const WORD = "word"
|
const WORD = "word"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
Configs: map[string]*ice.Config{
|
|
||||||
WORD: {Name: WORD, Help: "语言文字", Value: kit.Data(
|
WORD: {Name: WORD, Help: "语言文字", Value: kit.Data(
|
||||||
kit.MDB_PATH, "", kit.MDB_REGEXP, ".*\\.shy", kit.MDB_ALIAS, kit.Dict(
|
kit.MDB_PATH, "", kit.MDB_REGEXP, ".*\\.shy", kit.MDB_ALIAS, kit.Dict(
|
||||||
|
NAVMENU, []interface{}{TITLE, NAVMENU},
|
||||||
PREMENU, []interface{}{TITLE, PREMENU},
|
PREMENU, []interface{}{TITLE, PREMENU},
|
||||||
CHAPTER, []interface{}{TITLE, CHAPTER},
|
CHAPTER, []interface{}{TITLE, CHAPTER},
|
||||||
SECTION, []interface{}{TITLE, SECTION},
|
SECTION, []interface{}{TITLE, SECTION},
|
||||||
@ -60,8 +63,7 @@ func init() {
|
|||||||
CHAIN, []interface{}{CHART, CHAIN},
|
CHAIN, []interface{}{CHART, CHAIN},
|
||||||
),
|
),
|
||||||
)},
|
)},
|
||||||
},
|
}, Commands: map[string]*ice.Command{
|
||||||
Commands: map[string]*ice.Command{
|
|
||||||
WORD: {Name: "word path=src/main.shy auto 演示", Help: "语言文字", Meta: kit.Dict(
|
WORD: {Name: "word path=src/main.shy auto 演示", Help: "语言文字", Meta: kit.Dict(
|
||||||
ice.Display("/plugin/local/wiki/word.js", WORD),
|
ice.Display("/plugin/local/wiki/word.js", WORD),
|
||||||
), Action: ice.MergeAction(map[string]*ice.Action{
|
), Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
@ -74,6 +76,23 @@ func init() {
|
|||||||
_word_show(m, arg[0])
|
_word_show(m, arg[0])
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
},
|
"/word/": {Name: "word", Help: "文档", Meta: kit.Dict(
|
||||||
})
|
ice.Display("/plugin/local/wiki/word.js", WORD),
|
||||||
|
), Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
|
web.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(arg[0], ctx.ACTION, cli.RUN, arg[2:])
|
||||||
|
}},
|
||||||
|
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(ctx.COMMAND, "web.wiki.word")
|
||||||
|
if ls := strings.Split(m.Option("_names"), "/word/"); len(ls) > 1 {
|
||||||
|
m.Push("args", ls[1])
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
}, mdb.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if m.R.Method == http.MethodGet {
|
||||||
|
m.RenderIndex(web.SERVE, ice.VOLCANOS, "page/cmd.html")
|
||||||
|
return // 目录
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
}})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user