forked from x/ContextOS
add story
This commit is contained in:
parent
deb1b9b5c8
commit
e2d819dc8f
@ -1,4 +1,6 @@
|
|||||||
# 应用配置
|
# 应用配置
|
||||||
|
~wiki
|
||||||
|
config save var/tmp/story.json story
|
||||||
~code
|
~code
|
||||||
config save var/tmp/vim/vim.json vim
|
config save var/tmp/vim/vim.json vim
|
||||||
config save var/tmp/zsh.json zsh
|
config save var/tmp/zsh.json zsh
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
config load tmp/code.json login
|
config load tmp/code.json login
|
||||||
config load tmp/zsh.json zsh
|
config load tmp/zsh.json zsh
|
||||||
config load tmp/vim/vim.json vim
|
config load tmp/vim/vim.json vim
|
||||||
|
~wiki
|
||||||
|
config load tmp/story.json story
|
||||||
|
|
||||||
# 终端配置
|
# 终端配置
|
||||||
~cli
|
~cli
|
||||||
|
@ -52,11 +52,11 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
|||||||
"class": {Name: "class", Value: "", Help: "文档目录"},
|
"class": {Name: "class", Value: "", Help: "文档目录"},
|
||||||
"favor": {Name: "favor", Value: "index.md", Help: "默认文档"},
|
"favor": {Name: "favor", Value: "index.md", Help: "默认文档"},
|
||||||
|
|
||||||
"commit": {Name: "data", Value: map[string]interface{}{
|
"story": {Name: "story", Value: map[string]interface{}{
|
||||||
"data": map[string]interface{}{},
|
"data": map[string]interface{}{},
|
||||||
"ship": map[string]interface{}{},
|
"node": map[string]interface{}{},
|
||||||
"head": map[string]interface{}{},
|
"head": map[string]interface{}{},
|
||||||
}, Help: "数据"},
|
}, Help: "故事会"},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
"tree": {Name: "tree", Help: "目录", Form: map[string]int{"level": 1, "class": 1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"tree": {Name: "tree", Help: "目录", Form: map[string]int{"level": 1, "class": 1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
@ -80,65 +80,117 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
|||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"note": {Name: "note file", Help: "便签", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"note": {Name: "note file", Help: "便签", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
if len(arg) > 1 && arg[0] == "commit" {
|
if len(arg) == 0 {
|
||||||
m.Cmd("commit", arg[1:])
|
|
||||||
} else if len(arg) > 0 {
|
|
||||||
m.Cmd(kit.Select("tree", "text", strings.HasSuffix(arg[0], ".md")), arg[0])
|
|
||||||
} else {
|
|
||||||
m.Cmd("tree")
|
m.Cmd("tree")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch arg[0] {
|
||||||
|
case "favor", "commit":
|
||||||
|
m.Cmd("story", arg[0], arg[1:])
|
||||||
|
default:
|
||||||
|
m.Cmd(kit.Select("tree", "text", strings.HasSuffix(arg[0], ".md")), arg[0])
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"commit": {Name: "commit file name type text", Help: "提交", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"story": {Name: "story commit story scene enjoy happy", Help: "故事会", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
||||||
head := kit.Hashs(arg[0], arg[1])
|
switch arg[0] {
|
||||||
prev := m.Conf("commit", []string{"head", head, "ship"})
|
case "favor":
|
||||||
m.Log("info", "head: %v %v", head, m.Conf("commit", []string{"head", head}))
|
if len(arg) < 4 {
|
||||||
if len(arg) == 2 {
|
m.Cmdy("ssh.data", "show", arg[1:])
|
||||||
meta := m.Confm("commit", []string{"ship", prev})
|
break
|
||||||
m.Push("time", meta["time"])
|
}
|
||||||
m.Push("data", m.Conf("commit", []string{"data", kit.Format(meta["data"])}))
|
|
||||||
|
head := kit.Hashs(arg[2], arg[4])
|
||||||
|
prev := m.Conf(cmd, []string{"head", head, "node"})
|
||||||
|
m.Cmdy("ssh.data", "insert", arg[1], "story", arg[2], "scene", arg[3], "enjoy", arg[4], "node", prev)
|
||||||
|
|
||||||
|
case "commit":
|
||||||
|
head := kit.Hashs(arg[1], arg[3])
|
||||||
|
prev := m.Conf(cmd, []string{"head", head, "node"})
|
||||||
|
m.Log("info", "head: %v %#v", head, prev)
|
||||||
|
|
||||||
|
if len(arg) > 4 {
|
||||||
|
data := kit.Hashs(arg[4])
|
||||||
|
m.Log("info", "data: %v %v", data, arg[4])
|
||||||
|
if m.Conf(cmd, []string{"node", prev, "data"}) != data {
|
||||||
|
m.Conf(cmd, []string{"data", data}, arg[4])
|
||||||
|
|
||||||
|
meta := map[string]interface{}{
|
||||||
|
"time": m.Time(),
|
||||||
|
"story": arg[1],
|
||||||
|
"scene": arg[2],
|
||||||
|
"enjoy": arg[3],
|
||||||
|
"data": data,
|
||||||
|
"prev": prev,
|
||||||
|
}
|
||||||
|
node := kit.Hashs(kit.Format(meta))
|
||||||
|
m.Log("info", "node: %v %v", node, meta)
|
||||||
|
m.Conf(cmd, []string{"node", node}, meta)
|
||||||
|
|
||||||
|
m.Log("info", "head: %v %v", head, node)
|
||||||
|
m.Conf(cmd, []string{"head", head, "node"}, node)
|
||||||
|
m.Echo("%v", kit.Formats(meta))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for prev != "" {
|
||||||
|
node := m.Confm(cmd, []string{"node", prev})
|
||||||
|
m.Push("node", kit.Short(prev, 6))
|
||||||
|
m.Push("time", node["time"])
|
||||||
|
m.Push("data", m.Conf(cmd, []string{"data", kit.Format(node["data"])}))
|
||||||
|
prev = kit.Format(node["prev"])
|
||||||
|
}
|
||||||
m.Table()
|
m.Table()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
case "branch":
|
||||||
|
m.Confm(cmd, "head", func(key string, value map[string]interface{}) {
|
||||||
|
node := kit.Format(value["node"])
|
||||||
|
m.Push("key", kit.Short(key, 6))
|
||||||
|
m.Push("story", m.Conf(cmd, []string{"node", node, "story"}))
|
||||||
|
m.Push("scene", m.Conf(cmd, []string{"node", node, "scene"}))
|
||||||
|
m.Push("enjoy", m.Conf(cmd, []string{"node", node, "enjoy"}))
|
||||||
|
m.Push("node", kit.Short(value["node"], 6))
|
||||||
|
})
|
||||||
|
m.Table()
|
||||||
|
case "remote":
|
||||||
}
|
}
|
||||||
|
|
||||||
data := kit.Hashs(arg[3])
|
|
||||||
m.Log("info", "data: %v %v", data, arg[3])
|
|
||||||
m.Conf("commit", []string{"data", data}, arg[3])
|
|
||||||
|
|
||||||
meta := map[string]interface{}{
|
|
||||||
"prev": prev,
|
|
||||||
"time": m.Time(),
|
|
||||||
"file": arg[0],
|
|
||||||
"name": arg[1],
|
|
||||||
"type": arg[2],
|
|
||||||
"data": data,
|
|
||||||
}
|
|
||||||
ship := kit.Hashs(kit.Format(meta))
|
|
||||||
m.Log("info", "ship: %v %v", ship, meta)
|
|
||||||
m.Conf("commit", []string{"ship", ship}, meta)
|
|
||||||
|
|
||||||
m.Log("info", "head: %v %v", head, ship)
|
|
||||||
m.Conf("commit", []string{"head", head, "ship"}, ship)
|
|
||||||
m.Echo("%v", kit.Formats(meta))
|
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"table": {Name: "table", Help: "表格", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"table": {Name: "table", Help: "表格", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
||||||
if len(arg) == 0 {
|
switch len(arg) {
|
||||||
|
case 0:
|
||||||
return
|
return
|
||||||
}
|
case 2:
|
||||||
switch arg[1] {
|
if arg[1] != "head" {
|
||||||
case "data":
|
break
|
||||||
arg = []string{arg[0], m.Conf("commit", []string{"data", arg[2]})}
|
}
|
||||||
|
fallthrough
|
||||||
|
case 1:
|
||||||
|
arg = []string{arg[0], "head", kit.Hashs(m.Option("filename"), arg[1])}
|
||||||
|
fallthrough
|
||||||
default:
|
default:
|
||||||
msg := m.Spawn().Cmd("commit", m.Option("filename"), arg[0])
|
switch arg[1] {
|
||||||
m.Option("prev_data", msg.Append("data"))
|
case "name":
|
||||||
m.Option("prev_time", msg.Append("time"))
|
arg = []string{arg[0], "head", kit.Hashs(m.Option("filename"), arg[2])}
|
||||||
m.Option("file", m.Option("filename"))
|
fallthrough
|
||||||
m.Option("name", arg[0])
|
case "head":
|
||||||
m.Option("data", arg[1])
|
arg = []string{arg[0], "node", m.Conf("story", []string{"head", arg[2], "node"})}
|
||||||
|
fallthrough
|
||||||
|
case "node":
|
||||||
|
arg = []string{arg[0], "data", m.Conf("story", []string{"node", arg[2], "data"})}
|
||||||
|
fallthrough
|
||||||
|
case "data":
|
||||||
|
arg = []string{arg[0], m.Conf("story", []string{"data", arg[2]})}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.Option("scene", cmd)
|
||||||
|
m.Option("enjoy", arg[0])
|
||||||
|
m.Option("happy", arg[1])
|
||||||
|
|
||||||
head := []string{}
|
head := []string{}
|
||||||
for i, l := range strings.Split(strings.TrimSpace(arg[1]), "\n") {
|
for i, l := range strings.Split(strings.TrimSpace(arg[1]), "\n") {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
|
3
src/plugin/story/index.css
Normal file
3
src/plugin/story/index.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fieldset.item.story div.output {
|
||||||
|
}
|
||||||
|
|
36
src/plugin/story/index.go
Normal file
36
src/plugin/story/index.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"contexts/cli"
|
||||||
|
"contexts/ctx"
|
||||||
|
"toolkit"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Index = &ctx.Context{Name: `story`, Help: `plugin`,
|
||||||
|
Caches: map[string]*ctx.Cache{},
|
||||||
|
Configs: map[string]*ctx.Config{
|
||||||
|
"_index": &ctx.Config{Name: "index", Value: []interface{}{
|
||||||
|
map[string]interface{}{"name": "demo", "help": "demo",
|
||||||
|
"tmpl": "componet", "view": "", "init": "",
|
||||||
|
"type": "public", "ctx": "demo", "cmd": "demo",
|
||||||
|
"args": []interface{}{}, "inputs": []interface{}{
|
||||||
|
map[string]interface{}{"type": "text", "name": "pod", "value": "hello world"},
|
||||||
|
map[string]interface{}{"type": "button", "value": "执行"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
Commands: map[string]*ctx.Command{
|
||||||
|
"demo": {Name: "demo", Help: "demo", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
m.Echo(kit.Select("hello world", arg, 0))
|
||||||
|
return
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Print(cli.Index.Plugin(Index, os.Args[1:]))
|
||||||
|
}
|
3
src/plugin/story/index.js
Normal file
3
src/plugin/story/index.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Script["story/index.js"] = function(field, option, output) {return {
|
||||||
|
}}
|
||||||
|
|
41
src/plugin/story/index.shy
Normal file
41
src/plugin/story/index.shy
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
kit note "记事本" public "ssh._route" _ "web.wiki.note" \
|
||||||
|
text "" name dream imports plugin_dream action auto \
|
||||||
|
text "" name story imports plugin_story view long action auto \
|
||||||
|
button "查看" action auto \
|
||||||
|
button "返回" cb Last \
|
||||||
|
exports story file \
|
||||||
|
feature display inner
|
||||||
|
|
||||||
|
kit favor "收藏夹" public "ssh._route" _ "web.wiki.story" favor \
|
||||||
|
text "" name dream imports plugin_you action auto \
|
||||||
|
text "see" name table imports plugin_story_table action auto \
|
||||||
|
text "" name index imports plugin_story_id view tiny action auto \
|
||||||
|
feature detail "修改" "复制" "下载" \
|
||||||
|
exports story_table table "" story_id id "" \
|
||||||
|
button "记录" action auto \
|
||||||
|
button "返回" cb Last
|
||||||
|
|
||||||
|
kit commit "记录" public "ssh._route" _ "web.wiki.story" commit \
|
||||||
|
text "" name dream imports plugin_dream \
|
||||||
|
text "" name story imports plugin_story \
|
||||||
|
text "table" name sence \
|
||||||
|
text "hello" name enjoy \
|
||||||
|
textarea "" name happy half 4 \
|
||||||
|
button "提交"
|
||||||
|
|
||||||
|
kit branch "分支" public "ssh._route" _ "web.wiki.story" branch \
|
||||||
|
text "" name dream imports plugin_dream \
|
||||||
|
button "查看"
|
||||||
|
|
||||||
|
kit remote "仓库" public "ssh._route" _ "web.wiki.story" remote \
|
||||||
|
text "" name dream imports plugin_dream \
|
||||||
|
button "查看"
|
||||||
|
|
||||||
|
kit xls "表格" "index.js" "index.css" private "web.wiki.xls" \
|
||||||
|
text "" name scene imports plugin_xls_id action auto \
|
||||||
|
text "" name content \
|
||||||
|
button "执行" \
|
||||||
|
button "返回" cb Last \
|
||||||
|
feature style "mind" \
|
||||||
|
exports xls_id id
|
||||||
|
|
@ -1,11 +1,3 @@
|
|||||||
kit note "记事本" public "ssh._route" _ "web.wiki.note" \
|
|
||||||
text "" name you imports plugin_you action auto \
|
|
||||||
text "" name doc imports plugin_doc view long action auto \
|
|
||||||
button "查看" action auto \
|
|
||||||
button "返回" cb Last \
|
|
||||||
exports doc file \
|
|
||||||
feature display inner
|
|
||||||
|
|
||||||
kit tips "便签" private "web.code.favor" list \
|
kit tips "便签" private "web.code.favor" list \
|
||||||
text "" name dream imports plugin_you action auto \
|
text "" name dream imports plugin_you action auto \
|
||||||
text "tip" name table imports plugin_vim_table action auto \
|
text "tip" name table imports plugin_vim_table action auto \
|
||||||
|
@ -1059,8 +1059,9 @@ function Plugin(page, pane, field, inits, runs) {
|
|||||||
kit.classList.add(item, "args")
|
kit.classList.add(item, "args")
|
||||||
break
|
break
|
||||||
case "textarea":
|
case "textarea":
|
||||||
|
var half = parseInt(item.half||"1")||1
|
||||||
kit.AppendChild(option, "br")
|
kit.AppendChild(option, "br")
|
||||||
input.type = "textarea", item.style = "height:"+(item.height||"50px")+";width:"+(pane.target.clientWidth-35)+"px"
|
input.type = "textarea", item.style = "height:"+(item.height||"50px")+";width:"+((pane.target.clientWidth-35)/half)+"px"
|
||||||
// no break
|
// no break
|
||||||
case "text":
|
case "text":
|
||||||
item.value = value || item.value || ""
|
item.value = value || item.value || ""
|
||||||
@ -1531,9 +1532,26 @@ function Output(plugin, type, msg, cb, target, option) {
|
|||||||
kit.Selector(target, ".commit", function(item) {
|
kit.Selector(target, ".commit", function(item) {
|
||||||
var data = item.dataset
|
var data = item.dataset
|
||||||
item.oncontextmenu = function(event) {
|
item.oncontextmenu = function(event) {
|
||||||
plugin.oncarte(event, shy("", {}, ["提交"], function(event, value, meta) {
|
plugin.oncarte(event, shy("", {
|
||||||
plugin.Run(event, [option.you.vaule||"", "commit", option.doc.value||"", data.name, "table", data.data], function(msg) {
|
"提交": function(event) {
|
||||||
}, true)
|
plugin.Run(event, [option.dream.value, "commit", option.story.value, data.scene, data.enjoy, data.happy], function(msg) {
|
||||||
|
}, true)
|
||||||
|
},
|
||||||
|
"复制": function(event) {
|
||||||
|
plugin.ontoast(kit.CopyText(data.happy))
|
||||||
|
},
|
||||||
|
"收藏": function(event) {
|
||||||
|
kit.prompt("收藏到", function(table) {
|
||||||
|
plugin.Run(event, [option.dream.value, "favor", table, option.story.value, data.scene, data.enjoy, data.happy], function(msg) {
|
||||||
|
}, true)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
"共享": function(event) {
|
||||||
|
plugin.Run(event, [option.dream.value, "share", option.story.value, data.scene, data.enjoy, data.happy], function(msg) {
|
||||||
|
}, true)
|
||||||
|
},
|
||||||
|
}, ["提交", "复制", "收藏", "共享"], function(event, value, meta) {
|
||||||
|
meta[value](event)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
{{define "table"}}<table class="commit" data-file='{{options . "file"}}' data-name='{{options . "name"}}' data-data='{{options . "data"}}'
|
{{define "table"}}<table class="commit" data-scene='{{options . "scene"}}'
|
||||||
data-commit_time='{{options . "prev_time"}}' data-commit_data='{{options . "prev_data"}}'>{{range $i, $line := .|trans}}
|
data-enjoy='{{options . "enjoy"}}' data-happy='{{options . "happy"}}'>{{range $i, $line := .|trans}}
|
||||||
{{if eq $i 0}}
|
{{if eq $i 0}}
|
||||||
<tr>{{range $i, $v := $line}}<th>{{$v}}</th>{{end}}</tr>
|
<tr>{{range $i, $v := $line}}<th>{{$v}}</th>{{end}}</tr>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user