1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-07-25 17:46:40 +08:00
parent ed8a417851
commit dad4c73808
23 changed files with 132 additions and 48 deletions

View File

@ -60,9 +60,15 @@ func init() {
}
}},
}, Hand: func(m *ice.Message, arg ...string) {
switch m.Option(ice.MSG_THEME) {
case "black":
m.Option(FG, kit.Select(CYAN, arg, 1))
m.Option(BG, kit.Select(BLACK, arg, 2))
default:
dark := kit.IndexOf([]string{BLACK, "dark"}, m.Option(ice.MSG_THEME)) > -1
m.Option(FG, kit.Select(kit.Select(BLACK, SILVER, dark), arg, 1))
m.Option(BG, kit.Select(kit.Select(WHITE, BLACK, dark), arg, 2))
}
if m.IsCliUA() {
_qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0))
} else {

View File

@ -107,7 +107,7 @@ func CmdInputs(m *ice.Message, arg ...string) {
func PodCmd(m *ice.Message, arg ...ice.Any) bool {
Upload(m)
if pod := m.Option(ice.POD); pod != "" {
m.Options(ice.POD, "").Cmdy(append(kit.List(ice.SPACE, pod), arg...)...)
m.Options(ice.POD, []string{}, ice.MSG_USERPOD, pod).Cmdy(append(kit.List(ice.SPACE, pod), arg...)...)
return true
}
return false

View File

@ -87,9 +87,6 @@ func init() {
m.Cmdy(DIR, arg)
return
}
defer func() {
m.Debug("waht %v", m.FormatMeta())
}()
if kit.Ext(arg[0]) == ZIP {
m.Cmdy(ZIP, arg)
return

View File

@ -154,7 +154,7 @@ func init() {
ice.AddMergeAction(func(c *ice.Context, key string, cmd *ice.Command, sub string, action *ice.Action) {
switch sub {
case UPLOAD:
if c.Name == WEB && key == CACHE {
if kit.FileLines(action.Hand) == kit.FileLines(1) {
break
}
watch := action.Hand == nil

View File

@ -169,7 +169,7 @@ func init() {
} else if arg[0] == ctx.ACTION {
gdb.Event(m, DREAM_ACTION, arg)
} else {
m.Cmdy(nfs.CAT, arg[1:], kit.Dict(nfs.DIR_ROOT, path.Join(ice.USR_LOCAL_WORK, arg[0])))
m.EchoIFrame(m.MergePod(arg[0]))
}
}},
})
@ -188,6 +188,7 @@ func DreamProcess(m *ice.Message, args ice.Any, arg ...string) {
m.Cmdy(SPACE, m.Option(ice.MSG_USERPOD, arg[1]), m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ice.RUN, arg[2:])
} else if dream := m.Option(mdb.NAME); dream != "" {
m.Cmdy(SPACE, dream, m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ice.RUN, arg).Optionv(ice.FIELD_PREFIX, kit.Simple(ctx.ACTION, m.PrefixKey(), DREAM, dream, ice.RUN))
m.Push("_space", dream)
}
}
}

View File

@ -63,12 +63,12 @@ func ProcessIframe(m *ice.Message, name, link string, arg ...string) {
func PushPodCmd(m *ice.Message, cmd string, arg ...string) {
kit.If(m.Length() > 0 && len(m.Appendv(ice.POD)) == 0, func() { m.Table(func(value ice.Maps) { m.Push(ice.POD, m.Option(ice.MSG_USERPOD)) }) })
m.Cmds(SPACE, func(value ice.Maps) {
kit.Switch(value[mdb.TYPE], []string{SERVER, WORKER}, func() {
if kit.IsIn(value[mdb.TYPE], WORKER, SERVER) {
m.Cmd(SPACE, value[mdb.NAME], kit.Select(m.PrefixKey(), cmd), arg).Table(func(index int, val ice.Maps, head []string) {
val[ice.POD] = kit.Keys(value[mdb.NAME], val[ice.POD])
m.Push("", val, head)
})
})
}
})
}
func PushImages(m *ice.Message, name string) {

View File

@ -99,6 +99,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
r.ParseMultipartForm(kit.Int64(kit.Select("4096", r.Header.Get(ContentLength))))
kit.For(r.PostForm, func(k string, v []string) { _log(FORM, k, kit.Join(v, lex.SP)).Optionv(k, v) })
}
m.Option("_cmd_count", 0)
kit.For(r.Cookies(), func(k, v string) { m.Optionv(k, v) })
m.OptionDefault(ice.MSG_HEIGHT, "480", ice.MSG_WIDTH, "320")
m.Options(ice.MSG_USERWEB, _serve_domain(m), ice.MSG_USERPOD, m.Option(ice.POD))

View File

@ -69,7 +69,7 @@ func init() {
Index.MergeCommands(ice.Commands{
SHARE: {Name: "share hash auto login prunes", Help: "共享链", Actions: ice.MergeActions(ice.Actions{
mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) {
mdb.HashCreate(m, arg, m.OptionSimple(ice.CMD), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERROLE, m.Option(ice.MSG_USERROLE))
mdb.HashCreate(m, arg, m.OptionSimple(ice.POD, ice.CMD), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERROLE, m.Option(ice.MSG_USERROLE))
m.Option(mdb.LINK, _share_link(m, P(SHARE, m.Result())))
}},
LOGIN: {Help: "登录", Hand: func(m *ice.Message, arg ...string) {
@ -93,7 +93,8 @@ func init() {
}
default:
if msg.Append(ice.CMD) != "" {
RenderCmd(m, msg.Append(ice.CMD))
// RenderCmd(m, msg.Append(ice.CMD))
RenderPodCmd(m, msg.Append(ice.POD), msg.Append(ice.CMD))
} else {
RenderMain(m)
}

View File

@ -121,7 +121,7 @@ func _space_exec(m *ice.Message, source, target []string, c *websocket.Conn) {
case cli.PWD:
m.Push(mdb.LINK, m.MergePod(kit.Select("", source, -1)))
default:
m.Option("__target", kit.Reverse(kit.Simple(source)))
m.Options("__target", kit.Reverse(kit.Simple(source)), "_cmd_count", 0)
kit.If(aaa.Right(m, m.Detailv()), func() { m.TryCatch(m, true, func(_ *ice.Message) { m = m.Cmd() }) })
}
defer m.Cost(kit.Format("%v->%v %v %v", source, target, m.Detailv(), m.FormatSize()))

View File

@ -51,14 +51,15 @@ func _action_share(m *ice.Message, arg ...string) {
}
_action_exec(m, msg.Append(web.RIVER), msg.Append(web.STORM), arg[1], arg[2:]...)
case web.FIELD:
m.Option(ice.MSG_USERPOD, kit.Keys(m.Option(ice.MSG_USERPOD), msg.Append(ice.POD)))
if len(arg) == 1 {
m.Push(TITLE, msg.Append(TITLE))
m.Push(THEME, msg.Append(THEME))
m.Push(ctx.ARGS, msg.Append(mdb.TEXT))
m.Cmdy(ctx.COMMAND, msg.Append(mdb.NAME))
m.Cmdy(web.Space(m, msg.Append(ice.POD)), ctx.COMMAND, msg.Append(mdb.NAME))
break
}
m.Cmdy(msg.Append(mdb.NAME), arg[2:])
m.Cmdy(web.Space(m, msg.Append(ice.POD)), msg.Append(mdb.NAME), arg[2:])
}
}

View File

@ -27,6 +27,7 @@ func init() {
AppInstall(m, "Grapher", web.WIKI_DRAW)
AppInstall(m, "Photos", web.WIKI_FEEL)
AppInstall(m, "Books", web.WIKI_WORD)
AppInstall(m, "", cli.RUNTIME, mdb.ICON, "usr/icons/info.png")
AppInstall(m, "", web.DREAM, mdb.ICON, "usr/icons/Mission Control.png")
AppInstall(m, "", web.CODE_VIMER, mdb.ICON, "usr/icons/vimer.png")
AppInstall(m, "", web.CODE_COMPILE, mdb.ICON, "usr/icons/go.png")

View File

@ -4,7 +4,7 @@ fieldset.macos.desktop>div.output>fieldset.macos { background-color:transparent;
fieldset.macos.desktop>div.output>fieldset.macos>div.output { background-color:transparent; }
fieldset.macos.desktop>div.output>fieldset.macos.menu { line-height:25px; border-radius:0; height:25px; width:100%; position:absolute; top:0; overflow:hidden; }
fieldset.macos.desktop>div.output>fieldset.macos.searchs { position:absolute; z-index:100; }
fieldset.macos.desktop>div.output>fieldset.macos.searchs>form.option>div.item.icon.delete { display:none; }
// fieldset.macos.desktop>div.output>fieldset.macos.searchs>form.option>div.item.icon.delete { display:none; }
fieldset.macos.desktop>div.output>fieldset.macos.searchs>form.option>div.item.keyword input { width:320px; background-color:transparent; border:#404141 solid 1px; }
fieldset.macos.desktop>div.output>fieldset.macos.searchs>form.option>div.item.keyword:hover { background-color:transparent; }
fieldset.macos.desktop>div.output>fieldset.macos.notifications { border-radius:0; height:calc(100% - 125px); width:250px; overflow:auto; position:absolute; top:25px; right:0; }
@ -15,7 +15,7 @@ fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.titl
fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.time { font-size:12px; margin-top:10px; width:48px; }
fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.content { width:180px; }
fieldset.macos.desktop>div.output>fieldset.macos.dock { border:#ffffff3d solid 1px; border-radius:20px; position:absolute; bottom:10px; transition:margin-left 0.3s; }
fieldset.macos.desktop.cmd>div.output>fieldset.macos.dock { z-index:101; }
fieldset.macos.desktop.cmd>div.output>fieldset.macos.dock { z-index:11; }
fieldset.macos.desktop>div.output>div.desktop { padding-top:25px; }
fieldset.macos.desktop>div.output>div.desktop:not(.select) { display:none; }
fieldset.macos.desktop>div.output>div.desktop>div.item { position:absolute; text-align:center; }
@ -29,7 +29,7 @@ fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output>table.content
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output>table.content td { padding:10px; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output>table.content td>input { margin:5px; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.item.button { border-radius:20px; height:20px; width:20px; scale:0.7; position:absolute; top:16px; right:10px; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>legend { background-color:unset; padding-right:10px; margin:10px 0; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>legend { background-color:unset; padding-right:10px; margin:10px 0; box-shadow:none; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>*:not(.textarea) { margin:10px 0px 10px 10px; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.icon { margin-left:0; margin-top:10px; margin-bottom:8px; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item.button>span.icon { font-size:26px; line-height:28px; }

View File

@ -3,13 +3,14 @@ Volcanos(chat.ONIMPORT, {
(!can.page.ClassList.has(can, document.body, cli.BLACK) || can.isCmdMode()) && can.onlayout.background(can, can.user.info.background||"/require/usr/icons/background.jpg", can._fields)
can.ui = {}, can.base.isFunc(cb) && cb(msg), can.onmotion.clear(can)
can.onimport._menu(can), can.onimport._dock(can), can.onimport._searchs(can), can.onimport._notifications(can), can.onimport.layout(can)
can.onkeymap._build(can)
},
_menu: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.menu", style: html.OUTPUT}, function(sub) { can.ui.menu = sub
_menu: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.menu", style: html.OUTPUT, _space: can.Conf("_space")}, function(sub) { can.ui.menu = sub
sub.onexport.record = function(_, value, key, item) { delete(can.onfigure._path)
switch (value) {
case "create": can.onaction.create(event, can); break
case "desktop": var carte = can.user.carte(event, can, {}, can.core.Item(can.onfigure), function(event, button, meta, carte) { can.onfigure[button](event, can, carte) }); break
case "searchs": can.onmotion.toggle(can, can.ui.searchs._target); break
case "searchs": can.onaction._search(can); break
case "notifications": can.ui.notifications._output.innerHTML && can.onmotion.toggle(can, can.ui.notifications._target); break
default: can.onimport._window(can, value)
}
@ -29,6 +30,7 @@ Volcanos(chat.ONIMPORT, {
if (can.base.isIn(item.type, web.LINK, web.WORKER, web.SERVER, web.GATEWAY)) { can.onimport._window(can, {index: web.CHAT_IFRAME, args: [item.text]}), can.onkeymap.prevent(event) }
if (item.type == ssh.SHELL) { can.onimport._window(can, {index: web.CODE_XTERM, args: [item.text]}) }
}, can.ConfHeight() < 800 && can.onmotion.delay(can, function() { can.onmotion.hidden(can, sub._target) })
sub.onaction._close = function() { can.onmotion.hidden(can, sub._target) }
can.onmotion.hidden(can, sub._target)
}) },
_notifications: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.notifications", style: html.OUTPUT}, function(sub) { can.ui.notifications = sub
@ -90,8 +92,22 @@ Volcanos(chat.ONIMPORT, {
},
}, [""])
Volcanos(chat.ONACTION, {list: ["full"],
_search: function(can) {
if (can.onmotion.toggle(can, can.ui.searchs._target)) {
can.page.Select(can, can.ui.searchs._option, "input[name=keyword]", function(target) { can.onmotion.focus(can, target) })
}
},
create: function(event, can, button) { can.onimport._desktop(can) },
full: function(event, can) { document.body.requestFullscreen() },
onkeydown: function(event, can) {
can.db._key_list = can.onkeymap._parse(event, can, mdb.PLUGIN, can.db._key_list, can.ui.content)
},
})
Volcanos(chat.ONKEYMAP, {
_mode: {plugin: {
" ": function(event, can) { can.onkeymap.prevent(event), can.onaction._search(can) },
"Escape": function(event, can) { can.onmotion.hidden(can, can.ui.searchs._target) },
}}, _engine: {},
})
Volcanos(chat.ONDETAIL, {
select: function(can, target) { can.page.SelectChild(can, can.ui.desktop, html.FIELDSET, function(fieldset) {

View File

@ -4,6 +4,6 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.page.Append(can, can._o
].concat(msg.Table(function(item) {
return {view: [html.ITEM], list: [{img: can.page.drawText(can, item.name||item.index, 25, 0, 20)}], onclick: function(event) { can.sup.onexport.record(can, item) }}
}), [
{view: [html.MENU, "", can.user.mod.isPod? can.misc.ParseURL(can)[ice.POD]: location.host], onclick: function(event) { can.sup.onexport.record(can, html.DESKTOP) }},
{view: [html.MENU, "", can.Conf("_space")? can.Conf("_space"): can.user.mod.isPod? can.misc.ParseURL(can)[ice.POD]: location.host], onclick: function(event) { can.sup.onexport.record(can, html.DESKTOP) }},
{view: [html.MENU, "", "+"], onclick: function(event) { can.sup.onexport.record(can, mdb.CREATE) }},
])) }})

View File

@ -17,7 +17,14 @@ import (
func _inner_list(m *ice.Message, ext, file, dir string) {
kit.If(aaa.Right(m, dir, file), func() {
kit.If(nfs.IsSourceFile(m, ext), func() { m.Cmdy(nfs.CAT, path.Join(dir, file)) }, func() { _inner_show(m.RenderResult().SetResult(), ext, file, dir) })
kit.If(nfs.IsSourceFile(m, ext), func() {
m.Cmdy(nfs.CAT, path.Join(dir, file))
}, func() {
_inner_show(m.RenderResult().SetResult(), ext, file, dir)
if m.Result() == "" {
m.Cmdy(nfs.CAT, path.Join(dir, file))
}
})
})
}
func _inner_show(m *ice.Message, ext, file, dir string) {
@ -62,6 +69,7 @@ const (
OPERATOR = lex.OPERATOR
PREFIX = lex.PREFIX
SUFFIX = lex.SUFFIX
INCLUDE = "include"
)
const (
COMMENT = "comment"
@ -107,7 +115,12 @@ func init() {
m.Cmdy(FAVOR, mdb.INPUTS, arg)
}
}},
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.PLUGIN, arg) }},
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.PLUGIN, arg)
if m.Result() == "" {
m.Cmdy(mdb.PLUGIN, m.Option("parse", strings.ToLower(kit.Split(path.Base(arg[1]), ".")[0])), arg[1:])
}
}},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _inner_show(m, arg[0], arg[1], arg[2]) }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _inner_exec(m, arg[0], arg[1], arg[2]) }},
nfs.GREP: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.GREP, arg) }},

View File

@ -77,6 +77,9 @@ func init() {
kit.If(m.Cmd("").Length() == 0, func() { m.Cmd("", mdb.CREATE, mdb.TYPE, ISH) })
}},
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
if arg[1] == "shell" {
m.PushSearch(mdb.TYPE, ssh.SHELL, mdb.NAME, SH, mdb.TEXT, "/bin/sh")
}
mdb.IsSearchPreview(m, arg, func() []string { return []string{ssh.SHELL, SH, kit.Select("/bin/sh", os.Getenv("SHELL"))} })
mdb.IsSearchPreview(m, arg, func() []string { return []string{ssh.SHELL, ISH, "/bin/ish"} })
}},
@ -119,7 +122,7 @@ func init() {
web.ProcessPodCmd(m, "", "", m.OptionSimple(mdb.HASH), ctx.STYLE, web.OUTPUT)
}},
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "命令")) })
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "终端")) })
}},
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
ctx.PROCESS: {Hand: func(m *ice.Message, arg ...string) {

View File

@ -16,7 +16,7 @@ func init() {
Index.MergeCommands(ice.Commands{
EPIC: {Name: "epic hash list create", Help: "史记", Actions: ice.MergeActions(ice.Actions{
mdb.CREATE: {Name: "create time@date zone name"}, mdb.MODIFY: {Name: "modify time zone name"},
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,name")), Hand: func(m *ice.Message, arg ...string) {
}, mdb.ImportantHashAction(mdb.FIELD, "time,hash,zone,name")), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Table(func(value ice.Maps) {
if span := kit.Time(m.Time()) - kit.Time(value[mdb.TIME]); span > 0 {
m.Push(mdb.TEXT, kit.Format(`已经 <span style="font-size:24px;color:red">%v</span> 天<br>距 %s<br>`, int(time.Duration(span)/time.Hour/24), kit.Split(value[mdb.TIME])[0]))

View File

@ -6,6 +6,7 @@ import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
)
@ -22,6 +23,10 @@ func _task_action(m *ice.Message, status ice.Any, action ...string) string {
return kit.Join(action)
}
func _task_modify(m *ice.Message, field, value string, arg ...string) {
if space := m.Option(web.SPACE); space != "" {
m.Options(web.SPACE, "").Cmdy(web.SPACE, space, TASK, mdb.MODIFY, field, value, arg)
return
}
if field == STATUS {
switch value {
case PROCESS:
@ -62,7 +67,17 @@ func init() {
Index.MergeCommands(ice.Commands{
TASK: {Name: "task zone id auto insert", Help: "任务", Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
if space := m.Option(web.SPACE); space != "" && arg[0] != web.SPACE {
m.Options(web.SPACE, "").Cmdy(web.SPACE, space, TASK, mdb.INPUTS, arg)
return
}
switch arg[0] = strings.TrimPrefix(arg[0], "extra."); arg[0] {
case web.SPACE:
m.Cmd(web.SPACE, func(value ice.Maps) {
if kit.IsIn(value[mdb.TYPE], web.WORKER, web.SERVER) {
m.Push(arg[0], value[mdb.NAME])
}
})
case mdb.STATUS:
m.Push(arg[0], PREPARE, PROCESS, CANCEL, FINISH)
case LEVEL, SCORE:
@ -76,8 +91,12 @@ func init() {
mdb.ZoneInputs(m, arg)
}
}},
mdb.INSERT: {Name: "insert zone* type=once,step,week name* text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) {
mdb.INSERT: {Name: "insert space zone* type=once,step,week name* text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) {
if space, arg := arg[1], arg[2:]; space != "" {
m.Cmdy(web.SPACE, space, TASK, mdb.INSERT, web.SPACE, "", arg)
} else {
mdb.ZoneInsert(m, arg[:2], BEGIN_TIME, m.Time(), STATUS, PREPARE, LEVEL, 3, SCORE, 3, arg[2:])
}
}},
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { _task_modify(m, arg[0], arg[1], arg[2:]...) }},
CANCEL: {Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, CANCEL) }},

View File

@ -1,20 +1,39 @@
package wiki
import (
"path"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
)
func _feel_path(m *ice.Message, p string) string {
if nfs.Exists(m, ice.USR_LOCAL_IMAGE) {
return path.Join(ice.USR_LOCAL_IMAGE, p)
}
return p
}
const FEEL = "feel"
func init() {
Index.MergeCommands(ice.Commands{
FEEL: {Name: "feel path auto prev next record1 record2 upload actions", Help: "影音媒体", Actions: ice.MergeActions(ice.Actions{
"record1": {Help: "截图"}, "record2": {Help: "录屏"},
web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) {
m.Option(nfs.PATH, _feel_path(m, m.Option(nfs.PATH)))
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
m.Cmdy(web.CACHE, web.WATCH, m.Option(mdb.HASH), path.Join(m.Option(nfs.PATH), up[1]))
}},
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
nfs.Trash(m, _feel_path(m, m.Option(nfs.PATH)))
}},
}, WikiAction("", "png|PNG|jpg|JPG|jpeg|mp4|m4v|mov|MOV|webm")), Hand: func(m *ice.Message, arg ...string) {
kit.If(nfs.Exists(m, ice.USR_LOCAL_IMAGE), func() { m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_IMAGE) })
m.Option(nfs.DIR_ROOT, _feel_path(m, ""))
_wiki_list(m, kit.Slice(arg, 0, 1)...)
ctx.DisplayLocal(m, "")
}},

View File

@ -22,6 +22,8 @@ fieldset.web.wiki.portal.home>div.output>div.layout>div.main p { white-space:pre
fieldset.web.wiki.portal>div.output>div.layout>div.main>* { margin:20px auto; }
fieldset.web.wiki.portal>div.output>div.layout>div.main h2 { margin-top:40px; }
fieldset.web.wiki.portal>div.output>div.layout>div.main h3 { margin-top:20px; }
fieldset.web.wiki.portal>div.output>div.layout>div.main ul { margin:20px 40px; }
fieldset.web.wiki.portal>div.output>div.layout>div.main ol { margin:20px 40px; }
fieldset.web.wiki.portal>div.output>div.layout>div.main p code {
background-color:var(--code-bg-color); color:var(--code-fg-color); padding:0 10px;
}

View File

@ -20,7 +20,7 @@ func (m *Message) TryCatch(msg *Message, catch bool, cb ...func(msg *Message)) {
default:
fileline := m.FormatStack(2, 1)
m.Log(LOG_WARN, "catch: %s %s", e, fileline).Log("chain", msg.FormatChain())
m.Log(LOG_WARN, "catch: %s %s", e, kit.FileLine(4, 10)).Log("stack", m.FormatStack(2, 100))
m.Log(LOG_WARN, "catch: %s %s", e, kit.FileLine(4, 10)).Log("stack", m.FormatStack(2, 1000))
m.Log(LOG_WARN, "catch: %s %s", e, fileline).Result(ErrWarn, e, SP, m.FormatStack(2, 5))
if len(cb) > 1 {
m.TryCatch(msg, catch, cb[1:]...)
@ -143,6 +143,7 @@ func (m *Message) _command(arg ...Any) *Message {
}
}
}
m.Assert(kit.Int(m.Option("_cmd_count", kit.Int(m.Option("_cmd_count"))+1)) < 300)
list := kit.Simple(args...)
kit.If(len(list) == 0, func() { list = m.meta[MSG_DETAIL] })
if len(list) == 0 {

View File

@ -124,29 +124,32 @@ func _repos_each(m *ice.Message, title string, cb func(*git.Repository, ice.Maps
})
}
func _repos_each_origin(m *ice.Message, title string, cb func(*git.Repository, string, *http.BasicAuth, ice.Maps) error) {
func _repos_auth(m *ice.Message, origin string) *http.BasicAuth {
list := _repos_credentials(m)
insteadof := mdb.Config(m, INSTEADOF)
if insteadof := mdb.Config(m, INSTEADOF); insteadof != "" {
origin = insteadof + path.Base(origin)
}
if u, ok := list[kit.ParseURL(origin).Host]; !ok {
return nil
} else if password, ok := u.User.Password(); !ok {
return nil
} else {
return &http.BasicAuth{Username: u.User.Username(), Password: password}
}
}
func _repos_each_origin(m *ice.Message, title string, cb func(*git.Repository, string, *http.BasicAuth, ice.Maps) error) {
_repos_each(m, "", func(repos *git.Repository, value ice.Maps) error {
if value[ORIGIN] == "" {
return nil
}
remote, err := repos.Remote("origin")
if err != nil {
} else if remote, err := repos.Remote("origin"); err != nil {
return err
}
} else {
remoteURL := remote.Config().URLs[0]
if insteadof != "" {
if insteadof := mdb.Config(m, INSTEADOF); insteadof != "" {
remoteURL = insteadof + path.Base(remoteURL)
}
if u, ok := list[kit.ParseURL(remoteURL).Host]; !ok {
// return errors.New("not found userinfo")
} else if password, ok := u.User.Password(); !ok {
// return errors.New("not found password")
} else {
return cb(repos, remoteURL, &http.BasicAuth{Username: u.User.Username(), Password: password}, value)
return cb(repos, remoteURL, _repos_auth(m, remote.Config().URLs[0]), value)
}
return cb(repos, remoteURL, nil, value)
})
}
func _repos_branch(m *ice.Message, repos *git.Repository) error {
@ -458,7 +461,7 @@ func init() {
CLONE: {Name: "clone origin* branch name path", Help: "克隆", Hand: func(m *ice.Message, arg ...string) {
m.OptionDefault(mdb.NAME, path.Base(m.Option(ORIGIN)))
m.OptionDefault(nfs.PATH, path.Join(path.Join(nfs.USR, m.Option(mdb.NAME))))
if _, err := git.PlainClone(m.Option(nfs.PATH), false, &git.CloneOptions{URL: m.Option(ORIGIN)}); m.Warn(err) {
if _, err := git.PlainClone(m.Option(nfs.PATH), false, &git.CloneOptions{URL: m.Option(ORIGIN), Auth: _repos_auth(m, m.Option(ORIGIN))}); m.Warn(err) {
_repos_insert(m, m.Option(nfs.PATH))
}
}},

View File

@ -223,6 +223,6 @@ func (m *Message) resource(file string) string {
if p = strings.TrimPrefix(p, kit.Path("")+PS); strings.Contains(p, "/pkg/mod/") {
p = strings.Split(p, "/pkg/mod/")[1]
}
kit.If(file != "", func() { p = path.Join(path.Dir(p), file) })
kit.If(file == "", func() { p = kit.ExtChange(p, "js") }, func() { p = path.Join(path.Dir(p), file) })
return "/require/" + p
}