forked from x/ContextOS
tce add base.html
This commit is contained in:
parent
2b834d28e0
commit
5348baeb2b
@ -2382,7 +2382,9 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
}
|
}
|
||||||
if len(arg) > 3 {
|
if len(arg) > 3 {
|
||||||
for _, v := range group.Commands[item].Shares[arg[2]] {
|
for _, v := range group.Commands[item].Shares[arg[2]] {
|
||||||
if arg[3] == v {
|
match, e := regexp.MatchString(v, arg[3])
|
||||||
|
m.Assert(e)
|
||||||
|
if match {
|
||||||
m.Echo("ok")
|
m.Echo("ok")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -602,17 +602,16 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
r := m.Data["request"].(*http.Request) // {{{
|
r := m.Data["request"].(*http.Request) // {{{
|
||||||
w := m.Data["response"].(http.ResponseWriter)
|
w := m.Data["response"].(http.ResponseWriter)
|
||||||
|
|
||||||
m.Option("message", "")
|
|
||||||
if !m.Options("file") {
|
if !m.Options("file") {
|
||||||
m.Option("file", m.Cap("directory"))
|
m.Option("file", m.Cap("directory"))
|
||||||
}
|
}
|
||||||
dir := m.Option("file")
|
|
||||||
|
|
||||||
if !m.Options("username") {
|
if !m.Options("username") {
|
||||||
m.Option("username", "")
|
m.Option("username", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Option("right", "")
|
m.Option("right", "")
|
||||||
|
m.Option("message", "")
|
||||||
aaa := m.Find("aaa").Cmd("login", m.Option("sessid"))
|
aaa := m.Find("aaa").Cmd("login", m.Option("sessid"))
|
||||||
if aaa.Result(0) == "error: " {
|
if aaa.Result(0) == "error: " {
|
||||||
m.Option("sessid", "")
|
m.Option("sessid", "")
|
||||||
@ -620,15 +619,20 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
} else {
|
} else {
|
||||||
m.Option("username", aaa.Result(0))
|
m.Option("username", aaa.Result(0))
|
||||||
msg := m.Spawn(m.Target())
|
msg := m.Spawn(m.Target())
|
||||||
msg.Cmd("right", "check", aaa.Cap("group"), "command", "/upload", "file", dir)
|
msg.Cmd("right", "check", aaa.Cap("group"), "command", "/upload", "file", m.Option("file"))
|
||||||
if msg.Result(0) == "ok" {
|
if msg.Result(0) == "ok" {
|
||||||
m.Option("right", aaa.Cap("group"))
|
m.Option("right", aaa.Cap("group"))
|
||||||
} else {
|
} else {
|
||||||
m.Option("message", "your do not have the right of", dir)
|
m.Option("message", "your do not have the right of", m.Option("file"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Option("method") == "POST" {
|
if m.Option("method") == "POST" {
|
||||||
|
if !m.Options("right") {
|
||||||
|
m.Echo("you do not have the rightt, please contact manager!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if m.Options("notshareto") {
|
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"))
|
msg.Cmd("right", "del", m.Option("notshareto"), "command", "/upload", "file", m.Option("sharefile"))
|
||||||
@ -641,7 +645,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
m.Append("link", "hello")
|
m.Append("link", "hello")
|
||||||
return
|
return
|
||||||
} else if m.Options("content") {
|
} else if m.Options("content") {
|
||||||
name := path.Join(dir, m.Option("filename"))
|
name := path.Join(m.Option("file"), m.Option("filename"))
|
||||||
if _, e := os.Stat(name); e != nil {
|
if _, e := os.Stat(name); e != nil {
|
||||||
f, e := os.Create(name)
|
f, e := os.Create(name)
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
@ -657,7 +661,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
file, header, e := r.FormFile("file")
|
file, header, e := r.FormFile("file")
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
|
|
||||||
name := path.Join(dir, header.Filename)
|
name := path.Join(m.Option("file"), header.Filename)
|
||||||
|
|
||||||
if _, e := os.Stat(name); e != nil {
|
if _, e := os.Stat(name); e != nil {
|
||||||
f, e := os.Create(name)
|
f, e := os.Create(name)
|
||||||
@ -672,6 +676,19 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !m.Options("right") {
|
||||||
|
w.Header().Add("Content-Type", "text/html")
|
||||||
|
tmpl := template.Must(template.Must(template.ParseGlob(m.Conf("template_dir") + "/common/*.html")).ParseGlob(m.Conf("template_dir") + "upload.html"))
|
||||||
|
m.Assert(tmpl)
|
||||||
|
|
||||||
|
tmpl.ExecuteTemplate(w, "head", m.Meta)
|
||||||
|
tmpl.ExecuteTemplate(w, "login", m.Meta)
|
||||||
|
m.Option("message", "your do not have the right, please contact manager")
|
||||||
|
tmpl.ExecuteTemplate(w, "message", m.Meta)
|
||||||
|
tmpl.ExecuteTemplate(w, "tail", m.Meta)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
file := m.Option("file")
|
file := m.Option("file")
|
||||||
s, e := os.Stat(file)
|
s, e := os.Stat(file)
|
||||||
if m.Assert(e); !s.IsDir() {
|
if m.Assert(e); !s.IsDir() {
|
||||||
@ -736,7 +753,6 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
m.Assert(tmpl)
|
m.Assert(tmpl)
|
||||||
|
|
||||||
tmpl.ExecuteTemplate(w, "head", m.Meta)
|
tmpl.ExecuteTemplate(w, "head", m.Meta)
|
||||||
if m.Options("right") {
|
|
||||||
tmpl.ExecuteTemplate(w, "userinfo", m.Meta)
|
tmpl.ExecuteTemplate(w, "userinfo", m.Meta)
|
||||||
|
|
||||||
msg := m.Spawn(m.Target())
|
msg := m.Spawn(m.Target())
|
||||||
@ -748,8 +764,8 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
for i, j := range v.Commands {
|
for i, j := range v.Commands {
|
||||||
for v, n := range j.Shares {
|
for v, n := range j.Shares {
|
||||||
for _, nn := range n {
|
for _, nn := range n {
|
||||||
match, e := regexp.MatchString(nn, dir)
|
match, e := regexp.MatchString(nn, m.Option("file"))
|
||||||
m.Log("fuck", nil, "why %s %s", nn, dir)
|
m.Log("fuck", nil, "why %s %s", nn, m.Option("file"))
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
if match {
|
if match {
|
||||||
msg.Add("append", "group", k)
|
msg.Add("append", "group", k)
|
||||||
@ -765,17 +781,13 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl.ExecuteTemplate(w, "share", msg.Meta)
|
tmpl.ExecuteTemplate(w, "share", msg.Meta)
|
||||||
|
|
||||||
tmpl.ExecuteTemplate(w, "upload", m.Meta)
|
tmpl.ExecuteTemplate(w, "upload", m.Meta)
|
||||||
} else {
|
|
||||||
tmpl.ExecuteTemplate(w, "login", m.Meta)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch m.Option("cmd") {
|
switch m.Option("cmd") {
|
||||||
case "git":
|
case "git":
|
||||||
branch := m.Find("nfs").Cmd("git", "-C", dir, "branch")
|
branch := m.Find("nfs").Cmd("git", "-C", m.Option("file"), "branch")
|
||||||
m.Option("branch", branch.Result(0))
|
m.Option("branch", branch.Result(0))
|
||||||
status := m.Find("nfs").Cmd("git", "-C", dir, "status")
|
status := m.Find("nfs").Cmd("git", "-C", m.Option("file"), "status")
|
||||||
m.Option("status", status.Result(0))
|
m.Option("status", status.Result(0))
|
||||||
tmpl.ExecuteTemplate(w, "git", m.Meta)
|
tmpl.ExecuteTemplate(w, "git", m.Meta)
|
||||||
}
|
}
|
||||||
@ -785,9 +797,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl.ExecuteTemplate(w, "list", m.Meta)
|
tmpl.ExecuteTemplate(w, "list", m.Meta)
|
||||||
if m.Options("right") {
|
|
||||||
tmpl.ExecuteTemplate(w, "create", m.Meta)
|
tmpl.ExecuteTemplate(w, "create", m.Meta)
|
||||||
}
|
|
||||||
tmpl.ExecuteTemplate(w, "tail", m.Meta)
|
tmpl.ExecuteTemplate(w, "tail", m.Meta)
|
||||||
delete(m.Meta, "result")
|
delete(m.Meta, "result")
|
||||||
delete(m.Meta, "append")
|
delete(m.Meta, "append")
|
||||||
@ -899,6 +909,16 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
msg.Cmd("get", "method", "POST", "evaluating_add/", "questions", qs)
|
msg.Cmd("get", "method", "POST", "evaluating_add/", "questions", qs)
|
||||||
m.Add("append", "hi", "hello")
|
m.Add("append", "hi", "hello")
|
||||||
}},
|
}},
|
||||||
|
"/demo": &ctx.Command{Name: "/demo", Help: "应用示例", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
|
w := m.Data["response"].(http.ResponseWriter)
|
||||||
|
|
||||||
|
w.Header().Add("Content-Type", "text/html")
|
||||||
|
tmpl := template.Must(template.ParseGlob(m.Conf("template_dir") + "/common/*.html"))
|
||||||
|
m.Assert(tmpl)
|
||||||
|
|
||||||
|
tmpl.ExecuteTemplate(w, "head", m.Meta)
|
||||||
|
tmpl.ExecuteTemplate(w, "tail", m.Meta)
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
35
usr/template/common/base.html
Normal file
35
usr/template/common/base.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{{define "head"}}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
|
||||||
|
<style>
|
||||||
|
legend {
|
||||||
|
font-size:16px;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:lightgray;
|
||||||
|
}
|
||||||
|
code {
|
||||||
|
font-size:14px;
|
||||||
|
}
|
||||||
|
.message {
|
||||||
|
color:red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "message"}}
|
||||||
|
<fieldset class="message"><legend>message</legend>
|
||||||
|
<pre>{{index . "message"}}</pre>
|
||||||
|
</fieldset>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "tail"}}
|
||||||
|
<script src="library/context.js"></script>
|
||||||
|
</body>
|
||||||
|
{{end}}
|
@ -1,44 +1,3 @@
|
|||||||
{{define "head"}}
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<style>
|
|
||||||
legend {
|
|
||||||
font-size:16px;
|
|
||||||
font-weight:bold;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
cursor:pointer;
|
|
||||||
background-color:lightgray;
|
|
||||||
}
|
|
||||||
.time {
|
|
||||||
padding-right:20px;
|
|
||||||
}
|
|
||||||
.size {
|
|
||||||
text-align:right;
|
|
||||||
padding-right:20px;
|
|
||||||
}
|
|
||||||
.name {
|
|
||||||
padding-left:10px;
|
|
||||||
text-align:left;
|
|
||||||
}
|
|
||||||
.sort {
|
|
||||||
color:red;
|
|
||||||
}
|
|
||||||
.reverse {
|
|
||||||
color:green;
|
|
||||||
}
|
|
||||||
.message {
|
|
||||||
color:red;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-size:14px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{define "git"}}
|
{{define "git"}}
|
||||||
<fieldset><legend>branch</legend>
|
<fieldset><legend>branch</legend>
|
||||||
<pre>{{index . "branch"}}</pre>
|
<pre>{{index . "branch"}}</pre>
|
||||||
@ -56,12 +15,6 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "message"}}
|
|
||||||
<fieldset class="message"><legend>message</legend>
|
|
||||||
<pre>{{index . "message"}}</pre>
|
|
||||||
</fieldset>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{define "list"}}
|
{{define "list"}}
|
||||||
<fieldset><legend><input type="text" id="dir" value="{{index .file 0}}" onkeydown="return Change(event)"></legend>
|
<fieldset><legend><input type="text" id="dir" value="{{index .file 0}}" onkeydown="return Change(event)"></legend>
|
||||||
<table>
|
<table>
|
||||||
@ -84,9 +37,6 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</tr>
|
</tr>
|
||||||
<script>
|
|
||||||
var file = '{{index .file 0}}';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{{$meta := .}}
|
{{$meta := .}}
|
||||||
{{if .append}}
|
{{if .append}}
|
||||||
@ -110,22 +60,27 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{{end}}
|
<style>
|
||||||
|
.time {
|
||||||
{{define "create"}}
|
padding-right:20px;
|
||||||
<fieldset><legend>create</legend>
|
}
|
||||||
<form method="POST" action="/upload">
|
.size {
|
||||||
<table>
|
text-align:right;
|
||||||
<tr><td>filename:</td><td><input type="text" name="filename" required><input type="submit"></td></tr>
|
padding-right:20px;
|
||||||
<tr><td>content:</td><td><textarea rows="5" cols="80" name="content" required></textarea></td></tr>
|
}
|
||||||
</table>
|
.name {
|
||||||
</form>
|
padding-left:10px;
|
||||||
</fieldset>
|
text-align:left;
|
||||||
{{end}}
|
}
|
||||||
|
.sort {
|
||||||
{{define "tail"}}
|
color:red;
|
||||||
<script src="library/context.js"></script>
|
}
|
||||||
|
.reverse {
|
||||||
|
color:green;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
|
var file = '{{index .file 0}}';
|
||||||
function Change(event) {
|
function Change(event) {
|
||||||
if (event.keyCode == 13) {
|
if (event.keyCode == 13) {
|
||||||
ctx.Search("file", event.target.value);
|
ctx.Search("file", event.target.value);
|
||||||
@ -138,5 +93,15 @@
|
|||||||
location.assign(location.href)
|
location.assign(location.href)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
{{end}}
|
||||||
|
|
||||||
|
{{define "create"}}
|
||||||
|
<fieldset><legend>create</legend>
|
||||||
|
<form method="POST" action="/upload">
|
||||||
|
<table>
|
||||||
|
<tr><td>filename:</td><td><input type="text" name="filename" required><input type="submit"></td></tr>
|
||||||
|
<tr><td>content:</td><td><textarea rows="5" cols="80" name="content" required></textarea></td></tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</fieldset>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user