mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt wiki
This commit is contained in:
parent
fb5e13d687
commit
ad20ca96fc
@ -13,24 +13,30 @@ const CHAT = "chat"
|
|||||||
var Index = &ice.Context{Name: CHAT, Help: "聊天中心",
|
var Index = &ice.Context{Name: CHAT, 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.Cmd(web.SERVE, aaa.WHITE, HEADER, RIVER, ACTION, FOOTER)
|
||||||
m.Cmd(mdb.SEARCH, mdb.CREATE, P_SEARCH, m.Prefix(P_SEARCH))
|
m.Cmd(mdb.SEARCH, mdb.CREATE, P_SEARCH, m.Prefix(P_SEARCH))
|
||||||
m.Cmd(mdb.SEARCH, mdb.CREATE, EMAIL, m.Prefix(EMAIL))
|
m.Cmd(mdb.SEARCH, mdb.CREATE, EMAIL, m.Prefix(EMAIL))
|
||||||
|
m.Watch(web.SPACE_START, m.Prefix(NODE))
|
||||||
|
m.Watch(web.SPACE_STOP, m.Prefix(NODE))
|
||||||
m.Load()
|
m.Load()
|
||||||
m.Cmd(web.SERVE, aaa.WHITE, "header", "river", "action", "footer")
|
|
||||||
|
|
||||||
m.Conf(ACTION, "meta.domain.web.chat.meet.miss", "true")
|
for _, cmd := range []string{
|
||||||
m.Conf(ACTION, "meta.domain.web.chat.meet.mate", "true")
|
"web.chat.meet.miss",
|
||||||
m.Conf(ACTION, "meta.domain.web.chat.location", "true")
|
"web.chat.meet.mate",
|
||||||
m.Conf(ACTION, "meta.domain.web.chat.paste", "true")
|
"web.chat.location",
|
||||||
m.Conf(ACTION, "meta.domain.web.chat.scan", "true")
|
"web.chat.paste",
|
||||||
m.Conf(ACTION, "meta.domain.web.wiki.feel", "true")
|
"web.chat.scan",
|
||||||
m.Conf(ACTION, "meta.domain.web.wiki.draw", "true")
|
"web.wiki.feel",
|
||||||
m.Conf(ACTION, "meta.domain.web.wiki.data", "true")
|
"web.wiki.draw",
|
||||||
m.Conf(ACTION, "meta.domain.web.wiki.word", "true")
|
"web.wiki.data",
|
||||||
m.Conf(ACTION, "meta.domain.web.team.task", "true")
|
"web.wiki.word",
|
||||||
m.Conf(ACTION, "meta.domain.web.team.plan", "true")
|
"web.team.task",
|
||||||
m.Conf(ACTION, "meta.domain.web.mall.asset", "true")
|
"web.team.plan",
|
||||||
m.Conf(ACTION, "meta.domain.web.mall.salary", "true")
|
"web.mall.asset",
|
||||||
|
"web.mall.salary",
|
||||||
|
} {
|
||||||
|
m.Conf(ACTION, kit.Keym("domain", cmd), "true")
|
||||||
|
}
|
||||||
|
|
||||||
m.Conf(RIVER, "meta.template", kit.Dict(
|
m.Conf(RIVER, "meta.template", kit.Dict(
|
||||||
"base", kit.Dict(
|
"base", kit.Dict(
|
||||||
@ -62,8 +68,6 @@ var Index = &ice.Context{Name: CHAT, Help: "聊天中心",
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
m.Watch(web.SPACE_START, m.Prefix(NODE))
|
|
||||||
m.Watch(web.SPACE_STOP, m.Prefix(NODE))
|
|
||||||
}},
|
}},
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }},
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }},
|
||||||
},
|
},
|
||||||
@ -72,6 +76,6 @@ var Index = &ice.Context{Name: CHAT, Help: "聊天中心",
|
|||||||
func init() {
|
func init() {
|
||||||
web.Index.Register(Index, &web.Frame{},
|
web.Index.Register(Index, &web.Frame{},
|
||||||
HEADER, RIVER, STORM, ACTION, FOOTER,
|
HEADER, RIVER, STORM, ACTION, FOOTER,
|
||||||
LOCATION, PASTE, SCAN, FILES,
|
SCAN, PASTE, FILES, LOCATION,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,19 @@
|
|||||||
chapter "组织"
|
chapter "组织"
|
||||||
|
|
||||||
|
chat.go
|
||||||
|
chat.shy
|
||||||
|
|
||||||
|
header.go
|
||||||
|
search.go
|
||||||
|
river.go
|
||||||
|
action.go
|
||||||
|
footer.go
|
||||||
|
|
||||||
|
scan.go
|
||||||
|
paste.go
|
||||||
|
files.go
|
||||||
|
location.go
|
||||||
|
study.go
|
||||||
|
email.go
|
||||||
|
meet.go
|
||||||
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
package chat
|
|
||||||
|
|
||||||
import (
|
|
||||||
ice "github.com/shylinux/icebergs"
|
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
|
||||||
"github.com/shylinux/icebergs/base/web"
|
|
||||||
kit "github.com/shylinux/toolkits"
|
|
||||||
)
|
|
||||||
|
|
||||||
const FILES = "files"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
Index.Merge(&ice.Context{
|
|
||||||
Configs: map[string]*ice.Config{
|
|
||||||
FILES: {Name: FILES, Help: "文件", Value: kit.Data(kit.MDB_SHORT, "data")},
|
|
||||||
},
|
|
||||||
Commands: map[string]*ice.Command{
|
|
||||||
FILES: {Name: "files hash auto upload", Help: "扫码", Action: map[string]*ice.Action{
|
|
||||||
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
|
|
||||||
m.Cmdy(mdb.INSERT, FILES, "", mdb.HASH, "data", up[0], kit.MDB_NAME, up[1])
|
|
||||||
}},
|
|
||||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmdy(mdb.DELETE, FILES, "", mdb.HASH, kit.MDB_HASH, m.Option(kit.MDB_HASH))
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
m.Option(mdb.FIELDS, kit.Select("time,hash,name,data", mdb.DETAIL, len(arg) > 0))
|
|
||||||
m.Cmdy(mdb.SELECT, FILES, "", mdb.HASH, "hash", arg)
|
|
||||||
m.Table(func(index int, value map[string]string, head []string) {
|
|
||||||
m.PushDownload(value[kit.MDB_NAME], "/share/cache/"+value["data"])
|
|
||||||
})
|
|
||||||
if len(arg) == 0 {
|
|
||||||
m.SortTimeR(kit.MDB_TIME)
|
|
||||||
}
|
|
||||||
m.PushAction(mdb.REMOVE)
|
|
||||||
}},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
@ -3,7 +3,9 @@ package chat
|
|||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
|
"github.com/shylinux/icebergs/core/code"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -11,6 +13,8 @@ const (
|
|||||||
TITLE = "title"
|
TITLE = "title"
|
||||||
LOGIN = "login"
|
LOGIN = "login"
|
||||||
CHECK = "check"
|
CHECK = "check"
|
||||||
|
|
||||||
|
BACKGROUND = "background"
|
||||||
)
|
)
|
||||||
const HEADER = "header"
|
const HEADER = "header"
|
||||||
|
|
||||||
@ -46,18 +50,17 @@ func init() {
|
|||||||
aaa.USERROLE: {Name: "userrole", Help: "用户角色", Hand: func(m *ice.Message, arg ...string) {
|
aaa.USERROLE: {Name: "userrole", Help: "用户角色", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(aaa.UserRole(m, m.Option("who")))
|
m.Echo(aaa.UserRole(m, m.Option("who")))
|
||||||
}},
|
}},
|
||||||
|
BACKGROUND: {Name: "background", Help: "背景图片", Hand: func(m *ice.Message, arg ...string) {
|
||||||
"background": {Name: "background", Help: "背景图片", Hand: func(m *ice.Message, arg ...string) {
|
m.Option(BACKGROUND, m.Conf(HEADER, BACKGROUND, arg[0]))
|
||||||
m.Option("background", m.Conf(HEADER, "background", arg[0]))
|
|
||||||
}},
|
}},
|
||||||
"pack": {Name: "pack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
code.WEBPACK: {Name: "webpack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy("web.code.webpack", "create")
|
m.Cmdy(code.WEBPACK, mdb.CREATE)
|
||||||
}},
|
}},
|
||||||
"wx": {Name: "wx", Help: "微信", Hand: func(m *ice.Message, arg ...string) {
|
"wx": {Name: "wx", Help: "微信", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy("web.chat.wx.access", "config")
|
m.Cmdy("web.chat.wx.access", "config")
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option("background", m.Conf(HEADER, "background"))
|
m.Option(BACKGROUND, m.Conf(HEADER, BACKGROUND))
|
||||||
m.Echo(m.Conf(HEADER, TITLE))
|
m.Echo(m.Conf(HEADER, TITLE))
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
@ -17,7 +17,7 @@ func init() {
|
|||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
DRAW: {Name: "draw path=src/ file=main.svg 刷新:button=auto 编辑 save 项目 参数", Help: "思维导图", Meta: kit.Dict(
|
DRAW: {Name: "draw path=src/ file=main.svg 刷新:button=auto 编辑 save 项目 参数", Help: "思维导图", Meta: kit.Dict(
|
||||||
"display", "/plugin/local/wiki/draw.js", "style", "drawer",
|
"display", "/plugin/local/wiki/draw.js",
|
||||||
), Action: map[string]*ice.Action{
|
), Action: map[string]*ice.Action{
|
||||||
nfs.SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
nfs.SAVE: {Name: "save", 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("content"))
|
||||||
|
@ -9,18 +9,42 @@ var title = `<{{.Option "level"}} class="story"
|
|||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
data-type="{{.Option "type"}}"
|
data-type="{{.Option "type"}}"
|
||||||
>{{.Option "prefix"}} {{.Option "content"}}</{{.Option "level"}}>`
|
>{{.Option "prefix"}} {{.Option "content"}}</{{.Option "level"}}>`
|
||||||
|
|
||||||
var brief = `<p class="story"
|
var brief = `<p class="story"
|
||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
||||||
>{{.Option "text"}}</p>`
|
>{{.Option "text"}}</p>`
|
||||||
|
|
||||||
var refer = `<ul class="story"
|
var refer = `<ul class="story"
|
||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
||||||
{{range $index, $value := .Optionv "list"}}<li>{{index $value 0}}: <a href="{{index $value 1}}" target="_blank">{{index $value 1}}</a></li>{{end}}</ul>`
|
{{range $index, $value := .Optionv "list"}}<li>{{index $value 0}}: <a href="{{index $value 1}}" target="_blank">{{index $value 1}}</a></li>{{end}}</ul>`
|
||||||
var spark = `<p class="story {{.Option "style"}}" {{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}} data-type="{{.Option "type"}}" data-name="{{.Option "name"}}">{{.Option "text"}}</p>`
|
var spark = `<p class="story {{.Option "style"}}" {{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}} data-type="{{.Option "type"}}" data-name="{{.Option "name"}}">{{.Option "text"}}</p>`
|
||||||
|
|
||||||
|
var order = `<ul class="story"
|
||||||
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
||||||
|
{{range $index, $value := .Optionv "list"}}<li>{{$value}}</li>{{end}}</ul>`
|
||||||
|
var table = `<table class="story"
|
||||||
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
||||||
|
<tr>{{range $i, $v := .Optionv "head"}}<th>{{$v}}</th>{{end}}</tr>
|
||||||
|
{{range $index, $value := .Optionv "list"}}
|
||||||
|
<tr>{{range $i, $v := $value}}<td>{{$v}}</td>{{end}}</tr>
|
||||||
|
{{end}}
|
||||||
|
</table>`
|
||||||
|
var shell = `<code class="story"
|
||||||
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "input"}}"
|
||||||
|
>$ {{.Option "input"}} # {{.Option "name"}}
|
||||||
|
{{.Option "output"}}</code>`
|
||||||
|
var local = `<code class="story"
|
||||||
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
||||||
|
>{{range $index, $value := .Optionv "input"}}{{$value}}{{end}}</code>`
|
||||||
|
|
||||||
|
var image = `<img class="story"
|
||||||
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
||||||
|
title="{{.Option "text"}}" src="{{.Option "text"}}">`
|
||||||
var chart = `<svg class="story" vertion="1.1" xmlns="http://www.w3.org/2000/svg" dominant-baseline="middle" text-anchor="middle"
|
var chart = `<svg class="story" vertion="1.1" xmlns="http://www.w3.org/2000/svg" dominant-baseline="middle" text-anchor="middle"
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
||||||
width="{{.Option "width"}}" height="{{.Option "height"}}"
|
width="{{.Option "width"}}" height="{{.Option "height"}}"
|
||||||
@ -36,35 +60,7 @@ var field = `<fieldset class="story {{.Option "name"}}" data-type="{{.Option "ty
|
|||||||
<div class="status"></div>
|
<div class="status"></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
`
|
`
|
||||||
var shell = `<code class="story"
|
var other = ``
|
||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "input"}}"
|
|
||||||
>$ {{.Option "input"}} # {{.Option "name"}}
|
|
||||||
{{.Option "output"}}</code>
|
|
||||||
`
|
|
||||||
var local = `<code class="story"
|
|
||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
|
||||||
>{{range $index, $value := .Optionv "input"}}{{$value}}{{end}}</code>`
|
|
||||||
|
|
||||||
var order = `<ul class="story"
|
|
||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
|
||||||
{{range $index, $value := .Optionv "list"}}<li>{{$value}}</li>{{end}}</ul>`
|
|
||||||
|
|
||||||
var table = `<table class="story"
|
|
||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">
|
|
||||||
<tr>{{range $i, $v := .Optionv "head"}}<th>{{$v}}</th>{{end}}</tr>
|
|
||||||
{{range $index, $value := .Optionv "list"}}
|
|
||||||
<tr>{{range $i, $v := $value}}<td>{{$v}}</td>{{end}}</tr>
|
|
||||||
{{end}}
|
|
||||||
</table>`
|
|
||||||
|
|
||||||
var image = `<img class="story"
|
|
||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
|
||||||
data-type="{{.Option "type"}}" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}"
|
|
||||||
title="{{.Option "text"}}" src="{{.Option "text"}}">`
|
|
||||||
|
|
||||||
var video = `<video class="story"
|
var video = `<video class="story"
|
||||||
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
{{range $k, $v := .Optionv "extra"}}data-{{$k}}='{{$v}}'{{end}}
|
||||||
|
@ -2,7 +2,6 @@ package wiki
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
@ -53,11 +52,7 @@ 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.Cmd(mdb.SEARCH, mdb.CREATE, VIDEO, m.Prefix(VIDEO))
|
|
||||||
m.Cmd(mdb.SEARCH, mdb.CREATE, MUSIC, m.Prefix(MUSIC))
|
|
||||||
m.Load()
|
|
||||||
}},
|
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }},
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,15 @@ chapter "文档"
|
|||||||
wiki.go
|
wiki.go
|
||||||
wiki.shy
|
wiki.shy
|
||||||
|
|
||||||
baidu.go
|
|
||||||
music.go
|
|
||||||
video.go
|
|
||||||
|
|
||||||
chart.go
|
|
||||||
template.go
|
|
||||||
|
|
||||||
feel.go
|
feel.go
|
||||||
draw.go
|
draw.go
|
||||||
data.go
|
data.go
|
||||||
word.go
|
word.go
|
||||||
|
|
||||||
|
chart.go
|
||||||
|
template.go
|
||||||
|
|
||||||
|
baidu.go
|
||||||
|
music.go
|
||||||
|
video.go
|
||||||
|
|
||||||
|
@ -8,10 +8,7 @@ import (
|
|||||||
"github.com/shylinux/icebergs/base/ssh"
|
"github.com/shylinux/icebergs/base/ssh"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
"github.com/skip2/go-qrcode"
|
|
||||||
|
|
||||||
"bytes"
|
|
||||||
"encoding/base64"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
@ -114,6 +111,62 @@ func _spark_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(SPARK, "meta.template"))
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(SPARK, "meta.template"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.Render(ice.RENDER_TEMPLATE, m.Conf(ORDER, "meta.template"))
|
||||||
|
}
|
||||||
|
func _table_show(m *ice.Message, name, text string, arg ...string) {
|
||||||
|
head, list := []string{}, [][]string{}
|
||||||
|
for i, v := range kit.Split(strings.TrimSpace(text), "\n") {
|
||||||
|
if v = strings.ReplaceAll(v, "%", "%%"); i == 0 {
|
||||||
|
head = kit.Split(v)
|
||||||
|
} else {
|
||||||
|
line := kit.Split(v)
|
||||||
|
for i, v := range line {
|
||||||
|
if ls := kit.Split(v); len(ls) > 1 {
|
||||||
|
style := []string{}
|
||||||
|
for i := 1; i < len(ls)-1; i += 2 {
|
||||||
|
switch ls[i] {
|
||||||
|
case "bg":
|
||||||
|
ls[i] = "background-color"
|
||||||
|
case "fg":
|
||||||
|
ls[i] = "color"
|
||||||
|
}
|
||||||
|
style = append(style, ls[i]+":"+ls[i+1])
|
||||||
|
}
|
||||||
|
line[i] = kit.Format(`<span style="%s">%s</span>`, strings.Join(style, ";"), ls[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list = append(list, line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.Optionv("head", head)
|
||||||
|
m.Optionv("list", list)
|
||||||
|
|
||||||
|
_option(m, TABLE, name, text, arg...)
|
||||||
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(TABLE, "meta.template"))
|
||||||
|
}
|
||||||
|
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.Render(ice.RENDER_TEMPLATE, m.Conf(SHELL, "meta.template"))
|
||||||
|
}
|
||||||
|
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.Render(ice.RENDER_TEMPLATE, m.Conf(LOCAL, "meta.template"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func _image_show(m *ice.Message, name, text string, arg ...string) {
|
||||||
|
if name == "qrcode" {
|
||||||
|
m.EchoQRCode(text)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_option(m, IMAGE, name, text, arg...)
|
||||||
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(IMAGE, "meta.template"))
|
||||||
|
}
|
||||||
func _chart_show(m *ice.Message, kind, name, text string, arg ...string) {
|
func _chart_show(m *ice.Message, kind, name, text string, arg ...string) {
|
||||||
var chart Chart
|
var chart Chart
|
||||||
switch kind {
|
switch kind {
|
||||||
@ -221,60 +274,9 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
m.Option("meta", data)
|
m.Option("meta", data)
|
||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(FIELD, "meta.template"))
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(FIELD, "meta.template"))
|
||||||
}
|
}
|
||||||
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.Render(ice.RENDER_TEMPLATE, m.Conf(SHELL, "meta.template"))
|
|
||||||
}
|
|
||||||
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.Render(ice.RENDER_TEMPLATE, m.Conf(LOCAL, "meta.template"))
|
|
||||||
}
|
|
||||||
|
|
||||||
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.Render(ice.RENDER_TEMPLATE, m.Conf(ORDER, "meta.template"))
|
|
||||||
}
|
|
||||||
func _table_show(m *ice.Message, name, text string, arg ...string) {
|
|
||||||
head, list := []string{}, [][]string{}
|
|
||||||
for i, v := range kit.Split(strings.TrimSpace(text), "\n") {
|
|
||||||
if v = strings.ReplaceAll(v, "%", "%%"); i == 0 {
|
|
||||||
head = kit.Split(v)
|
|
||||||
} else {
|
|
||||||
line := kit.Split(v)
|
|
||||||
for i, v := range line {
|
|
||||||
if ls := kit.Split(v); len(ls) > 1 {
|
|
||||||
style := []string{}
|
|
||||||
for i := 1; i < len(ls)-1; i += 2 {
|
|
||||||
switch ls[i] {
|
|
||||||
case "bg":
|
|
||||||
ls[i] = "background-color"
|
|
||||||
case "fg":
|
|
||||||
ls[i] = "color"
|
|
||||||
}
|
|
||||||
style = append(style, ls[i]+":"+ls[i+1])
|
|
||||||
}
|
|
||||||
line[i] = kit.Format(`<span style="%s">%s</span>`, strings.Join(style, ";"), ls[0])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list = append(list, line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m.Optionv("head", head)
|
|
||||||
m.Optionv("list", list)
|
|
||||||
|
|
||||||
_option(m, TABLE, name, text, arg...)
|
|
||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(TABLE, "meta.template"))
|
|
||||||
}
|
|
||||||
func _image_show(m *ice.Message, name, text string, arg ...string) {
|
|
||||||
_option(m, IMAGE, name, text, arg...)
|
|
||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(IMAGE, "meta.template"))
|
|
||||||
}
|
|
||||||
func _other_show(m *ice.Message, name, text string, arg ...string) {
|
func _other_show(m *ice.Message, name, text string, arg ...string) {
|
||||||
_option(m, OTHER, name, text, arg...)
|
_option(m, OTHER, name, text, arg...)
|
||||||
// m.Cmdy(mdb.RENDER, web.RENDER.Frame, text)
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(OTHER, "meta.template"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func _word_show(m *ice.Message, name string, arg ...string) {
|
func _word_show(m *ice.Message, name string, arg ...string) {
|
||||||
@ -299,12 +301,13 @@ const (
|
|||||||
SHELL = "shell"
|
SHELL = "shell"
|
||||||
LOCAL = "local"
|
LOCAL = "local"
|
||||||
|
|
||||||
FIELD = "field"
|
|
||||||
IMAGE = "image"
|
IMAGE = "image"
|
||||||
CHART = "chart"
|
CHART = "chart"
|
||||||
PARSE = "parse"
|
FIELD = "field"
|
||||||
OTHER = "other"
|
OTHER = "other"
|
||||||
|
|
||||||
|
PARSE = "parse"
|
||||||
|
|
||||||
PREMENU = "premenu"
|
PREMENU = "premenu"
|
||||||
CHAPTER = "chapter"
|
CHAPTER = "chapter"
|
||||||
SECTION = "section"
|
SECTION = "section"
|
||||||
@ -322,18 +325,17 @@ func init() {
|
|||||||
TITLE: {Name: TITLE, Help: "标题", Value: kit.Data("template", title)},
|
TITLE: {Name: TITLE, Help: "标题", Value: kit.Data("template", title)},
|
||||||
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data("template", brief)},
|
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data("template", brief)},
|
||||||
REFER: {Name: REFER, Help: "参考", Value: kit.Data("template", refer)},
|
REFER: {Name: REFER, Help: "参考", Value: kit.Data("template", refer)},
|
||||||
SPARK: {Name: SPARK, Help: "段落", Value: kit.Data("template", spark,
|
SPARK: {Name: SPARK, Help: "段落", Value: kit.Data("template", spark, "prompt", kit.Dict("shell", "$ "))},
|
||||||
"prompt", kit.Dict("shell", "$ "),
|
|
||||||
)},
|
|
||||||
|
|
||||||
ORDER: {Name: ORDER, Help: "列表", Value: kit.Data("template", order)},
|
ORDER: {Name: ORDER, Help: "列表", Value: kit.Data("template", order)},
|
||||||
TABLE: {Name: TABLE, Help: "表格", Value: kit.Data("template", table)},
|
TABLE: {Name: TABLE, Help: "表格", Value: kit.Data("template", table)},
|
||||||
SHELL: {Name: SHELL, Help: "命令", Value: kit.Data("template", shell)},
|
SHELL: {Name: SHELL, Help: "命令", Value: kit.Data("template", shell)},
|
||||||
LOCAL: {Name: LOCAL, Help: "文件", Value: kit.Data("template", local)},
|
LOCAL: {Name: LOCAL, Help: "文件", Value: kit.Data("template", local)},
|
||||||
|
|
||||||
FIELD: {Name: FIELD, Help: "插件", Value: kit.Data("template", field)},
|
|
||||||
CHART: {Name: CHART, Help: "图表", Value: kit.Data("template", chart, "suffix", `</svg>`)},
|
|
||||||
IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data("template", image)},
|
IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data("template", image)},
|
||||||
|
CHART: {Name: CHART, Help: "图表", Value: kit.Data("template", chart, "suffix", `</svg>`)},
|
||||||
|
FIELD: {Name: FIELD, Help: "插件", Value: kit.Data("template", field)},
|
||||||
|
OTHER: {Name: FIELD, Help: "网页", Value: kit.Data("template", other)},
|
||||||
|
|
||||||
WORD: {Name: WORD, Help: "语言文字", Value: kit.Data(
|
WORD: {Name: WORD, Help: "语言文字", Value: kit.Data(
|
||||||
kit.MDB_PATH, "", "regs", ".*\\.shy", "alias", map[string]interface{}{
|
kit.MDB_PATH, "", "regs", ".*\\.shy", "alias", map[string]interface{}{
|
||||||
@ -359,11 +361,6 @@ func init() {
|
|||||||
_title_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
_title_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
}},
|
}},
|
||||||
BRIEF: {Name: "brief [name] text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
BRIEF: {Name: "brief [name] text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
|
||||||
m.Echo(`<br class="story" data-type="brief">`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
arg = _name(m, arg)
|
arg = _name(m, arg)
|
||||||
_brief_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
_brief_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
}},
|
}},
|
||||||
@ -371,7 +368,7 @@ func init() {
|
|||||||
arg = _name(m, arg)
|
arg = _name(m, arg)
|
||||||
_refer_show(m, arg[0], arg[1], arg[2:]...)
|
_refer_show(m, arg[0], arg[1], arg[2:]...)
|
||||||
}},
|
}},
|
||||||
SPARK: {Name: "spark [name] text", Help: "灵感", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SPARK: {Name: "spark [name] text", Help: "段落", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
m.Echo(`<br class="story" data-type="spark">`)
|
m.Echo(`<br class="story" data-type="spark">`)
|
||||||
return
|
return
|
||||||
@ -386,11 +383,6 @@ func init() {
|
|||||||
_order_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
_order_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
}},
|
}},
|
||||||
TABLE: {Name: "table [name] `[item item\n]...`", Help: "表格", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
TABLE: {Name: "table [name] `[item item\n]...`", Help: "表格", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if arg[0] == "cmd" {
|
|
||||||
msg := m.Cmd(kit.Split(arg[1])).Table()
|
|
||||||
arg[1] = msg.Result()
|
|
||||||
}
|
|
||||||
|
|
||||||
arg = _name(m, arg)
|
arg = _name(m, arg)
|
||||||
_table_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
_table_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
}},
|
}},
|
||||||
@ -403,25 +395,7 @@ func init() {
|
|||||||
_local_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
_local_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
FIELD: {Name: "field [name] cmd", Help: "插件", Action: map[string]*ice.Action{
|
|
||||||
"run": {Name: "run", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if !m.Warn(!m.Right(arg[1:]), ice.ErrNotRight, arg[1:]) {
|
|
||||||
m.Cmdy(arg[1:])
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
}, 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:]...)
|
|
||||||
}},
|
|
||||||
IMAGE: {Name: "image [name] url", Help: "图片", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
IMAGE: {Name: "image [name] url", Help: "图片", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if arg[0] == "qrcode" {
|
|
||||||
buf := bytes.NewBuffer(make([]byte, 0, 4096))
|
|
||||||
if qr, e := qrcode.New(arg[1], qrcode.Medium); m.Assert(e) {
|
|
||||||
m.Assert(qr.Write(kit.Int(kit.Select("256")), buf))
|
|
||||||
}
|
|
||||||
arg[1] = "data:image/png;base64," + base64.StdEncoding.EncodeToString(buf.Bytes())
|
|
||||||
}
|
|
||||||
|
|
||||||
arg = _name(m, arg)
|
arg = _name(m, arg)
|
||||||
_image_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
_image_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
m.Render("")
|
m.Render("")
|
||||||
@ -432,6 +406,21 @@ func init() {
|
|||||||
}
|
}
|
||||||
_chart_show(m, arg[0], arg[1], arg[2], arg[3:]...)
|
_chart_show(m, arg[0], arg[1], arg[2], arg[3:]...)
|
||||||
}},
|
}},
|
||||||
|
FIELD: {Name: "field [name] cmd", Help: "插件", Action: map[string]*ice.Action{
|
||||||
|
"run": {Name: "run", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if !m.Warn(!m.Right(arg[1:]), ice.ErrNotRight, arg[1:]) {
|
||||||
|
m.Cmdy(arg[1:])
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
}, 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:]...)
|
||||||
|
}},
|
||||||
|
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:]...)
|
||||||
|
}},
|
||||||
|
|
||||||
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) {
|
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 arg[0] == "auto" && (strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[")) {
|
if arg[0] == "auto" && (strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[")) {
|
||||||
arg[0] = "json"
|
arg[0] = "json"
|
||||||
@ -469,10 +458,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
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:]...)
|
|
||||||
}},
|
|
||||||
|
|
||||||
WORD: {Name: "word path=src/main.shy auto 演示", Help: "语言文字", Meta: kit.Dict(
|
WORD: {Name: "word path=src/main.shy auto 演示", Help: "语言文字", Meta: kit.Dict(
|
||||||
"display", "/plugin/local/wiki/word.js", "style", "word",
|
"display", "/plugin/local/wiki/word.js", "style", "word",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user