1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 09:34:05 +08:00
This commit is contained in:
harveyshao 2021-07-26 20:51:12 +08:00
parent 08f8ba8730
commit da6ffe8b0d
19 changed files with 162 additions and 232 deletions

View File

@ -358,6 +358,11 @@ func init() {
m.Cmdy(mdb.DELETE, SPIDE, "", mdb.HASH, CLIENT_NAME, m.Option(CLIENT_NAME))
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 2 {
m.Option(SPIDE_HEADER, ContentType, ContentJSON)
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(SPIDE, SPIDE_DEV, SPIDE_RAW, SPIDE_POST, arg[0], SPIDE_DATA, arg[1:]))))
return
}
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(SPIDE, SPIDE_DEV, SPIDE_RAW, SPIDE_POST, arg[0], SPIDE_JSON, arg[1:]))))
}},
}})

View File

@ -10,8 +10,8 @@ const BRIEF = "brief"
func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
BRIEF: {Name: "brief [name] text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
_word_template(m, cmd, arg...)
BRIEF: {Name: "brief text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
_wiki_template(m, cmd, "", arg[0], arg[1:]...)
}},
},
Configs: map[string]*ice.Config{

View File

@ -357,7 +357,7 @@ func Stack(m *ice.Message, name string, level int, data interface{}) {
m.Echo("</ul>")
}
func _chart_show(m *ice.Message, kind, name, text string, arg ...string) {
func _chart_show(m *ice.Message, kind, text string, arg ...string) {
var chart Chart
switch kind {
case LABEL: // 标签
@ -366,11 +366,6 @@ func _chart_show(m *ice.Message, kind, name, text string, arg ...string) {
chart = &Chain{}
}
// 基本参数
m.Option(kit.MDB_TYPE, strings.TrimSpace(kind))
m.Option(kit.MDB_NAME, strings.TrimSpace(name))
m.Option(kit.MDB_TEXT, strings.TrimSpace(text))
// 扩展参数
m.Option("font-size", "24")
m.Option("stroke", "blue")
@ -397,13 +392,13 @@ func _chart_show(m *ice.Message, kind, name, text string, arg ...string) {
}
// 计算尺寸
chart.Init(m, m.Option(kit.MDB_TEXT))
m.Option("height", chart.GetHeight())
chart.Init(m, text)
m.Option("width", chart.GetWidth())
m.Option("height", chart.GetHeight())
// 渲染引擎
m.RenderTemplate(m.Conf(CHART, kit.Keym(kit.MDB_TEMPLATE)))
defer m.RenderTemplate(m.Conf(CHART, kit.Keym("suffix")))
_wiki_template(m, CHART, "", text)
defer m.Echo(`</svg>`)
chart.Draw(m, 0, 0)
}
@ -416,11 +411,8 @@ const CHART = "chart"
func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
CHART: {Name: "chart label|chain [name] text", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 2 {
arg = []string{arg[0], "", arg[1]}
}
_chart_show(m, arg[0], arg[1], arg[2], arg[3:]...)
CHART: {Name: "chart label|chain text", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
_chart_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
}},
},
Configs: map[string]*ice.Config{
@ -430,7 +422,7 @@ vertion="1.1" xmlns="http://www.w3.org/2000/svg" dominant-baseline="middle" text
font-size="{{.Option "font-size"}}" stroke="{{.Option "stroke"}}" fill="{{.Option "fill"}}"
stroke-width="{{.Option "stroke-width"}}" font-family="{{.Option "font-family"}}"
width="{{.Option "width"}}" height="{{.Option "height"}}"
>`, "suffix", `</svg>`,
>`,
)},
},
})

View File

