mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt feel
This commit is contained in:
parent
4dc9a40470
commit
ed97853635
1
conf.go
1
conf.go
@ -24,6 +24,7 @@ const ( // DIR
|
|||||||
USR_VOLCANOS = "usr/volcanos"
|
USR_VOLCANOS = "usr/volcanos"
|
||||||
USR_INTSHELL = "usr/intshell"
|
USR_INTSHELL = "usr/intshell"
|
||||||
USR_PUBLISH = "usr/publish"
|
USR_PUBLISH = "usr/publish"
|
||||||
|
USR_LOCAL = "usr/local"
|
||||||
|
|
||||||
PROTO_JS = "proto.js"
|
PROTO_JS = "proto.js"
|
||||||
FRAME_JS = "frame.js"
|
FRAME_JS = "frame.js"
|
||||||
|
@ -15,7 +15,7 @@ const DATA = "data"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(kit.MDB_PATH, "usr/local/export", "regs", ".*\\.csv")},
|
DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(kit.MDB_PATH, "usr/local/export", kit.MDB_REGEXP, ".*\\.csv")},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(
|
DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(
|
||||||
|
@ -13,7 +13,7 @@ const DRAW = "draw"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(kit.MDB_PATH, "", "regs", ".*\\.svg")},
|
DRAW: {Name: DRAW, Help: "思维导图", Value: kit.Data(kit.MDB_PATH, "", kit.MDB_REGEXP, ".*\\.svg")},
|
||||||
},
|
},
|
||||||
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(
|
||||||
|
@ -12,7 +12,7 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(
|
FEEL: {Name: FEEL, Help: "影音媒体", Value: kit.Data(
|
||||||
kit.MDB_PATH, "usr/local/image", "regs", ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)",
|
kit.MDB_PATH, "usr/local/image", kit.MDB_REGEXP, ".*.(png|PNG|jpg|JPG|jpeg|mp4|m4v|MOV)",
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
@ -23,8 +23,7 @@ func init() {
|
|||||||
_wiki_upload(m, FEEL, m.Option(kit.MDB_PATH))
|
_wiki_upload(m, FEEL, m.Option(kit.MDB_PATH))
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if !_wiki_list(m, FEEL, kit.Select("./", arg, 0)) {
|
_wiki_list(m, FEEL, kit.Select("./", arg, 0))
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
49
core/wiki/image.go
Normal file
49
core/wiki/image.go
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package wiki
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
kit "github.com/shylinux/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
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"}}">`
|
||||||
|
|
||||||
|
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.Render(ice.RENDER_TEMPLATE, m.Conf(IMAGE, kit.Keym(kit.MDB_TEMPLATE)))
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
PNG = "png"
|
||||||
|
JPG = "jpg"
|
||||||
|
JPEG = "jpeg"
|
||||||
|
)
|
||||||
|
const IMAGE = "image"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.Merge(&ice.Context{
|
||||||
|
Configs: map[string]*ice.Config{
|
||||||
|
IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data(kit.MDB_TEMPLATE, image)},
|
||||||
|
},
|
||||||
|
Commands: map[string]*ice.Command{
|
||||||
|
IMAGE: {Name: "image [name] 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]))
|
||||||
|
}},
|
||||||
|
}, 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:]...)
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
@ -41,10 +41,6 @@ var local = `<code class="story"
|
|||||||
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 "input"}}{{$value}}{{end}}</code>`
|
>{{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"}}"
|
||||||
@ -61,8 +57,3 @@ var field = `<fieldset class="story {{.Option "name"}}" data-type="{{.Option "ty
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
`
|
`
|
||||||
var other = ``
|
var other = ``
|
||||||
|
|
||||||
var video = `<video 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"}}" controls></video>`
|
|
||||||
|
@ -1,41 +1,49 @@
|
|||||||
package wiki
|
package wiki
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var video = `<video 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"}}" controls></video>`
|
||||||
|
|
||||||
func _video_show(m *ice.Message, name, text string, arg ...string) {
|
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...)
|
_option(m, VIDEO, name, text, arg...)
|
||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(VIDEO, kit.Keym(kit.MDB_TEMPLATE)))
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(VIDEO, kit.Keym(kit.MDB_TEMPLATE)))
|
||||||
}
|
}
|
||||||
func _video_search(m *ice.Message, kind, name, text string) {
|
|
||||||
if kit.Contains(kind, "*") || kit.Contains(kind, VIDEO) {
|
const (
|
||||||
m.PushSearchWeb(VIDEO, name)
|
mp4 = "mp4"
|
||||||
}
|
m4v = "m4v"
|
||||||
}
|
MOV = "mov"
|
||||||
|
)
|
||||||
|
|
||||||
const VIDEO = "video"
|
const VIDEO = "video"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
VIDEO: {Name: "video", Help: "视频", Value: kit.Data(
|
VIDEO: {Name: "video", Help: "视频", Value: kit.Data(kit.MDB_TEMPLATE, video)},
|
||||||
kit.MDB_SHORT, kit.MDB_TEXT, kit.MDB_TEMPLATE, video,
|
|
||||||
)},
|
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
VIDEO: {Name: "video [name] url", Help: "视频", Action: map[string]*ice.Action{
|
VIDEO: {Name: "video [name] url", Help: "视频", Action: map[string]*ice.Action{
|
||||||
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_video_search(m, arg[0], arg[1], arg[2])
|
_video_show(m, arg[1], path.Join(arg[2], arg[1]))
|
||||||
}},
|
|
||||||
mdb.CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmd(mdb.INSERT, m.Prefix(VIDEO), "", mdb.HASH, arg)
|
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
arg = _name(m, arg)
|
arg = _name(m, arg)
|
||||||
_video_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
_video_show(m, arg[0], arg[1], arg[2:]...)
|
||||||
}},
|
}},
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ func _wiki_path(m *ice.Message, cmd string, arg ...string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func _wiki_list(m *ice.Message, cmd string, arg ...string) bool {
|
func _wiki_list(m *ice.Message, cmd string, arg ...string) bool {
|
||||||
m.Option("prefix", m.Option(nfs.DIR_ROOT, _wiki_path(m, cmd)))
|
m.Option(nfs.DIR_ROOT, _wiki_path(m, cmd))
|
||||||
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
||||||
if m.Option(nfs.DIR_DEEP) != "true" {
|
if m.Option(nfs.DIR_DEEP) != "true" {
|
||||||
// 目录列表
|
// 目录列表
|
||||||
@ -26,7 +26,6 @@ func _wiki_list(m *ice.Message, cmd string, arg ...string) bool {
|
|||||||
|
|
||||||
// 文件列表
|
// 文件列表
|
||||||
m.Option(nfs.DIR_TYPE, nfs.CAT)
|
m.Option(nfs.DIR_TYPE, nfs.CAT)
|
||||||
m.Option(nfs.DIR_REG, m.Conf(cmd, "meta.regs"))
|
|
||||||
m.Cmdy(nfs.DIR, kit.Select("./", arg, 0), "time,size,path")
|
m.Cmdy(nfs.DIR, kit.Select("./", arg, 0), "time,size,path")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -43,9 +42,12 @@ func _wiki_save(m *ice.Message, cmd, name, text string, arg ...string) {
|
|||||||
func _wiki_upload(m *ice.Message, cmd string, dir string) {
|
func _wiki_upload(m *ice.Message, cmd string, dir string) {
|
||||||
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
|
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
|
||||||
if p := _wiki_path(m, cmd, dir, up[1]); m.Option(ice.MSG_USERPOD) == "" {
|
if p := _wiki_path(m, cmd, dir, up[1]); m.Option(ice.MSG_USERPOD) == "" {
|
||||||
|
// 本机文件
|
||||||
m.Cmdy(web.CACHE, web.WATCH, up[0], p)
|
m.Cmdy(web.CACHE, web.WATCH, up[0], p)
|
||||||
} else {
|
} else {
|
||||||
m.Cmdy(web.SPIDE, web.SPIDE_DEV, web.SPIDE_SAVE, p, web.SPIDE_GET, kit.MergeURL2(m.Option(ice.MSG_USERWEB), "/share/cache/"+up[0]))
|
// 下发文件
|
||||||
|
m.Cmdy(web.SPIDE, web.SPIDE_DEV, web.SPIDE_SAVE, p, web.SPIDE_GET,
|
||||||
|
kit.MergeURL2(m.Option(ice.MSG_USERWEB), path.Join("/share/cache", up[0])))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,10 +56,12 @@ 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.Cmd(mdb.RENDER, mdb.CREATE, "png", m.Prefix(IMAGE))
|
m.Cmd(mdb.RENDER, mdb.CREATE, PNG, m.Prefix(IMAGE))
|
||||||
m.Load()
|
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()
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,18 +158,6 @@ func _local_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(LOCAL, kit.Keym(kit.MDB_TEMPLATE)))
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(LOCAL, kit.Keym(kit.MDB_TEMPLATE)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func _image_show(m *ice.Message, name, text string, arg ...string) {
|
|
||||||
if name == "qrcode" {
|
|
||||||
m.EchoQRCode(text)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !strings.HasPrefix(text, "http") && !strings.HasPrefix(text, "/") {
|
|
||||||
text = "/share/local/usr/local/image/" + text
|
|
||||||
}
|
|
||||||
|
|
||||||
_option(m, IMAGE, name, text, arg...)
|
|
||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(IMAGE, kit.Keym(kit.MDB_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 {
|
||||||
@ -304,7 +292,6 @@ const (
|
|||||||
SHELL = "shell"
|
SHELL = "shell"
|
||||||
LOCAL = "local"
|
LOCAL = "local"
|
||||||
|
|
||||||
IMAGE = "image"
|
|
||||||
CHART = "chart"
|
CHART = "chart"
|
||||||
FIELD = "field"
|
FIELD = "field"
|
||||||
OTHER = "other"
|
OTHER = "other"
|
||||||
@ -335,13 +322,12 @@ func init() {
|
|||||||
SHELL: {Name: SHELL, Help: "命令", Value: kit.Data(kit.MDB_TEMPLATE, shell)},
|
SHELL: {Name: SHELL, Help: "命令", Value: kit.Data(kit.MDB_TEMPLATE, shell)},
|
||||||
LOCAL: {Name: LOCAL, Help: "文件", Value: kit.Data(kit.MDB_TEMPLATE, local)},
|
LOCAL: {Name: LOCAL, Help: "文件", Value: kit.Data(kit.MDB_TEMPLATE, local)},
|
||||||
|
|
||||||
IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data(kit.MDB_TEMPLATE, image)},
|
|
||||||
CHART: {Name: CHART, Help: "图表", Value: kit.Data(kit.MDB_TEMPLATE, chart, "suffix", `</svg>`)},
|
CHART: {Name: CHART, Help: "图表", Value: kit.Data(kit.MDB_TEMPLATE, chart, "suffix", `</svg>`)},
|
||||||
FIELD: {Name: FIELD, Help: "插件", Value: kit.Data(kit.MDB_TEMPLATE, field)},
|
FIELD: {Name: FIELD, Help: "插件", Value: kit.Data(kit.MDB_TEMPLATE, field)},
|
||||||
OTHER: {Name: FIELD, Help: "网页", Value: kit.Data(kit.MDB_TEMPLATE, other)},
|
OTHER: {Name: FIELD, Help: "网页", Value: kit.Data(kit.MDB_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, "", kit.MDB_REGEXP, ".*\\.shy", "alias", map[string]interface{}{
|
||||||
PREMENU: []interface{}{TITLE, PREMENU},
|
PREMENU: []interface{}{TITLE, PREMENU},
|
||||||
CHAPTER: []interface{}{TITLE, CHAPTER},
|
CHAPTER: []interface{}{TITLE, CHAPTER},
|
||||||
SECTION: []interface{}{TITLE, SECTION},
|
SECTION: []interface{}{TITLE, SECTION},
|
||||||
@ -398,15 +384,6 @@ 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:]...)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
IMAGE: {Name: "image [name] url", Help: "图片", Action: map[string]*ice.Action{
|
|
||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
_image_show(m, arg[1], 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], kit.Select(arg[0], arg[1]), arg[2:]...)
|
|
||||||
m.Render("")
|
|
||||||
}},
|
|
||||||
CHART: {Name: "chart label|chain [name] text", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
CHART: {Name: "chart label|chain [name] text", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 2 {
|
if len(arg) == 2 {
|
||||||
arg = []string{arg[0], "", arg[1]}
|
arg = []string{arg[0], "", arg[1]}
|
||||||
|
2
go.sum
2
go.sum
@ -1,9 +1,11 @@
|
|||||||
github.com/AaronO/go-git-http v0.0.0-20161214145340-1d9485b3a98f/go.mod h1:+6Yuq73F9068Na+mSBNXCvyuxvgw4f/g5ii40e3U8Sc=
|
github.com/AaronO/go-git-http v0.0.0-20161214145340-1d9485b3a98f/go.mod h1:+6Yuq73F9068Na+mSBNXCvyuxvgw4f/g5ii40e3U8Sc=
|
||||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII=
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII=
|
||||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
|
||||||
|
github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A=
|
||||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/kr/pty v1.1.8 h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI=
|
||||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||||
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
||||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
|
13
misc.go
13
misc.go
@ -110,12 +110,15 @@ func (m *Message) PushSearchWeb(cmd string, name string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) IsTermUA() bool {
|
func (m *Message) IsCliUA() bool {
|
||||||
return m.Option(MSG_USERUA) == "" || strings.Contains(m.Option(MSG_USERUA), "curl")
|
if m.Option(MSG_USERUA) == "" || !strings.HasPrefix(m.Option(MSG_USERUA), "Mozilla/5.0") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func Render(m *Message, cmd string, args ...interface{}) string {
|
func Render(m *Message, cmd string, args ...interface{}) string {
|
||||||
if m.IsTermUA() {
|
if m.IsCliUA() {
|
||||||
switch arg := kit.Simple(args...); cmd {
|
switch arg := kit.Simple(args...); cmd {
|
||||||
case RENDER_QRCODE: // text [size]
|
case RENDER_QRCODE: // text [size]
|
||||||
return m.Cmdx("cli.qrcode", arg[0])
|
return m.Cmdx("cli.qrcode", arg[0])
|
||||||
@ -186,13 +189,13 @@ func (m *Message) PushDownload(key string, arg ...interface{}) { // [name] file
|
|||||||
m.Push(key, Render(m, RENDER_DOWNLOAD, arg...))
|
m.Push(key, Render(m, RENDER_DOWNLOAD, arg...))
|
||||||
}
|
}
|
||||||
func (m *Message) PushAnchor(arg ...interface{}) { // [name] link
|
func (m *Message) PushAnchor(arg ...interface{}) { // [name] link
|
||||||
if m.IsTermUA() {
|
if m.IsCliUA() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Push(kit.MDB_LINK, Render(m, RENDER_ANCHOR, arg...))
|
m.Push(kit.MDB_LINK, Render(m, RENDER_ANCHOR, arg...))
|
||||||
}
|
}
|
||||||
func (m *Message) PushButton(arg ...string) {
|
func (m *Message) PushButton(arg ...string) {
|
||||||
if m.IsTermUA() {
|
if m.IsCliUA() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Push(kit.MDB_ACTION, Render(m, RENDER_BUTTON, strings.Join(arg, ",")))
|
m.Push(kit.MDB_ACTION, Render(m, RENDER_BUTTON, strings.Join(arg, ",")))
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
qrcode hi
|
||||||
|
image `qrcode_for_gh_1c21ed4eb46b_258.jpg`
|
||||||
|
video `shg_1137499128_1047_36a6fc44db4a4100b7087e98c89bvide_f30.mp4`
|
||||||
|
field feel
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
title "微信公众号"
|
title "微信公众号"
|
||||||
refer `
|
refer `
|
||||||
官网 https://weixin.qq.com/
|
官网 https://weixin.qq.com/
|
||||||
@ -5,7 +12,6 @@ refer `
|
|||||||
文档 https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html
|
文档 https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html
|
||||||
源码 https://github.com/shylinux/icebergs/blob/master/misc/wx/wx.go
|
源码 https://github.com/shylinux/icebergs/blob/master/misc/wx/wx.go
|
||||||
`
|
`
|
||||||
image `qrcode_for_gh_1c21ed4eb46b_258.jpg`
|
|
||||||
|
|
||||||
chapter "应用"
|
chapter "应用"
|
||||||
field scan web.chat.scan
|
field scan web.chat.scan
|
||||||
|
Loading…
x
Reference in New Issue
Block a user