From 1ce3068a99c80c153fd41359255d173bce6e79e8 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Tue, 3 Nov 2020 12:30:56 +0000 Subject: [PATCH 1/5] fix: resource rename action invalid path --- http/resource.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/http/resource.go b/http/resource.go index e223bc79..daeb344b 100644 --- a/http/resource.go +++ b/http/resource.go @@ -7,6 +7,7 @@ import ( "net/http" "net/url" "os" + "path" "path/filepath" "strings" @@ -122,7 +123,7 @@ var resourcePostPutHandler = withUser(func(w http.ResponseWriter, r *http.Reques } err := d.RunHook(func() error { - dir, _ := filepath.Split(r.URL.Path) + dir, _ := path.Split(r.URL.Path) err := d.user.Fs.MkdirAll(dir, 0775) if err != nil { return err @@ -196,7 +197,8 @@ var resourcePatchHandler = withUser(func(w http.ResponseWriter, r *http.Request, if !d.user.Perm.Rename { return errors.ErrPermissionDenied } - dst = filepath.Clean("/" + dst) + src = path.Clean("/" + src) + dst = path.Clean("/" + dst) return d.user.Fs.Rename(src, dst) default: @@ -221,20 +223,20 @@ func checkParent(src, dst string) error { return nil } -func addVersionSuffix(path string, fs afero.Fs) string { +func addVersionSuffix(source string, fs afero.Fs) string { counter := 1 - dir, name := filepath.Split(path) + dir, name := path.Split(source) ext := filepath.Ext(name) base := strings.TrimSuffix(name, ext) for { - if _, err := fs.Stat(path); err != nil { + if _, err := fs.Stat(source); err != nil { break } renamed := fmt.Sprintf("%s(%d)%s", base, counter, ext) - path = filepath.ToSlash(dir) + renamed + source = path.Join(dir, renamed) counter++ } - return path + return source } From e119bc55ea82cefcbcc0571650107dfd5d73f570 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Tue, 3 Nov 2020 19:17:22 +0000 Subject: [PATCH 2/5] feat: shared folder file listing --- frontend/public/themes/dark.css | 6 ++-- frontend/src/css/_share.css | 57 +++++++++++++++++++++++++-------- frontend/src/views/Share.vue | 40 +++++++++++++++++++---- http/public.go | 12 +++++-- 4 files changed, 89 insertions(+), 26 deletions(-) diff --git a/frontend/public/themes/dark.css b/frontend/public/themes/dark.css index 1ee5f1ac..0ff15578 100644 --- a/frontend/public/themes/dark.css +++ b/frontend/public/themes/dark.css @@ -191,10 +191,10 @@ table th { } } -.share__box, .share__box__download { - background: var(--surfaceSecondary) !important; +.share__box, .share__box__header { + background: var(--surfacePrimary) !important; color: var(--textPrimary); } -.share__box__download { +.share__box__header { border-bottom-color: var(--divider); } \ No newline at end of file diff --git a/frontend/src/css/_share.css b/frontend/src/css/_share.css index a0e21153..28d10214 100644 --- a/frontend/src/css/_share.css +++ b/frontend/src/css/_share.css @@ -1,29 +1,58 @@ -.share__box { - text-align: center; - box-shadow: rgba(0, 0, 0, 0.06) 0px 1px 3px, rgba(0, 0, 0, 0.12) 0px 1px 2px; - background: #fff; - display: block; - border-radius: 0.2em; - width: 90%; - max-width: 25em; - margin: 6em auto; +.share { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: flex-start; } -.share__box__download { +@media (max-width: 736px) { + .share { + display: block; + } +} + +.share__box { + box-shadow: rgba(0, 0, 0, 0.06) 0px 1px 3px, rgba(0, 0, 0, 0.12) 0px 1px 2px; + background: #fff; + border-radius: 0.2em; + margin: 5px; + overflow: hidden; +} + +.share__box__header { width: 100%; padding: 1em; cursor: pointer; background: #ffffff; - color: rgba(0, 0, 0, 0.5); - border-bottom: 1px solid rgba(0, 0, 0, 0.05); + border-bottom: 1px solid rgba(0, 0, 0, 0.1); } -.share__box__info { +.share__box__body { padding: 2em 3em; } .share__box__title { - margin-top: .2em; + margin: 0 0 2em; overflow: hidden; text-overflow: ellipsis; } + +.share__box__info { + text-align: center; + flex: 1 1 auto; +} + +.share__box__items { + text-align: left; + flex: 10 0 15em; +} + +.share__box__items #listing.list .item { + cursor: auto; + border-left: 0; + border-right: 0; +} + +.share__box__items #listing.list .item .name { + width: auto; +} \ No newline at end of file diff --git a/frontend/src/views/Share.vue b/frontend/src/views/Share.vue index bbc15d75..ae42a271 100644 --- a/frontend/src/views/Share.vue +++ b/frontend/src/views/Share.vue @@ -1,10 +1,10 @@ @@ -34,7 +56,8 @@ export default { data: () => ({ loaded: false, notFound: false, - file: null + file: null, + showLimit: 500 }), watch: { '$route': 'fetchData' @@ -54,6 +77,9 @@ export default { }, }, methods: { + base64: function (name) { + return window.btoa(unescape(encodeURIComponent(name))) + }, fetchData: async function () { try { this.file = await api.getHash(this.hash) diff --git a/http/public.go b/http/public.go index 4467613d..269c5bdd 100644 --- a/http/public.go +++ b/http/public.go @@ -28,7 +28,7 @@ var withHashFile = func(fn handleFunc) handleFunc { Fs: d.user.Fs, Path: link.Path, Modify: d.user.Perm.Modify, - Expand: false, + Expand: true, Checker: d, }) if err != nil { @@ -54,7 +54,15 @@ func ifPathWithName(r *http.Request) string { } var publicShareHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) { - return renderJSON(w, r, d.raw) + file := d.raw.(*files.FileInfo) + + if file.IsDir { + file.Listing.Sorting = files.Sorting{By: "name", Asc: false} + file.Listing.ApplySort() + return renderJSON(w, r, file) + } + + return renderJSON(w, r, file) }) var publicDlHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) { From 4e48ffc14d09dabeea12dc495144277db62b5b7d Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Wed, 4 Nov 2020 12:11:18 +0000 Subject: [PATCH 3/5] fix: previewer title overflow --- frontend/src/components/files/Preview.vue | 4 +--- frontend/src/css/styles.css | 17 +++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/files/Preview.vue b/frontend/src/components/files/Preview.vue index 71d50632..1a8435b0 100644 --- a/frontend/src/components/files/Preview.vue +++ b/frontend/src/components/files/Preview.vue @@ -5,9 +5,7 @@ close -
- {{ this.name }} -
+
{{ this.name }}