forked from x/icebergs
add git.search
This commit is contained in:
parent
ac660c4f04
commit
6e8235346f
@ -126,7 +126,7 @@ const DREAM = "dream"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
DREAM: {Name: "dream name@key auto create startall stopall", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{
|
||||
DREAM: {Name: "dream name@key auto create origin startall stopall", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.IsSearchPreview(m, arg) {
|
||||
m.Cmds("", func(value ice.Maps) { m.PushSearch(mdb.TEXT, m.MergePod(value[mdb.NAME]), value) })
|
||||
@ -175,6 +175,9 @@ func init() {
|
||||
kit.Switch(m.Option(mdb.TYPE), []string{SERVER, WORKER}, func() { m.PushButton(OPEN) })
|
||||
}},
|
||||
OPEN: {Hand: func(m *ice.Message, arg ...string) { ctx.ProcessOpen(m, m.MergePod(m.Option(mdb.NAME))) }},
|
||||
"origin": {Name: "origin", Help: "仓库", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(m.MergePodCmd("", "web.code.git.search", "repos", "repos"))
|
||||
}},
|
||||
"startall": {Name: "startall name", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
reg, err := regexp.Compile(m.Option(mdb.NAME))
|
||||
if m.Warn(err) {
|
||||
@ -228,6 +231,14 @@ func init() {
|
||||
}, ctx.CmdAction(), DreamAction(), mdb.ImportantHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
_dream_list(m)
|
||||
m.RewriteAppend(func(value, key string, index int) string {
|
||||
if key == "icon" {
|
||||
if !kit.HasPrefix(value, nfs.PS, HTTP) {
|
||||
return kit.MergeURL("/require/"+value, ice.POD, m.Appendv(mdb.NAME)[index])
|
||||
}
|
||||
}
|
||||
return value
|
||||
})
|
||||
ctx.DisplayTableCard(m)
|
||||
} else if arg[0] == ctx.ACTION {
|
||||
gdb.Event(m, DREAM_ACTION, arg)
|
||||
|
@ -1,6 +1,8 @@
|
||||
package macos
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
@ -8,7 +10,6 @@ import (
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
"shylinux.com/x/icebergs/core/team"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -20,21 +21,22 @@ func init() {
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
Notify(m, cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME)
|
||||
FinderAppend(m, "Applications", m.PrefixKey())
|
||||
AppInstall(m, "Finder", nfs.DIR)
|
||||
AppInstall(m, "Safari", web.CHAT_IFRAME)
|
||||
AppInstall(m, "Terminal", web.CODE_XTERM)
|
||||
AppInstall(m, "Calendar", web.TEAM_PLAN, ctx.ARGS, team.MONTH)
|
||||
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.CHAT_FLOWS, mdb.ICON, "usr/icons/flows.png")
|
||||
AppInstall(m, "", web.CODE_COMPILE, mdb.ICON, "usr/icons/go.png")
|
||||
AppInstall(m, "", web.CODE_GIT_STATUS, mdb.ICON, "usr/icons/git.png")
|
||||
AppInstall(m, "usr/icons/Finder.png", nfs.DIR)
|
||||
AppInstall(m, "usr/icons/Safari.png", web.CHAT_IFRAME)
|
||||
AppInstall(m, "usr/icons/Terminal.png", web.CODE_XTERM)
|
||||
AppInstall(m, "usr/icons/Calendar.png", web.TEAM_PLAN)
|
||||
AppInstall(m, "usr/icons/Grapher.png", web.WIKI_DRAW)
|
||||
AppInstall(m, "usr/icons/Photos.png", web.WIKI_FEEL)
|
||||
AppInstall(m, "usr/icons/Books.png", web.WIKI_WORD)
|
||||
|
||||
AppInstall(m, "usr/icons/info.png", cli.RUNTIME)
|
||||
AppInstall(m, "usr/icons/Mission Control.png", web.DREAM, mdb.NAME, web.DREAM)
|
||||
AppInstall(m, "usr/icons/vimer.png", web.CODE_VIMER)
|
||||
AppInstall(m, "usr/icons/flows.png", web.CHAT_FLOWS)
|
||||
AppInstall(m, "usr/icons/go.png", web.CODE_COMPILE)
|
||||
AppInstall(m, "usr/icons/git.png", web.CODE_GIT_STATUS)
|
||||
}},
|
||||
code.INSTALL: {Hand: func(m *ice.Message, arg ...string) { AppInstall(m, arg[0], arg[1], arg[2:]...) }},
|
||||
code.INSTALL: {Hand: func(m *ice.Message, arg ...string) { AppInstall(m, arg[0], arg[1]) }},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case web.SPACE:
|
||||
@ -55,11 +57,10 @@ func init() {
|
||||
}, PodCmdAction(), CmdHashAction("space,index,args"))},
|
||||
})
|
||||
}
|
||||
func install(m *ice.Message, cmd, name, index string, arg ...string) {
|
||||
name, icon := kit.Select(kit.Select("", kit.Split(index, ice.PT), -1), name), ""
|
||||
kit.If(nfs.Exists(m, kit.PathJoin(USR_ICONS, name, nfs.PNG)), func() { icon = kit.PathJoin(USR_ICONS, name, nfs.PNG) })
|
||||
func install(m *ice.Message, cmd, icon, index string, arg ...string) {
|
||||
name := kit.TrimExt(path.Base(icon), "png")
|
||||
m.Cmd(Prefix(cmd), mdb.CREATE, mdb.NAME, name, mdb.ICON, icon, ctx.INDEX, index, arg)
|
||||
}
|
||||
func AppInstall(m *ice.Message, name, index string, arg ...string) {
|
||||
install(m, APPLICATIONS, name, index, arg...)
|
||||
func AppInstall(m *ice.Message, icon, index string, arg ...string) {
|
||||
install(m, APPLICATIONS, icon, index, arg...)
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/team"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -17,11 +16,11 @@ func init() {
|
||||
DESKTOP: {Help: "应用桌面", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.HashImport(m); m.Cmd(DESKTOP).Length() == 0 {
|
||||
DeskAppend(m, "Books", web.WIKI_WORD)
|
||||
DeskAppend(m, "Photos", web.WIKI_FEEL)
|
||||
DeskAppend(m, "Grapher", web.WIKI_DRAW)
|
||||
DeskAppend(m, "Calendar", web.TEAM_PLAN, ctx.ARGS, team.MONTH)
|
||||
DeskAppend(m, "flows", web.CHAT_FLOWS)
|
||||
DeskAppend(m, "usr/icons/Books.png", web.WIKI_WORD)
|
||||
DeskAppend(m, "usr/icons/Photos.png", web.WIKI_FEEL)
|
||||
DeskAppend(m, "usr/icons/Grapher.png", web.WIKI_DRAW)
|
||||
DeskAppend(m, "usr/icons/Calendar.png", web.TEAM_PLAN)
|
||||
DeskAppend(m, "usr/icons/flows.png", web.CHAT_FLOWS)
|
||||
}
|
||||
}},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashExport(m) }},
|
||||
@ -33,6 +32,6 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
func DeskAppend(m *ice.Message, name, index string, arg ...string) {
|
||||
install(m, DESKTOP, name, index, arg...)
|
||||
func DeskAppend(m *ice.Message, icon, index string) {
|
||||
install(m, DESKTOP, icon, index)
|
||||
}
|
||||
|
@ -13,18 +13,18 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{DOCK: {Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.HashImport(m); m.Cmd(DOCK).Length() == 0 {
|
||||
DockAppend(m, "Finder", Prefix(FINDER))
|
||||
DockAppend(m, "Safari", web.CHAT_IFRAME)
|
||||
DockAppend(m, "Terminal", web.CODE_XTERM)
|
||||
DockAppend(m, "", web.CODE_VIMER)
|
||||
DockAppend(m, "", web.CODE_COMPILE, mdb.ICON, "usr/icons/go.png")
|
||||
DockAppend(m, "", web.CODE_GIT_STATUS, mdb.ICON, "usr/icons/git.png")
|
||||
DockAppend(m, "usr/icons/Finder.png", Prefix(FINDER))
|
||||
DockAppend(m, "usr/icons/Safari.png", web.CHAT_IFRAME)
|
||||
DockAppend(m, "usr/icons/Terminal.png", web.CODE_XTERM)
|
||||
DockAppend(m, "usr/icons/vimer.png", web.CODE_VIMER)
|
||||
DockAppend(m, "usr/icons/go.png", web.CODE_COMPILE)
|
||||
DockAppend(m, "usr/icons/git.png", web.CODE_GIT_STATUS)
|
||||
}
|
||||
}},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashExport(m) }},
|
||||
}, aaa.RoleAction(), CmdHashAction(), mdb.ImportantHashAction())}})
|
||||
}
|
||||
|
||||
func DockAppend(m *ice.Message, name, index string, arg ...string) {
|
||||
install(m, DOCK, name, index, arg...)
|
||||
func DockAppend(m *ice.Message, icon, index string) {
|
||||
install(m, DOCK, icon, index)
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ func init() {
|
||||
}, CmdHashAction(mdb.NAME))}})
|
||||
}
|
||||
|
||||
func FinderAppend(m *ice.Message, name, index string, arg ...string) {
|
||||
install(m, FINDER, name, index, arg...)
|
||||
func FinderAppend(m *ice.Message, icon, index string) {
|
||||
install(m, FINDER, icon, index)
|
||||
}
|
||||
|
@ -13,6 +13,6 @@ func init() {
|
||||
MENU: {Actions: ice.MergeActions(aaa.RoleAction(), CmdHashAction(), mdb.ImportantHashAction())},
|
||||
})
|
||||
}
|
||||
func MenuAppend(m *ice.Message, name, index string, arg ...string) {
|
||||
install(m, MENU, name, index, arg...)
|
||||
func MenuAppend(m *ice.Message, icon, index string) {
|
||||
install(m, MENU, icon, index)
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ func _repos_auth(m *ice.Message, origin string) *http.BasicAuth {
|
||||
} else if password, ok := u.User.Password(); !ok {
|
||||
return nil
|
||||
} else {
|
||||
m.Debug("auth %v:%v", u.User.Username(), password)
|
||||
return &http.BasicAuth{Username: u.User.Username(), Password: password}
|
||||
}
|
||||
}
|
||||
|
10
misc/git/search.css
Normal file
10
misc/git/search.css
Normal file
@ -0,0 +1,10 @@
|
||||
fieldset.web.code.git.search>div.output>div.item div.title { display:flex; }
|
||||
fieldset.web.code.git.search>div.output>div.item div.title>img { height:48px; margin-right:10px; }
|
||||
fieldset.web.code.git.search>div.output>div.item div.title>div.name { height:48px; }
|
||||
fieldset.web.code.git.search>div.output>div.item div.title span.name { line-height:32px; }
|
||||
fieldset.web.code.git.search>div.output>div.item div.title div.label { font-size:12px; font-weight:normal; }
|
||||
fieldset.web.code.git.search>div.output>div.item div.title div.label span { padding:5px; padding-right:10px; }
|
||||
fieldset.web.code.git.search>div.output>div.item div.content { height:100px; }
|
||||
fieldset.web.code.git.search.zone>div.output>div.item { display:flex; padding:5px; }
|
||||
fieldset.web.code.git.search.zone>div.output>div.item>img { margin-right:5px; }
|
||||
fieldset.web.code.git.search.zone>div.output>div.item>span { line-height:32px; }
|
69
misc/git/search.go
Normal file
69
misc/git/search.go
Normal file
@ -0,0 +1,69 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/chat/macos"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func init() {
|
||||
const SEARCH = "search"
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SEARCH: {Name: "search repos keyword auto", Help: "代码源", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
macos.AppInstall(m, "usr/icons/gitea.png", m.PrefixKey(), ctx.ARGS, kit.Format([]string{"repos"}))
|
||||
}},
|
||||
cli.START: {Name: "start name", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.DREAM, cli.START)
|
||||
}},
|
||||
CLONE: {Name: "clone name", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(REPOS, CLONE, m.Option(REPOS))
|
||||
}},
|
||||
cli.OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(m.Option("html_url"))
|
||||
}},
|
||||
"origin": {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(m.Cmdv("web.spide", "repos", "client.origin") + "/explore/repos")
|
||||
}},
|
||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Cmdy("web.spide").RenameAppend("client.name", "repos", "client.url", "origin").Cut("time,repos,origin")
|
||||
return
|
||||
}
|
||||
res := kit.UnMarshal(m.Cmdx("web.spide", REPOS, web.SPIDE_RAW, http.MethodGet, "/api/v1/repos/search",
|
||||
"q", kit.Select("", arg, 1), "sort", "updated", "order", "desc", "page", "1", "limit", "100",
|
||||
))
|
||||
kit.For(kit.Value(res, "data"), func(value ice.Map) {
|
||||
value["size"] = kit.FmtSize(kit.Int(value["size"]) * 1000)
|
||||
if t, e := time.Parse(time.RFC3339, kit.Format(value["updated_at"])); e == nil {
|
||||
value["updated_at"] = t.Format("01-02 15:04")
|
||||
}
|
||||
m.Push("", value, []string{
|
||||
"avatar_url",
|
||||
"name",
|
||||
|
||||
"language",
|
||||
"forks_count",
|
||||
"stars_count",
|
||||
"watchers_count",
|
||||
"size", "updated_at",
|
||||
|
||||
"description",
|
||||
"clone_url",
|
||||
"html_url",
|
||||
"website",
|
||||
})
|
||||
m.PushButton(cli.START, CLONE, cli.OPEN)
|
||||
})
|
||||
m.RenameAppend("clone_url", "repos").StatusTimeCount().Display("")
|
||||
m.Action("origin")
|
||||
// m.Echo("%v", kit.Formats(res))
|
||||
}},
|
||||
})
|
||||
}
|
25
misc/git/search.js
Normal file
25
misc/git/search.js
Normal file
@ -0,0 +1,25 @@
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
if (can.isZoneMode()) { return can.onimport._vimer_zone(can, msg, can._output) }
|
||||
can.onappend.style(can, "card", can._output)
|
||||
can.page.Appends(can, can._output, msg.Table(function(value) {
|
||||
return {view: [[html.ITEM, value.status]], list: [
|
||||
{view: [wiki.TITLE, html.DIV], list: [{img: value.avatar_url}, {view: "name", list: [
|
||||
{view: "name", list: [
|
||||
{text: [value.name, "", "name"]},
|
||||
]},
|
||||
{view: "label", list: [
|
||||
{icon: "bi bi-file-earmark-code"}, {text: value.language},
|
||||
{icon: "bi bi-share"}, {text: value.forks_count},
|
||||
{icon: "bi bi-star"}, {text: value.stars_count},
|
||||
{icon: "bi bi-folder2"}, {text: value.size},
|
||||
{icon: "bi bi-clock"}, {text: value.updated_at},
|
||||
]}
|
||||
]}]}, {view: [wiki.CONTENT, html.DIV, value.description]},
|
||||
{view: html.ACTION, inner: value.action, _init: function(target) { can.onappend.mores(can, target, value, 5) }},
|
||||
]}
|
||||
})), can.onappend.board(can, msg)
|
||||
can.onimport.layout(can)
|
||||
},
|
||||
layout: function(can) { can.onlayout.expand(can, can._output, 360) },
|
||||
}, [""])
|
Loading…
x
Reference in New Issue
Block a user