From 67e0127be8d9bdd84ab2682c55d70d8759b1362b Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 12 Jan 2020 18:34:16 +0800 Subject: [PATCH] opt some --- README.md | 98 ++++++++++++++++++------------------ core/chat/chat.go | 7 +++ core/team/team.go | 8 +-- core/wiki/wiki.go | 9 +++- go.mod | 1 + go.sum | 3 ++ miss/Makefile | 1 + miss/README.md | 126 +--------------------------------------------- miss/go.mod | 10 ++++ miss/go.sum | 7 +++ miss/src/main.go | 12 +++++ miss/usr/volcanos | 1 + template.sh | 4 +- 13 files changed, 103 insertions(+), 184 deletions(-) mode change 100644 => 120000 miss/README.md create mode 100644 miss/go.mod create mode 100644 miss/go.sum create mode 100644 miss/src/main.go create mode 120000 miss/usr/volcanos diff --git a/README.md b/README.md index fadf1f43..2b0480ba 100644 --- a/README.md +++ b/README.md @@ -2,67 +2,67 @@ icebergs是一个后端框架,通过模块化、集群化实现资源的无限的扩展与自由的组合。 -使用icebergs可以将各种模块或项目集成到一起,快速开发出集中式的服务器。 +- 使用icebergs可以将各种模块或项目集成到一起,快速开发出集中式的服务器。 +- 使用icebergs可以将各种设备自由的组合在一起,快速搭建起分布式的服务器。 -使用icebergs可以将各种设备自由的组合在一起,快速搭建起分布式的服务器。 +所以通过icebergs开发出来的各种模块,无需任何多余代码,就可以独立运行,可以成为系统命令,可以远程调用,可以成为前端插件,可以成为小程序页面。 +从而提高代码的复用性与灵活性。 -所以通过icebergs开发出来的模块,无需任何多余代码,就可以独立运行,可以成为系统命令,可以远程调用,可以成为前端插件,可以成为小程序页面。 +## 1. 项目开发 -## 项目开发 -开发环境,需要安装git,golang - -一键创建项目 -``` +### 1.1 一键创建项目 +*开发环境,需要安装git和golang* +```sh mkdir miss; cd miss && curl -s https://shylinux.com/publish/template.sh | sh ``` - -运行环境,如需前端页面访问服务,需要安装git -一键复制项目 -``` -export ctx_dev=http://127.0.0.1:9020 && curl -s $ctx_dev/publish/ice.sh +### 1.2 一键部署项目 +*运行环境,如需通过前端页面访问服务,则需要安装git* +```sh +export ctx_dev=http://127.0.0.1:9020 && curl -s $ctx_dev/publish/ice.sh | sh ``` +*ctx_dev是开发机地址,不必是本机地址,可以是任意一台先前创建过项目的机器地址。* -## 1 原型 type.go -### 1.1 msg.Detail -### 1.2 msg.Option -### 1.3 msg.Append -### 1.4 msg.Result -### 1.5 msg.Travel -### 1.6 msg.Search -### 1.7 msg.Conf -### 1.8 msg.Cmd -### 1.9 msg.Cap +## 2 原型设计 type.go +### 2.1 msg.Detail +### 2.2 msg.Option +### 2.3 msg.Append +### 2.4 msg.Result +### 2.5 msg.Travel +### 2.6 msg.Search +### 2.7 msg.Conf +### 2.8 msg.Cmd +### 2.9 msg.Cap -## 2 框架 base.go -### 2.1 注册模块 Register -### 2.2 创建资源 Begin -### 2.3 加载配置 _init -### 2.4 启动服务 Start -### 2.5 保存配置 _exit -### 2.6 释放资源 Close +## 3 框架 base.go +### 3.1 注册模块 Register +### 3.2 创建资源 Begin +### 3.3 加载配置 _init +### 3.4 启动服务 Start +### 3.5 保存配置 _exit +### 3.6 释放资源 Close -## 3 基础模块 base/ -### 3.1 模块中心 base/ctx -### 3.2 命令中心 base/cli -### 3.3 认证中心 base/aaa -### 3.4 网页中心 base/web +## 4 基础模块 base/ +### 4.1 模块中心 base/ctx +### 4.2 命令中心 base/cli +### 4.3 认证中心 base/aaa +### 4.4 网页中心 base/web -### 3.5 词法中心 base/lex -### 3.6 语法中心 base/yac -### 3.7 事件中心 base/gdb -### 3.8 日志中心 base/log +### 4.5 词法中心 base/lex +### 4.6 语法中心 base/yac +### 4.7 事件中心 base/gdb +### 4.8 日志中心 base/log -### 3.9 网络中心 base/tcp -### 3.10 文件中心 base/nfs -### 3.11 终端中心 base/ssh -### 3.12 数据中心 base/mdb +### 4.9 网络中心 base/tcp +### 4.10 文件中心 base/nfs +### 4.11 终端中心 base/ssh +### 4.12 数据中心 base/mdb -## 4 核心模块 core/ -### 4.1 编程中心 core/code -### 4.2 文档中心 core/wiki -### 4.3 聊天中心 core/chat -### 4.4 团队中心 core/team -### 4.5 贸易中心 core/mall +## 5 核心模块 core/ +### 5.1 编程中心 core/code +### 5.2 文档中心 core/wiki +### 5.3 聊天中心 core/chat +### 5.4 团队中心 core/team +### 5.5 贸易中心 core/mall ## 5 配置 conf.go ### 5.1 环境 init diff --git a/core/chat/chat.go b/core/chat/chat.go index 56223a9b..ad8936d4 100644 --- a/core/chat/chat.go +++ b/core/chat/chat.go @@ -46,6 +46,13 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心", m.Cmd(ice.WEB_FAVOR, "river.root", "field", "total", "cli.git") m.Cmd(ice.WEB_FAVOR, "river.root", "field", "branch", "cli.git") m.Cmd(ice.WEB_FAVOR, "river.root", "field", "status", "cli.git") + + m.Cmd(ice.WEB_FAVOR, "river.root", "storm", "note") + m.Cmd(ice.WEB_FAVOR, "river.root", "field", "total", "cli.git") + m.Cmd(ice.WEB_FAVOR, "river.root", "field", "date", "web.team") + m.Cmd(ice.WEB_FAVOR, "river.root", "field", "miss", "web.team") + m.Cmd(ice.WEB_FAVOR, "river.root", "field", "progress", "web.team") + m.Cmd(ice.WEB_FAVOR, "river.root", "field", "note", "web.wiki") } // 用户权限 diff --git a/core/team/team.go b/core/team/team.go index b3452baa..a663b0b3 100644 --- a/core/team/team.go +++ b/core/team/team.go @@ -119,10 +119,7 @@ var Index = &ice.Context{Name: "team", Help: "团队中心", } } }}, - "stat": {Name: "stat", Help: "统计", Meta: kit.Dict( - "display", "demo.wasm", - // "display", "github.com/shylinux/icebergs/core/team/stat", - ), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + "stat": {Name: "stat", Help: "统计", Meta: kit.Dict(), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { hot := kit.Select(ice.FAVOR_MISS, m.Option("hot")) stat := map[string]int{} m.Option("cache.limit", "1000") @@ -136,8 +133,7 @@ var Index = &ice.Context{Name: "team", Help: "团队中心", } }}, "progress": {Name: "progress", Help: "进度", Meta: kit.Dict( - "remote", "you", - "display", "github.com/shylinux/icebergs/core/team/miss", + "remote", "you", "display", "team/miss", "detail", []string{"回退", "前进", "取消", "完成"}, ), List: kit.List( kit.MDB_INPUT, "text", "value", "", diff --git a/core/wiki/wiki.go b/core/wiki/wiki.go index 410ee78c..bc3993bf 100644 --- a/core/wiki/wiki.go +++ b/core/wiki/wiki.go @@ -1,6 +1,7 @@ package wiki import ( + "github.com/gomarkdown/markdown" "github.com/shylinux/icebergs" _ "github.com/shylinux/icebergs/base" "github.com/shylinux/icebergs/base/web" @@ -195,7 +196,11 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心", } // 生成网页 - m.Echo(string(buffer.Bytes())) + data := buffer.Bytes() + if strings.HasSuffix(arg[0], ".md") { + data = markdown.ToHTML(buffer.Bytes(), nil, nil) + } + m.Echo(string(data)) }}, "_tree": {Name: "_tree path", Help: "文库", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { m.Option("dir_deep", "true") @@ -203,7 +208,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心", m.Cmdy("nfs.dir", kit.Select(m.Conf("note", "meta.path"), arg, 0), m.Conf("note", "meta.head")) }}, "note": {Name: "note file", Help: "笔记", Meta: kit.Dict("remote", "you", "display", "inner"), List: kit.List( - kit.MDB_INPUT, "text", "name", "path", "value", "miss.md", + kit.MDB_INPUT, "text", "name", "path", "value", "README.md", kit.MDB_INPUT, "button", "name", "执行", "action", "auto", kit.MDB_INPUT, "button", "name", "返回", "cb", "Last", ), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { diff --git a/go.mod b/go.mod index e2da1653..1613dda3 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/shylinux/icebergs go 1.13 require ( + github.com/gomarkdown/markdown v0.0.0-20200112043221-ec51d717629d github.com/gorilla/websocket v1.4.1 github.com/shylinux/toolkits v0.1.0 github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086 diff --git a/go.sum b/go.sum index 5a464ddc..bf1bf5df 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,9 @@ +github.com/gomarkdown/markdown v0.0.0-20200112043221-ec51d717629d h1:Qw3Ku+gg4x3gfv71ayr0SbjJYWpWD10XoS9JbtFgvbg= +github.com/gomarkdown/markdown v0.0.0-20200112043221-ec51d717629d/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/shylinux/toolkits v0.1.0 h1:7ghnVEjuwLf7zBsyeR37ahm2gaOKIyjSw9F9Pp9oTBU= github.com/shylinux/toolkits v0.1.0/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g= github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086 h1:RYiqpb2ii2Z6J4x0wxK46kvPBbFuZcdhS+CIztmYgZs= github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo= +golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ= diff --git a/miss/Makefile b/miss/Makefile index 5caee8da..2787cdf8 100644 --- a/miss/Makefile +++ b/miss/Makefile @@ -1,3 +1,4 @@ all: @echo && date + export GOPRIVATE=github.com go build -o bin/ice.bin src/main.go && chmod u+x bin/ice.bin && ./bin/ice.sh restart diff --git a/miss/README.md b/miss/README.md deleted file mode 100644 index ca854c60..00000000 --- a/miss/README.md +++ /dev/null @@ -1,125 +0,0 @@ -{{title "ICEBERGS"}} -{{brief `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}} - -{{shell "一键创建项目" "usr" "install" `mkdir miss; cd miss && curl -s https://shylinux.com/publish/build.sh | sh`}} - -{{shell "一键启动项目" "usr" "install" `mkdir miss; cd miss && curl -s https://shylinux.com/publish/ice.sh | sh`}} - -{{chapter "配置模块 base/ctx"}} -{{chapter "命令模块 base/cli"}} -cli模块用于与系统进行交互。 - -{{order "命令" ` -系统信息 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模块会根据各种触发条件,择机执行各种命令。 - -{{order "命令" ` -信号器 ice.SIGNAL -定时器 ice.TIMER -触发器 ice.EVENT -`}} - -{{chapter "认证模块 base/aaa"}} -aaa模块用于各种权限管理与身份认证。 - -{{order "命令" ` -角色 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"}} - diff --git a/miss/README.md b/miss/README.md new file mode 120000 index 00000000..32d46ee8 --- /dev/null +++ b/miss/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/miss/go.mod b/miss/go.mod new file mode 100644 index 00000000..339a6890 --- /dev/null +++ b/miss/go.mod @@ -0,0 +1,10 @@ +module miss + +go 1.13 + +require github.com/shylinux/icebergs v0.1.9 // indirect + +replace ( + github.com/shylinux/icebergs => ../ + github.com/shylinux/toolkits => ../../toolkits +) diff --git a/miss/go.sum b/miss/go.sum new file mode 100644 index 00000000..91e90018 --- /dev/null +++ b/miss/go.sum @@ -0,0 +1,7 @@ +github.com/gomarkdown/markdown v0.0.0-20200112043221-ec51d717629d h1:Qw3Ku+gg4x3gfv71ayr0SbjJYWpWD10XoS9JbtFgvbg= +github.com/gomarkdown/markdown v0.0.0-20200112043221-ec51d717629d/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086 h1:RYiqpb2ii2Z6J4x0wxK46kvPBbFuZcdhS+CIztmYgZs= +github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo= +golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ= diff --git a/miss/src/main.go b/miss/src/main.go new file mode 100644 index 00000000..b9de0a2d --- /dev/null +++ b/miss/src/main.go @@ -0,0 +1,12 @@ +package main + +import ( + "github.com/shylinux/icebergs" + _ "github.com/shylinux/icebergs/base" + _ "github.com/shylinux/icebergs/core" + _ "github.com/shylinux/icebergs/misc" +) + +func main() { + println(ice.Run()) +} diff --git a/miss/usr/volcanos b/miss/usr/volcanos new file mode 120000 index 00000000..18cdef24 --- /dev/null +++ b/miss/usr/volcanos @@ -0,0 +1 @@ +../../../volcanos \ No newline at end of file diff --git a/template.sh b/template.sh index b6188c3f..5818bce1 100755 --- a/template.sh +++ b/template.sh @@ -29,7 +29,7 @@ func main() { } END - [ -f src/go.mod ] || cd src && go mod init ${ice_mod} && cd .. + [ -f go.mod ] || go mod init ${ice_mod} [ -f Makefile ] || cat >> Makefile <