1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-11-02 23:25:31 +08:00
parent c16a622aed
commit 1a02b3c0b9
7 changed files with 20 additions and 16 deletions

View File

@ -266,5 +266,5 @@ func RequireFile(m *ice.Message, file string) string {
return ""
}
func IsLocalHost(m *ice.Message) bool {
return m.R.Header.Get("X-Forwarded-For") == "" && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP))
return (m.R == nil || m.R.Header.Get("X-Forwarded-For") == "") && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP))
}

View File

@ -67,12 +67,8 @@ func init() {
}},
})
Index.MergeCommands(ice.Commands{
VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Icon: "vimer.png", Help: "编辑器", Meta: kit.Dict(
ctx.STYLE, INNER,
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(
ice.HELP, "帮助",
cli.MAIN, "程序",
)),
VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Help: "编辑器", Icon: "vimer.png", Meta: kit.Dict(
ctx.STYLE, INNER, ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(cli.MAIN, "程序")),
), Actions: ice.MergeActions(ice.Actions{
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
if mdb.IsSearchPreview(m, arg) {
@ -206,7 +202,11 @@ func init() {
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
}, aaa.RoleAction(), chat.FavorAction(), ctx.ConfAction(ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) {
if m.Cmdy(INNER, arg); arg[0] != ctx.ACTION {
m.Action(nfs.SAVE, COMPILE, mdb.SHOW, cli.EXEC, ice.APP)
if web.IsLocalHost(m) {
m.Action(nfs.SAVE, COMPILE, mdb.SHOW, cli.EXEC, ice.APP)
} else {
m.Action(nfs.SAVE, COMPILE, mdb.SHOW)
}
ctx.DisplayLocal(m, "")
ctx.Toolkit(m)
}

View File

@ -69,7 +69,8 @@ func (g *Group) EchoPath(group string, str string, arg ...ice.Any) *ice.Message
return g.Echo(group, `<path d="%s"></path>`, kit.Format(str, arg...))
}
func (g *Group) EchoText(group string, x, y int, text string, arg ...string) *ice.Message {
return g.Echo(group, "<text x=%d y=%d %s>%s</text>", x, y+8, formatStyle(arg...), text)
offset := kit.Int(kit.Select("8", "4", g.Get(group).IsMobileUA()))
return g.Echo(group, "<text x=%d y=%d %s>%s</text>", x, y+offset, formatStyle(arg...), text)
}
func (g *Group) EchoArrowLine(group string, x1, y1, x2, y2 int, arg ...string) *ice.Message { // marker-end
return g.EchoLine(group, x1, y1, x2, y2, "marker-end", kit.Format("url(#%s)", kit.Select("arrowhead", arg, 0)))
@ -103,12 +104,13 @@ var chart_list = map[string]func(m *ice.Message) Chart{}
func AddChart(name string, hand func(m *ice.Message) Chart) { chart_list[name] = hand }
func _chart_show(m *ice.Message, name, text string, arg ...string) {
m.Options(FONT_SIZE, "24", STROKE_WIDTH, "2")
kit.For(arg, func(k, v string) { m.Option(k, v) })
m.Option(FILL, kit.Select(m.Option(FILL), m.Option(BG)))
m.Option(STROKE, kit.Select(m.Option(STROKE), m.Option(FG)))
chart := chart_list[name](m)
chart.Init(m, text)
m.OptionDefault(STROKE_WIDTH, "2")
m.OptionDefault(FONT_SIZE, kit.Select("24", "13", m.IsMobileUA()))
m.Options(HEIGHT, chart.GetHeight(), WIDTH, chart.GetWidth())
_wiki_template(m, "", name, text, arg...)
defer m.RenderResult()

View File

@ -89,7 +89,6 @@ const CHAIN = "chain"
func init() {
wiki.AddChart(CHAIN, func(m *ice.Message) wiki.Chart {
m.OptionDefault(wiki.FONT_SIZE, "18")
m.OptionDefault(wiki.MARGINX, "60")
m.OptionDefault(wiki.MARGINY, "16")
m.OptionDefault(wiki.PADDING, "10")

View File

@ -75,4 +75,9 @@ const (
)
const LABEL = "label"
func init() { wiki.AddChart(LABEL, func(m *ice.Message) wiki.Chart { return &Label{} }) }
func init() {
wiki.AddChart(LABEL, func(m *ice.Message) wiki.Chart {
m.OptionDefault(wiki.FONT_SIZE, kit.Select("24", "13", m.IsMobileUA()))
return &Label{}
})
}

View File

@ -539,8 +539,8 @@ func init() {
password, _ = u.User.Password()
}
m.Sort("repos,status,file").StatusTimeCount(mdb.TIME, last,
REMOTE, remote, VERSION, ice.Info.Make.Versions(),
kit.Select(aaa.TECH, aaa.VOID, password == ""), m.Option(aaa.EMAIL),
REMOTE, remote, VERSION, ice.Info.Make.Versions(),
)
}
}},

View File

@ -23,7 +23,6 @@ const (
DIFF = "diff"
INSTEADOF = "insteadof"
OAUTH = "oauth"
GITEA = "gitea"
)
const STATUS = "status"
@ -61,7 +60,6 @@ func init() {
OAUTH: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
m.ProcessOpen(kit.MergeURL2(kit.Select(ice.Info.Make.Domain, m.Cmdx(REPOS, "remoteURL")), web.ChatCmdPath(m, web.TOKEN, "gen"), tcp.HOST, m.Option(ice.MSG_USERWEB)))
}},
GITEA: {Help: "资源", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Cmdv("web.spide", ice.HUB, web.CLIENT_URL)) }},
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
if !kit.IsIn(m.Option(mdb.TYPE), web.WORKER, web.SERVER) {
return
@ -91,7 +89,7 @@ func init() {
m.Action(INIT).Echo("please init repos. ").EchoButton(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, OAUTH, CONFIGS, GITEA)
m.Cmdy(REPOS, STATUS).Action(PULL, PUSH, INSTEADOF, OAUTH, CONFIGS)
kit.If(!m.IsCliUA(), func() { m.Cmdy(code.PUBLISH, ice.CONTEXTS, ice.DEV) })
} else {
_repos_cmd(m, arg[0], DIFF)