@ -22,7 +22,7 @@ func init() {
ice.Display("/plugin/local/wiki/draw.js"),
), Action: map[string]*ice.Action{
nfs.SAVE: {Name: "save path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
_wiki_save(m, DRAW, path.Join(arg...), m.Option("content"))
_wiki_save(m, DRAW, path.Join(arg...), m.Option(kit.MDB_CONTENT))
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if !_wiki_list(m, DRAW, kit.Select("./", path.Join(arg...))) {

View File

@ -1,7 +1,6 @@
package wiki
import (
"path"
"strings"
ice "github.com/shylinux/icebergs"
@ -10,62 +9,66 @@ import (
)
func _field_show(m *ice.Message, name, text string, arg ...string) {
// 基本参数
m.Option(kit.MDB_TYPE, FIELD)
m.Option(kit.MDB_NAME, name)
m.Option(kit.MDB_TEXT, text)
// 命令参数
data := kit.Dict(kit.MDB_NAME, name)
cmds := kit.Split(text)
meta, cmds := kit.Dict(), kit.Split(text)
m.Search(cmds[0], func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
data["feature"], data["inputs"] = cmd.Meta, cmd.List
if meta[FEATURE], meta[INPUTS] = cmd.Meta, cmd.List; name == "" {
name = cmd.Help
}
})
name = strings.ReplaceAll(name, " ", "_")
meta[kit.MDB_NAME] = name
// 扩展参数
for i := 0; i < len(arg)-1; i += 2 {
if strings.HasPrefix(arg[i], "args.") {
m.Option(arg[i], strings.TrimSpace(arg[i+1]))
kit.Value(data, arg[i], m.Option(arg[i]))
} else if strings.HasPrefix(arg[i], "args") {
kit.Value(meta, arg[i], m.Option(arg[i]))
} else if strings.HasPrefix(arg[i], ARGS) {
m.Option(arg[i], kit.Split(strings.TrimSuffix(strings.TrimPrefix(arg[i+1], "["), "]")))
kit.Value(data, arg[i], m.Optionv(arg[i]))
kit.Value(meta, arg[i], m.Optionv(arg[i]))
} else {
m.Parse("option", arg[i], arg[i+1])
kit.Value(data, arg[i], m.Optionv(arg[i]))
m.Parse(ice.MSG_OPTION, arg[i], arg[i+1])
kit.Value(meta, arg[i], m.Optionv(arg[i]))
}
switch arg[i] {
case "content":
data[arg[i]] = arg[i+1]
case kit.MDB_CONTENT:
meta[arg[i]] = arg[i+1]
case "args":
case ARGS:
args := kit.Simple(m.Optionv(arg[i]))
count := 0
kit.Fetch(data["inputs"], func(index int, value map[string]interface{}) {
if value["_input"] != "button" && value["type"] != "button" {
kit.Fetch(meta[INPUTS], func(index int, value map[string]interface{}) {
if value[kit.MDB_INPUT] != kit.MDB_BUTTON && value[kit.MDB_TYPE] != kit.MDB_BUTTON {
count++
}
})
if len(args) > count {
list := data["inputs"].([]interface{})
list := meta[INPUTS].([]interface{})
for i := count; i < len(args); i++ {
list = append(list, kit.Dict(
"_input", "text", "name", "args", "value", args[i],
kit.MDB_INPUT, "text", kit.MDB_NAME, "args", kit.MDB_VALUE, args[i],
))
}
data["inputs"] = list
meta[INPUTS] = list
}
}
}
m.Option(kit.MDB_META, meta)
// 渲染引擎
m.Option(kit.MDB_META, data)
m.RenderTemplate(m.Conf(FIELD, kit.Keym(kit.MDB_TEMPLATE)))
_wiki_template(m, FIELD, name, text)
}
const (
FEATURE = "feature"
INPUTS = "inputs"
ARGS = "args"
)
const FIELD = "field"
func init() {
@ -79,7 +82,7 @@ func init() {
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
arg = _name(m, arg)
_field_show(m, strings.ReplaceAll(kit.Select(path.Base(arg[1]), arg[0]), " ", "_"), arg[1], arg[2:]...)
_field_show(m, arg[0], arg[1], arg[2:]...)
}},
},
Configs: map[string]*ice.Config{

View File

@ -2,20 +2,14 @@ package wiki
import (
"path"
"strings"
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/mdb"
kit "github.com/shylinux/toolkits"
)
func _image_show(m *ice.Message, name, text string, arg ...string) {
if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, "/") {
text = path.Join("/share/local", _wiki_path(m, FEEL, text))
}
_option(m, IMAGE, name, text, arg...)
m.RenderTemplate(m.Conf(IMAGE, kit.Keym(kit.MDB_TEMPLATE)))
func _image_show(m *ice.Message, text string, arg ...string) {
_wiki_template(m, IMAGE, "", _wiki_link(m, IMAGE, text), arg...)
}
const (
@ -31,18 +25,18 @@ func init() {
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(mdb.RENDER, mdb.CREATE, PNG, m.Prefix(IMAGE))
}},
IMAGE: {Name: "image [name] url", Help: "图片", Action: map[string]*ice.Action{
IMAGE: {Name: "image url", Help: "图片", Action: map[string]*ice.Action{
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
_image_show(m, arg[1], path.Join(arg[2], arg[1]))
_image_show(m, path.Join(arg[2], arg[1]))
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
arg = _name(m, arg)
_image_show(m, arg[0], arg[1], arg[2:]...)
_image_show(m, arg[0], arg[1:]...)
}},
},
Configs: map[string]*ice.Config{
IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data(
kit.MDB_TEMPLATE, `<img {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}">`,
kit.MDB_PATH, "usr/local/image",
)},
},
})

View File

@ -7,9 +7,8 @@ import (
)
func _local_show(m *ice.Message, name, text string, arg ...string) {
m.Option("input", m.Cmdx(nfs.CAT, text))
_option(m, LOCAL, name, text, arg...)
m.RenderTemplate(m.Conf(LOCAL, kit.Keym(kit.MDB_TEMPLATE)))
m.Option(INPUT, m.Cmdx(nfs.CAT, text))
_wiki_template(m, LOCAL, name, text, arg...)
}
const LOCAL = "local"

View File

@ -1,38 +0,0 @@
package wiki
import (
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/mdb"
kit "github.com/shylinux/toolkits"
)
func _music_show(m *ice.Message, name, text string, arg ...string) {
_option(m, MUSIC, name, text, arg...)
}
func _music_search(m *ice.Message, kind, name, text string) {
if kit.Contains(kind, kit.MDB_FOREACH) || kit.Contains(kind, MUSIC) {
m.PushSearchWeb(MUSIC, name)
}
}
const MUSIC = "music"
func init() {
Index.Merge(&ice.Context{
Configs: map[string]*ice.Config{
MUSIC: {Name: "music", Help: "音乐", Value: kit.Data(kit.MDB_SHORT, kit.MDB_TEXT)},
},
Commands: map[string]*ice.Command{
MUSIC: {Name: "music [name] url", Help: "视频", Action: map[string]*ice.Action{
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
_music_search(m, arg[0], arg[1], arg[2])
}},
mdb.CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.INSERT, m.Prefix(MUSIC), "", mdb.HASH, arg)
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
arg = _name(m, arg)
_music_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
}},
}})
}

View File

@ -7,10 +7,9 @@ import (
kit "github.com/shylinux/toolkits"
)
func _order_show(m *ice.Message, name, text string, arg ...string) {
m.Optionv("list", kit.Split(strings.TrimSpace(text), "\n"))
_option(m, ORDER, name, text, arg...)
m.RenderTemplate(m.Conf(ORDER, kit.Keym(kit.MDB_TEMPLATE)))
func _order_show(m *ice.Message, text string, arg ...string) {
m.Optionv(kit.MDB_LIST, kit.Split(strings.TrimSpace(text), ice.MOD_NL))
_wiki_template(m, ORDER, "", text, arg...)
}
const ORDER = "order"
@ -18,9 +17,8 @@ const ORDER = "order"
func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
ORDER: {Name: "order [name] `[item \n]...`", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
arg = _name(m, arg)
_order_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
ORDER: {Name: "order `[item\n]...`", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
_order_show(m, arg[0], arg[1:]...)
}},
},
Configs: map[string]*ice.Config{

View File

@ -1,29 +0,0 @@
package wiki
import (
ice "github.com/shylinux/icebergs"
kit "github.com/shylinux/toolkits"
)
func _other_show(m *ice.Message, name, text string, arg ...string) {
_option(m, OTHER, name, text, arg...)
m.RenderTemplate(m.Conf(OTHER, kit.Keym(kit.MDB_TEMPLATE)))
}
const OTHER = "other"
func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
OTHER: {Name: "other [name] url", Help: "网页", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
arg = _name(m, arg)
_other_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
}},
},
Configs: map[string]*ice.Config{
OTHER: {Name: FIELD, Help: "网页", Value: kit.Data(
kit.MDB_TEMPLATE, ``,
)},
},
})
}

