From 2191cc3ec45b02983a728245ce6227908eccfd94 Mon Sep 17 00:00:00 2001 From: shaoying Date: Wed, 30 Oct 2019 22:53:36 +0800 Subject: [PATCH] opt /upload --- etc/common.shy | 3 - etc/conf/{.gitconfig => git.conf} | 0 etc/conf/tmux-1.8.conf | 112 +++++++++++++++++++++++++ etc/conf/{.tmux.conf => tmux-2.1.conf} | 0 etc/conf/{.vimrc => vimrc} | 0 etc/conf/{.zshrc => zshrc} | 0 src/contexts/cli/version.go | 2 +- src/contexts/web/web.go | 51 ++++++----- usr/librarys/chat.js | 4 +- 9 files changed, 145 insertions(+), 27 deletions(-) rename etc/conf/{.gitconfig => git.conf} (100%) create mode 100644 etc/conf/tmux-1.8.conf rename etc/conf/{.tmux.conf => tmux-2.1.conf} (100%) rename etc/conf/{.vimrc => vimrc} (100%) rename etc/conf/{.zshrc => zshrc} (100%) diff --git a/etc/common.shy b/etc/common.shy index d4bbb9a5..b070804a 100644 --- a/etc/common.shy +++ b/etc/common.shy @@ -4,6 +4,3 @@ upgrade plugin love upgrade plugin mind -~aaa - role root user shy shaoying - diff --git a/etc/conf/.gitconfig b/etc/conf/git.conf similarity index 100% rename from etc/conf/.gitconfig rename to etc/conf/git.conf diff --git a/etc/conf/tmux-1.8.conf b/etc/conf/tmux-1.8.conf new file mode 100644 index 00000000..cf442aad --- /dev/null +++ b/etc/conf/tmux-1.8.conf @@ -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; \ + " +# }}} diff --git a/etc/conf/.tmux.conf b/etc/conf/tmux-2.1.conf similarity index 100% rename from etc/conf/.tmux.conf rename to etc/conf/tmux-2.1.conf diff --git a/etc/conf/.vimrc b/etc/conf/vimrc similarity index 100% rename from etc/conf/.vimrc rename to etc/conf/vimrc diff --git a/etc/conf/.zshrc b/etc/conf/zshrc similarity index 100% rename from etc/conf/.zshrc rename to etc/conf/zshrc diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index e7abebb9..854e787d 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -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, } diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index 4479e599..4bf99049 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -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(`%s`, 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) + kind := h.Header.Get("Content-Type") + kind = strings.Split(kind, "/")[0] + 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(`%s`, 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 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())) diff --git a/usr/librarys/chat.js b/usr/librarys/chat.js index dd78ae7c..d571440c 100644 --- a/usr/librarys/chat.js +++ b/usr/librarys/chat.js @@ -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) {