1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00

opt /upload

This commit is contained in:
shaoying 2019-10-30 22:53:36 +08:00
parent f72dbb3a91
commit 2191cc3ec4
9 changed files with 145 additions and 27 deletions

View File

@ -4,6 +4,3 @@
upgrade plugin love
upgrade plugin mind
~aaa
role root user shy shaoying

112
etc/conf/tmux-1.8.conf Normal file
View File

@ -0,0 +1,112 @@
# 配置管理{{{
set -g prefix C-s
set -g base-index 1
set -g display-panes-time 5000
set -g display-time 5000
setw -g pane-base-index 1
set -g mode-keys vi
set -g history-limit 1000
set -g base-index 1
set -g display-panes-time 5000
set -g display-time 5000
set -g allow-rename off
set -g renumber-windows on
bind Space command-prompt
# }}}
# 会话管理{{{
bind s choose-tree -u
bind d confirm-before "detach-client"
# }}}
# 窗口管理{{{
bind c new-window
bind w choose-window
bind q confirm-before kill-window
bind f command-prompt -p "find window:" "find-window -N '%%'"
bind C-F command-prompt -p "find window:" "find-window '%%'"
bind e command-prompt -p "window new name:" "rename-window '%%'"
bind m command-prompt -p "move window from:,move window to:" "swap-window -s %% -t %%"
bind o last-window
bind n next-window
bind p previous-window
# }}}
# 面板管理{{{
bind i display-panes
bind x confirm-before -p "kill-pane #P? (y/n)" kill-pane
bind b break-pane
bind u split-window
bind v split-window -h
# bind C-u split-window -f
# bind C-v split-window -f -h
# bind u split-window -c "#{pane_current_path}"
# bind v split-window -h -c "#{pane_current_path}"
# bind C-u split-window -f -c "#{pane_current_path}"
# bind C-v split-window -f -h -c "#{pane_current_path}"
bind h select-pane -L
bind l select-pane -R
bind j select-pane -D
bind k select-pane -U
bind C-o confirm-before -p "kill all other pane(y/n)?" "kill-pane -a"
bind C-h command-prompt -p "size:" "resize-pane -L %%"
bind C-l command-prompt -p "size:" "resize-pane -R %%"
bind C-j command-prompt -p "size:" "resize-pane -D %%"
bind C-k command-prompt -p "size:" "resize-pane -U %%"
bind C-m command-prompt -p "swap pane from:,swap pane to:" "swap-pane -s %% -t %%"
# }}}
# 缓存管理{{{
bind C-s copy-mode
bind C-d clear-history
bind a choose-buffer
bind z paste-buffer
# }}}
# 命令管理{{{
bind @ confirm-before "source-file ~/.tmux.conf"
bind ! command-prompt "run-shell %%"
# }}}
# tmux 1.x or other {{{
if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -lt '2' ]" "\
set -g mouse-select-window on; \
set -g mouse-select-pane on; \
set -g mouse-resize-pane on; \
set -g mode-mouse on; \
" "\
set -g mouse on; \
"
# }}}
# tmux-2.6 or other{{{
if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` = '2' -a `tmux -V |cut -d' ' -f2|cut -d'.' -f2` = '6' ]" "\
bind -T copy-mode-vi e send-keys -X scroll-down; \
bind -T copy-mode-vi y send-keys -X scroll-up; \
bind -T copy-mode-vi d send-keys -X halfpage-down; \
bind -T copy-mode-vi u send-keys -X halfpage-up; \
bind -T copy-mode-vi f send-keys -X page-down; \
bind -T copy-mode-vi b send-keys -X page-up; \
bind -T copy-mode-vi v send-keys -X begin-selection; \
bind -T copy-mode-vi c send-keys -X copy-selection; \
" "\
bind -t vi-copy e scroll-down; \
bind -t vi-copy y scroll-up; \
bind -t vi-copy d halfpage-down; \
bind -t vi-copy u halfpage-up; \
bind -t vi-copy f page-down; \
bind -t vi-copy b page-up; \
bind -t vi-copy v begin-selection; \
bind -t vi-copy c copy-selection; \
bind -t vi-edit C-n history-down; \
bind -t vi-edit C-p history-up; \
bind -t vi-edit C-b cursor-left; \
bind -t vi-edit C-f cursor-right; \
"
# }}}

View File

@ -7,5 +7,5 @@ var version = struct {
self int
}{
[]string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"},
`2019-10-30 12:50:03`, `mac`, 667,
`2019-10-30 15:29:40`, `centos`, 654,
}

View File

@ -966,30 +966,37 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
if n, e := io.Copy(o, f); m.Assert(e) {
m.Log("upload", "file: %s %d", p, n)
code := kit.Hashs("uniq")
if o, p, e := kit.Create(path.Join(m.Conf("web.upload", "path"), "meta", code)); m.Assert(e) {
defer o.Close()
kind := h.Header.Get("Content-Type")
m.Log("upload", "file: %s %d", p, n)
fmt.Fprintf(o, "create_time: %s\n", m.Time())
fmt.Fprintf(o, "create_user: %s\n", m.Option("username"))
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, "size: %d\n", 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("type", kind)
m.Append("hash", name)
kind = strings.Split(kind, "/")[0]
m.Cmd("nfs.copy", path.Join(m.Conf("web.upload", "path"), kind, code), p)
if m.Options("river") {
m.Cmd("ssh.data", "insert", kit.Select(kind, m.Option("table")),
"name", h.Filename, "kind", kind, "hash", name, "size", n)
}
buf := bytes.NewBuffer(make([]byte, 0, 1024))
fmt.Fprintf(buf, "create_time: %s\n", m.Time())
fmt.Fprintf(buf, "create_user: %s\n", m.Option("username"))
fmt.Fprintf(buf, "name: %s\n", h.Filename)
fmt.Fprintf(buf, "type: %s\n", kind)
fmt.Fprintf(buf, "hash: %s\n", name)
fmt.Fprintf(buf, "size: %d\n", n)
b := buf.Bytes()
code := kit.Hashs(string(b))
if o, p, e := kit.Create(path.Join(m.Conf("web.upload", "path"), "meta", code)); m.Assert(e) {
defer o.Close()
if n, e := o.Write(b); m.Assert(e) {
m.Log("upload", "file: %s %d", p, n)
m.Cmd("nfs.copy", path.Join(m.Conf("web.upload", "path"), kind, code), p)
}
}
m.Append("size", kit.FmtSize(n))
m.Append("link", fmt.Sprintf(`<a href="/download/%s" target="_blank">%s</a>`, code, h.Filename))
m.Append("type", kind)
m.Append("hash", name)
m.Table()
}
}
@ -1002,8 +1009,8 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
kind := kit.Select("meta", kit.Select(m.Option("meta"), arg, 0))
file := strings.TrimPrefix(key, "/download/")
if file == "" {
// 文件列表
if file == "" {
if fs, e := ioutil.ReadDir(path.Join(m.Conf("web.upload", "path"), kind)); e == nil {
for _, f := range fs {
meta := kit.Linex(path.Join(m.Conf("web.upload", "path"), kind, f.Name()))

View File

@ -214,7 +214,9 @@ var page = Page({
return {
Show: function(which) {var pane = field.Pane
pane.Event(event, {}, {name: pane.Zone("show", page.who.get())})
output.innerHTML = "", pane.Appends([], "text", ["nick", "count"], "key", which||ctx.Search("river")||true)
output.innerHTML = "", pane.Appends([], "text", ["nick", "count"], "key", which||ctx.Search("river")||true, function(event, line) {
page.title(line.nick)
})
},
Action: {
"创建": function(event) {