View File

@ -2,7 +2,9 @@ package wiki
import (
"net/url"
"strconv"
"strings"
"time"
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/mdb"
@ -12,49 +14,57 @@ import (
const PARSE = "parse"
func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
PARSE: {Name: "parse type=auto,json,http,form,list auto text:textarea", Help: "解析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) < 2 {
return
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
PARSE: {Name: "parse type=auto,json,http,form,time,list auto text:textarea", Help: "解析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) < 2 {
return
}
if arg[1] = strings.TrimSpace(arg[1]); arg[0] != "auto" {
} else if strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[") {
arg[0] = "json"
} else if strings.HasPrefix(arg[1], "http") {
arg[0] = "http"
} else if strings.Contains(arg[1], "=") {
arg[0] = "form"
} else if _, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
arg[0] = "time"
} else {
arg[0] = "list"
}
switch m.Option(mdb.FIELDS, mdb.DETAIL); arg[0] {
case "json":
m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
case "http":
u, _ := url.Parse(arg[1])
for k, v := range u.Query() {
for _, v := range v {
m.Push(k, v)
}
}
if arg[0] == "auto" && (strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[")) {
arg[0] = "json"
} else if strings.HasPrefix(arg[1], "http") {
arg[0] = "http"
} else if strings.Contains(arg[1], "=") {
arg[0] = "form"
} else {
arg[0] = "list"
m.EchoQRCode(arg[1])
case "form":
for _, v := range kit.Split(arg[1], "&", "&", "&") {
ls := kit.Split(v, "=", "=", "=")
key, _ := url.QueryUnescape(ls[0])
value, _ := url.QueryUnescape(kit.Select("", ls, 1))
m.Push(key, value)
}
m.Option(mdb.FIELDS, mdb.DETAIL)
switch arg[0] {
case "json":
m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
case "http":
u, _ := url.Parse(arg[1])
for k, v := range u.Query() {
for _, v := range v {
m.Push(k, v)
}
}
m.EchoQRCode(arg[1])
case "form":
for _, v := range kit.Split(arg[1], "&", "&", "&") {
ls := kit.Split(v, "=", "=", "=")
key, _ := url.QueryUnescape(ls[0])
value, _ := url.QueryUnescape(kit.Select("", ls, 1))
m.Push(key, value)
}
case "list":
for i, v := range kit.Split(arg[1]) {
m.Push(kit.Format(i), v)
}
case "time":
if i, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
m.Echo(time.Unix(i, 0).Format(ice.MOD_TIME))
}
}},
},
Configs: map[string]*ice.Config{},
})
case "list":
for i, v := range kit.Split(arg[1]) {
m.Push(kit.Format(i), v)
}
}
}},
}})
}

