1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-01-17 11:25:44 +08:00
parent aeea2a4bad
commit 826cd54b79
8 changed files with 32 additions and 12 deletions

View File

@ -51,7 +51,7 @@ func init() {
}},
}, mdb.DevDataAction("name,service,username,password"), mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,service,username", ice.ACTION, SEND)), Hand: func(m *ice.Message, arg ...string) {
if mdb.HashSelect(m, arg...); len(arg) == 0 && m.Length() == 0 {
m.EchoInfoButton("please add admin email", mdb.CREATE, mdb.DEV_REQUEST)
m.EchoInfoButton(ice.Info.Template(m, "email.html"), mdb.CREATE, mdb.DEV_REQUEST)
} else if len(arg) == 0 {
m.Action(mdb.CREATE, mdb.DEV_REQUEST)
}

View File

@ -216,7 +216,7 @@ func DevDataAction(fields ...string) ice.Actions {
}
}},
DEV_CONFIRM: {Hand: func(m *ice.Message, arg ...string) {
m.EchoInfoButton(kit.JoinWord(m.PrefixKey(), DEV_CONFIRM, DEV_CREATE, m.Option(kit.Split(fields[0])[0])), DEV_CREATE)
m.EchoInfoButton(kit.JoinWord(m.PrefixKey(), m.Cmdx("nfs.cat", "src/template/mdb.hash/savefrom.html"), m.Option(kit.Split(fields[0])[0])), DEV_CREATE)
}},
DEV_CREATE: {Help: "创建", Hand: func(m *ice.Message, arg ...string) {
if !m.Warn(m.Option(ice.MSG_METHOD) != http.MethodPost, ice.ErrNotAllow) {

View File

@ -35,6 +35,7 @@ func init() {
})
}
func init() { ice.Info.Template = Template }
func Template(m *ice.Message, p string, data ...ice.Any) string {
if len(data) == 0 {
return kit.Renders(TemplateText(m, p), m)

View File

@ -7,6 +7,7 @@ import (
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web/html"
kit "shylinux.com/x/toolkits"
)
@ -35,7 +36,8 @@ func DevTokenAction(name, origin string) ice.Actions {
))
}},
mdb.DEV_CHOOSE: {Hand: func(m *ice.Message, arg ...string) {
m.EchoInfoButton(kit.Format("save token to %s", m.Option(cli.BACK)), mdb.DEV_RESPONSE)
m.EchoInfoButton(kit.JoinWord(m.PrefixKey(),
m.Cmdx(nfs.CAT, nfs.SRC_TEMPLATE+"web.token/saveto.html"), m.Option(cli.BACK)), mdb.DEV_RESPONSE)
}},
mdb.DEV_RESPONSE: {Help: "确认", Hand: func(m *ice.Message, arg ...string) {
if !m.Warn(m.Option(ice.MSG_METHOD) != http.MethodPost, ice.ErrNotAllow) {
@ -44,7 +46,8 @@ func DevTokenAction(name, origin string) ice.Actions {
}
}},
mdb.DEV_CONFIRM: {Hand: func(m *ice.Message, arg ...string) {
m.EchoInfoButton(kit.JoinWord(m.PrefixKey(), "save token for", m.Option(name)), mdb.DEV_CREATE)
m.EchoInfoButton(kit.JoinWord(m.PrefixKey(),
m.Cmdx(nfs.CAT, nfs.SRC_TEMPLATE+"web.token/savefrom.html"), m.Option(name)), mdb.DEV_CREATE)
}},
mdb.DEV_CREATE: {Help: "创建", Hand: func(m *ice.Message, arg ...string) {
if !m.Warn(m.Option(ice.MSG_METHOD) != http.MethodPost, ice.ErrNotAllow) {

View File

@ -29,19 +29,24 @@ func _autogen_list(m *ice.Message) string {
func _autogen_source(m *ice.Message, main, file string) {
m.Cmd(nfs.DEFS, main, m.Cmdx(nfs.CAT, ice.SRC_MAIN_SHY))
m.Cmd(nfs.PUSH, main, lex.NL+ssh.SOURCE+lex.SP+strings.TrimPrefix(file, nfs.SRC)+lex.NL)
ReposAddFile(m, "", ice.SRC_MAIN_SHY)
}
func _autogen_script(m *ice.Message, file string) {
m.Cmd(nfs.DEFS, file, nfs.Template(m, DEMO_SHY))
ReposAddFile(m, "", file)
}
func _autogen_module(m *ice.Message, file string) {
m.Cmd(nfs.DEFS, file, nfs.Template(m, DEMO_GO))
ReposAddFile(m, "", file)
}
func _autogen_defs(m *ice.Message, arg ...string) {
kit.For(arg, func(p string) {
m.Cmd(nfs.DEFS, p, m.Cmdx(nfs.CAT, p))
ReposAddFile(m, "", p)
})
}
func _autogen_import(m *ice.Message, main string, ctx string, mod string) {
m.Cmd(nfs.DEFS, ice.ETC_MISS_SH, m.Cmdx(nfs.CAT, ice.ETC_MISS_SH))
m.Cmd(nfs.DEFS, ice.README_MD, m.Cmdx(nfs.CAT, ice.README_MD))
m.Cmd(nfs.DEFS, ice.MAKEFILE, m.Cmdx(nfs.CAT, ice.MAKEFILE))
m.Cmd(nfs.DEFS, ice.LICENSE, m.Cmdx(nfs.CAT, ice.LICENSE))
m.Cmd(nfs.DEFS, main, m.Cmdx(nfs.CAT, ice.SRC_MAIN_GO))
_autogen_defs(m, ice.SRC_MAIN_GO, ice.ETC_MISS_SH, ice.README_MD, ice.MAKEFILE, ice.LICENSE)
begin, done, list := false, false, []string{}
m.Cmd(nfs.CAT, main, func(line string, index int) {
if begin && !done && strings.HasPrefix(line, ")") {
@ -58,6 +63,7 @@ func _autogen_import(m *ice.Message, main string, ctx string, mod string) {
})
m.Cmd(nfs.SAVE, main, kit.Join(list, lex.NL))
GoImports(m, main)
ReposAddFile(m, "", main)
}
func _autogen_version(m *ice.Message) string {
if mod := _autogen_mod(m, ice.GO_MOD); !nfs.Exists(m, ".git") {
@ -100,6 +106,7 @@ func _autogen_mod(m *ice.Message, file string) (mod string) {
host = path.Join(host, "x", path.Base(kit.Path("")))
}
m.Cmd(nfs.DEFS, file, kit.Format(nfs.Template(m, ice.GO_MOD), host))
ReposAddFile(m, "", ice.GO_MOD)
m.Cmd(nfs.CAT, file, func(line string) {
kit.If(strings.HasPrefix(line, nfs.MODULE), func() { mod = kit.Split(line, lex.SP)[1] })
})

View File

@ -1,11 +1,14 @@
package code
import (
"path"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
)
const (
@ -25,3 +28,6 @@ func init() {
})
}
func GitVersion(m *ice.Message) string { return m.Cmdx(cli.SYSTEM, GIT, VERSION) }
func ReposAddFile(m *ice.Message, dir string, file string) {
m.Cmd("web.code.git.repos", "add", kit.Dict(nfs.REPOS, path.Base(kit.Select(kit.Path(""), dir)), nfs.FILE, file))
}

View File

@ -82,6 +82,7 @@ var Info = struct {
PushStream func(m *Message) *Message
PushNotice func(m *Message, arg ...Any)
Template func(m *Message, p string, data ...Any) string
Save func(m *Message, key ...string) *Message
Load func(m *Message, key ...string) *Message
Open func(m *Message, p string) (io.ReadCloser, error)

View File

@ -30,7 +30,9 @@ const STATUS = "status"
func init() {
Index.MergeCommands(ice.Commands{
STATUS: {Name: "status repos:text auto", Help: "代码库", Icon: "git.png", Role: aaa.VOID, Meta: kit.Dict(
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict("actions", "操作", "message", "信息")),
ice.CTX_TRANS, kit.Dict(
html.INPUT, kit.Dict("actions", "操作", "message", "信息", "remote", "远程库"),
),
), Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
switch arg[0] {
@ -81,9 +83,9 @@ func init() {
if len(arg) > 0 && arg[0] == ctx.ACTION {
m.Cmdy(REPOS, arg)
} else if config, err := config.LoadConfig(config.GlobalScope); err == nil && config.User.Email == "" && mdb.Config(m, aaa.EMAIL) == "" {
m.EchoInfoButton("please config email and name. ", CONFIGS)
m.EchoInfoButton(nfs.Template(m, "email.html"), CONFIGS)
} else if !nfs.Exists(m, _GIT) {
m.EchoInfoButton("please init repos. ", INIT)
m.EchoInfoButton(nfs.Template(m, "init.html"), INIT)
} else if len(arg) == 0 {
kit.If(config != nil, func() { m.Option(aaa.EMAIL, kit.Select(mdb.Config(m, aaa.EMAIL), config.User.Email)) })
m.Cmdy(REPOS, STATUS).Action(PULL, PUSH, INSTEADOF, mdb.DEV_REQUEST, CONFIGS)