1
0
forked from x/icebergs

fix story

This commit is contained in:
shaoying 2020-01-08 18:30:47 +08:00
parent 07d0043035
commit 8181e3adea
9 changed files with 203 additions and 183 deletions

View File

@ -471,6 +471,8 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
switch arg[1] { switch arg[1] {
case "raw": case "raw":
cache, arg = arg[1], arg[1:] cache, arg = arg[1], arg[1:]
case "msg":
cache, arg = arg[1], arg[1:]
case "cache": case "cache":
cache, arg = arg[1], arg[1:] cache, arg = arg[1], arg[1:]
} }
@ -594,6 +596,18 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
} }
switch cache { switch cache {
case "msg":
var data map[string][]string
m.Assert(json.NewDecoder(res.Body).Decode(&data))
m.Info("res: %s", kit.Formats(data))
if len(data["append"]) > 0 {
for i := range data[data["append"][0]] {
for _, k := range data["append"] {
m.Push(k, data[k][i])
}
}
}
case "raw": case "raw":
if b, e := ioutil.ReadAll(res.Body); m.Assert(e) { if b, e := ioutil.ReadAll(res.Body); m.Assert(e) {
m.Echo(string(b)) m.Echo(string(b))
@ -615,6 +629,7 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
m.Push(key, kit.Format(value)) m.Push(key, kit.Format(value))
} }
}) })
m.Info("res: %s", m.Formats("meta"))
} }
}) })
} }
@ -1057,12 +1072,12 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
pull := end pull := end
var first map[string]interface{} var first map[string]interface{}
for begin != end { for begin != end {
if m.Cmd(ice.WEB_SPIDE, arg[1], "/story/pull", "begin", begin, "end", end).Table(func(index int, value map[string]string, head []string) { if m.Cmd(ice.WEB_SPIDE, arg[1], "msg", "/story/pull", "begin", begin, "end", end).Table(func(index int, value map[string]string, head []string) {
if m.Richs(ice.WEB_CACHE, nil, value["data"], nil) == nil { if m.Richs(ice.WEB_CACHE, nil, value["data"], nil) == nil {
// 导入缓存 // 导入缓存
m.Log(ice.LOG_IMPORT, "%v: %v", value["data"], value["save"]) m.Log(ice.LOG_IMPORT, "%v: %v", value["data"], value["save"])
if node := kit.UnMarshal(value["save"]); kit.Format(kit.Value(node, "file")) != "" { if node := kit.UnMarshal(value["save"]); kit.Format(kit.Value(node, "file")) != "" {
m.Cmd(ice.WEB_SPIDE, arg[1], "cache", "GET", "/story/download/"+kit.Format(value["data"])) m.Cmd(ice.WEB_SPIDE, arg[1], "cache", "GET", "/story/download/"+value["data"])
} else { } else {
m.Conf(ice.WEB_CACHE, kit.Keys("hash", value["data"]), node) m.Conf(ice.WEB_CACHE, kit.Keys("hash", value["data"]), node)
} }

View File

@ -20,8 +20,7 @@ END
[ -f Makefile ] || cat >> Makefile <<END [ -f Makefile ] || cat >> Makefile <<END
all: all:
@echo @echo && date
@date
go build -o ice.bin main.go && chmod u+x ice.bin && ./ice.sh restart go build -o ice.bin main.go && chmod u+x ice.bin && ./ice.sh restart
END END

View File

@ -52,7 +52,7 @@ fun! ShySync(target)
if a:target == "read" || a:target == "write" if a:target == "read" || a:target == "write"
call ShySend({"cmd": a:target, "arg": expand("<afile>")}) call ShySend({"cmd": a:target, "arg": expand("<afile>")})
elseif a:target == "exec" elseif a:target == "exec"
call ShySend({"cmd": a:target, "sub": getcmdline()}) call ShySend({"cmd": a:target, "arg": getcmdline()})
elseif a:target == "insert" elseif a:target == "insert"
call ShySend({"cmd": a:target, "sub": getreg("."), "row": line("."), "col": col(".")}) call ShySend({"cmd": a:target, "sub": getreg("."), "row": line("."), "col": col(".")})
else else
@ -93,13 +93,13 @@ fun! ShyHelp()
endfun endfun
call ShyLogin() call ShyLogin()
autocmd VimLeave * call ShyLogout() autocmd! VimLeave * call ShyLogout()
autocmd BufReadPost * call ShySync("bufs") autocmd! BufReadPost * call ShySync("bufs")
autocmd BufReadPost * call ShySync("read") autocmd! BufReadPost * call ShySync("read")
autocmd BufWritePre * call ShySync("write") autocmd! BufWritePre * call ShySync("write")
autocmd CmdlineLeave * call ShySync("exec") autocmd! CmdlineLeave * call ShySync("exec")
autocmd QuickFixCmdPost * call ShyCheck("fixs") autocmd! QuickFixCmdPost * call ShyCheck("fixs")
autocmd InsertLeave * call ShySync("insert") autocmd! InsertLeave * call ShySync("insert")
nnoremap <C-G><C-G> :call ShyGrep(expand("<cword>"))<CR> nnoremap <C-G><C-G> :call ShyGrep(expand("<cword>"))<CR>
nnoremap <C-G><C-R> :call ShyCheck("cache")<CR> nnoremap <C-G><C-R> :call ShyCheck("cache")<CR>
nnoremap <C-G><C-F> :call ShyFavor()<CR> nnoremap <C-G><C-F> :call ShyFavor()<CR>

View File

@ -208,7 +208,7 @@ var Index = &ice.Context{Name: "code", Help: "编程模块",
// 下发文件 // 下发文件
m.Option("you", you) m.Option("you", you)
m.Cmd(ice.WEB_SPACE, msg.Option("you"), ice.WEB_SPACE, "download", msg.Append("type"), msg.Append("name"), "self", msg.Append("data")) m.Cmd(ice.WEB_SPACE, msg.Option("you"), ice.WEB_STORY, ice.STORY_PULL, "dev", msg.Append("name"))
case "download": case "download":
// 下载文件 // 下载文件
@ -263,7 +263,7 @@ var Index = &ice.Context{Name: "code", Help: "编程模块",
case "read", "write", "exec": case "read", "write", "exec":
m.Cmd(ice.WEB_FAVOR, "vim.history", "vimrc", m.Option("cmd"), m.Option("arg"), m.Cmd(ice.WEB_FAVOR, "vim.history", "vimrc", m.Option("cmd"), m.Option("arg"),
"sid", m.Option("sid"), "pwd", m.Option("pwd")) "sid", m.Option("sid"), "pwd", m.Option("pwd"), "buf", m.Option("buf"))
case "tasklet": case "tasklet":
m.Cmd(ice.APP_MISS, m.Option("arg"), m.Option("sub")) m.Cmd(ice.APP_MISS, m.Option("arg"), m.Option("sub"))

View File

@ -33,28 +33,22 @@ var Index = &ice.Context{Name: "mall", Help: "团队模块",
m.Cmd(ice.CTX_CONFIG, "save", "mall.json", "web.mall.railway") m.Cmd(ice.CTX_CONFIG, "save", "mall.json", "web.mall.railway")
}}, }},
"passcode": &ice.Command{Name: "passcode", Help: "passcode", Meta: kit.Dict( "passcode": &ice.Command{Name: "passcode", Help: "passcode", Meta: kit.Dict("active", "mall/input"), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
"display", "mall/image", prefix := []string{ice.WEB_SPIDE, "12306"}
), List: kit.List(
kit.MDB_INPUT, "text", "name", "账号",
kit.MDB_INPUT, "text", "name", "密码",
kit.MDB_INPUT, "button", "name", "登录", "display", "mall/input",
kit.MDB_INPUT, "button", "name", "刷新", "display", "mall/input",
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
m.Cmd(ice.WEB_SPIDE, "12306", "raw", "/passport/web/auth/uamtk-static", "form", "appid", "otn") m.Cmd(prefix, "raw", "/passport/web/auth/uamtk-static", "form", "appid", "otn")
m.Cmd(ice.WEB_SPIDE, "12306", "raw", "GET", "/otn/HttpZF/GetJS") m.Cmd(prefix, "raw", "GET", "/otn/HttpZF/GetJS")
m.Cmd(ice.WEB_SPIDE, "12306", "raw", "/otn/login/conf") m.Cmd(prefix, "raw", "/otn/login/conf")
m.Cmdy(ice.WEB_SPIDE, "12306", "GET", fmt.Sprintf("/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand")) m.Cmdy(prefix, "GET", fmt.Sprintf("/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand"))
return return
} }
switch arg[0] { switch arg[0] {
case "check": case "check":
m.Cmdy(ice.WEB_SPIDE, "12306", "GET", fmt.Sprintf("/passport/captcha/captcha-check?answer=%s&rand=sjrand&login_site=E", arg[1])) m.Cmdy(prefix, "GET", fmt.Sprintf("/passport/captcha/captcha-check?login_site=E&rand=sjrand&answer=%s", arg[1]))
case "login": case "login":
m.Cmdy(ice.WEB_SPIDE, "12306", "raw", "/passport/web/login", "form", "username", arg[1], "password", arg[2], "answer", arg[3], "appid", "otn") m.Cmdy(prefix, "raw", "/passport/web/login", "form", "username", arg[1], "password", arg[2], "answer", arg[3], "appid", "otn")
} }
}}, }},
"railway": &ice.Command{Name: "railway", Help: "12306", List: kit.List( "railway": &ice.Command{Name: "railway", Help: "12306", List: kit.List(
@ -62,8 +56,7 @@ var Index = &ice.Context{Name: "mall", Help: "团队模块",
kit.MDB_INPUT, "text", "name", "from", "value", "北京", kit.MDB_INPUT, "text", "name", "from", "value", "北京",
kit.MDB_INPUT, "text", "name", "to", "value", "曲阜", kit.MDB_INPUT, "text", "name", "to", "value", "曲阜",
kit.MDB_INPUT, "button", "name", "查询", kit.MDB_INPUT, "button", "name", "查询",
), ), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
date := time.Now().Add(time.Hour * 24).Format("2006-01-02") date := time.Now().Add(time.Hour * 24).Format("2006-01-02")
if len(arg) > 0 { if len(arg) > 0 {
date, arg = arg[0], arg[1:] date, arg = arg[0], arg[1:]

View File

@ -2,7 +2,7 @@ module miss
go 1.13 go 1.13
require github.com/shylinux/icebergs v0.1.0 // indirect require github.com/shylinux/icebergs v0.1.0
replace ( replace (
github.com/shylinux/icebergs => ../ github.com/shylinux/icebergs => ../

125
miss/ice.md Normal file
View File

@ -0,0 +1,125 @@
# {{title "ICEBERGS"}}
icebergs是一个后端框架通过模块化、集群化实现资源的无限的扩展与自由的组合。
{{chain "icebergs" `
icebergs
type.go
msg.Detail
msg.Option
msg.Append
msg.Result
msg.Travel
msg.Search
msg.Conf
msg.Cmd
msg.Cap
base.go bg blue
Begin
_init
Start bg red
code
wiki
chat
ocean
river
action
storm
steam
team
mall
_exit
Close
conf.go
init
host
boot
node
user
work
auth
data
file
` "" "" 16}}
一键创建项目
```
mkdir miss; cd miss && curl -s https://shylinux.com/publish/build.sh | sh
```
一键启动项目
```
mkdir miss; cd miss && curl -s https://shylinux.com/publish/ice.sh | sh
```
## {{chapter "元始模块 base/ctx"}}
## {{chapter "配置模块 base/cli"}}
cli模块用于与系统进行交互。
- 系统信息 ice.CLI_RUNTIME
- 系统命令 ice.CLI_SYSTEM
## {{chapter "通信模块 base/tcp"}}
tcp模块用于管理网络的读写
## {{chapter "存储模块 base/nfs"}}
nfs模块用于管理文件的读写。
## {{chapter "终端模块 base/ssh"}}
ssh模块用于与终端交互。
## {{chapter "数据模块 base/mdb"}}
mdb模块用于管理数据的读写。
## {{chapter "词法模块 base/lex"}}
## {{chapter "语法模块 base/yac"}}
## {{chapter "日志模块 base/log"}}
log模块负责输出日志。
## {{chapter "事件模块 base/gdb"}}
gdb模块会根据各种触发条件择机执行各种命令。
- 信号器 ice.SIGNAL
- 定时器 ice.TIMER
- 触发器 ice.EVENT
## {{chapter "认证模块 base/aaa"}}
aaa模块用于各种权限管理与身份认证。
- 角色 ice.AAA_ROLE
- 用户 ice.AAA_USER
- 会话 ice.AAA_SESS
## {{chapter "网络模块 base/web"}}
web模块用于组织网络节点与生成前端网页
### {{section "网络爬虫 ice.WEB_SPIDE"}}
WEB_SPIDE功能用于发送网络请求获取相关数据。
### {{section "网络服务 ice.WEB_SERVE"}}
WEB_SERVE功能用于启动网络服务器接收网络请求。
### {{section "网络节点 ice.WEB_SPACE"}}
WEB_SPACE功能用于与相连网络节点进行通信。
### {{section "网络任务 ice.WEB_DREAM"}}
WEB_DREAM功能用于启动本地节点管理各种任务的相关资源。
### {{section "网络收藏 ice.WEB_FAVOR"}}
WEB_FAVOR功能用于收藏各种实时数据进行分类管理。
### {{section "网络缓存 ice.WEB_CACHE"}}
WEB_CACHE功能用于管理缓存数据自动存储与传输。
### {{section "网络存储 ice.WEB_STORY"}}
WEB_STORY功能用于记录数据的历史变化可以查看任意历史版本。
### {{section "网络共享 ice.WEB_SHARE"}}
WEB_SHARE功能用于数据与应用的共享可以查到所有数据流通记录。
### {{section "网络路由 ice.WEB_ROUTE"}}
### {{section "网络代理 ice.WEB_PROXY"}}
### {{section "网络分组 ice.WEB_GROUP"}}
### {{section "网络标签 ice.WEB_LABEL"}}

View File

@ -1,115 +0,0 @@
# icebergs
icebergs是一个后端框架通过模块化、集群化实现资源的无限的扩展与自由的组合。
{{chain "icebergs" `
icebergs
type.go
msg.Detail
msg.Option
msg.Append
msg.Result
msg.Travel
msg.Search
msg.Conf
msg.Cmd
msg.Cap
base.go bg blue
Begin
_init
Start bg red
code
wiki
chat
ocean
river
action
storm
steam
team
mall
_exit
Close
conf.go
init
host
boot
node
user
work
auth
data
file
` "" "" 16}}
一键创建项目
```
mkdir miss; cd miss && curl -s https://shylinux.com/publish/build.sh | sh
```
一键启动项目
```
mkdir miss; cd miss && curl -s https://shylinux.com/publish/ice.sh | sh
```
## 命令模块 base/cli
cli模块用于与系统进行交互。
- 系统信息 ice.CLI_RUNTIME
- 系统命令 ice.CLI_SYSTEM
## 网络模块 base/tcp
tcp模块用于管理网络的读写
## 文件模块 base/nfs
nfs模块用于管理文件的读写。
## 终端模块 base/ssh
ssh模块用于与终端交互。
## 数据模块 base/mdb
mdb模块用于管理数据的读写。
## 日志模块 base/log
log模块负责输出日志。
## 事件模块 base/gdb
gdb模块会根据各种触发条件择机执行各种命令。
- 信号器 ice.SIGNAL
- 定时器 ice.TIMER
- 触发器 ice.EVENT
## 认证模块 base/aaa
aaa模块用于各种权限管理与身份认证。
- 角色 ice.AAA_ROLE
- 用户 ice.AAA_USER
- 会话 ice.AAA_SESS
## 网页模块 base/web
web模块用于组织网络节点与生成前端网页
- 网络爬虫 ice.WEB_SPIDE
- 网络服务 ice.WEB_SERVE
- 网络节点 ice.WEB_SPACE
- 网络任务 ice.WEB_DREAM
- 网络收藏 ice.WEB_FAVOR
- 网络缓存 ice.WEB_CACHE
- 网络存储 ice.WEB_STORY
- 网络共享 ice.WEB_SHARE
- 网络路由 ice.WEB_ROUTE
- 网络代理 ice.WEB_PROXY
- 网络分组 ice.WEB_GROUP
- 网络标签 ice.WEB_LABEL

View File

@ -386,7 +386,10 @@ func (m *Message) Push(key string, value interface{}, arg ...interface{}) *Messa
} }
return m return m
} }
return m.Add(MSG_APPEND, key, kit.Format(value)) for _, v := range kit.Simple(value) {
m.Add(MSG_APPEND, key, v)
}
return m
} }
func (m *Message) Echo(str string, arg ...interface{}) *Message { func (m *Message) Echo(str string, arg ...interface{}) *Message {
if len(arg) > 0 { if len(arg) > 0 {
@ -677,7 +680,7 @@ func (m *Message) Space(arg interface{}) []string {
return []string{WEB_SPACE, kit.Format(arg)} return []string{WEB_SPACE, kit.Format(arg)}
} }
func (m *Message) Right(arg ...interface{}) bool { func (m *Message) Right(arg ...interface{}) bool {
return !m.Warn(m.Cmdx(AAA_ROLE, "right", m.Option(MSG_USERROLE), kit.Keys(arg...)) != "ok", "no right") return m.Option(MSG_USERROLE) == ROLE_ROOT || !m.Warn(m.Cmdx(AAA_ROLE, "right", m.Option(MSG_USERROLE), kit.Keys(arg...)) != "ok", "no right")
} }
func (m *Message) Event(key string, arg ...string) *Message { func (m *Message) Event(key string, arg ...string) *Message {
m.Cmd(GDB_EVENT, "action", key, arg) m.Cmd(GDB_EVENT, "action", key, arg)
@ -996,7 +999,7 @@ func (m *Message) Grow(key string, chain interface{}, data interface{}) int {
meta["count"] = id meta["count"] = id
// 保存数据 // 保存数据
if len(list) > kit.Int(kit.Select(m.Conf(WEB_CACHE, Meta("limit")), meta["limit"])) { if len(list) >= kit.Int(kit.Select(m.Conf(WEB_CACHE, Meta("limit")), meta["limit"])) {
least := kit.Int(kit.Select(m.Conf(WEB_CACHE, Meta("least")), meta["least"])) least := kit.Int(kit.Select(m.Conf(WEB_CACHE, Meta("least")), meta["least"]))
// 创建文件 // 创建文件