View File

@ -8,19 +8,17 @@ import (
kit "github.com/shylinux/toolkits"
)
func _refer_show(m *ice.Message, name, text string, arg ...string) {
func _refer_show(m *ice.Message, text string, arg ...string) {
list := [][]string{}
for _, v := range kit.Split(strings.TrimSpace(text), "\n", "\n") {
for _, v := range kit.Split(strings.TrimSpace(text), ice.MOD_NL, ice.MOD_NL) {
if ls := kit.Split(v); len(ls) == 1 {
list = append(list, []string{path.Base(ls[0]), ls[0]})
} else {
list = append(list, ls)
}
}
m.Optionv("list", list)
_option(m, REFER, name, text, arg...)
m.RenderTemplate(m.Conf(REFER, kit.Keym(kit.MDB_TEMPLATE)))
m.Optionv(kit.MDB_LIST, list)
_wiki_template(m, REFER, "", text, arg...)
}
const REFER = "refer"
@ -28,9 +26,8 @@ const REFER = "refer"
func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
REFER: {Name: "refer [name] `[name url]...`", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
arg = _name(m, arg)
_refer_show(m, arg[0], arg[1], arg[2:]...)
REFER: {Name: "refer `[[name] url\n]...`", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
_refer_show(m, arg[0], arg[1:]...)
}},
},
Configs: map[string]*ice.Config{

View File

@ -7,11 +7,14 @@ import (
)
func _shell_show(m *ice.Message, name, text string, arg ...string) {
m.Option("output", m.Cmdx(cli.SYSTEM, "sh", "-c", m.Option("input", text)))
_option(m, SHELL, name, text, arg...)
m.RenderTemplate(m.Conf(SHELL, kit.Keym(kit.MDB_TEMPLATE)))
m.Option(OUTPUT, m.Cmdx(cli.SYSTEM, "sh", "-c", m.Option(INPUT, text)))
_wiki_template(m, SHELL, name, text, arg...)
}
const (
INPUT = "input"
OUTPUT = "output"
)
const SHELL = "shell"
func init() {

View File

@ -13,7 +13,7 @@ func _spark_show(m *ice.Message, name, text string, arg ...string) {
return
}
prompt := kit.Select(name+"> ", m.Conf(SPARK, kit.Keym("prompt", name)))
prompt := kit.Select(name+"> ", m.Conf(SPARK, kit.Keym(kit.MDB_PROMPT, name)))
m.Echo(`<div class="story" data-type="spark" data-name="%s">`, name)
for _, l := range strings.Split(text, "\n") {
m.Echo("<div>")
@ -24,6 +24,10 @@ func _spark_show(m *ice.Message, name, text string, arg ...string) {
m.Echo("</div>")
}
const (
PROMPT = "prompt"
)
const SPARK = "spark"
func init() {
@ -42,7 +46,7 @@ func init() {
Configs: map[string]*ice.Config{
SPARK: {Name: SPARK, Help: "段落", Value: kit.Data(
kit.MDB_TEMPLATE, `<p {{.OptionTemplate}}>{{.Option "text"}}</p>`,
"prompt", kit.Dict("shell", "$ "),
kit.MDB_PROMPT, kit.Dict("shell", "$ "),
)},
},
})

View File

@ -7,9 +7,9 @@ import (
kit "github.com/shylinux/toolkits"
)
func _table_show(m *ice.Message, name, text string, arg ...string) {
func _table_show(m *ice.Message, text string, arg ...string) {
head, list := []string{}, [][]string{}
for i, v := range kit.Split(strings.TrimSpace(text), "\n") {
for i, v := range kit.Split(strings.TrimSpace(text), ice.MOD_NL) {
if v = strings.ReplaceAll(v, "%", "%%"); i == 0 {
head = kit.Split(v)
} else {
@ -35,8 +35,7 @@ func _table_show(m *ice.Message, name, text string, arg ...string) {
m.Optionv("head", head)
m.Optionv("list", list)
_option(m, TABLE, name, text, arg...)
m.RenderTemplate(m.Conf(TABLE, kit.Keym(kit.MDB_TEMPLATE)))
_wiki_template(m, ORDER, "", text, arg...)
}
const TABLE = "table"
@ -44,9 +43,8 @@ const TABLE = "table"
func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
TABLE: {Name: "table [name] `[item item\n]...`", Help: "表格", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
arg = _name(m, arg)
_table_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
TABLE: {Name: "table `[item item\n]...`", Help: "表格", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
_table_show(m, arg[0], arg[1:]...)
}},
},
Configs: map[string]*ice.Config{

View File

@ -1,8 +1,6 @@
package wiki
import (
"strings"
ice "github.com/shylinux/icebergs"
kit "github.com/shylinux/toolkits"
)
@ -10,12 +8,12 @@ import (
func _title_show(m *ice.Message, kind, text string, arg ...string) {
switch title, _ := m.Optionv(TITLE).(map[string]int); kind {
case PREMENU: // 前置目录
_option(m, kind, "", strings.TrimSpace(text), arg...)
_option(m, kind, "", "", arg...)
m.RenderTemplate(m.Conf(TITLE, kit.Keym(kind)))
return
case ENDMENU: // 后置目录
_option(m, kind, "", strings.TrimSpace(text), arg...)
_option(m, kind, "", "", arg...)
m.RenderTemplate(m.Conf(TITLE, kit.Keym(kind)))
return
@ -60,10 +58,14 @@ func init() {
ns := kit.Split(ice.Info.NodeName, "-")
arg = append(arg, ns[len(ns)-1])
}
if len(arg) == 1 {
arg = append(arg, "")
switch arg[0] {
case PREMENU, ENDMENU:
_title_show(m, arg[0], "", arg[1:]...)
case CHAPTER, SECTION:
_title_show(m, arg[0], arg[1], arg[2:]...)
default:
_title_show(m, "", arg[0], arg[1:]...)
}
_title_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
}},
},
Configs: map[string]*ice.Config{

View File

@ -2,20 +2,14 @@ package wiki
import (
"path"
"strings"
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/mdb"
kit "github.com/shylinux/toolkits"
)
func _video_show(m *ice.Message, name, text string, arg ...string) {
if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, "/") {
text = path.Join("/share/local", _wiki_path(m, FEEL, text))
}
_option(m, VIDEO, name, text, arg...)
m.RenderTemplate(m.Conf(VIDEO, kit.Keym(kit.MDB_TEMPLATE)))
func _video_show(m *ice.Message, text string, arg ...string) {
_wiki_template(m, VIDEO, "", _wiki_link(m, VIDEO, text), arg...)
}
const (
@ -29,18 +23,18 @@ const VIDEO = "video"
func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
VIDEO: {Name: "video [name] url", Help: "视频", Action: map[string]*ice.Action{
VIDEO: {Name: "video url", Help: "视频", Action: map[string]*ice.Action{
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
_video_show(m, arg[1], path.Join(arg[2], arg[1]))
_video_show(m, path.Join(arg[2], arg[1]))
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
arg = _name(m, arg)
_video_show(m, arg[0], arg[1], arg[2:]...)
_video_show(m, arg[0], arg[1:]...)
}},
},
Configs: map[string]*ice.Config{
VIDEO: {Name: "video", Help: "视频", Value: kit.Data(
kit.MDB_TEMPLATE, `<video {{.OptionTemplate}} title="{{.Option "text"}}" src="{{.Option "text"}}" controls></video>`,
kit.MDB_PATH, "usr/local/image",
)},
},
})

View File

@ -13,6 +13,12 @@ import (
func _wiki_path(m *ice.Message, cmd string, arg ...string) string {
return path.Join(m.Option(ice.MSG_LOCAL), m.Conf(cmd, kit.META_PATH), path.Join(arg...))
}
func _wiki_link(m *ice.Message, cmd string, text string) string {
if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, "/") {
text = path.Join("/share/local", _wiki_path(m, cmd, text))
}
return text
}
func _wiki_list(m *ice.Message, cmd string, arg ...string) bool {
m.Option(nfs.DIR_ROOT, _wiki_path(m, cmd))
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
@ -59,7 +65,9 @@ var Index = &ice.Context{Name: WIKI, Help: "文档中心",
func init() {
web.Index.Register(Index, &web.Frame{},
FEEL, WORD, DATA, DRAW, IMAGE, SPARK,
TITLE,
FEEL, WORD, DATA, DRAW,
TITLE, BRIEF,
IMAGE, SPARK,
)
}

View File

@ -1,16 +1,3 @@
title
title "hi"
premenu
chapter "文档"
section "文档"
endmenu
return
field "影音" web.wiki.feel
field "数据" web.wiki.data
field "文档" web.wiki.word
field "绘图" web.wiki.draw
title.go
brief.go
refer.go
@ -19,16 +6,13 @@ spark.go
order.go
table.go
chart.go
image.go
video.go
music.go
field.go
shell.go
local.go
parse.go
other.go
data.go
draw.go
@ -37,3 +21,9 @@ word.go
wiki.go
wiki.shy
field "影音" web.wiki.feel
field "数据" web.wiki.data
field "文档" web.wiki.word
field "绘图" web.wiki.draw