forked from x/icebergs
opt WEB_STORY
This commit is contained in:
parent
5f36ef2b0f
commit
762c9becb2
@ -96,7 +96,8 @@ var Index = &ice.Context{Name: "mdb", Help: "数据模块",
|
||||
})
|
||||
}
|
||||
}},
|
||||
ice.MDB_IMPORT: {Name: "import", Help: "导入数据", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
|
||||
ice.MDB_IMPORT: {Name: "import conf key type file", Help: "导入数据", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
msg := m.Cmd(ice.WEB_STORY, "index", arg[3])
|
||||
|
||||
switch arg[2] {
|
||||
@ -107,6 +108,7 @@ var Index = &ice.Context{Name: "mdb", Help: "数据模块",
|
||||
r := csv.NewReader(buf)
|
||||
if msg.Append("file") != "" {
|
||||
if f, e := os.Open(msg.Append("file")); m.Assert(e) {
|
||||
// 导入文件
|
||||
r = csv.NewReader(f)
|
||||
}
|
||||
}
|
||||
@ -122,8 +124,9 @@ var Index = &ice.Context{Name: "mdb", Help: "数据模块",
|
||||
for i, k := range head {
|
||||
data[k] = line[i]
|
||||
}
|
||||
m.Grow(arg[0], arg[1], data)
|
||||
m.Info("import %v", data)
|
||||
// 导入数据
|
||||
n := m.Grow(arg[0], arg[1], data)
|
||||
m.Log(ice.LOG_INSERT, "index: %d value: %v", n, data)
|
||||
}
|
||||
|
||||
case kit.MDB_HASH:
|
||||
@ -131,11 +134,11 @@ var Index = &ice.Context{Name: "mdb", Help: "数据模块",
|
||||
m.Assert(json.Unmarshal([]byte(msg.Append("text")), &data))
|
||||
for k, v := range data {
|
||||
m.Conf(arg[0], kit.Keys(arg[1], k), v)
|
||||
m.Info("import %v", v)
|
||||
m.Log(ice.LOG_MODIFY, "%s: %s", k, v)
|
||||
}
|
||||
}
|
||||
}},
|
||||
ice.MDB_EXPORT: {Name: "export conf key list|hash", Help: "导出数据", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
ice.MDB_EXPORT: {Name: "export conf key type name", Help: "导出数据", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
name := kit.Select(kit.Select(arg[0], arg[0]+":"+arg[1], arg[1] != ""), arg, 3)
|
||||
|
||||
switch arg[2] {
|
||||
@ -170,6 +173,17 @@ var Index = &ice.Context{Name: "mdb", Help: "数据模块",
|
||||
m.Cmdy(ice.WEB_STORY, "add", "json", name, kit.Formats(m.Confv(arg[0], arg[1])))
|
||||
}
|
||||
}},
|
||||
ice.MDB_DELETE: {Name: "delete conf key type", Help: "删除", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
switch arg[2] {
|
||||
case kit.MDB_DICT:
|
||||
m.Log(ice.LOG_DELETE, "%s: %s", arg[1], m.Conf(arg[0], arg[1]))
|
||||
m.Echo("%s", m.Conf(arg[0], arg[1]))
|
||||
m.Conf(arg[0], arg[1], "")
|
||||
case kit.MDB_META:
|
||||
case kit.MDB_LIST:
|
||||
case kit.MDB_HASH:
|
||||
}
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,6 @@ func (f *Frame) Spawn(m *ice.Message, c *ice.Context, arg ...string) ice.Server
|
||||
return &Frame{}
|
||||
}
|
||||
func (f *Frame) Begin(m *ice.Message, arg ...string) ice.Server {
|
||||
m.Target().Configs["history"] = &ice.Config{Name: "history", Help: "历史", Value: kit.Data()}
|
||||
return f
|
||||
}
|
||||
func (f *Frame) Start(m *ice.Message, arg ...string) bool {
|
||||
|
@ -5,26 +5,16 @@ import (
|
||||
)
|
||||
|
||||
var share_template = kit.Dict(
|
||||
"story.prefix", `<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
`, "story.suffix", `</body>`,
|
||||
|
||||
"download", `<a href="/code/zsh?cmd=download&arg=%s" target="_blank">%s</a>`,
|
||||
"share", `<a href="/share/%s" target="_blank">%s</a>`,
|
||||
"shy/story", `{{.}}`,
|
||||
"shy/chain", `<!DOCTYPE html>
|
||||
"qrcode", `<img src="/share/%s/qrcode">`,
|
||||
|
||||
"simple", `<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" text="text/css" href="/style.css">
|
||||
<meta charset='utf-8'>
|
||||
<title>{{.Option "name"}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<fieldset>
|
||||
{{.Append "type"}}
|
||||
{{.Append "text"}}
|
||||
</fieldset>
|
||||
{{.Option "text"}}
|
||||
</body>
|
||||
`,
|
||||
)
|
||||
|
683
base/web/web.go
683
base/web/web.go
File diff suppressed because it is too large
Load Diff
6
conf.go
6
conf.go
@ -168,8 +168,11 @@ const ( // CHAT
|
||||
const ( // TYPE
|
||||
TYPE_SPACE = "space"
|
||||
TYPE_STORY = "story"
|
||||
|
||||
TYPE_RIVER = "river"
|
||||
TYPE_STORM = "storm"
|
||||
TYPE_ACTION = "action"
|
||||
TYPE_ACTIVE = "active"
|
||||
|
||||
TYPE_DRIVE = "drive"
|
||||
TYPE_SHELL = "shell"
|
||||
@ -185,7 +188,10 @@ const ( // FAVOR
|
||||
)
|
||||
const ( // STORY
|
||||
STORY_CATCH = "catch"
|
||||
STORY_INDEX = "index"
|
||||
STORY_TRASH = "trash"
|
||||
STORY_WATCH = "watch"
|
||||
|
||||
STORY_STATUS = "status"
|
||||
STORY_COMMIT = "commit"
|
||||
STORY_BRANCH = "branch"
|
||||
|
@ -10,21 +10,13 @@ import (
|
||||
var Index = &ice.Context{Name: "chrome", Help: "浏览器",
|
||||
Caches: map[string]*ice.Cache{},
|
||||
Configs: map[string]*ice.Config{
|
||||
"chrome": {Name: "chrome", Help: "chrome", Value: kit.Data(kit.MDB_SHORT, "name")},
|
||||
"history": {Name: "history", Help: "history", Value: kit.Data(kit.MDB_SHORT, "name")},
|
||||
"chrome": {Name: "chrome", Help: "chrome", Value: kit.Data(kit.MDB_SHORT, "name", "history", "url.history")},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Load()
|
||||
}},
|
||||
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Save("history")
|
||||
}},
|
||||
|
||||
"/crx": {Name: "/crx", Help: "/crx", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
switch arg[0] {
|
||||
case "history":
|
||||
m.Cmdy("history", arg[1:])
|
||||
m.Cmdy(ice.WEB_FAVOR, m.Conf("chrome", "meta.history"), "spide", arg[3], arg[2])
|
||||
}
|
||||
}},
|
||||
"chrome": {Name: "chrome", Help: "浏览器", List: kit.List(
|
||||
@ -70,18 +62,6 @@ var Index = &ice.Context{Name: "chrome", Help: "浏览器",
|
||||
// 下发命令
|
||||
m.Cmdy(ice.WEB_SPACE, arg[0], "cookie", arg[1:])
|
||||
}},
|
||||
"history": {Name: "history id url title", Help: "历史", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
// 查看记录
|
||||
m.Grows("history", nil, "", "", func(index int, value map[string]interface{}) {
|
||||
m.Push("", value)
|
||||
})
|
||||
m.Sort("id", "int_r")
|
||||
return
|
||||
}
|
||||
// 添加记录
|
||||
m.Grow("history", nil, kit.Dict("hid", arg[0], "url", arg[1], "title", arg[2]))
|
||||
}},
|
||||
"bookmark": {Name: "bookmark", Help: "书签", List: kit.List(
|
||||
kit.MDB_INPUT, "text", "name", "name", "action", "auto",
|
||||
kit.MDB_INPUT, "text", "name", "id", "action", "auto",
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
var Index = &ice.Context{Name: "vim", Help: "编辑器",
|
||||
Caches: map[string]*ice.Cache{},
|
||||
Configs: map[string]*ice.Config{
|
||||
"vim": {Name: "vim", Help: "编辑器", Value: kit.Data(kit.MDB_SHORT, "name")},
|
||||
"vim": {Name: "vim", Help: "编辑器", Value: kit.Data(kit.MDB_SHORT, "name", "history", "vim.history")},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.WEB_LOGIN: {Name: "_login", Help: "_login", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
@ -47,7 +47,7 @@ var Index = &ice.Context{Name: "vim", Help: "编辑器",
|
||||
"/sync": {Name: "/sync", Help: "同步", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
switch arg[0] {
|
||||
case "read", "write", "exec", "insert":
|
||||
m.Cmd(ice.WEB_FAVOR, "vim.history", "vimrc", arg[0], kit.Select(m.Option("arg"), m.Option("sub")),
|
||||
m.Cmd(ice.WEB_FAVOR, m.Conf("vim", "meta.history"), "vimrc", arg[0], kit.Select(m.Option("arg"), m.Option("sub")),
|
||||
"sid", m.Option("sid"), "pwd", m.Option("pwd"), "buf", m.Option("buf"), "row", m.Option("row"), "col", m.Option("col"))
|
||||
|
||||
default:
|
||||
|
@ -70,6 +70,7 @@ ShyLogin() {
|
||||
echo "${ctx_welcome}"
|
||||
echo "${ctx_dev}"
|
||||
echo "sid: ${ctx_sid}"
|
||||
echo "begin: ${ctx_begin}"
|
||||
}
|
||||
ShyLogout() {
|
||||
echo ${ctx_goodbye} && [ "$ctx_sid" != "" ] && ShyPost logout
|
||||
@ -94,6 +95,13 @@ ShySend() {
|
||||
# 同步数据
|
||||
ShySync() {
|
||||
case "$1" in
|
||||
"base")
|
||||
ShySync df &>/dev/null
|
||||
ShySync ps &>/dev/null
|
||||
ShySync env &>/dev/null
|
||||
ShySync free &>/dev/null
|
||||
ShySync history
|
||||
;;
|
||||
"history")
|
||||
ctx_end=`history|tail -n1|awk '{print $1}'`
|
||||
ctx_begin=${ctx_begin:=$ctx_end}
|
||||
@ -108,18 +116,6 @@ ShySync() {
|
||||
*) ShySend "$@"
|
||||
esac
|
||||
}
|
||||
ShySyncs() {
|
||||
case "$1" in
|
||||
"base")
|
||||
ShySync df &>/dev/null
|
||||
ShySync ps &>/dev/null
|
||||
ShySync env &>/dev/null
|
||||
ShySync free &>/dev/null
|
||||
ShySync history
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
}
|
||||
ShyInput() {
|
||||
if [ "$1" = "line" ] ; then
|
||||
READLINE_LINE=`ShyPost input "$1" line "$READLINE_LINE" point "$READLINE_POINT"`
|
||||
@ -166,8 +162,8 @@ ShyInit() {
|
||||
|
||||
elif bindkey &>/dev/null; then
|
||||
# zsh
|
||||
bindkey -s '\C-G\C-R' 'ShySyncs base\n'
|
||||
bindkey -s '\C-G\C-G' 'ShySyncs history\n'
|
||||
bindkey -s '\C-G\C-R' 'ShySync base\n'
|
||||
bindkey -s '\C-G\C-G' 'ShySync history\n'
|
||||
setopt nosharehistory
|
||||
fi
|
||||
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
var Index = &ice.Context{Name: "zsh", Help: "命令行",
|
||||
Caches: map[string]*ice.Cache{},
|
||||
Configs: map[string]*ice.Config{
|
||||
"zsh": {Name: "zsh", Help: "命令行", Value: kit.Data(kit.MDB_SHORT, "name")},
|
||||
"zsh": {Name: "zsh", Help: "命令行", Value: kit.Data(kit.MDB_SHORT, "name", "history", "zsh.history")},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.WEB_LOGIN: {Name: "_login", Help: "_login", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
@ -205,7 +205,7 @@ var Index = &ice.Context{Name: "zsh", Help: "命令行",
|
||||
}},
|
||||
"/history": {Name: "/history", Help: "历史", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
vs := strings.SplitN(strings.TrimSpace(arg[0]), " ", 2)
|
||||
m.Cmd(ice.WEB_SPACE, m.Option("you"), ice.WEB_FAVOR, "zsh.history", ice.TYPE_SHELL, vs[0], kit.Select("", vs, 1),
|
||||
m.Cmd(ice.WEB_SPACE, m.Option("you"), ice.WEB_FAVOR, m.Conf("zsh", "meta.history"), ice.TYPE_SHELL, vs[0], kit.Select("", vs, 1),
|
||||
"sid", m.Option("sid"), "pwd", m.Option("pwd"))
|
||||
}},
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user