mirror of
https://shylinux.com/x/ContextOS
synced 2025-06-26 18:07:30 +08:00
add love.pics
This commit is contained in:
parent
79ef6c8718
commit
c2cdeef2b1
@ -7,5 +7,5 @@ var version = struct {
|
|||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
[]string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"},
|
[]string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"},
|
||||||
`2019-09-30 15:01:56`, `centos`, 622,
|
`2019-10-01 22:57:21`, `mac`, 631,
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,12 @@ func (web *WEB) HandleCmd(m *ctx.Message, key string, cmd *ctx.Command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 请求参数
|
// 请求参数
|
||||||
r.ParseMultipartForm(int64(msg.Confi("serve", "form_size")))
|
if r.ParseMultipartForm(int64(msg.Confi("serve", "form_size"))); r.MultipartForm != nil && len(r.MultipartForm.Value) > 0 {
|
||||||
|
for k, v := range r.MultipartForm.Value {
|
||||||
|
msg.Log("info", "%s: %v", k, v)
|
||||||
|
msg.Add("option", k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
if r.ParseForm(); len(r.PostForm) > 0 {
|
if r.ParseForm(); len(r.PostForm) > 0 {
|
||||||
for k, v := range r.PostForm {
|
for k, v := range r.PostForm {
|
||||||
msg.Log("info", "%s: %v", k, v)
|
msg.Log("info", "%s: %v", k, v)
|
||||||
@ -215,6 +220,8 @@ func (web *WEB) HandleCmd(m *ctx.Message, key string, cmd *ctx.Command) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg.Short("river")
|
||||||
|
|
||||||
// 用户登录
|
// 用户登录
|
||||||
if msg.Put("option", "request", r).Put("option", "response", w).Sess("web", msg); web.Login(msg, w, r) {
|
if msg.Put("option", "request", r).Put("option", "response", w).Sess("web", msg); web.Login(msg, w, r) {
|
||||||
msg.Log("cmd", "%s [] %v", key, msg.Meta["option"])
|
msg.Log("cmd", "%s [] %v", key, msg.Meta["option"])
|
||||||
@ -945,8 +952,6 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
if f, h, e := r.FormFile("upload"); m.Assert(e) {
|
if f, h, e := r.FormFile("upload"); m.Assert(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
m.Log("info", "waht %v", h.Header)
|
|
||||||
|
|
||||||
name := kit.Hashx(f)
|
name := kit.Hashx(f)
|
||||||
if o, p, e := kit.Create(path.Join(m.Conf("web.upload", "path"), "list", name)); m.Assert(e) {
|
if o, p, e := kit.Create(path.Join(m.Conf("web.upload", "path"), "list", name)); m.Assert(e) {
|
||||||
defer o.Close()
|
defer o.Close()
|
||||||
@ -959,18 +964,25 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
if o, p, e := kit.Create(path.Join(m.Conf("web.upload", "path"), "meta", code)); m.Assert(e) {
|
if o, p, e := kit.Create(path.Join(m.Conf("web.upload", "path"), "meta", code)); m.Assert(e) {
|
||||||
defer o.Close()
|
defer o.Close()
|
||||||
|
|
||||||
|
kind := h.Header.Get("Content-Type")
|
||||||
m.Log("upload", "file: %s %d", p, n)
|
m.Log("upload", "file: %s %d", p, n)
|
||||||
fmt.Fprintf(o, "create_time: %s\n", m.Time())
|
fmt.Fprintf(o, "create_time: %s\n", m.Time())
|
||||||
fmt.Fprintf(o, "create_user: %s\n", m.Option("username"))
|
fmt.Fprintf(o, "create_user: %s\n", m.Option("username"))
|
||||||
fmt.Fprintf(o, "type: %s\n", h.Header.Get("Content-Type"))
|
|
||||||
fmt.Fprintf(o, "name: %s\n", h.Filename)
|
fmt.Fprintf(o, "name: %s\n", h.Filename)
|
||||||
|
fmt.Fprintf(o, "type: %s\n", kind)
|
||||||
fmt.Fprintf(o, "hash: %s\n", name)
|
fmt.Fprintf(o, "hash: %s\n", name)
|
||||||
fmt.Fprintf(o, "size: %d\n", n)
|
fmt.Fprintf(o, "size: %d\n", n)
|
||||||
|
|
||||||
m.Append("size", kit.FmtSize(n))
|
m.Append("size", kit.FmtSize(n))
|
||||||
|
m.Append("code", code)
|
||||||
m.Append("link", fmt.Sprintf(`<a href="/download/%s" target="_blank">%s</a>`, code, h.Filename))
|
m.Append("link", fmt.Sprintf(`<a href="/download/%s" target="_blank">%s</a>`, code, h.Filename))
|
||||||
m.Append("type", h.Header.Get("Content-Type"))
|
m.Append("type", kind)
|
||||||
m.Append("hash", name)
|
m.Append("hash", name)
|
||||||
|
|
||||||
|
kind = strings.Split(kind, "/")[0]
|
||||||
|
m.Cmd("nfs.copy", path.Join(m.Conf("web.upload", "path"), kind, code), p)
|
||||||
|
m.Cmd("ssh.data", "insert", kit.Select(kind, m.Option("table")),
|
||||||
|
"name", h.Filename, "kind", kind, "hash", name, "size", n)
|
||||||
}
|
}
|
||||||
m.Table()
|
m.Table()
|
||||||
}
|
}
|
||||||
@ -982,15 +994,21 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
r := m.Optionv("request").(*http.Request)
|
r := m.Optionv("request").(*http.Request)
|
||||||
w := m.Optionv("response").(http.ResponseWriter)
|
w := m.Optionv("response").(http.ResponseWriter)
|
||||||
|
|
||||||
|
kind := kit.Select("meta", kit.Select(m.Option("meta"), arg, 0))
|
||||||
file := strings.TrimPrefix(key, "/download/")
|
file := strings.TrimPrefix(key, "/download/")
|
||||||
if file == "" {
|
if file == "" {
|
||||||
if fs, e := ioutil.ReadDir(path.Join(m.Conf("web.upload", "path"), "meta")); e == nil {
|
// 文件列表
|
||||||
|
if fs, e := ioutil.ReadDir(path.Join(m.Conf("web.upload", "path"), kind)); e == nil {
|
||||||
for _, f := range fs {
|
for _, f := range fs {
|
||||||
meta := kit.Linex(path.Join(m.Conf("web.upload", "path"), "meta", f.Name()))
|
meta := kit.Linex(path.Join(m.Conf("web.upload", "path"), kind, f.Name()))
|
||||||
m.Push("time", meta["create_time"])
|
m.Push("time", meta["create_time"])
|
||||||
m.Push("user", meta["create_user"])
|
m.Push("user", meta["create_user"])
|
||||||
m.Push("size", kit.FmtSize(int64(kit.Int(meta["size"]))))
|
m.Push("size", kit.FmtSize(int64(kit.Int(meta["size"]))))
|
||||||
|
if kind == "image" {
|
||||||
|
m.Push("name", f.Name())
|
||||||
|
} else {
|
||||||
m.Push("name", fmt.Sprintf(`<a href="/download/%s" target="_blank">%s</a>`, f.Name(), meta["name"]))
|
m.Push("name", fmt.Sprintf(`<a href="/download/%s" target="_blank">%s</a>`, f.Name(), meta["name"]))
|
||||||
|
}
|
||||||
m.Push("hash", meta["hash"][:8])
|
m.Push("hash", meta["hash"][:8])
|
||||||
}
|
}
|
||||||
m.Sort("time", "time_r").Table()
|
m.Sort("time", "time_r").Table()
|
||||||
@ -998,7 +1016,14 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if p := m.Cmdx("nfs.path", path.Join(m.Conf("web.upload", "path"), "meta", file)); p != "" {
|
// 直接下载
|
||||||
|
if p := m.Cmdx("nfs.path", path.Join(m.Conf("web.upload", "path"), "list", file)); p != "" {
|
||||||
|
m.Log("info", "download %s direct", p)
|
||||||
|
http.ServeFile(w, r, p)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 下载文件
|
||||||
|
if p := m.Cmdx("nfs.path", path.Join(m.Conf("web.upload", "path"), kind, file)); p != "" {
|
||||||
meta := kit.Linex(p)
|
meta := kit.Linex(p)
|
||||||
if p := m.Cmdx("nfs.path", path.Join(m.Conf("web.upload", "path"), "list", meta["hash"])); p != "" {
|
if p := m.Cmdx("nfs.path", path.Join(m.Conf("web.upload", "path"), "list", meta["hash"])); p != "" {
|
||||||
m.Log("info", "download %s %s", p, m.Cmdx("nfs.hash", meta["hash"]))
|
m.Log("info", "download %s %s", p, m.Cmdx("nfs.hash", meta["hash"]))
|
||||||
@ -1014,6 +1039,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 任意文件
|
||||||
if p := m.Cmdx("nfs.path", file); p != "" {
|
if p := m.Cmdx("nfs.path", file); p != "" {
|
||||||
m.Log("info", "download %s %s", p, m.Cmdx("nfs.hash", p))
|
m.Log("info", "download %s %s", p, m.Cmdx("nfs.hash", p))
|
||||||
http.ServeFile(w, r, p)
|
http.ServeFile(w, r, p)
|
||||||
|
@ -30,3 +30,8 @@ fieldset.item.love.media table td {
|
|||||||
text-align:center;
|
text-align:center;
|
||||||
min-width:60px;
|
min-width:60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset.item.love.pics img {
|
||||||
|
border:solid 2px red;
|
||||||
|
margin:10px;
|
||||||
|
}
|
||||||
|
@ -60,13 +60,20 @@ fun detail "详情" "index.js" protected \
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
kit note "回忆" "index.js" protected "ssh.data" update _ _ extra \
|
kit append "扩展" "index.js" protected "ssh.data" update _ _ extra \
|
||||||
text "love" name table imports plugin_table \
|
text "love" name table imports plugin_table \
|
||||||
text "1" name index imports plugin_index action auto view tiny \
|
text "1" name index imports plugin_index action auto view tiny \
|
||||||
text "" name field \
|
text "" name field \
|
||||||
text "" name value \
|
text "" name value \
|
||||||
button "添加"
|
button "添加"
|
||||||
|
|
||||||
|
kit pics "图片" "pics.js" "index.css" private "ssh.data" show \
|
||||||
|
text "image" name table imports plugin_table \
|
||||||
|
upfile "" name upload \
|
||||||
|
button "上传" cb upload \
|
||||||
|
button "记录" \
|
||||||
|
button "展示" cb show
|
||||||
|
|
||||||
fun delay "以后告诉你" protected \
|
fun delay "以后告诉你" protected \
|
||||||
text "delay" name table imports plugin_table \
|
text "delay" name table imports plugin_table \
|
||||||
text "" name when init date\
|
text "" name when init date\
|
||||||
|
30
src/plugin/love/pics.js
Normal file
30
src/plugin/love/pics.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{init: function(run, field, option, output) {
|
||||||
|
return {
|
||||||
|
onexport: {"": function(value, name, line) {var plugin = field.Plugin
|
||||||
|
kit.AppendChilds(output, [{img: ["/download/"+line.hash], data: {width: output.clientWidth, onclick: function() {
|
||||||
|
plugin.display("table")
|
||||||
|
}}}])
|
||||||
|
}},
|
||||||
|
show: function() {var plugin = field.Plugin
|
||||||
|
var msg = plugin.msg
|
||||||
|
var width = output.clientWidth
|
||||||
|
output.innerHTML = "", kit.List(ctx.Table(msg), function(line) {
|
||||||
|
kit.Opacity(kit.AppendChilds(output, [{img: ["/download/"+line.hash], data: {width: width, onclick: function(event) {
|
||||||
|
}}}]).last)
|
||||||
|
}, 1000, function() {
|
||||||
|
output.innerHTML = "", kit.List(ctx.Table(msg), function(line) {
|
||||||
|
kit.Opacity(kit.AppendChild(output, [{img: ["/download/"+line.hash], data: {width: 200, onclick: function(event) {
|
||||||
|
plugin.ontoast({width: width, height: width*3/5+40,
|
||||||
|
text: {img: ["/download/"+line.hash], data: {width: width-20, onclick: function(event) {
|
||||||
|
plugin.ontoast()
|
||||||
|
}}}, button: ["确定"], cb: function() {
|
||||||
|
plugin.ontoast()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}}}]).last)
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
}}}
|
||||||
|
|
@ -122,9 +122,12 @@ ctx = context = {__proto__: kit,
|
|||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
},
|
},
|
||||||
Upload: function(file, cb, detail) {
|
Upload: function(form, file, cb, detail) {
|
||||||
var data = new FormData()
|
var data = new FormData()
|
||||||
data.append("upload", file)
|
data.append("upload", file)
|
||||||
|
for (var k in form) {
|
||||||
|
data.append(k, form[k])
|
||||||
|
}
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest()
|
var xhr = new XMLHttpRequest()
|
||||||
xhr.onload = function(event) {
|
xhr.onload = function(event) {
|
||||||
|
@ -190,7 +190,9 @@ function Page(page) {
|
|||||||
})
|
})
|
||||||
if (!args.duration && args.button) {args.duration = -1}
|
if (!args.duration && args.button) {args.duration = -1}
|
||||||
|
|
||||||
var list = [{text: [args.title||"", "div", "title"]}, {text: [args.text||"", "div", "content"]}]
|
var main = typeof args.text == "string"? {text: [args.text||"", "div", "content"]}: args.text
|
||||||
|
|
||||||
|
var list = [{text: [args.title||"", "div", "title"]}, main]
|
||||||
args.inputs && args.inputs.forEach(function(input) {
|
args.inputs && args.inputs.forEach(function(input) {
|
||||||
if (typeof input == "string") {
|
if (typeof input == "string") {
|
||||||
list.push({inner: input, type: "label", style: {"margin-right": "5px"}})
|
list.push({inner: input, type: "label", style: {"margin-right": "5px"}})
|
||||||
@ -726,6 +728,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
}
|
}
|
||||||
var plugin = Meta(field, (field.Script && field.Script.init || function() {
|
var plugin = Meta(field, (field.Script && field.Script.init || function() {
|
||||||
})(run, field, option, output)||{}, {
|
})(run, field, option, output)||{}, {
|
||||||
|
ontoast: page.ontoast,
|
||||||
Inputs: {},
|
Inputs: {},
|
||||||
Appends: function() {
|
Appends: function() {
|
||||||
var name = "args"+kit.Selector(option, "input.args.temp").length
|
var name = "args"+kit.Selector(option, "input.args.temp").length
|
||||||
@ -943,8 +946,14 @@ function Plugin(page, pane, field, runs) {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
show_after: function(msg) {},
|
show_after: function(msg) {},
|
||||||
|
Option: function(key, value) {
|
||||||
|
if (value != undefined) {
|
||||||
|
option[key] && (option[key].value = value)
|
||||||
|
}
|
||||||
|
return option[key]? option[key].value: ""
|
||||||
|
},
|
||||||
upload: function(event) {
|
upload: function(event) {
|
||||||
ctx.Upload(option.upload.files[0], function(event, msg) {
|
ctx.Upload({river: meta.river, table: plugin.Option("table")}, option.upload.files[0], function(event, msg) {
|
||||||
kit.OrderTable(kit.AppendTable(kit.AppendChilds(output, "table"), ctx.Table(msg), msg.append))
|
kit.OrderTable(kit.AppendTable(kit.AppendChilds(output, "table"), ctx.Table(msg), msg.append))
|
||||||
page.ontoast("上传成功")
|
page.ontoast("上传成功")
|
||||||
}, function(event) {
|
}, function(event) {
|
||||||
|
@ -658,7 +658,7 @@ kit = toolkit = {__proto__: document,
|
|||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
Opacity: function(obj, list, interval) {
|
Opacity: function(obj, interval, list) {
|
||||||
kit.List(kit.Value(list, [0, 0.2, 0.4, 0.6, 1.0]), function(value) {
|
kit.List(kit.Value(list, [0, 0.2, 0.4, 0.6, 1.0]), function(value) {
|
||||||
obj.style.opacity = value
|
obj.style.opacity = value
|
||||||
}, kit.Value(interval, 150))
|
}, kit.Value(interval, 150))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user