1
0
forked from x/icebergs

opt index.css

This commit is contained in:
harveyshao 2023-01-15 18:00:13 +08:00
parent a350a17b69
commit 7bf0bd877c
13 changed files with 56 additions and 31 deletions

View File

@ -131,7 +131,7 @@ func init() {
if m.IsCliUA() {
_qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0))
} else {
m.Option(SIZE, kit.Select(kit.Format(kit.Min(480, kit.Int(m.Option(ice.HEIGHT)), kit.Int(m.Option(ice.WIDTH)))), arg, 3))
m.Option(SIZE, kit.Select(kit.Format(kit.Min(480, kit.Int(m.Option(ice.MSG_HEIGHT)), kit.Int(m.Option(ice.MSG_WIDTH)))), arg, 3))
_qrcode_web(m, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0))
m.StatusTime(mdb.LINK, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0))
}

View File

@ -149,7 +149,7 @@ const RUNTIME = "runtime"
func init() {
Index.MergeCommands(ice.Commands{
RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,bootinfo,api,cli,cmd,env,chain auto", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,api,cli,cmd,env,chain auto", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _runtime_init(m) }},
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf("", "", nil) }},
IFCONFIG: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("tcp.host") }},

View File

@ -160,7 +160,7 @@ func init() {
if len(arg) == 1 {
arg = append(arg, "")
}
m.Option(CMD_ENV, "COLUMNS", kit.Int(kit.Select("1920", m.Option(ice.WIDTH)))/12)
m.Option(CMD_ENV, "COLUMNS", kit.Int(kit.Select("1920", m.Option(ice.MSG_WIDTH)))/12)
m.Echo(SystemCmds(m, "man %s %s|col -b", kit.Select("", arg[1], arg[1] != "1"), arg[0]))
}},
}, mdb.HashAction(mdb.SHORT, "cmd", mdb.FIELD, "time,cmd,arg")), Hand: func(m *ice.Message, arg ...string) {

View File

@ -189,9 +189,9 @@ 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="/favicon.ico" rel="shortcut icon" type="image/ico">
<link href="/index.css{{.version}}" rel="stylesheet">
<link href="/page/cache.css{{.version}}" rel="stylesheet">
<link href="/page/index.css{{.version}}" rel="stylesheet">
<link href="/page/favicon.ico" rel="shortcut icon" type="image/ico">
</head>
<body>
<script>_version = "{{.version}}"</script>

View File

@ -93,7 +93,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
})
}
kit.Fetch(r.Cookies(), func(k, v string) { m.Optionv(k, v) })
m.OptionDefault(ice.HEIGHT, "480", ice.WIDTH, "320")
m.OptionDefault(ice.MSG_HEIGHT, "480", ice.MSG_WIDTH, "320")
m.Option(ice.MSG_USERUA, r.Header.Get(UserAgent))
m.Option(ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP))
m.Option(ice.MSG_USERADDR, kit.Select(r.RemoteAddr, r.Header.Get(ice.MSG_USERADDR)))

10
conf.go
View File

