diff --git a/base/web/share.go b/base/web/share.go index 11a49f2a..cfa7713c 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -139,7 +139,7 @@ func _share_action_list(m *ice.Message, value map[string]interface{}, river, sto return true } func _share_action(m *ice.Message, value map[string]interface{}, arg ...string) bool { - if len(arg) == 1 { + if len(arg) == 1 || arg[1] == "" { return _share_action_redirect(m, value, arg[0]) } if arg[1] == "" { @@ -217,8 +217,8 @@ func init() { m.Richs(ice.WEB_SHARE, nil, arg[0], func(key string, value map[string]interface{}) { m.Log(ice.LOG_EXPORT, "%s: %v", arg, kit.Format(value)) - if m.Option(ice.MSG_USERROLE) != ice.ROLE_ROOT && kit.Time(kit.Format(value[kit.MDB_TIME])) < kit.Time(m.Time()) { - m.Echo("invalid") + if m.Warn(m.Option(ice.MSG_USERROLE) != ice.ROLE_ROOT && kit.Time(kit.Format(value[kit.MDB_TIME])) < kit.Time(m.Time()), "expired") { + m.Echo("expired") return } diff --git a/conf.go b/conf.go index 07f6e0eb..c3f34ffb 100644 --- a/conf.go +++ b/conf.go @@ -131,6 +131,7 @@ const ( // LOG LOG_WARN = "warn" LOG_ERROR = "error" LOG_TRACE = "trace" + LOG_DEBUG = "debug" ) const ( // SSH SSH_SOURCE = "source" diff --git a/core/wiki/inner.go b/core/wiki/inner.go index 1a8c629c..49c687d9 100644 --- a/core/wiki/inner.go +++ b/core/wiki/inner.go @@ -14,19 +14,36 @@ const INNER = "inner" const QRCODE = "qrcode" const VEDIO = "vedio" -func _inner_list(m *ice.Message, name string) { +func _inner_protect(m *ice.Message, name string) bool { if ls := strings.Split(name, "/"); m.Conf(INNER, kit.Keys("meta.protect", ls[0])) == "true" { + return true + } + return false +} + +func _inner_list(m *ice.Message, name string) { + if _inner_protect(m, name) { m.Push("file", "../") return } - if m.Cmdy(kit.Keys(strings.TrimPrefix(path.Ext(name), "."), "list"), name); len(m.Resultv()) > 0 { + p := strings.TrimPrefix(path.Ext(name), ".") + if m.Cmdy(kit.Keys(p, "list"), name); len(m.Resultv()) > 0 { return } - m.Cmdy("nfs.dir", name, "file size time") + if strings.HasSuffix(name, "/") || m.Conf(INNER, kit.Keys("meta.source", p)) == "true" { + m.Cmdy("nfs.dir", name, "file size time") + } else { + m.Echo(name) + } } func _inner_save(m *ice.Message, name, text string) { + if _inner_protect(m, name) { + m.Echo("no right") + return + } + if m.Cmdy(kit.Keys(strings.TrimPrefix(path.Ext(name), "."), "save"), name, text); len(m.Resultv()) > 0 { return } @@ -53,6 +70,11 @@ func _inner_plug(m *ice.Message, name string) { m.Echo("{}") } func _inner_show(m *ice.Message, name string) { + if _inner_protect(m, name) { + m.Push("file", "../") + return + } + p := strings.TrimPrefix(path.Ext(name), ".") if msg := m.Cmd(kit.Keys(p, "show"), name); m != msg && msg.Hand { m.Copy(msg) @@ -80,6 +102,10 @@ func init() { Configs: map[string]*ice.Config{ INNER: {Name: "inner", Help: "编辑器", Value: kit.Data( "protect", kit.Dict("etc", "true", "var", "true", "usr", "true"), + "source", kit.Dict( + "sh", "true", "shy", "true", "py", "true", + "js", "true", "go", "true", "c", "true", + ), "plug", kit.Dict( "py", kit.Dict("display", true, "profile", true), "md", kit.Dict("display", true, "profile", true), @@ -121,7 +147,7 @@ func init() { web.StoryWatch(m, m.Option("data"), path.Join(m.Option("path"), m.Option("name"))) }}, "project": {Name: "project path", Help: "项目", Hand: func(m *ice.Message, arg ...string) { - _inner_list(m, path.Join("./", kit.Select("", arg, 0))) + _inner_list(m, path.Join("./", kit.Select("", arg, 0))+"/") }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) > 0 && arg[0] == "action" { diff --git a/info.go b/info.go index 16e0d40c..95c725f2 100644 --- a/info.go +++ b/info.go @@ -9,17 +9,6 @@ import ( "strings" ) -func (m *Message) Logs(level string, arg ...interface{}) *Message { - list := []string{} - for i := 0; i < len(arg)-1; i += 2 { - list = append(list, fmt.Sprintf("%v: %v", arg[i], arg[i+1])) - } - m.log(level, strings.Join(list, " ")) - return m -} -func (m *Message) Log(level string, str string, arg ...interface{}) *Message { - return m.log(level, str, arg...) -} func (m *Message) log(level string, str string, arg ...interface{}) *Message { if str = strings.TrimSpace(fmt.Sprintf(str, arg...)); Log != nil { // 日志模块 @@ -63,8 +52,17 @@ func (m *Message) log(level string, str string, arg ...interface{}) *Message { } return m } -func (m *Message) Cost(str string, arg ...interface{}) *Message { - return m.log(LOG_COST, "%s: %s", m.Format("cost"), kit.Format(str, arg...)) + +func (m *Message) Log(level string, str string, arg ...interface{}) *Message { + return m.log(level, str, arg...) +} +func (m *Message) Logs(level string, arg ...interface{}) *Message { + list := []string{} + for i := 0; i < len(arg)-1; i += 2 { + list = append(list, fmt.Sprintf("%v: %v", arg[i], arg[i+1])) + } + m.log(level, strings.Join(list, " ")) + return m } func (m *Message) Info(str string, arg ...interface{}) *Message { return m.log(LOG_INFO, str, arg...) @@ -87,6 +85,9 @@ func (m *Message) Error(err bool, str string, arg ...interface{}) bool { } return false } +func (m *Message) Debug(str string, arg ...interface{}) { + m.log(LOG_DEBUG, str, arg...) +} func (m *Message) Trace(key string, str string, arg ...interface{}) *Message { if m.Options(key) { m.Echo("trace: ").Echo(str, arg...) @@ -94,3 +95,6 @@ func (m *Message) Trace(key string, str string, arg ...interface{}) *Message { } return m } +func (m *Message) Cost(str string, arg ...interface{}) *Message { + return m.log(LOG_COST, "%s: %s", m.Format("cost"), kit.Format(str, arg...)) +}