forked from x/icebergs
opt code
This commit is contained in:
parent
be829ce488
commit
96df24975d
@ -165,3 +165,8 @@ func OptionLoad(m *ice.Message, file string) *ice.Message {
|
|||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Template(m *ice.Message, file string) string { return kit.Renders(TemplateText(m, file), m) }
|
||||||
|
func TemplateText(m *ice.Message, file string) string {
|
||||||
|
return m.Cmdx(CAT, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), path.Base(file)))
|
||||||
|
}
|
||||||
|
@ -162,7 +162,7 @@ func RenderIndex(m *ice.Message, repos string, file ...string) *ice.Message {
|
|||||||
}
|
}
|
||||||
func RenderMain(m *ice.Message, pod, index string, arg ...ice.Any) *ice.Message {
|
func RenderMain(m *ice.Message, pod, index string, arg ...ice.Any) *ice.Message {
|
||||||
if script := m.Cmdx(Space(m, pod), nfs.CAT, kit.Select(ice.SRC_MAIN_JS, index)); script != "" {
|
if script := m.Cmdx(Space(m, pod), nfs.CAT, kit.Select(ice.SRC_MAIN_JS, index)); script != "" {
|
||||||
return m.Echo(kit.Renders(_main_template, ice.Maps{"version": renderVersion(m), "script": script})).RenderResult()
|
return m.Echo(kit.Renders(m.Cmdx(nfs.CAT, path.Join(ice.SRC_TEMPLATE, "web/main.html")), ice.Maps{nfs.VERSION: renderVersion(m), nfs.SCRIPT: script})).RenderResult()
|
||||||
}
|
}
|
||||||
return RenderIndex(m, ice.VOLCANOS)
|
return RenderIndex(m, ice.VOLCANOS)
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ func RenderCmd(m *ice.Message, cmd string, arg ...ice.Any) {
|
|||||||
RenderPodCmd(m, "", cmd, arg...)
|
RenderPodCmd(m, "", cmd, arg...)
|
||||||
}
|
}
|
||||||
func RenderCmds(m *ice.Message, list ...ice.Any) {
|
func RenderCmds(m *ice.Message, list ...ice.Any) {
|
||||||
m.Echo(kit.Renders(_cmd_template, ice.Maps{"version": renderVersion(m), "list": kit.Format(list)})).RenderResult()
|
m.Echo(kit.Renders(m.Cmdx(nfs.CAT, path.Join(ice.SRC_TEMPLATE, "web/cmd.html")), ice.Maps{nfs.VERSION: renderVersion(m), ice.LIST: kit.Format(list)})).RenderResult()
|
||||||
}
|
}
|
||||||
func RenderPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) {
|
func RenderPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) {
|
||||||
msg := m.Cmd(Space(m, pod), ctx.COMMAND, kit.Select("web.wiki.word", cmd))
|
msg := m.Cmd(Space(m, pod), ctx.COMMAND, kit.Select("web.wiki.word", cmd))
|
||||||
@ -178,7 +178,7 @@ func RenderPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) {
|
|||||||
ctx.INDEX, cmd, ctx.ARGS, kit.Simple(arg), ctx.DISPLAY, m.Option(ice.MSG_DISPLAY),
|
ctx.INDEX, cmd, ctx.ARGS, kit.Simple(arg), ctx.DISPLAY, m.Option(ice.MSG_DISPLAY),
|
||||||
mdb.LIST, kit.UnMarshal(msg.Append(mdb.LIST)), mdb.META, kit.UnMarshal(msg.Append(mdb.META)),
|
mdb.LIST, kit.UnMarshal(msg.Append(mdb.LIST)), mdb.META, kit.UnMarshal(msg.Append(mdb.META)),
|
||||||
)))
|
)))
|
||||||
m.Echo(kit.Renders(_cmd_template, ice.Maps{"version": renderVersion(m), "list": list})).RenderResult()
|
m.Echo(kit.Renders(m.Cmdx(nfs.CAT, path.Join(ice.SRC_TEMPLATE, "web/cmd.html")), ice.Maps{nfs.VERSION: renderVersion(m), ice.LIST: list})).RenderResult()
|
||||||
}
|
}
|
||||||
func renderVersion(m *ice.Message) string {
|
func renderVersion(m *ice.Message) string {
|
||||||
if strings.Contains(m.R.URL.RawQuery, "debug=true") {
|
if strings.Contains(m.R.URL.RawQuery, "debug=true") {
|
||||||
@ -186,35 +186,3 @@ func renderVersion(m *ice.Message) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var _main_template = `<!DOCTYPE html>
|
|
||||||
<head>
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=0.8,maximum-scale=0.8,user-scalable=no">
|
|
||||||
<meta charset="utf-8"><title>volcanos</title>
|
|
||||||
<link href="/index.css{{.version}}" rel="stylesheet">
|
|
||||||
<link href="/page/cache.css{{.version}}" rel="stylesheet">
|
|
||||||
<link href="/favicon.ico" rel="shortcut icon" type="image/ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script>_version = "{{.version}}"</script>
|
|
||||||
<script src="/proto.js{{.version}}"></script>
|
|
||||||
<script src="/page/cache.js{{.version}}"></script>
|
|
||||||
<script>{{.script}}</script>
|
|
||||||
</body>
|
|
||||||
`
|
|
||||||
|
|
||||||
var _cmd_template = `<!DOCTYPE html>
|
|
||||||
<head>
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=0.8,maximum-scale=0.8,user-scalable=no">
|
|
||||||
<meta charset="utf-8"><title>volcanos</title>
|
|
||||||
<link href="/index.css{{.version}}" rel="stylesheet">
|
|
||||||
<link href="/page/cache.css{{.version}}" rel="stylesheet">
|
|
||||||
<link href="/favicon.ico" rel="shortcut icon" type="image/ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script>_version = "{{.version}}"</script>
|
|
||||||
<script src="/proto.js{{.version}}"></script>
|
|
||||||
<script src="/page/cache.js{{.version}}"></script>
|
|
||||||
<script>Volcanos({{.list}})</script>
|
|
||||||
</body>
|
|
||||||
`
|
|
||||||
|
1
conf.go
1
conf.go
@ -140,6 +140,7 @@ const ( // DIR
|
|||||||
SRC_HELP = "src/help/"
|
SRC_HELP = "src/help/"
|
||||||
SRC_DEBUG = "src/debug/"
|
SRC_DEBUG = "src/debug/"
|
||||||
SRC_RELEASE = "src/release/"
|
SRC_RELEASE = "src/release/"
|
||||||
|
SRC_TEMPLATE = "src/template/"
|
||||||
SRC_MAIN_SHY = "src/main.shy"
|
SRC_MAIN_SHY = "src/main.shy"
|
||||||
SRC_MAIN_SH = "src/main.sh"
|
SRC_MAIN_SH = "src/main.sh"
|
||||||
SRC_MAIN_JS = "src/main.js"
|
SRC_MAIN_JS = "src/main.js"
|
||||||
|
@ -26,13 +26,13 @@ func _defs_list(m *ice.Message) string {
|
|||||||
}
|
}
|
||||||
func _autogen_source(m *ice.Message, main, file string) {
|
func _autogen_source(m *ice.Message, main, file string) {
|
||||||
main = kit.ExtChange(main, SHY)
|
main = kit.ExtChange(main, SHY)
|
||||||
m.Cmd(nfs.DEFS, main, `title "{{.Option "name"}}"`+ice.NL)
|
m.Cmd(nfs.DEFS, main, nfs.Template(m, ice.SRC_MAIN_SHY))
|
||||||
m.Cmd(nfs.PUSH, main, ssh.SOURCE+ice.SP+strings.TrimPrefix(file, ice.SRC+ice.PS)+ice.NL)
|
m.Cmd(nfs.PUSH, main, ssh.SOURCE+ice.SP+strings.TrimPrefix(file, ice.SRC+ice.PS)+ice.NL)
|
||||||
}
|
}
|
||||||
func _autogen_script(m *ice.Message, file string) { m.Cmd(nfs.DEFS, file, _script_template) }
|
func _autogen_script(m *ice.Message, file string) { m.Cmd(nfs.DEFS, file, nfs.Template(m, "demo.shy")) }
|
||||||
func _autogen_module(m *ice.Message, file string) { m.Cmd(nfs.DEFS, file, _module_template) }
|
func _autogen_module(m *ice.Message, file string) { m.Cmd(nfs.DEFS, file, nfs.Template(m, "demo.go")) }
|
||||||
func _autogen_import(m *ice.Message, main string, ctx string, mod string) {
|
func _autogen_import(m *ice.Message, main string, ctx string, mod string) {
|
||||||
m.Cmd(nfs.DEFS, main, _main_template)
|
m.Cmd(nfs.DEFS, main, nfs.Template(m, ice.SRC_MAIN_GO))
|
||||||
begin, done, list := false, false, []string{}
|
begin, done, list := false, false, []string{}
|
||||||
m.Cmd(nfs.CAT, main, func(line string, index int) {
|
m.Cmd(nfs.CAT, main, func(line string, index int) {
|
||||||
if begin && !done && strings.HasPrefix(line, ")") {
|
if begin && !done && strings.HasPrefix(line, ")") {
|
||||||
@ -50,20 +50,21 @@ func _autogen_import(m *ice.Message, main string, ctx string, mod string) {
|
|||||||
m.Cmd(nfs.SAVE, main, kit.Join(list, ice.NL))
|
m.Cmd(nfs.SAVE, main, kit.Join(list, ice.NL))
|
||||||
m.Cmd(cli.SYSTEM, "goimports", "-w", main)
|
m.Cmd(cli.SYSTEM, "goimports", "-w", main)
|
||||||
}
|
}
|
||||||
func _autogen_version(m *ice.Message) {
|
func _autogen_version(m *ice.Message) string {
|
||||||
if mod := _autogen_mod(m, ice.GO_MOD); !nfs.ExistsFile(m, ".git") {
|
if mod := _autogen_mod(m, ice.GO_MOD); !nfs.ExistsFile(m, ".git") {
|
||||||
m.Cmdy(cli.SYSTEM, GIT, ice.INIT)
|
m.Cmdy(cli.SYSTEM, GIT, ice.INIT)
|
||||||
m.Cmd(cli.SYSTEM, GIT, "remote", "add", "origin", "https://"+mod)
|
m.Cmd(cli.SYSTEM, GIT, nfs.REMOTE, "add", nfs.ORIGIN, "https://"+mod)
|
||||||
m.Cmd(cli.SYSTEM, GIT, "add", ice.GO_MOD, ice.SRC, ice.ETC_MISS_SH)
|
m.Cmd(cli.SYSTEM, GIT, "add", ice.GO_MOD, ice.SRC, ice.ETC_MISS_SH)
|
||||||
m.Cmd("web.code.git.repos", mdb.CREATE, nfs.ORIGIN, "https://"+mod, mdb.NAME, path.Base(mod), nfs.PATH, nfs.PWD)
|
m.Cmd("web.code.git.repos", mdb.CREATE, nfs.ORIGIN, "https://"+mod, mdb.NAME, path.Base(mod), nfs.PATH, nfs.PWD)
|
||||||
}
|
}
|
||||||
m.Cmd(nfs.DEFS, ".gitignore", _git_ignore)
|
m.Cmd(nfs.DEFS, ".gitignore", nfs.Template(m, "gitignore"))
|
||||||
m.Cmd(nfs.DEFS, ice.SRC_BINPACK_GO, `package main`+ice.NL)
|
m.Cmd(nfs.DEFS, ice.SRC_BINPACK_GO, nfs.Template(m, ice.SRC_BINPACK_GO))
|
||||||
m.Cmd(nfs.SAVE, ice.SRC_VERSION_GO, kit.Format(_version_template, _autogen_gits(m, nfs.MODULE, _autogen_mod(m, ice.GO_MOD), tcp.HOSTNAME, ice.Info.Hostname)))
|
m.Cmd(nfs.SAVE, ice.SRC_VERSION_GO, kit.Format(nfs.Template(m, ice.SRC_VERSION_GO), _autogen_gits(m, nfs.MODULE, _autogen_mod(m, ice.GO_MOD), tcp.HOSTNAME, ice.Info.Hostname)))
|
||||||
m.Cmd(cli.SYSTEM, "gofmt", "-w", ice.SRC_VERSION_GO)
|
m.Cmd(cli.SYSTEM, "gofmt", "-w", ice.SRC_VERSION_GO)
|
||||||
m.Cmdy(nfs.DIR, ice.SRC_BINPACK_GO)
|
m.Cmdy(nfs.DIR, ice.SRC_BINPACK_GO)
|
||||||
m.Cmdy(nfs.DIR, ice.SRC_VERSION_GO)
|
m.Cmdy(nfs.DIR, ice.SRC_VERSION_GO)
|
||||||
m.Cmdy(nfs.DIR, ice.SRC_MAIN_GO)
|
m.Cmdy(nfs.DIR, ice.SRC_MAIN_GO)
|
||||||
|
return ice.SRC_VERSION_GO
|
||||||
}
|
}
|
||||||
func _autogen_gits(m *ice.Message, arg ...string) string {
|
func _autogen_gits(m *ice.Message, arg ...string) string {
|
||||||
res := []string{}
|
res := []string{}
|
||||||
@ -90,54 +91,63 @@ func _autogen_mod(m *ice.Message, file string) (mod string) {
|
|||||||
} else {
|
} else {
|
||||||
host = path.Join(host, "x", path.Base(kit.Path("")))
|
host = path.Join(host, "x", path.Base(kit.Path("")))
|
||||||
}
|
}
|
||||||
m.Cmd(nfs.DEFS, file, kit.Format(`module %s
|
m.Cmd(nfs.DEFS, file, kit.Format(nfs.Template(m, ice.GO_MOD), host))
|
||||||
|
|
||||||
go 1.11
|
|
||||||
`, host))
|
|
||||||
m.Cmd(nfs.CAT, file, func(line string) {
|
m.Cmd(nfs.CAT, file, func(line string) {
|
||||||
if strings.HasPrefix(line, "module") {
|
if strings.HasPrefix(line, nfs.MODULE) {
|
||||||
mod = kit.Split(line, ice.SP)[1]
|
mod = kit.Split(line, ice.SP)[1]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
GIT = "git"
|
||||||
|
)
|
||||||
const AUTOGEN = "autogen"
|
const AUTOGEN = "autogen"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
AUTOGEN: {Name: "autogen path auto module binpack script", Help: "生成", Actions: ice.Actions{
|
AUTOGEN: {Name: "autogen path auto version module script", Help: "生成", Actions: ice.Actions{
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case cli.MAIN:
|
case cli.MAIN:
|
||||||
m.Cmdy(nfs.DIR, nfs.PWD, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_ROOT, m.Option(nfs.PATH), nfs.DIR_REG, `.*\.go$`)).RenameAppend(nfs.PATH, arg[0])
|
m.Cmdy(nfs.DIR, nfs.PWD, nfs.PATH, kit.Dict(nfs.DIR_ROOT, ice.SRC, nfs.DIR_REG, kit.ExtReg(GO)))
|
||||||
|
case mdb.ZONE, mdb.NAME:
|
||||||
|
m.Cmdy(nfs.DIR, nfs.PWD, mdb.NAME, kit.Dict(nfs.DIR_ROOT, ice.SRC, nfs.DIR_TYPE, nfs.DIR))
|
||||||
|
case mdb.KEY:
|
||||||
|
m.Push(arg[0], Prefix(m.Option(mdb.ZONE), m.Option(mdb.NAME)))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
nfs.MODULE: {Name: "module name*=hi help type*=Zone,Hash,Data,Code,Lang main*=main.go@key zone key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
nfs.MODULE: {Name: "module name*=hi help type*=Zone,Hash,Data,Code,Lang main*=main.go@key zone key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.OptionDefault(mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME))
|
m.OptionDefault(mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME))
|
||||||
m.OptionDefault(mdb.KEY, Prefix(m.Option(mdb.ZONE), m.Option(mdb.NAME)))
|
m.OptionDefault(mdb.KEY, Prefix(m.Option(mdb.ZONE), m.Option(mdb.NAME)))
|
||||||
|
m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)))
|
||||||
m.Option(mdb.TEXT, kit.Format("`name:\"list %s\" help:\"%s\"`", _defs_list(m), m.Option(mdb.HELP)))
|
m.Option(mdb.TEXT, kit.Format("`name:\"list %s\" help:\"%s\"`", _defs_list(m), m.Option(mdb.HELP)))
|
||||||
nfs.OptionFiles(m, nfs.DiskFile)
|
nfs.OptionFiles(m, nfs.DiskFile)
|
||||||
if p := path.Join(ice.SRC, m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), SHY)); !nfs.ExistsFile(m, p) {
|
if p := path.Join(ice.SRC, kit.ExtChange(m.Option(nfs.FILE), SHY)); !nfs.ExistsFile(m, p) {
|
||||||
_autogen_source(m, path.Join(ice.SRC, m.Option(cli.MAIN)), p)
|
_autogen_source(m, path.Join(ice.SRC, m.Option(cli.MAIN)), p)
|
||||||
_autogen_script(m, p)
|
_autogen_script(m, p)
|
||||||
}
|
}
|
||||||
if p := path.Join(ice.SRC, m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)); !nfs.ExistsFile(m, p) {
|
if p := path.Join(ice.SRC, m.Option(nfs.FILE)); !nfs.ExistsFile(m, p) {
|
||||||
|
_autogen_import(m, path.Join(ice.SRC, m.Option(cli.MAIN)), m.Option(mdb.ZONE), _autogen_mod(m, ice.GO_MOD))
|
||||||
_autogen_module(m, p)
|
_autogen_module(m, p)
|
||||||
}
|
}
|
||||||
_autogen_import(m, path.Join(ice.SRC, m.Option(cli.MAIN)), m.Option(mdb.ZONE), _autogen_mod(m, ice.GO_MOD))
|
|
||||||
m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)))
|
|
||||||
_autogen_version(m.Spawn())
|
_autogen_version(m.Spawn())
|
||||||
}},
|
}},
|
||||||
nfs.SCRIPT: {Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
nfs.SCRIPT: {Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(nfs.DEFS, ice.ETC_MISS_SH, _miss_template)
|
m.Cmd(nfs.DEFS, ice.ETC_MISS_SH, nfs.Template(m, ice.ETC_MISS_SH))
|
||||||
defer m.Cmdy(nfs.CAT, ice.ETC_MISS_SH)
|
defer m.Cmdy(nfs.CAT, ice.ETC_MISS_SH)
|
||||||
m.Cmdy(nfs.DIR, ice.ETC_MISS_SH)
|
m.Cmdy(nfs.DIR, ice.ETC_MISS_SH)
|
||||||
m.Cmdy(nfs.DIR, ice.GO_MOD)
|
m.Cmdy(nfs.DIR, ice.GO_MOD)
|
||||||
m.Cmdy(nfs.DIR, ice.GO_SUM)
|
m.Cmdy(nfs.DIR, ice.GO_SUM)
|
||||||
}},
|
}},
|
||||||
|
DEVPACK: {Help: "开发", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(WEBPACK, mdb.REMOVE)
|
||||||
|
m.Cmdy(nfs.DIR, path.Join(ice.USR_VOLCANOS, PAGE))
|
||||||
|
}},
|
||||||
WEBPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
WEBPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(WEBPACK, mdb.CREATE)
|
m.Cmdy(WEBPACK, mdb.CREATE)
|
||||||
|
m.Cmdy(nfs.DIR, path.Join(ice.USR_VOLCANOS, PAGE))
|
||||||
m.Cmdy(nfs.DIR, ice.USR_PUBLISH, kit.Dict(nfs.DIR_REG, "can.*"))
|
m.Cmdy(nfs.DIR, ice.USR_PUBLISH, kit.Dict(nfs.DIR_REG, "can.*"))
|
||||||
}},
|
}},
|
||||||
BINPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
BINPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -151,74 +161,13 @@ func init() {
|
|||||||
m.Cmdy(nfs.DIR, ice.USR_RELEASE+BINPACK_GO)
|
m.Cmdy(nfs.DIR, ice.USR_RELEASE+BINPACK_GO)
|
||||||
m.Cmdy(nfs.DIR, ice.USR_RELEASE+CONF_GO)
|
m.Cmdy(nfs.DIR, ice.USR_RELEASE+CONF_GO)
|
||||||
}
|
}
|
||||||
_autogen_version(m)
|
m.Cmdy(nfs.CAT, _autogen_version(m))
|
||||||
m.Cmdy(nfs.CAT, ice.SRC_VERSION_GO)
|
}},
|
||||||
|
VERSION: {Help: "版本", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(nfs.CAT, _autogen_version(m))
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, arg ...string) {
|
}, Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(nfs.CAT, kit.Select(path.Base(ice.SRC_VERSION_GO), arg, 0), kit.Dict(nfs.DIR_ROOT, ice.SRC))
|
m.Cmdy(nfs.CAT, kit.Select(path.Base(ice.SRC_VERSION_GO), arg, 0), kit.Dict(nfs.DIR_ROOT, ice.SRC))
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _miss_template = `#! /bin/sh
|
|
||||||
|
|
||||||
if [ -f $PWD/.ish/plug.sh ]; then source $PWD/.ish/plug.sh; elif [ -f $HOME/.ish/plug.sh ]; then source $HOME/.ish/plug.sh; else
|
|
||||||
ctx_temp=$(mktemp); if curl -h &>/dev/null; then curl -o $ctx_temp -fsSL https://shylinux.com; else wget -O $ctx_temp -q http://shylinux.com; fi; source $ctx_temp intshell
|
|
||||||
fi
|
|
||||||
|
|
||||||
require miss.sh
|
|
||||||
ish_miss_prepare_compile
|
|
||||||
ish_miss_prepare_develop
|
|
||||||
ish_miss_prepare_project
|
|
||||||
|
|
||||||
ish_miss_make; if [ -n "$*" ]; then ish_miss_serve "$@"; fi
|
|
||||||
`
|
|
||||||
var _main_template = `package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"shylinux.com/x/ice"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() { print(ice.Run()) }
|
|
||||||
`
|
|
||||||
var _module_template = `package {{.Option "zone"}}
|
|
||||||
|
|
||||||
import (
|
|
||||||
"shylinux.com/x/ice"
|
|
||||||
)
|
|
||||||
|
|
||||||
type {{.Option "name"}} struct {
|
|
||||||
ice.{{.Option "type"}}
|
|
||||||
|
|
||||||
list string {{.Option "text"}}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) {
|
|
||||||
s.{{.Option "type"}}.List(m, arg...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { ice.Cmd("{{.Option "key"}}", {{.Option "name"}}{}) }
|
|
||||||
`
|
|
||||||
var _version_template = `package main
|
|
||||||
|
|
||||||
import ice "shylinux.com/x/icebergs"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
ice.Info.Make = ice.MakeInfo{
|
|
||||||
%s
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
var _script_template = `chapter "{{.Option "name"}}"
|
|
||||||
|
|
||||||
field {{.Option "key"}}
|
|
||||||
`
|
|
||||||
var _git_ignore = `
|
|
||||||
src/binpack.go
|
|
||||||
src/version.go
|
|
||||||
etc/
|
|
||||||
bin/
|
|
||||||
var/
|
|
||||||
usr/
|
|
||||||
.*
|
|
||||||
`
|
|
||||||
|
@ -16,11 +16,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _binpack_file(m *ice.Message, w io.Writer, arg ...string) {
|
func _binpack_file(m *ice.Message, w io.Writer, arg ...string) {
|
||||||
if strings.HasPrefix(arg[0], "usr/volcanos/page/") && !strings.Contains(arg[0], "/cache.") {
|
if strings.HasPrefix(arg[0], "usr/volcanos/publish/") && !strings.HasSuffix(arg[0], "/proto.js") {
|
||||||
fmt.Fprintf(w, " \"%s\": \"%s\",\n", kit.Select(arg[0], arg, 1), "")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(arg[0], "usr/volcanos/publish/") && !strings.HasSuffix(arg[0], "/proto.js") {
|
if strings.HasPrefix(arg[0], "usr/volcanos/page/") && !strings.Contains(arg[0], "/cache.") {
|
||||||
|
fmt.Fprintf(w, " \"%s\": \"%s\",\n", kit.Select(arg[0], arg, 1), "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch path.Base(arg[0]) {
|
switch path.Base(arg[0]) {
|
||||||
@ -39,32 +39,24 @@ func _binpack_file(m *ice.Message, w io.Writer, arg ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _binpack_dir(m *ice.Message, w io.Writer, dir string) {
|
func _binpack_dir(m *ice.Message, w io.Writer, dir string) {
|
||||||
nfs.DirDeepAll(m, dir, nfs.PWD, func(value ice.Maps) {
|
nfs.DirDeepAll(m, dir, nfs.PWD, func(value ice.Maps) { _binpack_file(m, w, path.Join(dir, value[nfs.PATH])) })
|
||||||
_binpack_file(m, w, path.Join(dir, value[nfs.PATH]))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
func _binpack_all(m *ice.Message) {
|
func _binpack_all(m *ice.Message) {
|
||||||
nfs.OptionFiles(m, nfs.DiskFile)
|
nfs.OptionFiles(m, nfs.DiskFile)
|
||||||
if w, p, e := nfs.CreateFile(m, ice.SRC_BINPACK_GO); m.Assert(e) {
|
if w, p, e := nfs.CreateFile(m, ice.SRC_BINPACK_GO); m.Assert(e) {
|
||||||
defer w.Close()
|
defer w.Close()
|
||||||
defer m.Echo(p)
|
defer m.Echo(p)
|
||||||
fmt.Fprintln(w, _binpack_template)
|
fmt.Fprintln(w, nfs.Template(m, ice.SRC_BINPACK_GO))
|
||||||
defer fmt.Fprintln(w, _binpack_template_end)
|
defer fmt.Fprintln(w, nfs.Template(m, "binpack_end.go"))
|
||||||
_binpack_dir(m, w, ice.USR_VOLCANOS)
|
for _, p := range []string{ice.USR_VOLCANOS, ice.USR_INTSHELL, ice.SRC} {
|
||||||
_binpack_dir(m, w, ice.USR_INTSHELL)
|
_binpack_dir(m, w, p)
|
||||||
_binpack_dir(m, w, ice.SRC)
|
}
|
||||||
_binpack_file(m, w, ice.ETC_MISS_SH)
|
for _, p := range []string{ice.ETC_MISS_SH, ice.ETC_INIT_SHY, ice.ETC_EXIT_SHY, ice.README_MD, ice.MAKEFILE, ice.LICENSE} {
|
||||||
_binpack_file(m, w, ice.ETC_INIT_SHY)
|
_binpack_file(m, w, p)
|
||||||
_binpack_file(m, w, ice.ETC_EXIT_SHY)
|
}
|
||||||
_binpack_file(m, w, ice.README_MD)
|
list, cache := map[string]bool{}, kit.Select(ice.USR_REQUIRE, m.Cmdx(cli.SYSTEM, GO, "env", "GOMODCACHE"))
|
||||||
_binpack_file(m, w, ice.MAKEFILE)
|
|
||||||
_binpack_file(m, w, ice.LICENSE)
|
|
||||||
|
|
||||||
cache := kit.Select(ice.USR_REQUIRE, m.Cmdx(cli.SYSTEM, "go", "env", "GOMODCACHE"))
|
|
||||||
list := map[string]bool{}
|
|
||||||
for k := range ice.Info.File {
|
for k := range ice.Info.File {
|
||||||
ls := strings.Split(k, ice.PS)
|
switch ls := strings.Split(k, ice.PS); ls[2] {
|
||||||
switch ls[2] {
|
|
||||||
case ice.SRC:
|
case ice.SRC:
|
||||||
case ice.USR:
|
case ice.USR:
|
||||||
list[path.Join(kit.Slice(ls, 2, -1)...)] = true
|
list[path.Join(kit.Slice(ls, 2, -1)...)] = true
|
||||||
@ -73,7 +65,7 @@ func _binpack_all(m *ice.Message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, p := range kit.SortedKey(list) {
|
for _, p := range kit.SortedKey(list) {
|
||||||
m.Cmd(nfs.DIR, p, nfs.PATH, kit.Dict(nfs.DIR_ROOT, nfs.PWD, nfs.DIR_REG, kit.ExtReg("(sh|shy|js)"))).Tables(func(value ice.Maps) {
|
m.Cmd(nfs.DIR, p, nfs.PATH, kit.Dict(nfs.DIR_ROOT, nfs.PWD, nfs.DIR_REG, kit.ExtReg("(sh|shy|py|js|css|html)"))).Tables(func(value ice.Maps) {
|
||||||
if strings.Contains(value[nfs.PATH], "/go/pkg/mod/") {
|
if strings.Contains(value[nfs.PATH], "/go/pkg/mod/") {
|
||||||
_binpack_file(m, w, value[nfs.PATH], ice.USR_REQUIRE+strings.Split(value[nfs.PATH], "/go/pkg/mod/")[1])
|
_binpack_file(m, w, value[nfs.PATH], ice.USR_REQUIRE+strings.Split(value[nfs.PATH], "/go/pkg/mod/")[1])
|
||||||
} else {
|
} else {
|
||||||
@ -98,28 +90,8 @@ const BINPACK = "binpack"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
BINPACK: {Name: "binpack path auto create insert", Help: "打包", Actions: ice.MergeActions(ice.Actions{
|
BINPACK: {Name: "binpack path auto create insert", Help: "打包", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.CREATE: {Name: "create", Hand: func(m *ice.Message, arg ...string) { _binpack_all(m) }},
|
mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) { _binpack_all(m) }},
|
||||||
mdb.INSERT: {Name: "insert path*", Hand: func(m *ice.Message, arg ...string) { mdb.HashCreate(m) }},
|
mdb.INSERT: {Name: "insert path*", Hand: func(m *ice.Message, arg ...string) { mdb.HashCreate(m) }},
|
||||||
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path"))},
|
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path"))},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _binpack_template = `package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/base64"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
pack := ice.Maps{`
|
|
||||||
var _binpack_template_end = ` }
|
|
||||||
nfs.PackFile.RemoveAll(ice.SRC)
|
|
||||||
for k, v := range pack {
|
|
||||||
if b, e := base64.StdEncoding.DecodeString(v); e == nil {
|
|
||||||
nfs.PackFile.WriteFile(k, b)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
|
@ -44,7 +44,7 @@ func init() {
|
|||||||
C: {Name: "c path auto", Help: "编程", Actions: ice.MergeActions(ice.Actions{
|
C: {Name: "c path auto", Help: "编程", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _c_show(m, arg...) }},
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _c_show(m, arg...) }},
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _c_exec(m, arg...) }},
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _c_exec(m, arg...) }},
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_c_template) }},
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.c")) }},
|
||||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
|
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
|
||||||
}, PlugAction())},
|
}, PlugAction())},
|
||||||
H: {Name: "h path auto", Help: "编程", Actions: ice.MergeActions(ice.Actions{
|
H: {Name: "h path auto", Help: "编程", Actions: ice.MergeActions(ice.Actions{
|
||||||
@ -52,10 +52,3 @@ func init() {
|
|||||||
}, PlugAction())},
|
}, PlugAction())},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _c_template = `#include <stdio.h>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
printf("hello world\n");
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
@ -3,9 +3,9 @@ code.shy
|
|||||||
|
|
||||||
install.go
|
install.go
|
||||||
upgrade.go
|
upgrade.go
|
||||||
autogen.go
|
|
||||||
webpack.go
|
webpack.go
|
||||||
binpack.go
|
binpack.go
|
||||||
|
autogen.go
|
||||||
compile.go
|
compile.go
|
||||||
publish.go
|
publish.go
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,44 +36,49 @@ func _compile_target(m *ice.Message, arg ...string) (string, string, string, str
|
|||||||
return main, file, goos, arch
|
return main, file, goos, arch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "version"
|
||||||
|
)
|
||||||
const COMPILE = "compile"
|
const COMPILE = "compile"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack webpack", Help: "编译", Actions: ice.MergeActions(ice.Actions{
|
COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack webpack devpack", Help: "编译", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { cli.IsAlpine(m, GO, "go git") }},
|
||||||
kit.Fetch([]string{"curl", "make", "gcc", "vim", "tmux"}, func(cmd string) { cli.IsSystem(m, cmd) })
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if cli.IsAlpine(m, "git"); !cli.IsAlpine(m, "go", "go git") {
|
switch arg[0] {
|
||||||
m.Cmd(mdb.INSERT, cli.MIRRORS, "", mdb.ZONE, cli.CLI, "go", cli.CMD, kit.Format("install download https://golang.google.cn/dl/go1.15.5.%s-%s.tar.gz usr/local", runtime.GOOS, runtime.GOARCH))
|
case VERSION:
|
||||||
|
m.Push(arg[0], "1.15.15")
|
||||||
|
default:
|
||||||
|
m.Cmdy(nfs.DIR, ice.SRC, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_REG, kit.ExtReg(GO)))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
BINPACK: {Help: "版本", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(AUTOGEN, BINPACK) }},
|
||||||
m.Cmdy(nfs.DIR, ice.SRC, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_REG, kit.ExtReg(GO)))
|
|
||||||
}},
|
|
||||||
BINPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(AUTOGEN, BINPACK) }},
|
|
||||||
WEBPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(AUTOGEN, WEBPACK) }},
|
WEBPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(AUTOGEN, WEBPACK) }},
|
||||||
|
DEVPACK: {Help: "开发", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(AUTOGEN, DEVPACK) }},
|
||||||
|
INSTALL: {Name: "install version=1.15.15", Help: "安装", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(INSTALL, web.DOWNLOAD, kit.Format("https://golang.google.cn/dl/go%s.%s-%s.%s", m.Option(VERSION), runtime.GOOS, runtime.GOARCH, kit.Select("tar.gz", "zip", runtime.GOOS == cli.WINDOWS)), ice.USR_LOCAL)
|
||||||
|
}},
|
||||||
}, ctx.ConfAction(cli.ENV, kit.Dict("GOPRIVATE", "shylinux.com,github.com", "GOPROXY", "https://goproxy.cn,direct", "CGO_ENABLED", "0"))), Hand: func(m *ice.Message, arg ...string) {
|
}, ctx.ConfAction(cli.ENV, kit.Dict("GOPRIVATE", "shylinux.com,github.com", "GOPROXY", "https://goproxy.cn,direct", "CGO_ENABLED", "0"))), Hand: func(m *ice.Message, arg ...string) {
|
||||||
_autogen_version(m.Spawn())
|
|
||||||
main, file, goos, arch := _compile_target(m, arg...)
|
main, file, goos, arch := _compile_target(m, arg...)
|
||||||
env := kit.Simple(cli.PATH, kit.Env(cli.PATH), cli.HOME, kit.Select(kit.Path(""), kit.Env(cli.HOME)), m.Configv(cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch)
|
env := kit.Simple(cli.PATH, kit.Env(cli.PATH), cli.HOME, kit.Select(kit.Path(""), kit.Env(cli.HOME)), m.Configv(cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch)
|
||||||
if runtime.GOOS == cli.WINDOWS {
|
if runtime.GOOS == cli.WINDOWS {
|
||||||
env = append(env, "GOPATH", kit.HomePath("go"))
|
env = append(env, "GOPATH", kit.HomePath(GO), "GOCACHE", kit.HomePath("go/go-build"))
|
||||||
env = append(env, "GOCACHE", kit.HomePath("go/go-build"))
|
|
||||||
}
|
}
|
||||||
m.Optionv(cli.CMD_ENV, env)
|
m.Optionv(cli.CMD_ENV, env)
|
||||||
if !strings.Contains(m.Cmdx(nfs.CAT, ice.GO_MOD), "shylinux.com/x/ice") {
|
if !strings.Contains(m.Cmdx(nfs.CAT, ice.GO_MOD), "shylinux.com/x/ice") {
|
||||||
m.Cmd(cli.SYSTEM, GO, "get", "shylinux.com/x/ice")
|
m.Cmd(cli.SYSTEM, GO, "get", "shylinux.com/x/ice")
|
||||||
}
|
}
|
||||||
|
m.Cmd(AUTOGEN, VERSION)
|
||||||
|
defer m.StatusTime(VERSION, strings.TrimPrefix(m.Cmdx(cli.SYSTEM, GO, VERSION), "go version "))
|
||||||
if msg := m.Cmd(cli.SYSTEM, GO, cli.BUILD, "-o", file, main, ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO); !cli.IsSuccess(msg) {
|
if msg := m.Cmd(cli.SYSTEM, GO, cli.BUILD, "-o", file, main, ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO); !cli.IsSuccess(msg) {
|
||||||
m.Copy(msg)
|
m.Copy(msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Logs(mdb.EXPORT, nfs.SOURCE, main, nfs.TARGET, file)
|
m.Logs(COMPILE, nfs.SOURCE, main, nfs.TARGET, file)
|
||||||
m.Cmdy(nfs.DIR, file, nfs.DIR_WEB_FIELDS).StatusTimeCount()
|
if m.Cmdy(nfs.DIR, file, nfs.DIR_WEB_FIELDS); strings.Contains(file, ice.ICE) {
|
||||||
if strings.Contains(file, ice.ICE) {
|
|
||||||
m.Cmdy(PUBLISH, ice.CONTEXTS)
|
m.Cmdy(PUBLISH, ice.CONTEXTS)
|
||||||
}
|
}
|
||||||
m.StatusTime("version", strings.TrimPrefix(m.Cmdx(cli.SYSTEM, GO, "version"), "go version "))
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -80,14 +80,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(kit.Format(_css_template, kit.Select("plugin", ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO)))))
|
m.Echo(kit.Format(nfs.Template(m, "demo.css"), kit.Select("plugin", ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO)))))
|
||||||
}},
|
}},
|
||||||
}, PlugAction())},
|
}, PlugAction())},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _css_template = `
|
|
||||||
body fieldset.%s div.output {
|
|
||||||
background-color:red;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
@ -120,7 +120,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(_go_template, path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
m.Echo(nfs.Template(m, "demo.go"), path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
||||||
}},
|
}},
|
||||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { _go_complete(m, arg...) }},
|
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { _go_complete(m, arg...) }},
|
||||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, GODOC, "gotags", "-f", nfs.TAGS, "-R", nfs.PWD) }},
|
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, GODOC, "gotags", "-f", nfs.TAGS, "-R", nfs.PWD) }},
|
||||||
@ -140,10 +140,3 @@ func init() {
|
|||||||
}, PlugAction())},
|
}, PlugAction())},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _go_template = `package %s
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,19 +22,8 @@ func init() {
|
|||||||
m.EchoIFrame(kit.MergeURL(path.Join("/require/", arg[2], arg[1]), "_v", kit.Hashs("uniq")))
|
m.EchoIFrame(kit.MergeURL(path.Join("/require/", arg[2], arg[1]), "_v", kit.Hashs("uniq")))
|
||||||
}},
|
}},
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(kit.Renders(_html_template, ice.Maps{ice.LIST: kit.Format(kit.List(kit.Dict(ctx.INDEX, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO)))))})).RenderResult()
|
m.Echo(kit.Renders(nfs.TemplateText(m, "demo.html"), ice.Maps{ice.LIST: kit.Format(kit.List(kit.Dict(ctx.INDEX, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO)))))})).RenderResult()
|
||||||
}},
|
}},
|
||||||
}, PlugAction())},
|
}, PlugAction())},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _html_template = `<!DOCTYPE html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8"><title>volcanos</title>
|
|
||||||
<link href="/publish/can.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script src="/publish/can.js"></script>
|
|
||||||
<script>Volcanos({{.list}})</script>
|
|
||||||
</body>
|
|
||||||
`
|
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,13 +30,7 @@ func init() {
|
|||||||
ctx.ProcessCommand(m, kit.Select("can._plugin", ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))), kit.Simple())
|
ctx.ProcessCommand(m, kit.Select("can._plugin", ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))), kit.Simple())
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_js_template) }},
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.js")) }},
|
||||||
}, PlugAction())},
|
}, PlugAction())},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _js_template = `
|
|
||||||
Volcanos(chat.ONIMPORT, {_init: function(can, msg) {
|
|
||||||
msg.Echo("hello world").Dump(can)
|
|
||||||
}})
|
|
||||||
`
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package code
|
package code
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -13,28 +12,13 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
"shylinux.com/x/icebergs/base/tcp"
|
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _publish_file(m *ice.Message, file string, arg ...string) string {
|
func _publish_bin_list(m *ice.Message, p string) *ice.Message {
|
||||||
if strings.HasSuffix(file, ice.ICE_BIN) {
|
m.Option(cli.CMD_DIR, p)
|
||||||
file, arg = cli.SystemFind(m, os.Args[0]), kit.Simple(kit.Keys(ice.ICE, runtime.GOOS, runtime.GOARCH))
|
defer m.SortTimeR(mdb.TIME)
|
||||||
} else if s, e := nfs.StatFile(m, file); m.Assert(e) && s.IsDir() {
|
|
||||||
file = m.Cmdx(nfs.TAR, mdb.IMPORT, path.Base(file), file)
|
|
||||||
defer func() { nfs.Remove(m, file) }()
|
|
||||||
}
|
|
||||||
target := path.Join(ice.USR_PUBLISH, kit.Select(path.Base(file), arg, 0))
|
|
||||||
m.Logs(mdb.EXPORT, PUBLISH, target, cli.FROM, file)
|
|
||||||
return m.Cmdx(nfs.LINK, target, file)
|
|
||||||
}
|
|
||||||
func _publish_list(m *ice.Message, arg ...string) {
|
|
||||||
m.Option(nfs.DIR_REG, kit.Select("", arg, 0))
|
|
||||||
nfs.DirDeepAll(m, ice.USR_PUBLISH, nfs.PWD, nil, kit.Select(nfs.DIR_WEB_FIELDS, arg, 1))
|
|
||||||
}
|
|
||||||
func _publish_bin_list(m *ice.Message, dir string) {
|
|
||||||
p := m.Option(cli.CMD_DIR, dir)
|
|
||||||
for _, ls := range strings.Split(cli.SystemCmds(m, "ls |xargs file |grep executable"), ice.NL) {
|
for _, ls := range strings.Split(cli.SystemCmds(m, "ls |xargs file |grep executable"), ice.NL) {
|
||||||
if file := strings.TrimSpace(strings.Split(ls, ice.DF)[0]); file != "" {
|
if file := strings.TrimSpace(strings.Split(ls, ice.DF)[0]); file != "" {
|
||||||
if s, e := nfs.StatFile(m, path.Join(p, file)); e == nil {
|
if s, e := nfs.StatFile(m, path.Join(p, file)); e == nil {
|
||||||
@ -43,44 +27,41 @@ func _publish_bin_list(m *ice.Message, dir string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.SortTimeR(mdb.TIME)
|
return m
|
||||||
}
|
}
|
||||||
func PublishScript(m *ice.Message, arg ...string) {
|
func _publish_list(m *ice.Message, arg ...string) *ice.Message {
|
||||||
u := web.OptionUserWeb(m)
|
m.Option(nfs.DIR_REG, kit.Select("", arg, 0))
|
||||||
host := tcp.PublishLocalhost(m, strings.Split(u.Host, ice.DF)[0])
|
return nfs.DirDeepAll(m, ice.USR_PUBLISH, nfs.PWD, nil, kit.Select(nfs.DIR_WEB_FIELDS, arg, 1))
|
||||||
m.Option(cli.CTX_ENV, kit.Select("", ice.SP+kit.JoinKV(ice.EQ, ice.SP, cli.CTX_POD, m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
|
}
|
||||||
m.Option(web.DOMAIN, fmt.Sprintf("%s://%s:%s", u.Scheme, host, kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1)))
|
func _publish_file(m *ice.Message, file string, arg ...string) string {
|
||||||
for _, v := range arg {
|
if strings.HasSuffix(file, ice.ICE_BIN) {
|
||||||
m.EchoScript(kit.Renders(v, m))
|
file, arg = cli.SystemFind(m, os.Args[0]), kit.Simple(kit.Keys(ice.ICE, runtime.GOOS, runtime.GOARCH))
|
||||||
|
} else if s, e := nfs.StatFile(m, file); m.Assert(e) && s.IsDir() {
|
||||||
|
file = m.Cmdx(nfs.TAR, mdb.IMPORT, path.Base(file), file)
|
||||||
|
defer func() { nfs.Remove(m, file) }()
|
||||||
}
|
}
|
||||||
|
target := path.Join(ice.USR_PUBLISH, kit.Select(path.Base(file), arg, 0))
|
||||||
|
return m.Logs(mdb.EXPORT, PUBLISH, target, nfs.FROM, file).Cmdx(nfs.LINK, target, file)
|
||||||
}
|
}
|
||||||
func _publish_contexts(m *ice.Message, arg ...string) {
|
func _publish_contexts(m *ice.Message, arg ...string) {
|
||||||
u := web.OptionUserWeb(m)
|
|
||||||
host := tcp.PublishLocalhost(m, strings.Split(u.Host, ice.DF)[0])
|
|
||||||
m.Option(cli.CTX_ENV, kit.Select("", ice.SP+kit.JoinKV(ice.EQ, ice.SP, cli.CTX_POD, m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
|
|
||||||
m.Option(web.DOMAIN, fmt.Sprintf("%s://%s:%s", u.Scheme, host, kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1)))
|
|
||||||
for _, k := range kit.Default(arg, ice.MISC) {
|
for _, k := range kit.Default(arg, ice.MISC) {
|
||||||
switch k {
|
switch k {
|
||||||
case INSTALL:
|
|
||||||
m.Echo(kit.Renders(strings.TrimSpace(m.Config(kit.Keys(ice.CONTEXTS, ice.MISC))), m))
|
|
||||||
return
|
|
||||||
case ice.MISC:
|
|
||||||
_publish_file(m, ice.ICE_BIN)
|
|
||||||
case ice.CORE:
|
|
||||||
m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.COM).Append(web.CLIENT_ORIGIN))
|
|
||||||
case ice.BASE:
|
case ice.BASE:
|
||||||
m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.SHY).Append(web.CLIENT_ORIGIN))
|
m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.SHY).Append(web.CLIENT_ORIGIN))
|
||||||
m.Option(nfs.REMOTE, kit.Select(ice.Info.Make.Remote, cli.SystemExec(m, "git", "config", "remote.origin.url")))
|
case ice.CORE:
|
||||||
|
m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.DEV).Append(web.CLIENT_ORIGIN))
|
||||||
|
default:
|
||||||
|
m.Options(web.DOMAIN, m.Option(ice.MSG_USERHOST), cli.CTX_ENV, kit.Select("", ice.SP+kit.JoinKV(ice.EQ, ice.SP, cli.CTX_POD, m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
|
||||||
|
_publish_file(m, ice.ICE_BIN)
|
||||||
}
|
}
|
||||||
if buf, err := kit.Render(m.Config(kit.Keys(ice.CONTEXTS, k)), m); m.Assert(err) {
|
if s := strings.TrimSpace(kit.Renders(m.Config(kit.Keys(ice.CONTEXTS, k)), m)); k == INSTALL {
|
||||||
m.EchoScript(strings.TrimSpace(string(buf)))
|
m.Echo(s)
|
||||||
|
} else {
|
||||||
|
m.EchoScript(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
GIT = "git"
|
|
||||||
)
|
|
||||||
const PUBLISH = "publish"
|
const PUBLISH = "publish"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -88,21 +69,17 @@ func init() {
|
|||||||
PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.MergeActions(ice.Actions{
|
PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config(ice.CONTEXTS, _contexts) }},
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config(ice.CONTEXTS, _contexts) }},
|
||||||
ice.VOLCANOS: {Help: "火山架", Hand: func(m *ice.Message, arg ...string) {
|
ice.VOLCANOS: {Help: "火山架", Hand: func(m *ice.Message, arg ...string) {
|
||||||
defer func() { m.EchoQRCode(m.Option(ice.MSG_USERWEB)) }()
|
_publish_list(m, kit.ExtReg(`(html|css|js)`)).Cmdy("", ice.CONTEXTS, ice.MISC).Echo(ice.NL).EchoQRCode(m.Option(ice.MSG_USERWEB))
|
||||||
defer func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.MISC) }()
|
|
||||||
_publish_list(m, kit.ExtReg(`(html|css|js)`))
|
|
||||||
}},
|
}},
|
||||||
ice.ICEBERGS: {Help: "冰山架", Hand: func(m *ice.Message, arg ...string) {
|
ice.ICEBERGS: {Help: "冰山架", Hand: func(m *ice.Message, arg ...string) {
|
||||||
defer func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.CORE) }()
|
_publish_bin_list(m, ice.USR_PUBLISH).Cmdy("", ice.CONTEXTS, ice.CORE)
|
||||||
_publish_bin_list(m, ice.USR_PUBLISH)
|
|
||||||
}},
|
}},
|
||||||
ice.INTSHELL: {Help: "神农架", Hand: func(m *ice.Message, arg ...string) {
|
ice.INTSHELL: {Help: "神农架", Hand: func(m *ice.Message, arg ...string) {
|
||||||
defer func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.BASE) }()
|
_publish_list(m, kit.ExtReg(`(sh|vim|conf)`)).Cmdy("", ice.CONTEXTS, ice.BASE)
|
||||||
_publish_list(m, kit.ExtReg(`(sh|vim|conf)`))
|
|
||||||
}},
|
}},
|
||||||
ice.CONTEXTS: {Hand: func(m *ice.Message, arg ...string) { _publish_contexts(m, arg...) }},
|
ice.CONTEXTS: {Hand: func(m *ice.Message, arg ...string) { _publish_contexts(m, arg...) }},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.DIR, arg[1:]).Cut("path,size,time").ProcessAgain() }},
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.DIR, arg[1:]).Cut("path,size,time") }},
|
||||||
mdb.CREATE: {Name: "create file", Help: "添加", Hand: func(m *ice.Message, arg ...string) { _publish_file(m, m.Option(nfs.FILE)) }},
|
mdb.CREATE: {Name: "create file", Hand: func(m *ice.Message, arg ...string) { _publish_file(m, m.Option(nfs.FILE)) }},
|
||||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH))) }},
|
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH))) }},
|
||||||
}, ctx.ConfAction(ice.CONTEXTS, _contexts), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, ctx.ConfAction(ice.CONTEXTS, _contexts), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(nfs.DIR, kit.Select("", arg, 0), nfs.DIR_WEB_FIELDS, kit.Dict(nfs.DIR_ROOT, ice.USR_PUBLISH)).SortTimeR(mdb.TIME)
|
m.Cmdy(nfs.DIR, kit.Select("", arg, 0), nfs.DIR_WEB_FIELDS, kit.Dict(nfs.DIR_ROOT, ice.USR_PUBLISH)).SortTimeR(mdb.TIME)
|
||||||
@ -111,13 +88,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _contexts = kit.Dict(
|
var _contexts = kit.Dict(
|
||||||
ice.MISC, `
|
ice.MISC, `export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp app username {{.Option "user.name"}} usernick "{{.Option "user.nick"}}"`,
|
||||||
export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp app username {{.Option "user.name"}} usernick "{{.Option "user.nick"}}"
|
ice.CORE, `temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL {{.Option "domain"}}; else wget -O $temp -q {{.Option "domain"}}; fi; source $temp binary`,
|
||||||
`,
|
ice.BASE, `temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL {{.Option "domain"}}; else wget -O $temp -q {{.Option "domain"}}; fi; source $temp source`,
|
||||||
ice.CORE, `
|
|
||||||
temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL {{.Option "domain"}}; else wget -O $temp -q {{.Option "domain"}}; fi; source $temp binary
|
|
||||||
`,
|
|
||||||
ice.BASE, `
|
|
||||||
temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL {{.Option "domain"}}; else wget -O $temp -q {{.Option "domain"}}; fi; source $temp source
|
|
||||||
`,
|
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _sh_cmds(m *ice.Message, p string) (string, string) {
|
func _sh_cmds(m *ice.Message, p string) (string, string) {
|
||||||
cmds, text := kit.Select(SH, m.Config(ssh.SHELL)), kit.Format(strings.TrimSpace(_sh_cmd_template), m.Option(ice.MSG_USERHOST), m.Option(ice.MSG_USERPOD), p)
|
cmds, text := kit.Select(SH, m.Config(ssh.SHELL)), kit.Format(strings.TrimSpace(nfs.Template(m, "cmd.sh")), m.Option(ice.MSG_USERHOST), m.Option(ice.MSG_USERPOD), p)
|
||||||
if head := kit.Select("", strings.Split(m.Cmdx(nfs.CAT, p), ice.NL), 0); strings.HasPrefix(head, "#!") {
|
if head := kit.Select("", strings.Split(m.Cmdx(nfs.CAT, p), ice.NL), 0); strings.HasPrefix(head, "#!") {
|
||||||
cmds = strings.TrimSpace(strings.TrimPrefix(head, "#!"))
|
cmds = strings.TrimSpace(strings.TrimPrefix(head, "#!"))
|
||||||
}
|
}
|
||||||
@ -33,18 +33,8 @@ func init() {
|
|||||||
cmds, text := _sh_cmds(m, path.Join(arg[2], arg[1]))
|
cmds, text := _sh_cmds(m, path.Join(arg[2], arg[1]))
|
||||||
m.Cmdy(cli.SYSTEM, cmds, "-c", text).Status(ssh.SHELL, strings.ReplaceAll(text, ice.NL, "; "))
|
m.Cmdy(cli.SYSTEM, cmds, "-c", text).Status(ssh.SHELL, strings.ReplaceAll(text, ice.NL, "; "))
|
||||||
}},
|
}},
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_sh_template) }},
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.sh")) }},
|
||||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
|
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
|
||||||
}, PlugAction())},
|
}, PlugAction())},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _sh_template = `#!/bin/sh
|
|
||||||
|
|
||||||
demo() {
|
|
||||||
echo "hello world"
|
|
||||||
}
|
|
||||||
`
|
|
||||||
var _sh_cmd_template = `export ctx_dev=%s ctx_pod=%s ctx_mod=%s
|
|
||||||
temp=$(mktemp); if curl -V &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi && source $temp $ctx_mod
|
|
||||||
`
|
|
||||||
|
@ -24,7 +24,7 @@ func init() {
|
|||||||
ctx.ProcessCommand(m, web.WIKI_WORD, kit.Simple(path.Join(arg[2], arg[1])))
|
ctx.ProcessCommand(m, web.WIKI_WORD, kit.Simple(path.Join(arg[2], arg[1])))
|
||||||
}},
|
}},
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(_shy_template, path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
m.Echo(nfs.Template(m, "demo.shy"), path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
||||||
}},
|
}},
|
||||||
}, PlugAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, PlugAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() {
|
if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() {
|
||||||
@ -35,5 +35,3 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _shy_template = `chapter "%s"`
|
|
||||||
|
@ -25,7 +25,6 @@ func _webpack_can(m *ice.Message) {
|
|||||||
m.Option(nfs.DIR_ROOT, "")
|
m.Option(nfs.DIR_ROOT, "")
|
||||||
m.Cmd(nfs.COPY, USR_PUBLISH_CAN_CSS, _volcanos(m, ice.INDEX_CSS), _volcanos(m, PAGE_CACHE_CSS))
|
m.Cmd(nfs.COPY, USR_PUBLISH_CAN_CSS, _volcanos(m, ice.INDEX_CSS), _volcanos(m, PAGE_CACHE_CSS))
|
||||||
m.Cmd(nfs.COPY, USR_PUBLISH_CAN_JS, _volcanos(m, ice.PROTO_JS), _volcanos(m, PAGE_CACHE_JS))
|
m.Cmd(nfs.COPY, USR_PUBLISH_CAN_JS, _volcanos(m, ice.PROTO_JS), _volcanos(m, PAGE_CACHE_JS))
|
||||||
m.Cmdy(nfs.DIR, _volcanos(m, PAGE))
|
|
||||||
}
|
}
|
||||||
func _webpack_css(m *ice.Message, css, js io.Writer, p string) {
|
func _webpack_css(m *ice.Message, css, js io.Writer, p string) {
|
||||||
fmt.Fprintln(css, kit.Format("/* %s */", path.Join(ice.PS, p)))
|
fmt.Fprintln(css, kit.Format("/* %s */", path.Join(ice.PS, p)))
|
||||||
@ -52,6 +51,7 @@ func _webpack_cache(m *ice.Message, dir string, write bool) {
|
|||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
defer js.Close()
|
defer js.Close()
|
||||||
defer fmt.Fprintln(js, `_can_name = ""`)
|
defer fmt.Fprintln(js, `_can_name = ""`)
|
||||||
|
defer m.Cmdy(nfs.DIR, _volcanos(m, PAGE))
|
||||||
defer _webpack_can(m)
|
defer _webpack_can(m)
|
||||||
if !write {
|
if !write {
|
||||||
return
|
return
|
||||||
@ -103,7 +103,7 @@ func _webpack_build(m *ice.Message, file string) {
|
|||||||
if nfs.ExistsFile(m, ice.SRC_MAIN_JS) {
|
if nfs.ExistsFile(m, ice.SRC_MAIN_JS) {
|
||||||
main_js = ice.SRC_MAIN_JS
|
main_js = ice.SRC_MAIN_JS
|
||||||
}
|
}
|
||||||
fmt.Fprintf(f, _webpack_template,
|
fmt.Fprintf(f, nfs.Template(m, "index.html"),
|
||||||
m.Cmdx(nfs.CAT, _volcanos(m, ice.INDEX_CSS)), m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_CSS)),
|
m.Cmdx(nfs.CAT, _volcanos(m, ice.INDEX_CSS)), m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_CSS)),
|
||||||
m.Cmdx(nfs.CAT, _volcanos(m, ice.PROTO_JS)), m.Cmdx(nfs.CAT, kit.Keys(file, JS)),
|
m.Cmdx(nfs.CAT, _volcanos(m, ice.PROTO_JS)), m.Cmdx(nfs.CAT, kit.Keys(file, JS)),
|
||||||
m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_JS)), m.Cmdx(nfs.CAT, main_js),
|
m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_JS)), m.Cmdx(nfs.CAT, main_js),
|
||||||
@ -131,10 +131,10 @@ const WEBPACK = "webpack"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
WEBPACK: {Name: "webpack path auto create remove", Help: "打包", Actions: ice.MergeActions(ice.Actions{
|
WEBPACK: {Name: "webpack path auto create remove", Help: "打包", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.CREATE: {Name: "create", Help: "发布", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Help: "发布", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_webpack_cache(m.Spawn(), _volcanos(m), true)
|
_webpack_cache(m.Spawn(), _volcanos(m), true)
|
||||||
}},
|
}},
|
||||||
mdb.REMOVE: {Name: "remove", Help: "调试", Hand: func(m *ice.Message, arg ...string) {
|
mdb.REMOVE: {Help: "调试", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_webpack_cache(m.Spawn(), _volcanos(m), false)
|
_webpack_cache(m.Spawn(), _volcanos(m), false)
|
||||||
}},
|
}},
|
||||||
mdb.INSERT: {Name: "insert path*", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INSERT: {Name: "insert path*", Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -155,18 +155,3 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _webpack_template = `
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<style type="text/css">%s</style>
|
|
||||||
<style type="text/css">%s</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script>%s</script>
|
|
||||||
<script>%s</script>
|
|
||||||
<script>%s</script>
|
|
||||||
<script>%s</script>
|
|
||||||
</body>
|
|
||||||
`
|
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/tcp"
|
"shylinux.com/x/icebergs/base/tcp"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
"shylinux.com/x/icebergs/core/code"
|
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
SESS: {Name: "sess hash auto invite prunes", Help: "会话流", Actions: ice.MergeActions(ice.Actions{
|
SESS: {Name: "sess hash auto invite prunes", Help: "会话流", Actions: ice.MergeActions(ice.Actions{
|
||||||
aaa.INVITE: {Hand: func(m *ice.Message, arg ...string) {
|
aaa.INVITE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
code.PublishScript(m, `export ctx_dev={{.Option "domain"}}; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev; source $ctx_temp`)
|
// code.PublishScript(m, `export ctx_dev={{.Option "domain"}}; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev; source $ctx_temp`)
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.FIELD, "time,hash,status,username,hostname,release,pid,pwd,grant"))},
|
}, mdb.HashAction(mdb.FIELD, "time,hash,status,username,hostname,release,pid,pwd,grant"))},
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package webview
|
package webview
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
@ -39,7 +40,7 @@ func (w WebView) Menu() bool {
|
|||||||
} else {
|
} else {
|
||||||
w.WebView.SetTitle(ice.CONTEXTS)
|
w.WebView.SetTitle(ice.CONTEXTS)
|
||||||
w.WebView.SetSize(200, 60*len(list), webview.HintNone)
|
w.WebView.SetSize(200, 60*len(list), webview.HintNone)
|
||||||
w.WebView.Navigate(kit.Format(_menu_template, kit.Join(list, ice.NL)))
|
w.WebView.Navigate(kit.Format(`data:text/html,`+m.Cmdx(nfs.CAT, path.Join(ice.SRC_TEMPLATE, "webview", "home.html")), kit.Join(list, ice.NL)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,21 +86,3 @@ func Run(cb func(*WebView) ice.Any) {
|
|||||||
view.navigate("http://localhost:9020")
|
view.navigate("http://localhost:9020")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _menu_template = `data:text/html,
|
|
||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<style>button { font-size:24px; font-family:monospace; margin:10px; width:-webkit-fill-available; display:block; clear:both; }</style>
|
|
||||||
<script>
|
|
||||||
document.body.onkeydown = function(event) {
|
|
||||||
if (event.metaKey) {
|
|
||||||
switch (event.key) {
|
|
||||||
case "q": window.terminate(); break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>%s</body>
|
|
||||||
</html>`
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user