@ -85,7 +85,9 @@ const ( // DIR
PLUGIN = "plugin"
STORY = "story"
FAVICON_ICO = "favicon.ico"
PAGE_FAVICON_ICO = "page/favicon.ico"
INDEX_CSS = "index.css"
PROTO_JS = "proto.js"
FRAME_JS = "frame.js"
INDEX_JS = "index.js"
@ -165,7 +167,6 @@ const ( // MSG
MSG_TARGET = "_target"
MSG_HANDLE = "_handle"
MSG_UPLOAD = "_upload"
MSG_DAEMON = "_daemon"
MSG_ACTION = "_action"
MSG_STATUS = "_status"
@ -195,6 +196,9 @@ const ( // MSG
MSG_TOPIC = "sess.topic"
MSG_RIVER = "sess.river"
MSG_STORM = "sess.storm"
MSG_WIDTH = "sess.width"
MSG_HEIGHT = "sess.height"
MSG_DAEMON = "sess.daemon"
MSG_FILES = "file.system"
LOG_DISABLE = "log.disable"
@ -289,8 +293,6 @@ const ( // web
TOPIC = "topic"
TITLE = "title"
WIDTH = "width"
HEIGHT = "height"
)
const ( // nfs
SOURCE = "source"

View File

@ -81,9 +81,9 @@ var _div_template = `<!DOCTYPE html>
<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 rel="shortcut icon" type="image/ico" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="/index.css">
<link rel="stylesheet" type="text/css" href="/page/cache.css">
<link rel="stylesheet" type="text/css" href="/page/index.css">
<link rel="shortcut icon" type="image/ico" href="/page/favicon.ico">
<style type="text/css">%s</style>
</head>
<body>
@ -97,9 +97,9 @@ var _div_template2 = `<!DOCTYPE html>
<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 rel="shortcut icon" type="image/ico" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="/index.css">
<link rel="stylesheet" type="text/css" href="/page/cache.css">
<link rel="stylesheet" type="text/css" href="/page/index.css">
<link rel="shortcut icon" type="image/ico" href="/page/favicon.ico">
</head>
<body>
<script src="/proto.js"></script>

View File

@ -224,9 +224,9 @@ var _website_template = `<!DOCTYPE html>
<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 rel="shortcut icon" type="image/ico" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="/index.css">
<link rel="stylesheet" type="text/css" href="/page/cache.css">
<link rel="stylesheet" type="text/css" href="/page/index.css">
<link rel="shortcut icon" type="image/ico" href="/page/favicon.ico">
</head>
<body>
<script src="/proto.js"></script>
@ -239,9 +239,9 @@ var _website_template2 = `<!DOCTYPE html>
<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 rel="shortcut icon" type="image/ico" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="/index.css">
<link rel="stylesheet" type="text/css" href="/page/cache.css">
<link rel="stylesheet" type="text/css" href="/page/index.css">
<link rel="shortcut icon" type="image/ico" href="/page/favicon.ico">
</head>
<body>
<script src="/proto.js"></script>

View File

@ -39,7 +39,7 @@ func _binpack_dir(m *ice.Message, w io.Writer, dir string) {
}
func _binpack_can(m *ice.Message, w io.Writer, dir string) {
for _, k := range []string{ice.FAVICON_ICO, ice.PROTO_JS, ice.FRAME_JS} {
for _, k := range []string{ice.PAGE_FAVICON_ICO, ice.PROTO_JS, ice.FRAME_JS} {
_binpack_file(m, w, path.Join(dir, k))
}
for _, k := range []string{LIB, PAGE, PANEL, PLUGIN, "publish/client/nodejs/"} {

View File

@ -91,7 +91,7 @@ func init() {
}
p := path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))
switch m.Cmd(nfs.SAVE, p); m.Option(nfs.FILE) {
case "proto.js", "page/index.css":
case "index.css", "proto.js":
m.Cmd("", DEVPACK)
}
switch arg[0] {
@ -111,6 +111,24 @@ func init() {
web.DREAM: {Name: "dream name*=hi repos", Help: "空间", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(web.DREAM, cli.START, arg)
}},
nfs.REPOS: {Name: "repos", Help: "仓库", Hand: func(m *ice.Message, arg ...string) {
m.Option("view", "change")
m.Cmd("web.code.git.status", func(value ice.Maps) {
m.Push(mdb.TYPE, value[mdb.TYPE])
if value[nfs.REPOS] == path.Base(kit.Path("")) {
if ls := kit.Split(value[nfs.FILE]); len(ls) == 1 {
m.Push(nfs.PATH, "./")
m.Push(nfs.FILE, ls[0])
} else {
m.Push(nfs.PATH, ls[0]+ice.PS)
m.Push(nfs.FILE, path.Join(ls[1:]...))
}
} else {
m.Push(nfs.PATH, path.Join(ice.USR, value[nfs.REPOS])+ice.PS)
m.Push(nfs.FILE, value[nfs.FILE])
}
})
}},
"_open": {Help: "打开", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(cli.DAEMON, cli.OPEN, "-a", kit.Split(arg[0], ice.PT, ice.PT)[0])
}},

View File

@ -23,7 +23,7 @@ func _publish(m *ice.Message, file ...string) string {
}
func _webpack_can(m *ice.Message) {
m.Option(nfs.DIR_ROOT, "")
m.Cmd(nfs.COPY, _volcanos(m, PAGE_CAN_CSS), _volcanos(m, PAGE_INDEX_CSS), _volcanos(m, PAGE_CACHE_CSS))
m.Cmd(nfs.COPY, _volcanos(m, PAGE_CAN_CSS), _volcanos(m, ice.INDEX_CSS), _volcanos(m, PAGE_CACHE_CSS))
m.Cmd(nfs.COPY, _volcanos(m, PAGE_CAN_JS), _volcanos(m, ice.PROTO_JS), _volcanos(m, PAGE_CACHE_JS))
m.Cmdy(nfs.DIR, _volcanos(m, PAGE))
}
@ -104,7 +104,7 @@ func _webpack_build(m *ice.Message, file string) {
main_js = ice.SRC_MAIN_JS
}
fmt.Fprintf(f, _webpack_template,
m.Cmdx(nfs.CAT, _volcanos(m, PAGE_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, PAGE_CACHE_JS)), m.Cmdx(nfs.CAT, main_js),
)
@ -118,7 +118,6 @@ const (
PLUGIN = "plugin"
)
const (
PAGE_INDEX_CSS = "page/index.css"
PAGE_CACHE_CSS = "page/cache.css"
PAGE_INDEX_JS = "page/index.js"
PAGE_CACHE_JS = "page/cache.js"

View File

@ -112,6 +112,7 @@ func _status_stat(m *ice.Message, files, adds, dels int) (int, int, int) {
return files, adds, dels
}
func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
onlychange := m.Option("view") == "change"
ReposList(m).Tables(func(value ice.Maps) {
m.Option(cli.CMD_DIR, value[nfs.PATH])
files, adds, dels = _status_stat(m, files, adds, dels)
@ -126,6 +127,9 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
case "swp", "swo", ice.BIN, ice.VAR:
return
}
if onlychange && ls[0] == "##" {
return
}
switch m.Push(REPOS, value[REPOS]).Push(mdb.TYPE, ls[0]).Push(nfs.FILE, ls[1]); ls[0] {
case "##":
if m.Push(TAGS, tags); strings.Contains(ls[1], "ahead") || !strings.Contains(ls[1], "...") {
@ -242,6 +246,8 @@ func init() {
}
}
}},
"change": {Help: "变更", Hand: func(m *ice.Message, arg ...string) {
}},
"branch_switch": {Help: "切换", Hand: func(m *ice.Message, arg ...string) {
_repos_cmd(m, m.Option(REPOS), "checkout", m.Option(BRANCH))
}},

View File

@ -52,9 +52,9 @@ func Render(m *Message, cmd string, args ...Any) string {
case RENDER_ANCHOR:
return kit.Format(`<a href="%s" target="_blank">%s</a>`, kit.Select(arg[0], arg, 1), arg[0])
case RENDER_IMAGES:
return kit.Format(`<img src="%s" style="max-height:%spx; max-width:%spx">`, arg[0], m.Option(HEIGHT), m.Option(WIDTH))
return kit.Format(`<img src="%s" style="max-height:%spx; max-width:%spx">`, arg[0], m.Option(MSG_HEIGHT), m.Option(MSG_WIDTH))
case RENDER_VIDEOS:
return kit.Format(`<video src="%s" style="max-height:%spx; max-width:%spx" controls>`, arg[0], m.Option(HEIGHT), m.Option(WIDTH))
return kit.Format(`<video src="%s" style="max-height:%spx; max-width:%spx" controls>`, arg[0], m.Option(MSG_HEIGHT), m.Option(MSG_WIDTH))
case RENDER_IFRAME:
return kit.Format(`<iframe src="%s"></iframe>`, arg[0])
case RENDER_SCRIPT: