diff --git a/base/nfs/dir.go b/base/nfs/dir.go index 39b0a251..383f7e3b 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -43,7 +43,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d } } } - return m + return m // 打包文件 } list, e := ioutil.ReadDir(path.Join(root, name)) @@ -75,7 +75,8 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d } p := path.Join(root, name, f.Name()) - if !(dir_type == TYPE_CAT && f.IsDir() || dir_type == TYPE_DIR && !f.IsDir()) && (dir_reg == nil || dir_reg.MatchString(f.Name())) { + isDir := f.IsDir() || kit.IsDir(p) + if !(dir_type == TYPE_CAT && isDir || dir_type == TYPE_DIR && !isDir) && (dir_reg == nil || dir_reg.MatchString(f.Name())) { switch cb := m.OptionCB(DIR).(type) { case func(f os.FileInfo, p string): cb(f, p) @@ -90,7 +91,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d case mdb.TIME: m.Push(field, f.ModTime().Format(ice.MOD_TIME)) case mdb.TYPE: - m.Push(field, kit.Select(CAT, DIR, f.IsDir())) + m.Push(field, kit.Select(CAT, DIR, isDir)) case "tree": if level == 0 { @@ -99,16 +100,16 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d m.Push(field, strings.Repeat("| ", level-1)+"|-"+f.Name()) } case "full": - m.Push(field, path.Join(root, name, f.Name())+kit.Select("", ice.PS, f.IsDir())) + m.Push(field, path.Join(root, name, f.Name())+kit.Select("", ice.PS, isDir)) case PATH: - m.Push(field, path.Join(name, f.Name())+kit.Select("", ice.PS, f.IsDir())) + m.Push(field, path.Join(name, f.Name())+kit.Select("", ice.PS, isDir)) case FILE: - m.Push(field, f.Name()+kit.Select("", ice.PS, f.IsDir())) + m.Push(field, f.Name()+kit.Select("", ice.PS, isDir)) case mdb.NAME: m.Push(field, f.Name()) case SIZE: - if f.IsDir() { + if isDir { if ls, e := ioutil.ReadDir(path.Join(root, name, f.Name())); e == nil { m.Push(field, len(ls)) } else { @@ -118,7 +119,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d m.Push(field, kit.FmtSize(f.Size())) } case LINE: - if f.IsDir() { + if isDir { if ls, e := ioutil.ReadDir(path.Join(root, name, f.Name())); e == nil { m.Push(field, len(ls)) } else { @@ -136,7 +137,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d } case mdb.HASH, "hashs": var h [20]byte - if f.IsDir() { + if isDir { if d, e := ioutil.ReadDir(p); m.Assert(e) { meta := []string{} for _, v := range d { @@ -153,7 +154,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d m.Push(mdb.HASH, kit.Select(kit.Format(h[:6]), kit.Format(h[:]), field == mdb.HASH)) case mdb.LINK: - m.PushDownload(mdb.LINK, kit.Select("", f.Name(), !f.IsDir()), path.Join(root, name, f.Name())) + m.PushDownload(mdb.LINK, kit.Select("", f.Name(), !isDir), path.Join(root, name, f.Name())) case mdb.SHOW: switch p := m.MergeURL2("/share/local/"+path.Join(name, f.Name()), ice.POD, m.Option(ice.MSG_USERPOD)); kit.Ext(f.Name()) { case "png", "jpg": @@ -167,7 +168,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d if m.IsCliUA() || m.Option(ice.MSG_USERROLE) == aaa.VOID { break } - m.PushButton(kit.Select("", TRASH, !f.IsDir())) + m.PushButton(kit.Select("", TRASH, !isDir)) default: m.Push(field, "") } @@ -178,7 +179,8 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d case "node_modules", "pluged", "target", "trash": continue } - if f.IsDir() && deep { + + if deep && isDir { _dir_list(m, root, path.Join(name, f.Name()), level+1, deep, dir_type, dir_reg, fields) } } diff --git a/conf.go b/conf.go index 381c04e9..955b2978 100644 --- a/conf.go +++ b/conf.go @@ -152,6 +152,7 @@ const ( // DIR SRC_RELAY_GO = "src/relay.go" README_MD = "README.md" MAKEFILE = "Makefile" + LICENSE = "LICENSE" ICE_BIN = "ice.bin" GO_SUM = "go.sum" GO_MOD = "go.mod" diff --git a/core/code/binpack.go b/core/code/binpack.go index eefc7eb9..d0be7246 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -61,7 +61,6 @@ func _binpack_can(m *ice.Message, f *os.File, dir string) { fmt.Fprintln(f) } func _binpack_ctx(m *ice.Message, f *os.File) { - _binpack_dir(m, f, ice.SRC_HELP) _binpack_dir(m, f, ice.SRC) } @@ -149,6 +148,7 @@ func init() { fmt.Fprintln(f, _binpack_file(m, ice.ETC_EXIT_SHY)) fmt.Fprintln(f) + fmt.Fprintln(f, _binpack_file(m, ice.LICENSE)) fmt.Fprintln(f, _binpack_file(m, ice.MAKEFILE)) fmt.Fprintln(f, _binpack_file(m, ice.README_MD)) fmt.Fprintln(f) diff --git a/core/wiki/chart.go b/core/wiki/chart.go index 56a7da91..038dd365 100644 --- a/core/wiki/chart.go +++ b/core/wiki/chart.go @@ -62,11 +62,21 @@ func (g *Group) Option(group string, key string, arg ...interface{}) string { } func (g *Group) Get(group string) *ice.Message { return g.list[group] } +func (g *Group) Join(arg ...string) string { + args := []string{} + for i := 0; i < len(arg)-1; i += 2 { + if arg[i] == "" { + continue + } + args = append(args, kit.Format(`%s="%s"`, arg[i], arg[i+1])) + } + return kit.Join(args, ice.SP) +} func (g *Group) Echo(group string, str string, arg ...interface{}) *ice.Message { return g.Get(group).Echo(str, arg...) } func (g *Group) EchoRect(group string, height, width, x, y int, arg ...string) *ice.Message { // rx ry - return g.Echo(group, ``, height, width, kit.Select("4", arg, 0), kit.Select("4", arg, 1), x, y) + return g.Echo(group, ``, height, width, kit.Select("4", arg, 0), kit.Select("4", arg, 1), x, y, g.Join(kit.Slice(arg, 2)...)) } func (g *Group) EchoLine(group string, x1, y1, x2, y2 int) *ice.Message { return g.Echo(group, "", x1, y1, x2, y2) @@ -75,7 +85,7 @@ func (g *Group) EchoText(group string, x, y int, text string, arg ...string) *ic if text == "" { return g.Get(group) } - return g.Echo(group, "%s", x, y, text) + return g.Echo(group, "%s", x, y, g.Join(arg...), text) } func (g *Group) EchoTexts(group string, x, y int, text string, arg ...string) *ice.Message { m := g.Get(group) diff --git a/core/wiki/chart/label.go b/core/wiki/chart/label.go index b24a5717..03ad993c 100644 --- a/core/wiki/chart/label.go +++ b/core/wiki/chart/label.go @@ -74,9 +74,19 @@ func (l *Label) Draw(m *ice.Message, x, y int) wiki.Chart { // 输出 if m.Option(SHOW_BLOCK) == ice.TRUE { - gs.EchoRect(RECT, item.GetHeight(), item.GetWidth(), left+item.MarginX/2, top+item.MarginY/2) + args := []string{"4", "4"} + if mod := kit.Int(m.Option("order.mod")); mod != 0 && i%mod == 0 { + args = append(args, "fill", m.Option("order.bg")) + } + gs.EchoRect(RECT, item.GetHeight(), item.GetWidth(), left+item.MarginX/2, top+item.MarginY/2, args...) } - gs.EchoTexts(TEXT, left+item.GetWidths()/2, top+item.GetHeights()/2, item.Text) + + args := []string{} + if mod := kit.Int(m.Option("order.mod")); mod != 0 && i%mod == 0 { + args = append(args, "stroke", m.Option("order.fg")) + args = append(args, "fill", m.Option("order.fg")) + } + gs.EchoTexts(TEXT, left+item.GetWidths()/2, top+item.GetHeights()/2, item.Text, args...) left += item.GetWidths() }