forked from x/ContextOS
mac mod web.travel
This commit is contained in:
parent
885b787b3d
commit
2b834d28e0
@ -46,6 +46,7 @@ type Command struct {
|
|||||||
|
|
||||||
Formats map[string]int
|
Formats map[string]int
|
||||||
Options map[string]string
|
Options map[string]string
|
||||||
|
Shares map[string][]string
|
||||||
Appends map[string]string
|
Appends map[string]string
|
||||||
Hand func(m *Message, c *Context, key string, arg ...string)
|
Hand func(m *Message, c *Context, key string, arg ...string)
|
||||||
}
|
}
|
||||||
@ -2368,18 +2369,27 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
m.Echo("ok")
|
m.Echo("ok")
|
||||||
}
|
}
|
||||||
case m.Has("command"):
|
case m.Has("command"):
|
||||||
if x, ok := group.Commands[item]; ok {
|
|
||||||
if len(arg) > 2 {
|
if len(arg) > 1 {
|
||||||
if len(x.Options) > 0 {
|
if _, ok := group.Commands[item]; !ok {
|
||||||
for i := 2; i < len(arg)-1; i += 2 {
|
return
|
||||||
if x, ok := x.Options[arg[i]]; !ok || x != arg[i+1] {
|
}
|
||||||
return
|
}
|
||||||
}
|
if len(arg) > 2 {
|
||||||
}
|
if _, ok := group.Commands[item].Shares[arg[2]]; !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(arg) > 3 {
|
||||||
|
for _, v := range group.Commands[item].Shares[arg[2]] {
|
||||||
|
if arg[3] == v {
|
||||||
|
m.Echo("ok")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Echo("ok")
|
return
|
||||||
}
|
}
|
||||||
|
m.Echo("ok")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -2411,14 +2421,18 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
if group.Commands == nil {
|
if group.Commands == nil {
|
||||||
group.Commands = map[string]*Command{}
|
group.Commands = map[string]*Command{}
|
||||||
}
|
}
|
||||||
// group.Commands[item] = x
|
|
||||||
options := map[string]string{}
|
command, ok := group.Commands[item]
|
||||||
|
if !ok {
|
||||||
|
command = &Command{Shares: map[string][]string{}}
|
||||||
|
group.Commands[item] = command
|
||||||
|
}
|
||||||
|
|
||||||
for i := 2; i < len(arg)-1; i += 2 {
|
for i := 2; i < len(arg)-1; i += 2 {
|
||||||
options[arg[i]] = arg[i+1]
|
command.Shares[arg[i]] = append(command.Shares[arg[i]], arg[i+1])
|
||||||
}
|
|
||||||
group.Commands[item] = &Command{
|
|
||||||
Options: options,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// group.Commands[item] = x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2445,7 +2459,38 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
case m.Has("config"):
|
case m.Has("config"):
|
||||||
delete(gs[i].Configs, item)
|
delete(gs[i].Configs, item)
|
||||||
case m.Has("command"):
|
case m.Has("command"):
|
||||||
delete(gs[i].Commands, item)
|
if gs[i].Commands == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if len(arg) == 2 {
|
||||||
|
delete(gs[i].Commands, item)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if gs[i].Commands[item] == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
shares := gs[i].Commands[item].Shares
|
||||||
|
if shares == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if len(arg) == 3 {
|
||||||
|
delete(shares, arg[2])
|
||||||
|
break
|
||||||
|
}
|
||||||
|
m.Log("fuck", nil, "wh %v", shares)
|
||||||
|
|
||||||
|
for i := 0; i < len(shares[arg[2]]); i++ {
|
||||||
|
if shares[arg[2]][i] == arg[3] {
|
||||||
|
m.Log("fuck", nil, "====%v", arg[3])
|
||||||
|
for ; i < len(shares[arg[2]])-1; i++ {
|
||||||
|
shares[arg[2]][i] = shares[arg[2]][i+1]
|
||||||
|
}
|
||||||
|
shares[arg[2]] = shares[arg[2]][:i]
|
||||||
|
m.Log("fuck", nil, "====%v", shares)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
delete(index, gs[i].Name)
|
delete(index, gs[i].Name)
|
||||||
delete(current.Index, gs[i].Name)
|
delete(current.Index, gs[i].Name)
|
||||||
|
@ -2,6 +2,7 @@ package web // {{{
|
|||||||
// }}}
|
// }}}
|
||||||
import ( // {{{
|
import ( // {{{
|
||||||
"contexts"
|
"contexts"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"toolkit"
|
"toolkit"
|
||||||
|
|
||||||
@ -612,29 +613,30 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Option("right", "")
|
m.Option("right", "")
|
||||||
if !m.Options("sessid") {
|
aaa := m.Find("aaa").Cmd("login", m.Option("sessid"))
|
||||||
|
if aaa.Result(0) == "error: " {
|
||||||
m.Option("sessid", "")
|
m.Option("sessid", "")
|
||||||
m.Option("message", "please login")
|
m.Option("message", "login failure")
|
||||||
} else {
|
} else {
|
||||||
msg := m.Find("aaa").Cmd("login", m.Option("sessid"))
|
m.Option("username", aaa.Result(0))
|
||||||
if msg.Result(0) == "error: " {
|
msg := m.Spawn(m.Target())
|
||||||
m.Option("sessid", "")
|
msg.Cmd("right", "check", aaa.Cap("group"), "command", "/upload", "file", dir)
|
||||||
m.Option("message", "login failure")
|
if msg.Result(0) == "ok" {
|
||||||
|
m.Option("right", aaa.Cap("group"))
|
||||||
} else {
|
} else {
|
||||||
m.Option("username", msg.Result(0))
|
m.Option("message", "your do not have the right of", dir)
|
||||||
msg = m.Spawn(m.Target())
|
|
||||||
msg.Cmd("right", "check", msg.Cap("group"), "command", "/upload", "file", dir)
|
|
||||||
if msg.Result(0) == "ok" {
|
|
||||||
m.Option("right", "ok")
|
|
||||||
} else {
|
|
||||||
m.Option("message", "your do not have the right of", dir)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Option("method") == "POST" {
|
if m.Option("method") == "POST" {
|
||||||
if m.Options("shareto") {
|
if m.Options("notshareto") {
|
||||||
msg := m.Spawn(m.Target())
|
msg := m.Spawn(m.Target())
|
||||||
|
msg.Cmd("right", "del", m.Option("notshareto"), "command", "/upload", "file", m.Option("sharefile"))
|
||||||
|
m.Append("link", "hello")
|
||||||
|
return
|
||||||
|
} else if m.Options("shareto") {
|
||||||
|
msg := aaa.Spawn(m.Target())
|
||||||
|
msg.Sesss("aaa", aaa)
|
||||||
msg.Cmd("right", "add", m.Option("shareto"), "command", "/upload", "file", m.Option("sharefile"))
|
msg.Cmd("right", "add", m.Option("shareto"), "command", "/upload", "file", m.Option("sharefile"))
|
||||||
m.Append("link", "hello")
|
m.Append("link", "hello")
|
||||||
return
|
return
|
||||||
@ -739,15 +741,24 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
|
|
||||||
msg := m.Spawn(m.Target())
|
msg := m.Spawn(m.Target())
|
||||||
|
|
||||||
for k, v := range msg.Target().Index {
|
index := msg.Target().Index
|
||||||
for i, j := range v.Commands {
|
if index != nil && index[m.Option("right")] != nil {
|
||||||
for v, n := range j.Options {
|
for k, v := range index[m.Option("right")].Index {
|
||||||
if n == dir {
|
// for k, v := range index {
|
||||||
msg.Add("append", "group", k)
|
for i, j := range v.Commands {
|
||||||
msg.Add("append", "command", i)
|
for v, n := range j.Shares {
|
||||||
msg.Add("append", "argument", v)
|
for _, nn := range n {
|
||||||
msg.Add("append", "value", n)
|
match, e := regexp.MatchString(nn, dir)
|
||||||
m.Log("fuck", nil, "why %v", msg.Meta)
|
m.Log("fuck", nil, "why %s %s", nn, dir)
|
||||||
|
m.Assert(e)
|
||||||
|
if match {
|
||||||
|
msg.Add("append", "group", k)
|
||||||
|
msg.Add("append", "command", i)
|
||||||
|
msg.Add("append", "argument", v)
|
||||||
|
msg.Add("append", "value", nn)
|
||||||
|
msg.Add("append", "delete", "delete")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,11 @@
|
|||||||
<tr>
|
<tr>
|
||||||
{{range $key := index $meta "append"}}
|
{{range $key := index $meta "append"}}
|
||||||
<td class="{{$key}}">
|
<td class="{{$key}}">
|
||||||
<code>{{index $meta $key $i}}</code>
|
{{if eq $key "delete"}}
|
||||||
|
<button onclick="return deleteshare(event, '{{index $meta "value" $i}}', '{{index $meta "group" $i}}')">delete</button>
|
||||||
|
{{else}}
|
||||||
|
<code>{{index $meta $key $i}}</code>
|
||||||
|
{{end}}
|
||||||
</td>
|
</td>
|
||||||
{{end}}
|
{{end}}
|
||||||
</tr>
|
</tr>
|
||||||
@ -81,5 +85,13 @@
|
|||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
function deleteshare(event, file, group) {
|
||||||
|
ctx.POST("/upload", {
|
||||||
|
notshareto: group,
|
||||||
|
sharefile: file,
|
||||||
|
}, function(msg) {
|
||||||
|
ctx.Refresh();
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user