mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 17:44:05 +08:00
opt wiki
This commit is contained in:
parent
b82e74f038
commit
893eb37967
3
base.go
3
base.go
@ -62,9 +62,6 @@ var Index = &Context{Name: "ice", Help: "冰山模块",
|
|||||||
},
|
},
|
||||||
Configs: map[string]*Config{
|
Configs: map[string]*Config{
|
||||||
"table": {Name: "数据缓存", Value: map[string]interface{}{
|
"table": {Name: "数据缓存", Value: map[string]interface{}{
|
||||||
"space": " ",
|
|
||||||
"col_sep": " ",
|
|
||||||
"row_sep": "\n",
|
|
||||||
"compact": "false",
|
"compact": "false",
|
||||||
}},
|
}},
|
||||||
"help": {Value: map[string]interface{}{
|
"help": {Value: map[string]interface{}{
|
||||||
|
@ -150,7 +150,7 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块",
|
|||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
rg, _ := regexp.Compile(m.Option("dir_reg"))
|
rg, _ := regexp.Compile(m.Option("dir_reg"))
|
||||||
dir(m, kit.Select("./", m.Option("dir_root")), kit.Select("", arg, 0), 0, m.Options("dir_deep"), "both", rg,
|
dir(m, kit.Select("./", m.Option("dir_root")), kit.Select("", arg, 0), 0, m.Options("dir_deep"), kit.Select("both", m.Option("dir_type")), rg,
|
||||||
strings.Split(kit.Select("time size line path", arg, 1), " "), ice.ICE_TIME)
|
strings.Split(kit.Select("time size line path", arg, 1), " "), ice.ICE_TIME)
|
||||||
}},
|
}},
|
||||||
"cat": {Name: "cat path", Help: "保存", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"cat": {Name: "cat path", Help: "保存", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
@ -1458,7 +1458,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
"/share/": {Name: "/share/", Help: "共享链", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/share/": {Name: "/share/", Help: "共享链", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "local":
|
case "local":
|
||||||
http.ServeFile(m.W, m.R, "usr/"+path.Join(arg[1:]...))
|
http.ServeFile(m.W, m.R, m.Cmdx(arg[1], path.Join(arg[2:]...)))
|
||||||
|
|
||||||
case "login":
|
case "login":
|
||||||
Cookie(m, m.Cmdx(ice.AAA_USER, "login", m.Option("username"), m.Option("password")))
|
Cookie(m, m.Cmdx(ice.AAA_USER, "login", m.Option("username"), m.Option("password")))
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -38,17 +39,19 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
"table": {Name: "table", Help: "表格", Value: kit.Data("template", table)},
|
"table": {Name: "table", Help: "表格", Value: kit.Data("template", table)},
|
||||||
"chart": {Name: "chart", Help: "绘图", Value: kit.Data("prefix", prefix, "suffix", `</svg>`)},
|
"chart": {Name: "chart", Help: "绘图", Value: kit.Data("prefix", prefix, "suffix", `</svg>`)},
|
||||||
|
|
||||||
"mind": {Name: "mind", Help: "思维导图", Value: kit.Data(kit.MDB_SHORT, "name", "prefix", `<svg vertion="1.1" xmlns="http://www.w3.org/2000/svg" width="%v" height="%v">`, "suffix", `</svg>`)},
|
"mind": {Name: "mind", Help: "思维导图", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.svg", "prefix", `<svg vertion="1.1" xmlns="http://www.w3.org/2000/svg" width="%v" height="%v">`, "suffix", `</svg>`)},
|
||||||
"word": {Name: "word", Help: "语言文字", Value: kit.Data(kit.MDB_SHORT, "name")},
|
"word": {Name: "word", Help: "语言文字", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.shy")},
|
||||||
"data": {Name: "data", Help: "数据表格", Value: kit.Data(kit.MDB_SHORT, "name")},
|
"data": {Name: "data", Help: "数据表格", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.csv")},
|
||||||
"feel": {Name: "feel", Help: "影音媒体", Value: kit.Data(kit.MDB_SHORT, "name")},
|
"feel": {Name: "feel", Help: "影音媒体", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.(JPG|MOV|m4v)")},
|
||||||
|
"walk": {Name: "walk", Help: "走遍世界", Value: kit.Data(kit.MDB_SHORT, "name", "path", "usr/local", "regs", ".*\\.csv")},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Cmd(ice.CTX_CONFIG, "load", kit.Keys(m.Cap(ice.CTX_FOLLOW), "json"))
|
m.Cmd(ice.CTX_CONFIG, "load", kit.Keys(m.Cap(ice.CTX_FOLLOW), "json"))
|
||||||
|
|
||||||
}},
|
}},
|
||||||
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Cmd(ice.CTX_CONFIG, "save", kit.Keys(m.Cap(ice.CTX_FOLLOW), "json"), kit.Keys(m.Cap(ice.CTX_FOLLOW), "mind"))
|
m.Cmd(ice.CTX_CONFIG, "save", kit.Keys(m.Cap(ice.CTX_FOLLOW), "json"), kit.Keys(m.Cap(ice.CTX_FOLLOW), "feel"))
|
||||||
}},
|
}},
|
||||||
"chart": {Name: "chart block|chain|table name text [fg bg fs ls p m]", Help: "绘图", Meta: map[string]interface{}{
|
"chart": {Name: "chart block|chain|table name text [fg bg fs ls p m]", Help: "绘图", Meta: map[string]interface{}{
|
||||||
"display": "inner",
|
"display": "inner",
|
||||||
@ -217,9 +220,9 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
|
|
||||||
// 生成网页
|
// 生成网页
|
||||||
data := buffer.Bytes()
|
data := buffer.Bytes()
|
||||||
if strings.HasSuffix(arg[0], ".md") {
|
// if strings.HasSuffix(arg[0], ".md") {
|
||||||
data = markdown.ToHTML(buffer.Bytes(), nil, nil)
|
data = markdown.ToHTML(buffer.Bytes(), nil, nil)
|
||||||
}
|
// }
|
||||||
m.Echo(string(data))
|
m.Echo(string(data))
|
||||||
}},
|
}},
|
||||||
"_tree": {Name: "_tree path", Help: "文库", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
"_tree": {Name: "_tree path", Help: "文库", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||||
@ -259,93 +262,150 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
kit.MDB_INPUT, "text", "name", "name",
|
kit.MDB_INPUT, "text", "name", "name",
|
||||||
kit.MDB_INPUT, "button", "name", "执行",
|
kit.MDB_INPUT, "button", "name", "执行",
|
||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == "action" {
|
if len(arg) > 0 && arg[0] == "action" {
|
||||||
switch arg[1] {
|
switch arg[1] {
|
||||||
case "保存":
|
case "保存":
|
||||||
m.Cmd("nfs.save", path.Join("usr", arg[2]), arg[3:])
|
m.Cmd("nfs.save", path.Join(m.Conf(cmd, "meta.path"), arg[2]), arg[3:])
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Option("dir_root", "usr")
|
// 文件列表
|
||||||
|
m.Option("dir_root", m.Conf(cmd, "meta.path"))
|
||||||
|
m.Option("dir_reg", m.Conf(cmd, "meta.regs"))
|
||||||
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
||||||
if m.Append("path") == "" && m.Result() == "" {
|
m.Sort("time", "time_r")
|
||||||
m.Echo(m.Conf("mind", "meta.prefix"), "100%", "100%")
|
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
||||||
m.Echo(m.Conf("mind", "meta.suffix"))
|
// 目录列表
|
||||||
|
m.Option("dir_reg", "")
|
||||||
|
m.Option("dir_type", "dir")
|
||||||
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
"word": {Name: "word", Help: "语言文字", Meta: kit.Dict("display", "wiki/word"), List: kit.List(
|
"word": {Name: "word", Help: "语言文字", Meta: kit.Dict("display", "wiki/word"), List: kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "name",
|
kit.MDB_INPUT, "text", "name", "name",
|
||||||
kit.MDB_INPUT, "button", "name", "执行",
|
kit.MDB_INPUT, "button", "name", "执行",
|
||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == "action" {
|
if len(arg) > 0 && arg[0] == "action" {
|
||||||
switch arg[1] {
|
switch arg[1] {
|
||||||
case "保存":
|
case "保存":
|
||||||
m.Cmd("nfs.save", path.Join("usr", arg[2]), arg[3])
|
m.Cmd("nfs.save", path.Join(m.Conf(cmd, "meta.path"), arg[2]), arg[3])
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Option("dir_root", "usr")
|
// 文件列表
|
||||||
|
m.Option("dir_root", m.Conf(cmd, "meta.path"))
|
||||||
|
m.Option("dir_reg", m.Conf(cmd, "meta.regs"))
|
||||||
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
||||||
|
m.Sort("time", "time_r")
|
||||||
|
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
||||||
|
// 目录列表
|
||||||
|
m.Option("dir_reg", "")
|
||||||
|
m.Option("dir_type", "dir")
|
||||||
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Option("preview", m.Cmdx("_text", path.Join(m.Conf(cmd, "meta.path"), arg[0])))
|
||||||
}},
|
}},
|
||||||
"data": {Name: "data", Help: "数据表格", Meta: kit.Dict("display", "wiki/data"), List: kit.List(
|
"data": {Name: "data", Help: "数据表格", Meta: kit.Dict("display", "wiki/data"), List: kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "name",
|
kit.MDB_INPUT, "text", "name", "name",
|
||||||
kit.MDB_INPUT, "button", "name", "执行",
|
kit.MDB_INPUT, "button", "name", "执行",
|
||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == "action" {
|
if len(arg) > 0 && arg[0] == "action" {
|
||||||
switch arg[1] {
|
switch arg[1] {
|
||||||
case "保存":
|
case "保存":
|
||||||
m.Cmd("nfs.save", path.Join("usr", arg[2]), arg[3])
|
m.Cmd("nfs.save", path.Join(m.Conf("mind", "meta.path"), arg[2]), arg[3])
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Option("dir_root", "usr")
|
// 文件列表
|
||||||
|
m.Option("dir_root", m.Conf(cmd, "meta.path"))
|
||||||
|
m.Option("dir_reg", m.Conf(cmd, "meta.regs"))
|
||||||
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
||||||
if len(arg) > 0 && strings.HasSuffix(arg[0], ".csv") {
|
m.Sort("time", "time_r")
|
||||||
m.CSV(m.Result())
|
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
||||||
|
// 目录列表
|
||||||
|
m.Option("dir_reg", "")
|
||||||
|
m.Option("dir_type", "dir")
|
||||||
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
m.CSV(m.Result())
|
||||||
}},
|
}},
|
||||||
"feel": {Name: "feel", Help: "影音媒体", Meta: kit.Dict("display", "wiki/feel"), List: kit.List(
|
"feel": {Name: "feel", Help: "影音媒体", Meta: kit.Dict("display", "wiki/feel"), List: kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "name",
|
kit.MDB_INPUT, "text", "name", "name",
|
||||||
kit.MDB_INPUT, "button", "name", "执行",
|
kit.MDB_INPUT, "button", "name", "执行",
|
||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == "action" {
|
if len(arg) > 0 && arg[0] == "action" {
|
||||||
switch arg[1] {
|
switch arg[1] {
|
||||||
case "保存":
|
case "保存":
|
||||||
m.Cmd("nfs.save", path.Join("usr", arg[2]), arg[3])
|
m.Cmd("nfs.save", path.Join(m.Conf("mind", "meta.path"), arg[2]), arg[3])
|
||||||
|
case "标签":
|
||||||
|
m.Conf("feel", kit.Keys(path.Base(arg[2]), "-2"), arg[3])
|
||||||
|
p := path.Join(m.Conf(cmd, "meta.path"), arg[2])
|
||||||
|
q := path.Join(m.Conf(cmd, "meta.path"), arg[3])
|
||||||
|
os.MkdirAll(q, 0777)
|
||||||
|
m.Assert(os.Link(p, path.Join(q, path.Base(arg[2]))))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Option("dir_root", "usr")
|
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
||||||
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
// 文件列表
|
||||||
m.Sort("time", "time_r")
|
m.Option("dir_root", m.Conf(cmd, "meta.path"))
|
||||||
|
m.Option("dir_reg", m.Conf(cmd, "meta.regs"))
|
||||||
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0), "time size path").Table(func(index int, value map[string]string, head []string) {
|
||||||
|
m.Push("label", m.Conf("feel", path.Base(value["path"])))
|
||||||
|
})
|
||||||
|
|
||||||
|
// 目录列表
|
||||||
|
m.Option("dir_reg", "")
|
||||||
|
m.Option("dir_type", "dir")
|
||||||
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
||||||
|
|
||||||
|
if len(arg) > 0 {
|
||||||
|
m.Sort("time", "time_r")
|
||||||
|
} else {
|
||||||
|
m.Sort("line", "int_r")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 下载文件
|
||||||
|
m.Echo(path.Join(m.Conf(cmd, "meta.path"), arg[0]))
|
||||||
}},
|
}},
|
||||||
"walk": {Name: "walk", Help: "走遍世界", Meta: kit.Dict("display", "wiki/walk"), List: kit.List(
|
"walk": {Name: "walk", Help: "走遍世界", Meta: kit.Dict("display", "wiki/walk"), List: kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "file",
|
kit.MDB_INPUT, "text", "name", "file",
|
||||||
kit.MDB_INPUT, "button", "name", "执行",
|
kit.MDB_INPUT, "button", "name", "执行",
|
||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == "action" {
|
if len(arg) > 0 && arg[0] == "action" {
|
||||||
switch arg[1] {
|
switch arg[1] {
|
||||||
case "保存":
|
case "保存":
|
||||||
m.Cmd("nfs.save", path.Join("usr", arg[2]), arg[3])
|
m.Cmd("nfs.save", path.Join(m.Conf("mind", "meta.path"), arg[2]), arg[3])
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Option("dir_root", "usr")
|
// 文件列表
|
||||||
|
m.Option("dir_root", m.Conf(cmd, "meta.path"))
|
||||||
|
m.Option("dir_reg", m.Conf(cmd, "meta.regs"))
|
||||||
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
||||||
if len(arg) > 0 && strings.HasSuffix(arg[0], ".csv") {
|
m.Sort("time", "time_r")
|
||||||
m.Option("title", "我走过的世界")
|
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
||||||
m.CSV(m.Result())
|
// 目录列表
|
||||||
|
m.Option("dir_reg", "")
|
||||||
|
m.Option("dir_type", "dir")
|
||||||
|
m.Cmdy("nfs.dir", kit.Select("./", arg, 0))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
m.Option("title", "我走过的世界")
|
||||||
|
m.CSV(m.Result())
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
6
type.go
6
type.go
@ -523,7 +523,7 @@ func (m *Message) Table(cbs ...interface{}) *Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//计算列宽
|
//计算列宽
|
||||||
space := kit.Select(m.Conf("table", "space"), m.Option("table.space"))
|
space := kit.Select(" ", m.Option("table.space"))
|
||||||
depth, width := 0, map[string]int{}
|
depth, width := 0, map[string]int{}
|
||||||
for _, k := range m.meta[MSG_APPEND] {
|
for _, k := range m.meta[MSG_APPEND] {
|
||||||
if len(m.meta[k]) > depth {
|
if len(m.meta[k]) > depth {
|
||||||
@ -538,8 +538,8 @@ func (m *Message) Table(cbs ...interface{}) *Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 回调函数
|
// 回调函数
|
||||||
rows := kit.Select(m.Conf("table", "row_sep"), m.Option("table.row_sep"))
|
rows := kit.Select(" ", m.Option("table.row_sep"))
|
||||||
cols := kit.Select(m.Conf("table", "col_sep"), m.Option("table.col_sep"))
|
cols := kit.Select("\n", m.Option("table.col_sep"))
|
||||||
compact := kit.Select(m.Conf("table", "compact"), m.Option("table.compact")) == "true"
|
compact := kit.Select(m.Conf("table", "compact"), m.Option("table.compact")) == "true"
|
||||||
cb := func(maps map[string]string, lists []string, line int) bool {
|
cb := func(maps map[string]string, lists []string, line int) bool {
|
||||||
for i, v := range lists {
|
for i, v := range lists {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user