Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
948e05c083 | ||
|
|
fb5b28d9cb | ||
|
|
677bce376b | ||
|
|
8faa96f5e6 | ||
|
|
f62806f6c9 | ||
|
|
58835b7e53 | ||
|
|
7a5298a755 | ||
|
|
bc4a6462ce | ||
|
|
ac3673e111 | ||
|
|
c746c1931d | ||
|
|
586d198d47 | ||
|
|
9515ceeb42 | ||
|
|
e8b4e9af46 | ||
|
|
10e399b3c3 | ||
|
|
dcbc3286e2 | ||
|
|
b185f9b56e | ||
|
|
7096b3dab9 | ||
|
|
36cacdf598 | ||
|
|
4e48ffc14d | ||
|
|
e119bc55ea | ||
|
|
1ce3068a99 | ||
|
|
d562d1a60d | ||
|
|
9f858398ab | ||
|
|
0ac80e8387 | ||
|
|
0dca0b92d1 | ||
|
|
c9b36ba32e | ||
|
|
f2c4e78381 | ||
|
|
05bff54b71 | ||
|
|
2bd163d92a | ||
|
|
5e27ba5c8c | ||
|
|
5aaeb3b76d | ||
|
|
36fb9f562a | ||
|
|
ad99bf1801 | ||
|
|
4c2a094255 | ||
|
|
97693cc611 | ||
|
|
c6d4fcd08f | ||
|
|
dd7b9ddd85 | ||
|
|
26d62e4117 | ||
|
|
babd7783af | ||
|
|
1529e796df | ||
|
|
d4b904b92b | ||
|
|
12d4177823 | ||
|
|
8142b32f38 | ||
|
|
c5abbb4e1c | ||
|
|
65ac73414f | ||
|
|
ede4213c8e | ||
|
|
b60d291490 | ||
|
|
b9ede79888 | ||
|
|
3d2cb838d1 | ||
|
|
778734419d |
No files matched your search
@@ -23,7 +23,7 @@ jobs:
|
|||||||
- '*'
|
- '*'
|
||||||
test:
|
test:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/golang:1.14.6
|
- image: circleci/golang:1.15.2
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
command: go test ./...
|
command: go test ./...
|
||||||
build-go:
|
build-go:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/golang:1.14.6
|
- image: circleci/golang:1.15.2
|
||||||
steps:
|
steps:
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: '~/project'
|
at: '~/project'
|
||||||
@@ -49,12 +49,12 @@ jobs:
|
|||||||
- '*'
|
- '*'
|
||||||
release:
|
release:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/golang:1.14.6
|
- image: circleci/golang:1.15.2
|
||||||
steps:
|
steps:
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: '~/project'
|
at: '~/project'
|
||||||
- setup_remote_docker
|
- setup_remote_docker
|
||||||
- run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
|
- run: echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
|
||||||
- run: curl -sL https://git.io/goreleaser | bash
|
- run: curl -sL https://git.io/goreleaser | bash
|
||||||
- run: docker logout
|
- run: docker logout
|
||||||
workflows:
|
workflows:
|
||||||
|
|||||||
@@ -2,6 +2,83 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
## [2.11.0](https://github.com/filebrowser/filebrowser/compare/v2.10.0...v2.11.0) (2020-12-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add sharing management ([#1178](https://github.com/filebrowser/filebrowser/issues/1178)) (closes [#1000](https://github.com/filebrowser/filebrowser/issues/1000)) ([677bce3](https://github.com/filebrowser/filebrowser/commit/677bce376b024d9ff38f34e74243034fe5a1ec3c))
|
||||||
|
* download shared subdirectory ([#1184](https://github.com/filebrowser/filebrowser/issues/1184)) ([fb5b28d](https://github.com/filebrowser/filebrowser/commit/fb5b28d9cbdee10d38fcd719b9fd832121be58ef))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* check user input to prevent permission elevation ([#1196](https://github.com/filebrowser/filebrowser/issues/1196)) (closes [#1195](https://github.com/filebrowser/filebrowser/issues/1195)) ([f62806f](https://github.com/filebrowser/filebrowser/commit/f62806f6c9e9c7f392d1b747d65b8fe40b313e89))
|
||||||
|
* delete extra remove prefix ([#1186](https://github.com/filebrowser/filebrowser/issues/1186)) ([7a5298a](https://github.com/filebrowser/filebrowser/commit/7a5298a7556f7dcc52f59b8ea76d040d3ddc3d12))
|
||||||
|
* move files between different volumes (closes [#1177](https://github.com/filebrowser/filebrowser/issues/1177)) ([58835b7](https://github.com/filebrowser/filebrowser/commit/58835b7e535cc96e1c8a5d85821c1545743ca757))
|
||||||
|
* recaptcha race condition ([#1176](https://github.com/filebrowser/filebrowser/issues/1176)) ([ac3673e](https://github.com/filebrowser/filebrowser/commit/ac3673e111afac6616af9650ca07028b6c27e6cd))
|
||||||
|
|
||||||
|
## [2.10.0](https://github.com/filebrowser/filebrowser/compare/v2.9.0...v2.10.0) (2020-11-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add hide dotfiles param ([#1148](https://github.com/filebrowser/filebrowser/issues/1148)) ([10e399b](https://github.com/filebrowser/filebrowser/commit/10e399b3c3dbdcfb4465a9d4138e1da6bae0873d))
|
||||||
|
* add single click mode ([#1139](https://github.com/filebrowser/filebrowser/issues/1139)) ([e8b4e9a](https://github.com/filebrowser/filebrowser/commit/e8b4e9af46d6e99dbeb965dd9727d9ed017d52a2))
|
||||||
|
* automatically jump to the next photo when deleting while previewing ([#1143](https://github.com/filebrowser/filebrowser/issues/1143)) ([9515cee](https://github.com/filebrowser/filebrowser/commit/9515ceeb42e5ef5267400220a2082dec775e843d))
|
||||||
|
* shared folder file listing ([e119bc5](https://github.com/filebrowser/filebrowser/commit/e119bc55ea82cefcbcc0571650107dfd5d73f570))
|
||||||
|
* shared item information ([36cacdf](https://github.com/filebrowser/filebrowser/commit/36cacdf598e4e09f064c8ace0ca7a6c24b23028e))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* empty folder in archive ([7096b3d](https://github.com/filebrowser/filebrowser/commit/7096b3dab92441981c9964e4a6175af0a255d2be))
|
||||||
|
* fix hanging when reading a named pipe file (closes [#1155](https://github.com/filebrowser/filebrowser/issues/1155)) ([586d198](https://github.com/filebrowser/filebrowser/commit/586d198d47b525eeccc6fe587573a3ad83adb4f6))
|
||||||
|
* previewer title overflow ([4e48ffc](https://github.com/filebrowser/filebrowser/commit/4e48ffc14d09dabeea12dc495144277db62b5b7d))
|
||||||
|
* resource rename action invalid path ([1ce3068](https://github.com/filebrowser/filebrowser/commit/1ce3068a99c80c153fd41359255d173bce6e79e8))
|
||||||
|
|
||||||
|
## [2.9.0](https://github.com/filebrowser/filebrowser/compare/v2.8.0...v2.9.0) (2020-10-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* support WKWebview custom protocol ([#1113](https://github.com/filebrowser/filebrowser/issues/1113)) ([0ac80e8](https://github.com/filebrowser/filebrowser/commit/0ac80e8387a69924284259bde448af2813d84ed1))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* allow start from Windows explorer ([f2c4e78](https://github.com/filebrowser/filebrowser/commit/f2c4e78381610879eda5316d38a999c89df6c14a))
|
||||||
|
* file upload missing path slash ([5e27ba5](https://github.com/filebrowser/filebrowser/commit/5e27ba5c8c1be603c6ae7fec8de48e3532dea1f7))
|
||||||
|
* preview case sensitive file extension ([05bff54](https://github.com/filebrowser/filebrowser/commit/05bff54b71543fd232f1089c40504d0cbfd106be))
|
||||||
|
* search missing path slash ([2bd163d](https://github.com/filebrowser/filebrowser/commit/2bd163d92a856d65c8d4615e37898470c1edf2f4))
|
||||||
|
|
||||||
|
## [2.8.0](https://github.com/filebrowser/filebrowser/compare/v2.7.0...v2.8.0) (2020-10-05)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add disable exec flag ([#1090](https://github.com/filebrowser/filebrowser/issues/1090)) ([97693cc](https://github.com/filebrowser/filebrowser/commit/97693cc6117ce1c956baede91de5dd48b904e175))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* empty commands setting ([c6d4fcd](https://github.com/filebrowser/filebrowser/commit/c6d4fcd08f5f1531c2cef514dc86019e23e7289f))
|
||||||
|
* file upload path encoding ([babd778](https://github.com/filebrowser/filebrowser/commit/babd7783afe85b790e1c558375d7b5013b2d366f))
|
||||||
|
* fix empty command name ([#1106](https://github.com/filebrowser/filebrowser/issues/1106)) ([36fb9f5](https://github.com/filebrowser/filebrowser/commit/36fb9f562a2c005ca4390fdebde0b4690201dff9))
|
||||||
|
* fix panic when accessing nonexistent .js file in static path ([#1105](https://github.com/filebrowser/filebrowser/issues/1105)) ([ad99bf1](https://github.com/filebrowser/filebrowser/commit/ad99bf180197e0e6d82231a86457585de16366a8))
|
||||||
|
* preview key shortcut conflict ([dd7b9dd](https://github.com/filebrowser/filebrowser/commit/dd7b9ddd8546361060ef99e838a691b2fc6c495a))
|
||||||
|
* search results absolute url ([26d62e4](https://github.com/filebrowser/filebrowser/commit/26d62e411716a5eb9a5a703e47484cfb3fbf3bd0))
|
||||||
|
|
||||||
|
## [2.7.0](https://github.com/filebrowser/filebrowser/compare/v2.6.2...v2.7.0) (2020-09-11)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add --socket-perm flag to control unix socket file permissions (closes [#1060](https://github.com/filebrowser/filebrowser/issues/1060)) ([65ac734](https://github.com/filebrowser/filebrowser/commit/65ac73414fadc4686c94803a93ff319e8f7ce9d1))
|
||||||
|
* preview mobile dropdown ([7787344](https://github.com/filebrowser/filebrowser/commit/778734419de314d4cb64d07109bbab73f8e2e42a))
|
||||||
|
* preview size button ([3d2cb83](https://github.com/filebrowser/filebrowser/commit/3d2cb838d111ee61047599f49e76de80c821f341))
|
||||||
|
* put selected files in the root of the archive (closes [#1065](https://github.com/filebrowser/filebrowser/issues/1065)) ([8142b32](https://github.com/filebrowser/filebrowser/commit/8142b32f3865eccd3331328e0d087f805d186ed5))
|
||||||
|
|
||||||
### [2.6.2](https://github.com/filebrowser/filebrowser/compare/v2.6.1...v2.6.2) (2020-08-05)
|
### [2.6.2](https://github.com/filebrowser/filebrowser/compare/v2.6.1...v2.6.2) (2020-08-05)
|
||||||
|
|
||||||
### [2.6.1](https://github.com/filebrowser/filebrowser/compare/v2.6.0...v2.6.1) (2020-07-28)
|
### [2.6.1](https://github.com/filebrowser/filebrowser/compare/v2.6.0...v2.6.1) (2020-07-28)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ For installation instructions please refer to our docs at [https://filebrowser.o
|
|||||||
|
|
||||||
[Authentication Method](https://filebrowser.org/configuration/authentication-method) - You can change the way the user authenticates with the filebrowser server
|
[Authentication Method](https://filebrowser.org/configuration/authentication-method) - You can change the way the user authenticates with the filebrowser server
|
||||||
|
|
||||||
[Commander Runner](https://filebrowser.org/configuration/command-runner) - The command runner is a feature that enables you to execute any shell command you want before or after a certain event.
|
[Command Runner](https://filebrowser.org/configuration/command-runner) - The command runner is a feature that enables you to execute any shell command you want before or after a certain event.
|
||||||
|
|
||||||
[Custom Branding](https://filebrowser.org/configuration/custom-branding) - You can customize your File Browser installation by change its name to any other you want, by adding a global custom style sheet and by using your own logotype if you want.
|
[Custom Branding](https://filebrowser.org/configuration/custom-branding) - You can customize your File Browser installation by change its name to any other you want, by adding a global custom style sheet and by using your own logotype if you want.
|
||||||
|
|
||||||
|
|||||||
@@ -140,10 +140,12 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut
|
|||||||
fmt.Fprintf(w, "\tAddress:\t%s\n", ser.Address)
|
fmt.Fprintf(w, "\tAddress:\t%s\n", ser.Address)
|
||||||
fmt.Fprintf(w, "\tTLS Cert:\t%s\n", ser.TLSCert)
|
fmt.Fprintf(w, "\tTLS Cert:\t%s\n", ser.TLSCert)
|
||||||
fmt.Fprintf(w, "\tTLS Key:\t%s\n", ser.TLSKey)
|
fmt.Fprintf(w, "\tTLS Key:\t%s\n", ser.TLSKey)
|
||||||
|
fmt.Fprintf(w, "\tExec Enabled:\t%t\n", ser.EnableExec)
|
||||||
fmt.Fprintln(w, "\nDefaults:")
|
fmt.Fprintln(w, "\nDefaults:")
|
||||||
fmt.Fprintf(w, "\tScope:\t%s\n", set.Defaults.Scope)
|
fmt.Fprintf(w, "\tScope:\t%s\n", set.Defaults.Scope)
|
||||||
fmt.Fprintf(w, "\tLocale:\t%s\n", set.Defaults.Locale)
|
fmt.Fprintf(w, "\tLocale:\t%s\n", set.Defaults.Locale)
|
||||||
fmt.Fprintf(w, "\tView mode:\t%s\n", set.Defaults.ViewMode)
|
fmt.Fprintf(w, "\tView mode:\t%s\n", set.Defaults.ViewMode)
|
||||||
|
fmt.Fprintf(w, "\tSingle Click:\t%t\n", set.Defaults.SingleClick)
|
||||||
fmt.Fprintf(w, "\tCommands:\t%s\n", strings.Join(set.Defaults.Commands, " "))
|
fmt.Fprintf(w, "\tCommands:\t%s\n", strings.Join(set.Defaults.Commands, " "))
|
||||||
fmt.Fprintf(w, "\tSorting:\n")
|
fmt.Fprintf(w, "\tSorting:\n")
|
||||||
fmt.Fprintf(w, "\t\tBy:\t%s\n", set.Defaults.Sorting.By)
|
fmt.Fprintf(w, "\t\tBy:\t%s\n", set.Defaults.Sorting.By)
|
||||||
|
|||||||
+2
-3
@@ -2,7 +2,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
@@ -32,7 +31,7 @@ override the options.`,
|
|||||||
s := &settings.Settings{
|
s := &settings.Settings{
|
||||||
Key: generateKey(),
|
Key: generateKey(),
|
||||||
Signup: mustGetBool(flags, "signup"),
|
Signup: mustGetBool(flags, "signup"),
|
||||||
Shell: strings.Split(strings.TrimSpace(mustGetString(flags, "shell")), " "),
|
Shell: convertCmdStrToCmdArray(mustGetString(flags, "shell")),
|
||||||
AuthMethod: authMethod,
|
AuthMethod: authMethod,
|
||||||
Defaults: defaults,
|
Defaults: defaults,
|
||||||
Branding: settings.Branding{
|
Branding: settings.Branding{
|
||||||
@@ -62,7 +61,7 @@ override the options.`,
|
|||||||
|
|
||||||
fmt.Printf(`
|
fmt.Printf(`
|
||||||
Congratulations! You've set up your database to use with File Browser.
|
Congratulations! You've set up your database to use with File Browser.
|
||||||
Now add your first user via 'filebrowser users new' and then you just
|
Now add your first user via 'filebrowser users add' and then you just
|
||||||
need to call the main command to boot up the server.
|
need to call the main command to boot up the server.
|
||||||
`)
|
`)
|
||||||
printSettings(ser, s, auther)
|
printSettings(ser, s, auther)
|
||||||
|
|||||||
+1
-3
@@ -1,8 +1,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
@@ -50,7 +48,7 @@ you want to change. Other options will remain unchanged.`,
|
|||||||
case "auth.method":
|
case "auth.method":
|
||||||
hasAuth = true
|
hasAuth = true
|
||||||
case "shell":
|
case "shell":
|
||||||
set.Shell = strings.Split(strings.TrimSpace(mustGetString(flags, flag.Name)), " ")
|
set.Shell = convertCmdStrToCmdArray(mustGetString(flags, flag.Name))
|
||||||
case "branding.name":
|
case "branding.name":
|
||||||
set.Branding.Name = mustGetString(flags, flag.Name)
|
set.Branding.Name = mustGetString(flags, flag.Name)
|
||||||
case "branding.disableExternal":
|
case "branding.disableExternal":
|
||||||
|
|||||||
+13
-2
@@ -35,6 +35,7 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cobra.OnInitialize(initConfig)
|
cobra.OnInitialize(initConfig)
|
||||||
|
cobra.MousetrapHelpText = ""
|
||||||
|
|
||||||
rootCmd.SetVersionTemplate("File Browser version {{printf \"%s\" .Version}}\n")
|
rootCmd.SetVersionTemplate("File Browser version {{printf \"%s\" .Version}}\n")
|
||||||
|
|
||||||
@@ -58,11 +59,13 @@ func addServerFlags(flags *pflag.FlagSet) {
|
|||||||
flags.StringP("key", "k", "", "tls key")
|
flags.StringP("key", "k", "", "tls key")
|
||||||
flags.StringP("root", "r", ".", "root to prepend to relative paths")
|
flags.StringP("root", "r", ".", "root to prepend to relative paths")
|
||||||
flags.String("socket", "", "socket to listen to (cannot be used with address, port, cert nor key flags)")
|
flags.String("socket", "", "socket to listen to (cannot be used with address, port, cert nor key flags)")
|
||||||
|
flags.Uint32("socket-perm", 0666, "unix socket file permissions")
|
||||||
flags.StringP("baseurl", "b", "", "base url")
|
flags.StringP("baseurl", "b", "", "base url")
|
||||||
flags.String("cache-dir", "", "file cache directory (disabled if empty)")
|
flags.String("cache-dir", "", "file cache directory (disabled if empty)")
|
||||||
flags.Int("img-processors", 4, "image processors count")
|
flags.Int("img-processors", 4, "image processors count")
|
||||||
flags.Bool("disable-thumbnails", false, "disable image thumbnails")
|
flags.Bool("disable-thumbnails", false, "disable image thumbnails")
|
||||||
flags.Bool("disable-preview-resize", false, "disable resize of image previews")
|
flags.Bool("disable-preview-resize", false, "disable resize of image previews")
|
||||||
|
flags.Bool("disable-exec", false, "disables Command Runner feature")
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
@@ -143,6 +146,10 @@ user created with the credentials from options "username" and "password".`,
|
|||||||
case server.Socket != "":
|
case server.Socket != "":
|
||||||
listener, err = net.Listen("unix", server.Socket)
|
listener, err = net.Listen("unix", server.Socket)
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
|
socketPerm, err := cmd.Flags().GetUint32("socket-perm") //nolint:govet
|
||||||
|
checkErr(err)
|
||||||
|
err = os.Chmod(server.Socket, os.FileMode(socketPerm))
|
||||||
|
checkErr(err)
|
||||||
case server.TLSKey != "" && server.TLSCert != "":
|
case server.TLSKey != "" && server.TLSCert != "":
|
||||||
cer, err := tls.LoadX509KeyPair(server.TLSCert, server.TLSKey) //nolint:shadow
|
cer, err := tls.LoadX509KeyPair(server.TLSCert, server.TLSKey) //nolint:shadow
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
@@ -236,6 +243,9 @@ func getRunParams(flags *pflag.FlagSet, st *storage.Storage) *settings.Server {
|
|||||||
_, disablePreviewResize := getParamB(flags, "disable-preview-resize")
|
_, disablePreviewResize := getParamB(flags, "disable-preview-resize")
|
||||||
server.ResizePreview = !disablePreviewResize
|
server.ResizePreview = !disablePreviewResize
|
||||||
|
|
||||||
|
_, disableExec := getParamB(flags, "disable-exec")
|
||||||
|
server.EnableExec = !disableExec
|
||||||
|
|
||||||
return server
|
return server
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,8 +302,9 @@ func quickSetup(flags *pflag.FlagSet, d pythonData) {
|
|||||||
Signup: false,
|
Signup: false,
|
||||||
CreateUserDir: false,
|
CreateUserDir: false,
|
||||||
Defaults: settings.UserDefaults{
|
Defaults: settings.UserDefaults{
|
||||||
Scope: ".",
|
Scope: ".",
|
||||||
Locale: "en",
|
Locale: "en",
|
||||||
|
SingleClick: false,
|
||||||
Perm: users.Permissions{
|
Perm: users.Permissions{
|
||||||
Admin: false,
|
Admin: false,
|
||||||
Execute: true,
|
Execute: true,
|
||||||
|
|||||||
+6
-2
@@ -27,15 +27,16 @@ var usersCmd = &cobra.Command{
|
|||||||
|
|
||||||
func printUsers(usrs []*users.User) {
|
func printUsers(usrs []*users.User) {
|
||||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||||
fmt.Fprintln(w, "ID\tUsername\tScope\tLocale\tV. Mode\tAdmin\tExecute\tCreate\tRename\tModify\tDelete\tShare\tDownload\tPwd Lock")
|
fmt.Fprintln(w, "ID\tUsername\tScope\tLocale\tV. Mode\tS.Click\tAdmin\tExecute\tCreate\tRename\tModify\tDelete\tShare\tDownload\tPwd Lock")
|
||||||
|
|
||||||
for _, u := range usrs {
|
for _, u := range usrs {
|
||||||
fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%s\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t\n",
|
fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%s\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t\n",
|
||||||
u.ID,
|
u.ID,
|
||||||
u.Username,
|
u.Username,
|
||||||
u.Scope,
|
u.Scope,
|
||||||
u.Locale,
|
u.Locale,
|
||||||
u.ViewMode,
|
u.ViewMode,
|
||||||
|
u.SingleClick,
|
||||||
u.Perm.Admin,
|
u.Perm.Admin,
|
||||||
u.Perm.Execute,
|
u.Perm.Execute,
|
||||||
u.Perm.Create,
|
u.Perm.Create,
|
||||||
@@ -75,6 +76,7 @@ func addUserFlags(flags *pflag.FlagSet) {
|
|||||||
flags.String("scope", ".", "scope for users")
|
flags.String("scope", ".", "scope for users")
|
||||||
flags.String("locale", "en", "locale for users")
|
flags.String("locale", "en", "locale for users")
|
||||||
flags.String("viewMode", string(users.ListViewMode), "view mode for users")
|
flags.String("viewMode", string(users.ListViewMode), "view mode for users")
|
||||||
|
flags.Bool("singleClick", false, "use single clicks only")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getViewMode(flags *pflag.FlagSet) users.ViewMode {
|
func getViewMode(flags *pflag.FlagSet) users.ViewMode {
|
||||||
@@ -95,6 +97,8 @@ func getUserDefaults(flags *pflag.FlagSet, defaults *settings.UserDefaults, all
|
|||||||
defaults.Locale = mustGetString(flags, flag.Name)
|
defaults.Locale = mustGetString(flags, flag.Name)
|
||||||
case "viewMode":
|
case "viewMode":
|
||||||
defaults.ViewMode = getViewMode(flags)
|
defaults.ViewMode = getViewMode(flags)
|
||||||
|
case "singleClick":
|
||||||
|
defaults.SingleClick = mustGetBool(flags, flag.Name)
|
||||||
case "perm.admin":
|
case "perm.admin":
|
||||||
defaults.Perm.Admin = mustGetBool(flags, flag.Name)
|
defaults.Perm.Admin = mustGetBool(flags, flag.Name)
|
||||||
case "perm.execute":
|
case "perm.execute":
|
||||||
|
|||||||
+8
-6
@@ -41,17 +41,19 @@ options you want to change.`,
|
|||||||
checkErr(err)
|
checkErr(err)
|
||||||
|
|
||||||
defaults := settings.UserDefaults{
|
defaults := settings.UserDefaults{
|
||||||
Scope: user.Scope,
|
Scope: user.Scope,
|
||||||
Locale: user.Locale,
|
Locale: user.Locale,
|
||||||
ViewMode: user.ViewMode,
|
ViewMode: user.ViewMode,
|
||||||
Perm: user.Perm,
|
SingleClick: user.SingleClick,
|
||||||
Sorting: user.Sorting,
|
Perm: user.Perm,
|
||||||
Commands: user.Commands,
|
Sorting: user.Sorting,
|
||||||
|
Commands: user.Commands,
|
||||||
}
|
}
|
||||||
getUserDefaults(flags, &defaults, false)
|
getUserDefaults(flags, &defaults, false)
|
||||||
user.Scope = defaults.Scope
|
user.Scope = defaults.Scope
|
||||||
user.Locale = defaults.Locale
|
user.Locale = defaults.Locale
|
||||||
user.ViewMode = defaults.ViewMode
|
user.ViewMode = defaults.ViewMode
|
||||||
|
user.SingleClick = defaults.SingleClick
|
||||||
user.Perm = defaults.Perm
|
user.Perm = defaults.Perm
|
||||||
user.Commands = defaults.Commands
|
user.Commands = defaults.Commands
|
||||||
user.Sorting = defaults.Sorting
|
user.Sorting = defaults.Sorting
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/asdine/storm"
|
"github.com/asdine/storm"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -178,3 +179,15 @@ func cleanUpMapValue(v interface{}) interface{} {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convertCmdStrToCmdArray checks if cmd string is blank (whitespace included)
|
||||||
|
// then returns empty string array, else returns the splitted word array of cmd.
|
||||||
|
// This is to ensure the result will never be []string{""}
|
||||||
|
func convertCmdStrToCmdArray(cmd string) []string {
|
||||||
|
var cmdArray []string
|
||||||
|
trimmedCmdStr := strings.TrimSpace(cmd)
|
||||||
|
if trimmedCmdStr != "" {
|
||||||
|
cmdArray = strings.Split(trimmedCmdStr, " ")
|
||||||
|
}
|
||||||
|
return cmdArray
|
||||||
|
}
|
||||||
+6
-2
@@ -135,6 +135,10 @@ func (i *FileInfo) Checksum(algo string) error {
|
|||||||
//nolint:goconst
|
//nolint:goconst
|
||||||
//TODO: use constants
|
//TODO: use constants
|
||||||
func (i *FileInfo) detectType(modify, saveContent bool) error {
|
func (i *FileInfo) detectType(modify, saveContent bool) error {
|
||||||
|
if IsNamedPipe(i.Mode) {
|
||||||
|
i.Type = "blob"
|
||||||
|
return nil
|
||||||
|
}
|
||||||
// failing to detect the type should not return error.
|
// failing to detect the type should not return error.
|
||||||
// imagine the situation where a file in a dir with thousands
|
// imagine the situation where a file in a dir with thousands
|
||||||
// of files couldn't be opened: we'd have immediately
|
// of files couldn't be opened: we'd have immediately
|
||||||
@@ -232,9 +236,9 @@ func (i *FileInfo) readListing(checker rules.Checker) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(f.Mode().String(), "L") {
|
if IsSymlink(f.Mode()) {
|
||||||
// It's a symbolic link. We try to follow it. If it doesn't work,
|
// It's a symbolic link. We try to follow it. If it doesn't work,
|
||||||
// we stay with the link information instead if the target's.
|
// we stay with the link information instead of the target's.
|
||||||
info, err := i.Fs.Stat(fPath)
|
info, err := i.Fs.Stat(fPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
f = info
|
f = info
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package files
|
package files
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -48,3 +49,11 @@ func isBinary(content []byte, _ int) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsNamedPipe(mode os.FileMode) bool {
|
||||||
|
return mode&os.ModeNamedPipe != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsSymlink(mode os.FileMode) bool {
|
||||||
|
return mode&os.ModeSymlink != 0
|
||||||
|
}
|
||||||
+82
-6
@@ -3,11 +3,31 @@ package fileutils
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MoveFile moves file from src to dst.
|
||||||
|
// By default the rename filesystem system call is used. If src and dst point to different volumes
|
||||||
|
// the file copy is used as a fallback
|
||||||
|
func MoveFile(fs afero.Fs, src, dst string) error {
|
||||||
|
if fs.Rename(src, dst) == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// fallback
|
||||||
|
err := CopyFile(fs, src, dst)
|
||||||
|
if err != nil {
|
||||||
|
_ = fs.Remove(dst)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := fs.Remove(src); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// CopyFile copies a file from source to dest and returns
|
// CopyFile copies a file from source to dest and returns
|
||||||
// an error if any.
|
// an error if any.
|
||||||
func CopyFile(fs afero.Fs, source, dest string) error {
|
func CopyFile(fs afero.Fs, source, dest string) error {
|
||||||
@@ -38,15 +58,71 @@ func CopyFile(fs afero.Fs, source, dest string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the mode if the user can't
|
// Copy the mode
|
||||||
// open the file.
|
|
||||||
info, err := fs.Stat(source)
|
info, err := fs.Stat(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fs.Chmod(dest, info.Mode())
|
return err
|
||||||
if err != nil {
|
}
|
||||||
return err
|
err = fs.Chmod(dest, info.Mode())
|
||||||
}
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommonPrefix returns common directory path of provided files
|
||||||
|
func CommonPrefix(sep byte, paths ...string) string {
|
||||||
|
// Handle special cases.
|
||||||
|
switch len(paths) {
|
||||||
|
case 0:
|
||||||
|
return ""
|
||||||
|
case 1:
|
||||||
|
return path.Clean(paths[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note, we treat string as []byte, not []rune as is often
|
||||||
|
// done in Go. (And sep as byte, not rune). This is because
|
||||||
|
// most/all supported OS' treat paths as string of non-zero
|
||||||
|
// bytes. A filename may be displayed as a sequence of Unicode
|
||||||
|
// runes (typically encoded as UTF-8) but paths are
|
||||||
|
// not required to be valid UTF-8 or in any normalized form
|
||||||
|
// (e.g. "é" (U+00C9) and "é" (U+0065,U+0301) are different
|
||||||
|
// file names.
|
||||||
|
c := []byte(path.Clean(paths[0]))
|
||||||
|
|
||||||
|
// We add a trailing sep to handle the case where the
|
||||||
|
// common prefix directory is included in the path list
|
||||||
|
// (e.g. /home/user1, /home/user1/foo, /home/user1/bar).
|
||||||
|
// path.Clean will have cleaned off trailing / separators with
|
||||||
|
// the exception of the root directory, "/" (in which case we
|
||||||
|
// make it "//", but this will get fixed up to "/" bellow).
|
||||||
|
c = append(c, sep)
|
||||||
|
|
||||||
|
// Ignore the first path since it's already in c
|
||||||
|
for _, v := range paths[1:] {
|
||||||
|
// Clean up each path before testing it
|
||||||
|
v = path.Clean(v) + string(sep)
|
||||||
|
|
||||||
|
// Find the first non-common byte and truncate c
|
||||||
|
if len(v) < len(c) {
|
||||||
|
c = c[:len(v)]
|
||||||
|
}
|
||||||
|
for i := 0; i < len(c); i++ {
|
||||||
|
if v[i] != c[i] {
|
||||||
|
c = c[:i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove trailing non-separator characters and the final separator
|
||||||
|
for i := len(c) - 1; i >= 0; i-- {
|
||||||
|
if c[i] == sep {
|
||||||
|
c = c[:i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package fileutils
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestCommonPrefix(t *testing.T) {
|
||||||
|
testCases := map[string]struct {
|
||||||
|
paths []string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
"same lvl": {
|
||||||
|
paths: []string{
|
||||||
|
"/home/user/file1",
|
||||||
|
"/home/user/file2",
|
||||||
|
},
|
||||||
|
want: "/home/user",
|
||||||
|
},
|
||||||
|
"sub folder": {
|
||||||
|
paths: []string{
|
||||||
|
"/home/user/folder",
|
||||||
|
"/home/user/folder/file",
|
||||||
|
},
|
||||||
|
want: "/home/user/folder",
|
||||||
|
},
|
||||||
|
"relative path": {
|
||||||
|
paths: []string{
|
||||||
|
"/home/user/folder",
|
||||||
|
"/home/user/folder/../folder2",
|
||||||
|
},
|
||||||
|
want: "/home/user",
|
||||||
|
},
|
||||||
|
"no common path": {
|
||||||
|
paths: []string{
|
||||||
|
"/home/user/folder",
|
||||||
|
"/etc/file",
|
||||||
|
},
|
||||||
|
want: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for name, tt := range testCases {
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
if got := CommonPrefix('/', tt.paths...); got != tt.want {
|
||||||
|
t.Errorf("CommonPrefix() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,24 +13,25 @@
|
|||||||
|
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="[{[ .StaticURL ]}]/img/icons/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="[{[ .StaticURL ]}]/img/icons/favicon-32x32.png">
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="[{[ .StaticURL ]}]/img/icons/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="[{[ .StaticURL ]}]/img/icons/favicon-16x16.png">
|
||||||
|
|
||||||
<!-- Add to home screen for Android and modern mobile browsers -->
|
<!-- Add to home screen for Android and modern mobile browsers -->
|
||||||
<link rel="manifest" id="manifestPlaceholder" crossorigin="use-credentials">
|
<link rel="manifest" id="manifestPlaceholder" crossorigin="use-credentials">
|
||||||
<meta name="theme-color" content="#2979ff">
|
<meta name="theme-color" content="#2979ff">
|
||||||
|
|
||||||
<!-- Add to home screen for Safari on iOS -->
|
<!-- Add to home screen for Safari on iOS/iPadOS -->
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
<meta name="apple-mobile-web-app-title" content="assets">
|
<meta name="apple-mobile-web-app-title" content="assets">
|
||||||
<link rel="apple-touch-icon" href="[{[ .StaticURL ]}]/img/icons/apple-touch-icon-152x152.png">
|
<link rel="apple-touch-icon" href="[{[ .StaticURL ]}]/img/icons/apple-touch-icon.png">
|
||||||
|
|
||||||
<!-- Add to home screen for Windows -->
|
<!-- Add to home screen for Windows -->
|
||||||
<meta name="msapplication-TileImage" content="[{[ .StaticURL ]}]/img/icons/msapplication-icon-144x144.png">
|
<meta name="msapplication-TileImage" content="[{[ .StaticURL ]}]/img/icons/mstile-144x144.png">
|
||||||
<meta name="msapplication-TileColor" content="#2979ff">
|
<meta name="msapplication-TileColor" content="#2979ff">
|
||||||
|
|
||||||
<!-- Inject Some Variables and generate the manifest json -->
|
<!-- Inject Some Variables and generate the manifest json -->
|
||||||
<script>
|
<script>
|
||||||
window.FileBrowser = JSON.parse(`[{[ .Json ]}]`);
|
window.FileBrowser = JSON.parse(`[{[ .Json ]}]`);
|
||||||
|
|
||||||
var fullStaticURL = window.location.origin + window.FileBrowser.StaticURL;
|
var fullStaticURL = window.location.origin + window.FileBrowser.StaticURL;
|
||||||
var dynamicManifest = {
|
var dynamicManifest = {
|
||||||
"name": window.FileBrowser.Name || 'File Browser',
|
"name": window.FileBrowser.Name || 'File Browser',
|
||||||
|
|||||||
@@ -191,10 +191,11 @@ table th {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.share__box, .share__box__download {
|
.share__box {
|
||||||
background: var(--surfaceSecondary) !important;
|
background: var(--surfacePrimary) !important;
|
||||||
color: var(--textPrimary);
|
color: var(--textPrimary);
|
||||||
}
|
}
|
||||||
.share__box__download {
|
|
||||||
border-bottom-color: var(--divider);
|
.share__box__element {
|
||||||
|
border-top-color: var(--divider);
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ export async function put (url, content = '') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function download (format, ...files) {
|
export function download (format, ...files) {
|
||||||
let url = `${baseURL}/api/raw`
|
let url = store.getters['isSharing'] ? `${baseURL}/api/public/dl/${store.state.hash}` : `${baseURL}/api/raw`
|
||||||
|
|
||||||
if (files.length === 1) {
|
if (files.length === 1) {
|
||||||
url += removePrefix(files[0]) + '?'
|
url += removePrefix(files[0]) + '?'
|
||||||
@@ -85,6 +85,11 @@ export function download (format, ...files) {
|
|||||||
export async function post (url, content = '', overwrite = false, onupload) {
|
export async function post (url, content = '', overwrite = false, onupload) {
|
||||||
url = removePrefix(url)
|
url = removePrefix(url)
|
||||||
|
|
||||||
|
let bufferContent
|
||||||
|
if (content instanceof Blob && !['http:', 'https:'].includes(window.location.protocol)) {
|
||||||
|
bufferContent = await new Response(content).arrayBuffer()
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let request = new XMLHttpRequest()
|
let request = new XMLHttpRequest()
|
||||||
request.open('POST', `${baseURL}/api/resources${url}?override=${overwrite}`, true)
|
request.open('POST', `${baseURL}/api/resources${url}?override=${overwrite}`, true)
|
||||||
@@ -108,7 +113,7 @@ export async function post (url, content = '', overwrite = false, onupload) {
|
|||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
request.send(content)
|
request.send(bufferContent || content)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +121,7 @@ function moveCopy (items, copy = false, overwrite = false, rename = false) {
|
|||||||
let promises = []
|
let promises = []
|
||||||
|
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
const from = removePrefix(item.from)
|
const from = item.from
|
||||||
const to = encodeURIComponent(removePrefix(item.to))
|
const to = encodeURIComponent(removePrefix(item.to))
|
||||||
const url = `${from}?action=${copy ? 'copy' : 'rename'}&destination=${to}&override=${overwrite}&rename=${rename}`
|
const url = `${from}?action=${copy ? 'copy' : 'rename'}&destination=${to}&override=${overwrite}&rename=${rename}`
|
||||||
promises.push(resourceAction(url, 'PATCH'))
|
promises.push(resourceAction(url, 'PATCH'))
|
||||||
|
|||||||
@@ -1,8 +1,31 @@
|
|||||||
import { fetchJSON, removePrefix } from './utils'
|
import { fetchURL, removePrefix } from './utils'
|
||||||
|
import url from '../utils/url'
|
||||||
|
|
||||||
export default async function search (url, query) {
|
export default async function search (base, query) {
|
||||||
url = removePrefix(url)
|
base = removePrefix(base)
|
||||||
query = encodeURIComponent(query)
|
query = encodeURIComponent(query)
|
||||||
|
|
||||||
return fetchJSON(`/api/search${url}?query=${query}`, {})
|
if (!base.endsWith('/')) {
|
||||||
}
|
base += '/'
|
||||||
|
}
|
||||||
|
|
||||||
|
let res = await fetchURL(`/api/search${base}?query=${query}`, {})
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
let data = await res.json()
|
||||||
|
|
||||||
|
data = data.map((item) => {
|
||||||
|
item.url = `/files${base}` + url.encodePath(item.path)
|
||||||
|
|
||||||
|
if (item.dir) {
|
||||||
|
item.url += '/'
|
||||||
|
}
|
||||||
|
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
|
||||||
|
return data
|
||||||
|
} else {
|
||||||
|
throw Error(res.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
import { fetchURL, fetchJSON, removePrefix } from './utils'
|
import { fetchURL, fetchJSON, removePrefix } from './utils'
|
||||||
|
|
||||||
|
export async function list() {
|
||||||
|
return fetchJSON('/api/shares')
|
||||||
|
}
|
||||||
|
|
||||||
export async function getHash(hash) {
|
export async function getHash(hash) {
|
||||||
return fetchJSON(`/api/public/share/${hash}`)
|
return fetchJSON(`/api/public/share/${hash}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ export async function fetchJSON (url, opts) {
|
|||||||
export function removePrefix (url) {
|
export function removePrefix (url) {
|
||||||
if (url.startsWith('/files')) {
|
if (url.startsWith('/files')) {
|
||||||
url = url.slice(6)
|
url = url.slice(6)
|
||||||
|
} else if (store.getters['isSharing']) {
|
||||||
|
url = url.slice(7 + store.state.hash.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url === '') url = '/'
|
if (url === '') url = '/'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<header v-if="!isEditor">
|
<header v-if="!isEditor && !isPreview">
|
||||||
<div>
|
<div>
|
||||||
<button @click="openSidebar" :aria-label="$t('buttons.toggleSidebar')" :title="$t('buttons.toggleSidebar')" class="action">
|
<button @click="openSidebar" :aria-label="$t('buttons.toggleSidebar')" :title="$t('buttons.toggleSidebar')" class="action">
|
||||||
<i class="material-icons">menu</i>
|
<i class="material-icons">menu</i>
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
<search v-if="isLogged"></search>
|
<search v-if="isLogged"></search>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<template v-if="isLogged">
|
<template v-if="isLogged || isSharing">
|
||||||
<button @click="openSearch" :aria-label="$t('buttons.search')" :title="$t('buttons.search')" class="search-button action">
|
<button v-show="!isSharing" @click="openSearch" :aria-label="$t('buttons.search')" :title="$t('buttons.search')" class="search-button action">
|
||||||
<i class="material-icons">search</i>
|
<i class="material-icons">search</i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<!-- Menu that shows on listing AND mobile when there are files selected -->
|
<!-- Menu that shows on listing AND mobile when there are files selected -->
|
||||||
<div id="file-selection" v-if="isMobile && isListing">
|
<div id="file-selection" v-if="isMobile && isListing && !isSharing">
|
||||||
<span v-if="selectedCount > 0">{{ selectedCount }} selected</span>
|
<span v-if="selectedCount > 0">{{ selectedCount }} selected</span>
|
||||||
<share-button v-show="showShareButton"></share-button>
|
<share-button v-show="showShareButton"></share-button>
|
||||||
<rename-button v-show="showRenameButton"></rename-button>
|
<rename-button v-show="showRenameButton"></rename-button>
|
||||||
@@ -37,13 +37,13 @@
|
|||||||
<delete-button v-show="showDeleteButton"></delete-button>
|
<delete-button v-show="showDeleteButton"></delete-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<shell-button v-show="user.perm.execute" />
|
<shell-button v-if="isExecEnabled && !isSharing && user.perm.execute" />
|
||||||
<switch-button v-show="isListing"></switch-button>
|
<switch-button v-show="isListing"></switch-button>
|
||||||
<download-button v-show="showDownloadButton"></download-button>
|
<download-button v-show="showDownloadButton"></download-button>
|
||||||
<upload-button v-show="showUpload"></upload-button>
|
<upload-button v-show="showUpload"></upload-button>
|
||||||
<info-button v-show="isFiles"></info-button>
|
<info-button v-show="isFiles"></info-button>
|
||||||
|
|
||||||
<button v-show="isListing" @click="toggleMultipleSelection" :aria-label="$t('buttons.selectMultiple')" :title="$t('buttons.selectMultiple')" class="action" >
|
<button v-show="isListing || (isSharing && req.isDir)" @click="toggleMultipleSelection" :aria-label="$t('buttons.selectMultiple')" :title="$t('buttons.selectMultiple')" class="action" >
|
||||||
<i class="material-icons">check_circle</i>
|
<i class="material-icons">check_circle</i>
|
||||||
<span>{{ $t('buttons.select') }}</span>
|
<span>{{ $t('buttons.select') }}</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -68,7 +68,7 @@ import CopyButton from './buttons/Copy'
|
|||||||
import ShareButton from './buttons/Share'
|
import ShareButton from './buttons/Share'
|
||||||
import ShellButton from './buttons/Shell'
|
import ShellButton from './buttons/Shell'
|
||||||
import {mapGetters, mapState} from 'vuex'
|
import {mapGetters, mapState} from 'vuex'
|
||||||
import { logoURL } from '@/utils/constants'
|
import { logoURL, enableExec } from '@/utils/constants'
|
||||||
import * as api from '@/api'
|
import * as api from '@/api'
|
||||||
import buttons from '@/utils/buttons'
|
import buttons from '@/utils/buttons'
|
||||||
|
|
||||||
@@ -108,8 +108,10 @@ export default {
|
|||||||
'selectedCount',
|
'selectedCount',
|
||||||
'isFiles',
|
'isFiles',
|
||||||
'isEditor',
|
'isEditor',
|
||||||
|
'isPreview',
|
||||||
'isListing',
|
'isListing',
|
||||||
'isLogged'
|
'isLogged',
|
||||||
|
'isSharing'
|
||||||
]),
|
]),
|
||||||
...mapState([
|
...mapState([
|
||||||
'req',
|
'req',
|
||||||
@@ -119,6 +121,7 @@ export default {
|
|||||||
'multiple'
|
'multiple'
|
||||||
]),
|
]),
|
||||||
logoURL: () => logoURL,
|
logoURL: () => logoURL,
|
||||||
|
isExecEnabled: () => enableExec,
|
||||||
isMobile () {
|
isMobile () {
|
||||||
return this.width <= 736
|
return this.width <= 736
|
||||||
},
|
},
|
||||||
@@ -126,7 +129,7 @@ export default {
|
|||||||
return this.isListing && this.user.perm.create
|
return this.isListing && this.user.perm.create
|
||||||
},
|
},
|
||||||
showDownloadButton () {
|
showDownloadButton () {
|
||||||
return this.isFiles && this.user.perm.download
|
return (this.isFiles && this.user.perm.download) || (this.isSharing && this.selectedCount > 0)
|
||||||
},
|
},
|
||||||
showDeleteButton () {
|
showDeleteButton () {
|
||||||
return this.isFiles && (this.isListing
|
return this.isFiles && (this.isListing
|
||||||
@@ -154,7 +157,7 @@ export default {
|
|||||||
: this.user.perm.create)
|
: this.user.perm.create)
|
||||||
},
|
},
|
||||||
showMore () {
|
showMore () {
|
||||||
return this.isFiles && this.$store.state.show === 'more'
|
return (this.isFiles || this.isSharing) && this.$store.state.show === 'more'
|
||||||
},
|
},
|
||||||
showOverlay () {
|
showOverlay () {
|
||||||
return this.showMore
|
return this.showMore
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<ul v-show="results.length > 0">
|
<ul v-show="results.length > 0">
|
||||||
<li v-for="(s,k) in filteredResults" :key="k">
|
<li v-for="(s,k) in filteredResults" :key="k">
|
||||||
<router-link @click.native="close" :to="'./' + s.path">
|
<router-link @click.native="close" :to="s.url">
|
||||||
<i v-if="s.dir" class="material-icons">folder</i>
|
<i v-if="s.dir" class="material-icons">folder</i>
|
||||||
<i v-else class="material-icons">insert_drive_file</i>
|
<i v-else class="material-icons">insert_drive_file</i>
|
||||||
<span>./{{ s.path }}</span>
|
<span>./{{ s.path }}</span>
|
||||||
@@ -183,8 +183,12 @@ export default {
|
|||||||
|
|
||||||
this.ongoing = true
|
this.ongoing = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.results = await search(path, this.value)
|
||||||
|
} catch (error) {
|
||||||
|
this.$showError(error)
|
||||||
|
}
|
||||||
|
|
||||||
this.results = await search(path, this.value)
|
|
||||||
this.ongoing = false
|
this.ongoing = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ export default {
|
|||||||
name: 'download-button',
|
name: 'download-button',
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['req', 'selected']),
|
...mapState(['req', 'selected']),
|
||||||
...mapGetters(['isListing', 'selectedCount'])
|
...mapGetters(['isListing', 'selectedCount', 'isSharing'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
download: function () {
|
download: function () {
|
||||||
if (!this.isListing) {
|
if (!this.isListing && !this.isSharing) {
|
||||||
api.download(null, this.$route.path)
|
api.download(null, this.$route.path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<template>
|
||||||
|
<button :title="$t('buttons.info')" :aria-label="$t('buttons.info')" class="action" @click="$emit('change-size')">
|
||||||
|
<i class="material-icons">{{ this.icon }}</i>
|
||||||
|
<span>{{ $t('buttons.info') }}</span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'preview-size-button',
|
||||||
|
props: [ 'size' ],
|
||||||
|
computed: {
|
||||||
|
icon () {
|
||||||
|
if (this.size) {
|
||||||
|
return 'photo_size_select_large'
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'hd'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -77,6 +77,13 @@ export default {
|
|||||||
window.removeEventListener('resize', this.onResize)
|
window.removeEventListener('resize', this.onResize)
|
||||||
document.removeEventListener('mouseup', this.onMouseUp)
|
document.removeEventListener('mouseup', this.onMouseUp)
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
src: function () {
|
||||||
|
this.scale = 1
|
||||||
|
this.setZoom()
|
||||||
|
this.setCenter()
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onLoad() {
|
onLoad() {
|
||||||
let img = this.$refs.imgex
|
let img = this.$refs.imgex
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let files = await upload.scanFiles(dt)
|
let files = await upload.scanFiles(dt)
|
||||||
let path = this.$route.path + base
|
let path = this.$route.path.endsWith('/') ? this.$route.path + base : this.$route.path + '/' + base
|
||||||
let items = this.req.items
|
let items = this.req.items
|
||||||
|
|
||||||
if (base !== '') {
|
if (base !== '') {
|
||||||
@@ -409,7 +409,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = this.$route.path
|
let path = this.$route.path.endsWith('/') ? this.$route.path : this.$route.path + '/'
|
||||||
let conflict = upload.checkConflict(files, this.req.items)
|
let conflict = upload.checkConflict(files, this.req.items)
|
||||||
|
|
||||||
if (conflict) {
|
if (conflict) {
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
@dragstart="dragStart"
|
@dragstart="dragStart"
|
||||||
@dragover="dragOver"
|
@dragover="dragOver"
|
||||||
@drop="drop"
|
@drop="drop"
|
||||||
@click="click"
|
@click="itemClick"
|
||||||
@dblclick="open"
|
@dblclick="dblclick"
|
||||||
@touchstart="touchstart"
|
@touchstart="touchstart"
|
||||||
:data-dir="isDir"
|
:data-dir="isDir"
|
||||||
:aria-label="name"
|
:aria-label="name"
|
||||||
:aria-selected="isSelected">
|
:aria-selected="isSelected">
|
||||||
<div>
|
<div>
|
||||||
<img v-if="type==='image' && isThumbsEnabled" v-lazy="thumbnailUrl">
|
<img v-if="type==='image' && isThumbsEnabled && !isSharing" v-lazy="thumbnailUrl">
|
||||||
<i v-else class="material-icons">{{ icon }}</i>
|
<i v-else class="material-icons">{{ icon }}</i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -47,8 +47,12 @@ export default {
|
|||||||
},
|
},
|
||||||
props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index'],
|
props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index'],
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['selected', 'req', 'user', 'jwt']),
|
...mapState(['user', 'selected', 'req', 'jwt']),
|
||||||
...mapGetters(['selectedCount']),
|
...mapGetters(['selectedCount', 'isSharing']),
|
||||||
|
singleClick () {
|
||||||
|
if (this.isSharing) return false
|
||||||
|
return this.user.singleClick
|
||||||
|
},
|
||||||
isSelected () {
|
isSelected () {
|
||||||
return (this.selected.indexOf(this.index) !== -1)
|
return (this.selected.indexOf(this.index) !== -1)
|
||||||
},
|
},
|
||||||
@@ -60,10 +64,10 @@ export default {
|
|||||||
return 'insert_drive_file'
|
return 'insert_drive_file'
|
||||||
},
|
},
|
||||||
isDraggable () {
|
isDraggable () {
|
||||||
return this.user.perm.rename
|
return !this.isSharing && this.user.perm.rename
|
||||||
},
|
},
|
||||||
canDrop () {
|
canDrop () {
|
||||||
if (!this.isDir) return false
|
if (!this.isDir || this.isSharing) return false
|
||||||
|
|
||||||
for (let i of this.selected) {
|
for (let i of this.selected) {
|
||||||
if (this.req.items[i].url === this.url) {
|
if (this.req.items[i].url === this.url) {
|
||||||
@@ -170,8 +174,12 @@ export default {
|
|||||||
|
|
||||||
action(overwrite, rename)
|
action(overwrite, rename)
|
||||||
},
|
},
|
||||||
|
itemClick: function(event) {
|
||||||
|
if (this.singleClick && !this.$store.state.multiple) this.open()
|
||||||
|
else this.click(event)
|
||||||
|
},
|
||||||
click: function (event) {
|
click: function (event) {
|
||||||
if (this.selectedCount !== 0) event.preventDefault()
|
if (!this.singleClick && this.selectedCount !== 0) event.preventDefault()
|
||||||
if (this.$store.state.selected.indexOf(this.index) !== -1) {
|
if (this.$store.state.selected.indexOf(this.index) !== -1) {
|
||||||
this.removeSelected(this.index)
|
this.removeSelected(this.index)
|
||||||
return
|
return
|
||||||
@@ -198,9 +206,12 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.ctrlKey && !this.$store.state.multiple) this.resetSelected()
|
if (!this.singleClick && !event.ctrlKey && !event.metaKey && !this.$store.state.multiple) this.resetSelected()
|
||||||
this.addSelected(this.index)
|
this.addSelected(this.index)
|
||||||
},
|
},
|
||||||
|
dblclick: function () {
|
||||||
|
if (!this.singleClick) this.open()
|
||||||
|
},
|
||||||
touchstart () {
|
touchstart () {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.touches = 0
|
this.touches = 0
|
||||||
|
|||||||
@@ -5,14 +5,19 @@
|
|||||||
<i class="material-icons">close</i>
|
<i class="material-icons">close</i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">{{ this.name }}</div>
|
||||||
<span>{{ this.name }}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<rename-button :disabled="loading" v-if="user.perm.rename"></rename-button>
|
<preview-size-button v-if="isResizeEnabled && this.req.type === 'image'" @change-size="toggleSize" v-bind:size="fullSize" :disabled="loading"></preview-size-button>
|
||||||
<delete-button :disabled="loading" v-if="user.perm.delete"></delete-button>
|
<button @click="openMore" id="more" :aria-label="$t('buttons.more')" :title="$t('buttons.more')" class="action">
|
||||||
<download-button :disabled="loading" v-if="user.perm.download"></download-button>
|
<i class="material-icons">more_vert</i>
|
||||||
<info-button :disabled="loading"></info-button>
|
</button>
|
||||||
|
|
||||||
|
<div id="dropdown" :class="{ active : showMore }">
|
||||||
|
<rename-button :disabled="loading" v-if="user.perm.rename"></rename-button>
|
||||||
|
<delete-button :disabled="loading" v-if="user.perm.delete"></delete-button>
|
||||||
|
<download-button :disabled="loading" v-if="user.perm.download"></download-button>
|
||||||
|
<info-button :disabled="loading"></info-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="loading" v-if="loading">
|
<div class="loading" v-if="loading">
|
||||||
@@ -45,20 +50,23 @@
|
|||||||
but don't worry, you can <a :href="download">download it</a>
|
but don't worry, you can <a :href="download">download it</a>
|
||||||
and watch it with your favorite video player!
|
and watch it with your favorite video player!
|
||||||
</video>
|
</video>
|
||||||
<object v-else-if="req.extension == '.pdf'" class="pdf" :data="raw"></object>
|
<object v-else-if="req.extension.toLowerCase() == '.pdf'" class="pdf" :data="raw"></object>
|
||||||
<a v-else-if="req.type == 'blob'" :href="download">
|
<a v-else-if="req.type == 'blob'" :href="download">
|
||||||
<h2 class="message">{{ $t('buttons.download') }} <i class="material-icons">file_download</i></h2>
|
<h2 class="message">{{ $t('buttons.download') }} <i class="material-icons">file_download</i></h2>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<div v-show="showMore" @click="resetPrompts" class="overlay"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import url from '@/utils/url'
|
import url from '@/utils/url'
|
||||||
import { baseURL } from '@/utils/constants'
|
import { baseURL, resizePreview } from '@/utils/constants'
|
||||||
import { files as api } from '@/api'
|
import { files as api } from '@/api'
|
||||||
|
import PreviewSizeButton from '@/components/buttons/PreviewSize'
|
||||||
import InfoButton from '@/components/buttons/Info'
|
import InfoButton from '@/components/buttons/Info'
|
||||||
import DeleteButton from '@/components/buttons/Delete'
|
import DeleteButton from '@/components/buttons/Delete'
|
||||||
import RenameButton from '@/components/buttons/Rename'
|
import RenameButton from '@/components/buttons/Rename'
|
||||||
@@ -75,6 +83,7 @@ const mediaTypes = [
|
|||||||
export default {
|
export default {
|
||||||
name: 'preview',
|
name: 'preview',
|
||||||
components: {
|
components: {
|
||||||
|
PreviewSizeButton,
|
||||||
InfoButton,
|
InfoButton,
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
RenameButton,
|
RenameButton,
|
||||||
@@ -87,11 +96,12 @@ export default {
|
|||||||
nextLink: '',
|
nextLink: '',
|
||||||
listing: null,
|
listing: null,
|
||||||
name: '',
|
name: '',
|
||||||
subtitles: []
|
subtitles: [],
|
||||||
|
fullSize: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['req', 'user', 'oldReq', 'jwt', 'loading']),
|
...mapState(['req', 'user', 'oldReq', 'jwt', 'loading', 'show']),
|
||||||
hasPrevious () {
|
hasPrevious () {
|
||||||
return (this.previousLink !== '')
|
return (this.previousLink !== '')
|
||||||
},
|
},
|
||||||
@@ -102,13 +112,19 @@ export default {
|
|||||||
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
||||||
},
|
},
|
||||||
previewUrl () {
|
previewUrl () {
|
||||||
if (this.req.type === 'image') {
|
if (this.req.type === 'image' && !this.fullSize) {
|
||||||
return `${baseURL}/api/preview/big${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
return `${baseURL}/api/preview/big${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
||||||
}
|
}
|
||||||
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
||||||
},
|
},
|
||||||
raw () {
|
raw () {
|
||||||
return `${this.previewUrl}&inline=true`
|
return `${this.previewUrl}&inline=true`
|
||||||
|
},
|
||||||
|
showMore () {
|
||||||
|
return this.$store.state.show === 'more'
|
||||||
|
},
|
||||||
|
isResizeEnabled () {
|
||||||
|
return resizePreview
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -117,16 +133,29 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted () {
|
async mounted () {
|
||||||
window.addEventListener('keyup', this.key)
|
window.addEventListener('keydown', this.key)
|
||||||
this.$store.commit('setPreviewMode', true)
|
this.$store.commit('setPreviewMode', true)
|
||||||
this.listing = this.oldReq.items
|
this.listing = this.oldReq.items
|
||||||
|
this.$root.$on('preview-deleted', this.deleted)
|
||||||
this.updatePreview()
|
this.updatePreview()
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
window.removeEventListener('keyup', this.key)
|
window.removeEventListener('keydown', this.key)
|
||||||
this.$store.commit('setPreviewMode', false)
|
this.$store.commit('setPreviewMode', false)
|
||||||
|
this.$root.$off('preview-deleted', this.deleted)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
deleted () {
|
||||||
|
this.listing = this.listing.filter(item => item.name !== this.name)
|
||||||
|
|
||||||
|
if (this.hasNext) {
|
||||||
|
this.next()
|
||||||
|
} else if (!this.hasPrevious && !this.hasNext) {
|
||||||
|
this.back()
|
||||||
|
} else {
|
||||||
|
this.prev()
|
||||||
|
}
|
||||||
|
},
|
||||||
back () {
|
back () {
|
||||||
this.$store.commit('setPreviewMode', false)
|
this.$store.commit('setPreviewMode', false)
|
||||||
let uri = url.removeLastDir(this.$route.path) + '/'
|
let uri = url.removeLastDir(this.$route.path) + '/'
|
||||||
@@ -139,7 +168,10 @@ export default {
|
|||||||
this.$router.push({ path: this.nextLink })
|
this.$router.push({ path: this.nextLink })
|
||||||
},
|
},
|
||||||
key (event) {
|
key (event) {
|
||||||
event.preventDefault()
|
|
||||||
|
if (this.show !== null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (event.which === 13 || event.which === 39) { // right arrow
|
if (event.which === 13 || event.which === 39) { // right arrow
|
||||||
if (this.hasNext) this.next()
|
if (this.hasNext) this.next()
|
||||||
@@ -189,6 +221,15 @@ export default {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
openMore () {
|
||||||
|
this.$store.commit('showHover', 'more')
|
||||||
|
},
|
||||||
|
resetPrompts () {
|
||||||
|
this.$store.commit('closeHovers')
|
||||||
|
},
|
||||||
|
toggleSize () {
|
||||||
|
this.fullSize = !this.fullSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import {mapGetters, mapMutations, mapState} from 'vuex'
|
import {mapGetters, mapMutations, mapState} from 'vuex'
|
||||||
import { files as api } from '@/api'
|
import { files as api } from '@/api'
|
||||||
import url from '@/utils/url'
|
|
||||||
import buttons from '@/utils/buttons'
|
import buttons from '@/utils/buttons'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -32,17 +31,20 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['closeHovers']),
|
...mapMutations(['closeHovers']),
|
||||||
submit: async function () {
|
submit: async function () {
|
||||||
this.closeHovers()
|
|
||||||
buttons.loading('delete')
|
buttons.loading('delete')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!this.isListing) {
|
if (!this.isListing) {
|
||||||
await api.remove(this.$route.path)
|
await api.remove(this.$route.path)
|
||||||
buttons.success('delete')
|
buttons.success('delete')
|
||||||
this.$router.push({ path: url.removeLastDir(this.$route.path) + '/' })
|
|
||||||
|
this.$root.$emit('preview-deleted')
|
||||||
|
this.closeHovers()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.closeHovers()
|
||||||
|
|
||||||
if (this.selectedCount === 0) {
|
if (this.selectedCount === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ export default {
|
|||||||
return this.commands.join(' ')
|
return this.commands.join(' ')
|
||||||
},
|
},
|
||||||
set (value) {
|
set (value) {
|
||||||
this.$emit('update:commands', value.split(' '))
|
if (value !== '') {
|
||||||
|
this.$emit('update:commands', value.split(' '))
|
||||||
|
} else {
|
||||||
|
this.$emit('update:commands', [])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,14 @@
|
|||||||
<p><input type="checkbox" :disabled="admin" v-model="perm.delete"> {{ $t('settings.perm.delete') }}</p>
|
<p><input type="checkbox" :disabled="admin" v-model="perm.delete"> {{ $t('settings.perm.delete') }}</p>
|
||||||
<p><input type="checkbox" :disabled="admin" v-model="perm.download"> {{ $t('settings.perm.download') }}</p>
|
<p><input type="checkbox" :disabled="admin" v-model="perm.download"> {{ $t('settings.perm.download') }}</p>
|
||||||
<p><input type="checkbox" :disabled="admin" v-model="perm.modify"> {{ $t('settings.perm.modify') }}</p>
|
<p><input type="checkbox" :disabled="admin" v-model="perm.modify"> {{ $t('settings.perm.modify') }}</p>
|
||||||
<p><input type="checkbox" :disabled="admin" v-model="perm.execute"> {{ $t('settings.perm.execute') }}</p>
|
<p v-if="isExecEnabled"><input type="checkbox" :disabled="admin" v-model="perm.execute"> {{ $t('settings.perm.execute') }}</p>
|
||||||
<p><input type="checkbox" :disabled="admin" v-model="perm.rename"> {{ $t('settings.perm.rename') }}</p>
|
<p><input type="checkbox" :disabled="admin" v-model="perm.rename"> {{ $t('settings.perm.rename') }}</p>
|
||||||
<p><input type="checkbox" :disabled="admin" v-model="perm.share"> {{ $t('settings.perm.share') }}</p>
|
<p><input type="checkbox" :disabled="admin" v-model="perm.share"> {{ $t('settings.perm.share') }}</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { enableExec } from '@/utils/constants'
|
||||||
export default {
|
export default {
|
||||||
name: 'permissions',
|
name: 'permissions',
|
||||||
props: ['perm'],
|
props: ['perm'],
|
||||||
@@ -33,7 +34,8 @@ export default {
|
|||||||
|
|
||||||
this.perm.admin = value
|
this.perm.admin = value
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
isExecEnabled: () => enableExec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -24,8 +24,12 @@
|
|||||||
<input type="checkbox" :disabled="user.perm.admin" v-model="user.lockPassword"> {{ $t('settings.lockPassword') }}
|
<input type="checkbox" :disabled="user.perm.admin" v-model="user.lockPassword"> {{ $t('settings.lockPassword') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<input type="checkbox" v-model="user.singleClick"> {{ $t('settings.singleClick') }}
|
||||||
|
</p>
|
||||||
|
|
||||||
<permissions :perm.sync="user.perm" />
|
<permissions :perm.sync="user.perm" />
|
||||||
<commands :commands.sync="user.commands" />
|
<commands v-if="isExecEnabled" :commands.sync="user.commands" />
|
||||||
|
|
||||||
<div v-if="!isDefault">
|
<div v-if="!isDefault">
|
||||||
<h3>{{ $t('settings.rules') }}</h3>
|
<h3>{{ $t('settings.rules') }}</h3>
|
||||||
@@ -40,6 +44,7 @@ import Languages from './Languages'
|
|||||||
import Rules from './Rules'
|
import Rules from './Rules'
|
||||||
import Permissions from './Permissions'
|
import Permissions from './Permissions'
|
||||||
import Commands from './Commands'
|
import Commands from './Commands'
|
||||||
|
import { enableExec } from '@/utils/constants'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'user',
|
name: 'user',
|
||||||
@@ -53,7 +58,8 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
passwordPlaceholder () {
|
passwordPlaceholder () {
|
||||||
return this.isNew ? '' : this.$t('settings.avoidChanges')
|
return this.isNew ? '' : this.$t('settings.avoidChanges')
|
||||||
}
|
},
|
||||||
|
isExecEnabled: () => enableExec
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'user.perm.admin': function () {
|
'user.perm.admin': function () {
|
||||||
|
|||||||
+56
-20
@@ -1,29 +1,65 @@
|
|||||||
.share__box {
|
.share {
|
||||||
text-align: center;
|
display: flex;
|
||||||
box-shadow: rgba(0, 0, 0, 0.06) 0px 1px 3px, rgba(0, 0, 0, 0.12) 0px 1px 2px;
|
flex-wrap: wrap;
|
||||||
background: #fff;
|
justify-content: center;
|
||||||
display: block;
|
align-items: flex-start;
|
||||||
border-radius: 0.2em;
|
|
||||||
width: 90%;
|
|
||||||
max-width: 25em;
|
|
||||||
margin: 6em auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.share__box__download {
|
@media (max-width: 736px) {
|
||||||
width: 100%;
|
.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 {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
cursor: pointer;
|
text-align: center;
|
||||||
background: #ffffff;
|
}
|
||||||
color: rgba(0, 0, 0, 0.5);
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
.share__box__icon i {
|
||||||
|
font-size: 10em;
|
||||||
|
color: #40c4ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share__box__center {
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.share__box__info {
|
.share__box__info {
|
||||||
padding: 2em 3em;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.share__box__title {
|
.share__box__element {
|
||||||
margin-top: .2em;
|
padding: 1em;
|
||||||
overflow: hidden;
|
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
text-overflow: ellipsis;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.share__box__items {
|
||||||
|
text-align: left;
|
||||||
|
flex: 10 0 25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share__box__items #listing.list .item {
|
||||||
|
cursor: pointer;
|
||||||
|
border-left: 0;
|
||||||
|
border-right: 0;
|
||||||
|
border-bottom: 0;
|
||||||
|
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.share__box__items #listing.list .item .name {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share__box__items #listing.list .item .modified {
|
||||||
|
width: 25%;
|
||||||
|
}
|
||||||
@@ -119,18 +119,23 @@
|
|||||||
|
|
||||||
#previewer .bar {
|
#previewer .bar {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: right;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
height: 3.7em;
|
height: 3.7em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#previewer .bar > * {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
#previewer .bar .title {
|
#previewer .bar .title {
|
||||||
margin-right: auto;
|
display: block;
|
||||||
|
flex: 1 1 auto;
|
||||||
padding: 0 1em;
|
padding: 0 1em;
|
||||||
line-height: 2.7em;
|
line-height: 2.3em;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
word-break: break-word;
|
text-overflow: ellipsis;
|
||||||
|
font-size: 1.2em;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,10 +225,6 @@
|
|||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
#previewer .title span {
|
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#previewer .loading {
|
#previewer .loading {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@
|
|||||||
"documentation": "documentation",
|
"documentation": "documentation",
|
||||||
"branding": "Branding",
|
"branding": "Branding",
|
||||||
"disableExternalLinks": "Disable external links (except documentation)",
|
"disableExternalLinks": "Disable external links (except documentation)",
|
||||||
"brandingHelp": "You can costumize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
"brandingHelp": "You can customize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
||||||
"admin": "Admin",
|
"admin": "Admin",
|
||||||
"administrator": "Administrator",
|
"administrator": "Administrator",
|
||||||
"allowCommands": "تنفيذ الأوامر",
|
"allowCommands": "تنفيذ الأوامر",
|
||||||
@@ -233,4 +233,4 @@
|
|||||||
"downloadFile": "Download File",
|
"downloadFile": "Download File",
|
||||||
"downloadFolder": "Download Folder"
|
"downloadFolder": "Download Folder"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,8 @@
|
|||||||
"toggleSidebar": "Toggle sidebar",
|
"toggleSidebar": "Toggle sidebar",
|
||||||
"update": "Update",
|
"update": "Update",
|
||||||
"upload": "Upload",
|
"upload": "Upload",
|
||||||
"permalink": "Get Permanent Link"
|
"permalink": "Get Permanent Link",
|
||||||
|
"hideDotfiles": "Hide dotfiles"
|
||||||
},
|
},
|
||||||
"success": {
|
"success": {
|
||||||
"linkCopied": "Link copied!"
|
"linkCopied": "Link copied!"
|
||||||
@@ -131,7 +132,7 @@
|
|||||||
"documentation": "documentation",
|
"documentation": "documentation",
|
||||||
"branding": "Branding",
|
"branding": "Branding",
|
||||||
"disableExternalLinks": "Disable external links (except documentation)",
|
"disableExternalLinks": "Disable external links (except documentation)",
|
||||||
"brandingHelp": "You can costumize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
"brandingHelp": "You can customize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
||||||
"admin": "Admin",
|
"admin": "Admin",
|
||||||
"administrator": "Administrator",
|
"administrator": "Administrator",
|
||||||
"allowCommands": "Execute commands",
|
"allowCommands": "Execute commands",
|
||||||
@@ -156,6 +157,9 @@
|
|||||||
"permissions": "Permissions",
|
"permissions": "Permissions",
|
||||||
"permissionsHelp": "You can set the user to be an administrator or choose the permissions individually. If you select \"Administrator\", all of the other options will be automatically checked. The management of users remains a privilege of an administrator.\n",
|
"permissionsHelp": "You can set the user to be an administrator or choose the permissions individually. If you select \"Administrator\", all of the other options will be automatically checked. The management of users remains a privilege of an administrator.\n",
|
||||||
"profileSettings": "Profile Settings",
|
"profileSettings": "Profile Settings",
|
||||||
|
"shareManagement": "Share Management",
|
||||||
|
"path": "Path",
|
||||||
|
"shareDuration": "Share Duration",
|
||||||
"ruleExample1": "prevents the access to any dot file (such as .git, .gitignore) in every folder.\n",
|
"ruleExample1": "prevents the access to any dot file (such as .git, .gitignore) in every folder.\n",
|
||||||
"ruleExample2": "blocks the access to the file named Caddyfile on the root of the scope.",
|
"ruleExample2": "blocks the access to the file named Caddyfile on the root of the scope.",
|
||||||
"rules": "Rules",
|
"rules": "Rules",
|
||||||
@@ -173,13 +177,14 @@
|
|||||||
"globalRules": "This is a global set of allow and disallow rules. They apply to every user. You can define specific rules on each user's settings to override this ones.",
|
"globalRules": "This is a global set of allow and disallow rules. They apply to every user. You can define specific rules on each user's settings to override this ones.",
|
||||||
"allowSignup": "Allow users to signup",
|
"allowSignup": "Allow users to signup",
|
||||||
"createUserDir": "Auto create user home dir while adding new user",
|
"createUserDir": "Auto create user home dir while adding new user",
|
||||||
|
"singleClick": "Use single clicks to open files and directories",
|
||||||
"insertRegex": "Insert regex expression",
|
"insertRegex": "Insert regex expression",
|
||||||
"insertPath": "Insert the path",
|
"insertPath": "Insert the path",
|
||||||
"userUpdated": "User updated!",
|
"userUpdated": "User updated!",
|
||||||
"userDefaults": "User default settings",
|
"userDefaults": "User default settings",
|
||||||
"defaultUserDescription": "This are the default settings for new users.",
|
"defaultUserDescription": "This are the default settings for new users.",
|
||||||
"executeOnShell": "Execute on shell",
|
"executeOnShell": "Execute on shell",
|
||||||
"executeOnShellDescription": "By default, File Browser executes the commands by calling their binaries directly. If you want to run them on a shell instead (such as Bash or PowerShell), you can define it here with the required arguments and flags. If set, the command you execute will be appended as an argument. This apply to both user commands and event hooks.",
|
"executeOnShellDescription": "By default, File Browser executes the commands by calling their binaries directly. If you want to run them on a shell instead (such as Bash or PowerShell), you can define it here with the required arguments and flags. If set, the command you execute will be appended as an argument. This apply to both user commands and event hooks.",
|
||||||
"perm": {
|
"perm": {
|
||||||
"create": "Create files and directories",
|
"create": "Create files and directories",
|
||||||
"delete": "Delete files and directories",
|
"delete": "Delete files and directories",
|
||||||
@@ -188,7 +193,8 @@
|
|||||||
"execute": "Execute commands",
|
"execute": "Execute commands",
|
||||||
"rename": "Rename or move files and directories",
|
"rename": "Rename or move files and directories",
|
||||||
"share": "Share files"
|
"share": "Share files"
|
||||||
}
|
},
|
||||||
|
"hideDotfiles": "Hide dotfiles"
|
||||||
},
|
},
|
||||||
"sidebar": {
|
"sidebar": {
|
||||||
"help": "Help",
|
"help": "Help",
|
||||||
@@ -242,6 +248,7 @@
|
|||||||
},
|
},
|
||||||
"download": {
|
"download": {
|
||||||
"downloadFile": "Download File",
|
"downloadFile": "Download File",
|
||||||
"downloadFolder": "Download Folder"
|
"downloadFolder": "Download Folder",
|
||||||
|
"downloadSelected": "Download Selected"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"home": "Accueil",
|
"home": "Accueil",
|
||||||
"lastModified": "Dernière modification",
|
"lastModified": "Dernière modification",
|
||||||
"loading": "Chargement...",
|
"loading": "Chargement...",
|
||||||
"lonely": "Il semble qu'il n'y ai rien par ici...",
|
"lonely": "Il semble qu'il n'y ait rien par ici...",
|
||||||
"metadata": "Metadonnées",
|
"metadata": "Metadonnées",
|
||||||
"multipleSelectionEnabled": "Sélection multiple activée",
|
"multipleSelectionEnabled": "Sélection multiple activée",
|
||||||
"name": "Nom",
|
"name": "Nom",
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
"documentation": "documentation",
|
"documentation": "documentation",
|
||||||
"branding": "Branding",
|
"branding": "Branding",
|
||||||
"disableExternalLinks": "Disable external links (except documentation)",
|
"disableExternalLinks": "Disable external links (except documentation)",
|
||||||
"brandingHelp": "You can costumize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
"brandingHelp": "You can customize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
||||||
"admin": "Admin",
|
"admin": "Admin",
|
||||||
"administrator": "Administrateur",
|
"administrator": "Administrateur",
|
||||||
"allowCommands": "Exécuter des commandes",
|
"allowCommands": "Exécuter des commandes",
|
||||||
@@ -233,4 +233,4 @@
|
|||||||
"downloadFile": "Download File",
|
"downloadFile": "Download File",
|
||||||
"downloadFolder": "Download Folder"
|
"downloadFolder": "Download Folder"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
"documentation": "documentation",
|
"documentation": "documentation",
|
||||||
"branding": "Branding",
|
"branding": "Branding",
|
||||||
"disableExternalLinks": "Disable external links (except documentation)",
|
"disableExternalLinks": "Disable external links (except documentation)",
|
||||||
"brandingHelp": "You can costumize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
"brandingHelp": "You can customize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
||||||
"admin": "Admin",
|
"admin": "Admin",
|
||||||
"administrator": "Amministratore",
|
"administrator": "Amministratore",
|
||||||
"allowCommands": "Esegui comandi",
|
"allowCommands": "Esegui comandi",
|
||||||
@@ -233,4 +233,4 @@
|
|||||||
"downloadFile": "Download File",
|
"downloadFile": "Download File",
|
||||||
"downloadFolder": "Download Folder"
|
"downloadFolder": "Download Folder"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
"documentation": "documentation",
|
"documentation": "documentation",
|
||||||
"branding": "Branding",
|
"branding": "Branding",
|
||||||
"disableExternalLinks": "Disable external links (except documentation)",
|
"disableExternalLinks": "Disable external links (except documentation)",
|
||||||
"brandingHelp": "You can costumize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
"brandingHelp": "You can customize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
||||||
"admin": "管理者",
|
"admin": "管理者",
|
||||||
"administrator": "管理者",
|
"administrator": "管理者",
|
||||||
"allowCommands": "コマンドの実行",
|
"allowCommands": "コマンドの実行",
|
||||||
@@ -233,4 +233,4 @@
|
|||||||
"downloadFile": "Download File",
|
"downloadFile": "Download File",
|
||||||
"downloadFolder": "Download Folder"
|
"downloadFolder": "Download Folder"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
"documentation": "documentation",
|
"documentation": "documentation",
|
||||||
"branding": "Branding",
|
"branding": "Branding",
|
||||||
"disableExternalLinks": "Disable external links (except documentation)",
|
"disableExternalLinks": "Disable external links (except documentation)",
|
||||||
"brandingHelp": "You can costumize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
"brandingHelp": "You can customize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
||||||
"admin": "Admin",
|
"admin": "Admin",
|
||||||
"administrator": "Administrator",
|
"administrator": "Administrator",
|
||||||
"allowCommands": "Wykonaj polecenie",
|
"allowCommands": "Wykonaj polecenie",
|
||||||
@@ -233,4 +233,4 @@
|
|||||||
"downloadFile": "Download File",
|
"downloadFile": "Download File",
|
||||||
"downloadFolder": "Download Folder"
|
"downloadFolder": "Download Folder"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
"documentation": "documentação",
|
"documentation": "documentação",
|
||||||
"branding": "Branding",
|
"branding": "Branding",
|
||||||
"disableExternalLinks": "Disable external links (except documentation)",
|
"disableExternalLinks": "Disable external links (except documentation)",
|
||||||
"brandingHelp": "You can costumize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
"brandingHelp": "You can customize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
||||||
"admin": "Admin",
|
"admin": "Admin",
|
||||||
"administrator": "Administrador",
|
"administrator": "Administrador",
|
||||||
"allowCommands": "Executar comandos",
|
"allowCommands": "Executar comandos",
|
||||||
@@ -233,4 +233,4 @@
|
|||||||
"downloadFile": "Baixar arquivo",
|
"downloadFile": "Baixar arquivo",
|
||||||
"downloadFolder": "Baixar pasta"
|
"downloadFolder": "Baixar pasta"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
"documentation": "documentation",
|
"documentation": "documentation",
|
||||||
"branding": "Branding",
|
"branding": "Branding",
|
||||||
"disableExternalLinks": "Disable external links (except documentation)",
|
"disableExternalLinks": "Disable external links (except documentation)",
|
||||||
"brandingHelp": "You can costumize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
"brandingHelp": "You can customize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
||||||
"admin": "Админ",
|
"admin": "Админ",
|
||||||
"administrator": "Администратор",
|
"administrator": "Администратор",
|
||||||
"allowCommands": "Запуск команд",
|
"allowCommands": "Запуск команд",
|
||||||
@@ -233,4 +233,4 @@
|
|||||||
"downloadFile": "Download File",
|
"downloadFile": "Download File",
|
||||||
"downloadFolder": "Download Folder"
|
"downloadFolder": "Download Folder"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,8 +90,8 @@
|
|||||||
"copy": "复制",
|
"copy": "复制",
|
||||||
"copyMessage": "请选择欲复制至的目录:",
|
"copyMessage": "请选择欲复制至的目录:",
|
||||||
"currentlyNavigating": "当前目录:",
|
"currentlyNavigating": "当前目录:",
|
||||||
"deleteMessageMultiple": "你确定要删除这 {count} 个文件吗?",
|
"deleteMessageMultiple": "你确定要删除这 {count} 个文件吗?",
|
||||||
"deleteMessageSingle": "你确定要删除这个文件/文件夹吗?",
|
"deleteMessageSingle": "你确定要删除这个文件/文件夹吗?",
|
||||||
"deleteTitle": "删除文件",
|
"deleteTitle": "删除文件",
|
||||||
"displayName": "名称:",
|
"displayName": "名称:",
|
||||||
"download": "下载文件",
|
"download": "下载文件",
|
||||||
@@ -112,31 +112,38 @@
|
|||||||
"replaceMessage": "您尝试上传的文件中有一个与现有文件的名称存在冲突。是否替换现有的同名文件?",
|
"replaceMessage": "您尝试上传的文件中有一个与现有文件的名称存在冲突。是否替换现有的同名文件?",
|
||||||
"rename": "重命名",
|
"rename": "重命名",
|
||||||
"renameMessage": "请输入新名称,旧名称为:",
|
"renameMessage": "请输入新名称,旧名称为:",
|
||||||
"show": "揭示",
|
"show": "点击以显示",
|
||||||
"size": "大小",
|
"size": "大小",
|
||||||
"schedule": "计划",
|
"schedule": "计划",
|
||||||
"scheduleMessage": "请选择发布这篇帖子的日期。",
|
"scheduleMessage": "请选择发布这篇帖子的日期。",
|
||||||
"newArchetype": "创建一个基于原型的新帖子。您的文件将会创建在内容文件夹中。"
|
"newArchetype": "创建一个基于原型的新帖子。您的文件将会创建在内容文件夹中。",
|
||||||
|
"upload": "上传",
|
||||||
|
"uploadMessage": "选择上传项。"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"instanceName": "Instance name",
|
"themes": {
|
||||||
|
"title": "主题",
|
||||||
|
"light": "浅色",
|
||||||
|
"dark": "深色"
|
||||||
|
},
|
||||||
|
"instanceName": "实例名称",
|
||||||
"brandingDirectoryPath": "品牌信息文件夹路径",
|
"brandingDirectoryPath": "品牌信息文件夹路径",
|
||||||
"documentation": "帮助文档",
|
"documentation": "帮助文档",
|
||||||
"branding": "品牌",
|
"branding": "品牌",
|
||||||
"disableExternalLinks": "禁止外部链接(帮助文档除外)",
|
"disableExternalLinks": "禁止外部链接(帮助文档除外)",
|
||||||
"brandingHelp": "您可以通过改变名称,更换商标,加入自定义样式,甚至禁用外部链接来自定义File Browser的外观和给人的感觉。\n想获得更多信息,请查看 {0} 。",
|
"brandingHelp": "您可以通过改变实例名称,更换Logo,加入自定义样式,甚至禁用到Github的外部链接来自定义File Browser的外观和给人的感觉。\n想获得更多信息,请查看 {0} 。",
|
||||||
"admin": "管理员",
|
"admin": "管理员",
|
||||||
"administrator": "管理员",
|
"administrator": "管理员",
|
||||||
"allowCommands": "执行命令(Linux 代码)",
|
"allowCommands": "执行命令(shell 命令)",
|
||||||
"allowEdit": "编辑、重命名或删除文件/目录",
|
"allowEdit": "编辑、重命名或删除文件/目录",
|
||||||
"allowNew": "创建新文件和目录",
|
"allowNew": "创建新文件和目录",
|
||||||
"allowPublish": "发布新的帖子与页面",
|
"allowPublish": "发布新的帖子与页面",
|
||||||
"avoidChanges": "(留空以避免更改)",
|
"avoidChanges": "(留空以避免更改)",
|
||||||
"changePassword": "更改密码",
|
"changePassword": "更改密码",
|
||||||
"commandRunner": "命令执行器",
|
"commandRunner": "命令执行器",
|
||||||
"commandRunnerHelp": "Here you can set commands that are executed in the named events. You must write one per line. The environment variables {0} and {1} will be available, being {0} relative to {1}. For more information about this feature and the available environment variables, please read the {2}.",
|
"commandRunnerHelp": "在这里你可以设置在下面的事件中执行的命令。每行必须写一条命令。可以在命令中使用环境变量 {0} 和 {1}。关于此功能和可用环境变量的更多信息,请阅读{2}.",
|
||||||
"commandsUpdated": "命令已更新!",
|
"commandsUpdated": "命令已更新!",
|
||||||
"customStylesheet": "自定义样式表",
|
"customStylesheet": "自定义样式表(CSS)",
|
||||||
"examples": "例子",
|
"examples": "例子",
|
||||||
"globalSettings": "全局设置",
|
"globalSettings": "全局设置",
|
||||||
"language": "语言",
|
"language": "语言",
|
||||||
@@ -149,15 +156,18 @@
|
|||||||
"permissions": "权限",
|
"permissions": "权限",
|
||||||
"permissionsHelp": "您可以将该用户设置为管理员,也可以单独选择各项权限。如果选择了“管理员”,则其他的选项会被自动勾上,同时该用户可以管理其他用户。",
|
"permissionsHelp": "您可以将该用户设置为管理员,也可以单独选择各项权限。如果选择了“管理员”,则其他的选项会被自动勾上,同时该用户可以管理其他用户。",
|
||||||
"profileSettings": "个人设置",
|
"profileSettings": "个人设置",
|
||||||
"ruleExample1": "阻止用户访问所有文件夹下任何以 . 开头的文件(隐藏文件, 例如: .git, .gitignore)。",
|
"shareManagement": "分享管理",
|
||||||
|
"path": "路径",
|
||||||
|
"shareDuration": "分享期限",
|
||||||
|
"ruleExample1": "阻止用户访问所有文件夹下任何以 . 开头的文件(隐藏文件, 例如: .git, .gitignore)。",
|
||||||
"ruleExample2": "阻止用户访问其目录范围的根目录下名为 Caddyfile 的文件。",
|
"ruleExample2": "阻止用户访问其目录范围的根目录下名为 Caddyfile 的文件。",
|
||||||
"rules": "规则",
|
"rules": "规则",
|
||||||
"rulesHelp": "您可以为该用户制定一组黑名单或白名单式的规则,被屏蔽的文件将不会显示在列表中,用户也无权限访问,支持相对于目录范围的路径。",
|
"rulesHelp": "您可以为该用户制定一组黑名单或白名单式的规则,被屏蔽的文件将不会显示在列表中,用户也无权限访问,支持相对于目录范围的路径。",
|
||||||
"scope": "目录范围",
|
"scope": "目录范围",
|
||||||
"settingsUpdated": "设置已更新!",
|
"settingsUpdated": "设置已更新!",
|
||||||
"user": "用户",
|
"user": "用户",
|
||||||
"userCommands": "用户命令(Linux 代码)",
|
"userCommands": "用户命令(shell 命令)",
|
||||||
"userCommandsHelp": "指定该用户可以执行的命令(Linux 代码),用空格分隔。例如:",
|
"userCommandsHelp": "指定该用户可以执行的命令(shell 代码),用空格分隔。例如:",
|
||||||
"userCreated": "用户已创建!",
|
"userCreated": "用户已创建!",
|
||||||
"userDeleted": "用户已删除!",
|
"userDeleted": "用户已删除!",
|
||||||
"userManagement": "用户管理",
|
"userManagement": "用户管理",
|
||||||
@@ -167,12 +177,12 @@
|
|||||||
"allowSignup": "允许用户注册",
|
"allowSignup": "允许用户注册",
|
||||||
"createUserDir": "在添加新用户的同时自动创建用户的个人目录",
|
"createUserDir": "在添加新用户的同时自动创建用户的个人目录",
|
||||||
"insertRegex": "插入正则表达式",
|
"insertRegex": "插入正则表达式",
|
||||||
"insertPath": "Insert the path",
|
"insertPath": "插入路径",
|
||||||
"userUpdated": "用户已更新!",
|
"userUpdated": "用户已更新!",
|
||||||
"userDefaults": "用户默认设置",
|
"userDefaults": "用户默认设置",
|
||||||
"defaultUserDescription": "这些是新用户的默认设置",
|
"defaultUserDescription": "这些是新用户的默认设置。",
|
||||||
"executeOnShell": "在Shell中执行",
|
"executeOnShell": "在Shell中执行",
|
||||||
"executeOnShellDescription": "By default, File Browser executes the commands by calling their binaries directly. If you want to run them on a shell instead (such as Bash or PowerShell), you can define it here with the required arguments and flags. If set, the command you execute will be appended as an argument. This apply to both user commands and event hooks.",
|
"executeOnShellDescription": "默认情况下,File Browser通过直接调用命令的二进制包来执行命令,如果想在shell中执行(如Bash、PowerShell),你可以在这里定义所使用的shell和参数。如果设置了这个选项,所执行的命令会作为参数追加在后面。本选项对用户命令和事件钩子都生效。",
|
||||||
"perm": {
|
"perm": {
|
||||||
"create": "创建文件和文件夹",
|
"create": "创建文件和文件夹",
|
||||||
"delete": "删除文件和文件夹",
|
"delete": "删除文件和文件夹",
|
||||||
@@ -209,18 +219,22 @@
|
|||||||
"languages": {
|
"languages": {
|
||||||
"ar": "العربية",
|
"ar": "العربية",
|
||||||
"en": "English",
|
"en": "English",
|
||||||
|
"is": "Icelandic",
|
||||||
"it": "Italiano",
|
"it": "Italiano",
|
||||||
"fr": "Français",
|
"fr": "Français",
|
||||||
"pt": "Português",
|
"pt": "Português",
|
||||||
"ptBR": "Português (Brasil)",
|
"ptBR": "Português(Brasil)",
|
||||||
"ja": "日本語",
|
"ja": "日本語",
|
||||||
"zhCN": "中文 (简体)",
|
"zhCN": "中文(简体)",
|
||||||
"zhTW": "中文 (繁體)",
|
"zhTW": "中文(繁體)",
|
||||||
"es": "Español",
|
"es": "Español",
|
||||||
"de": "Deutsch",
|
"de": "Deutsch",
|
||||||
"ru": "Русский",
|
"ru": "Русский",
|
||||||
"pl": "Polski",
|
"pl": "Polski",
|
||||||
"ko": "한국어"
|
"ko": "한국어",
|
||||||
|
"nlBE": "Dutch(Belgium)",
|
||||||
|
"ro": "Romanian",
|
||||||
|
"svSE": "Swedish(Sweden)"
|
||||||
},
|
},
|
||||||
"time": {
|
"time": {
|
||||||
"unit": "时间单位",
|
"unit": "时间单位",
|
||||||
@@ -231,6 +245,7 @@
|
|||||||
},
|
},
|
||||||
"download": {
|
"download": {
|
||||||
"downloadFile": "下载文件",
|
"downloadFile": "下载文件",
|
||||||
"downloadFolder": "下载文件夹"
|
"downloadFolder": "下载文件夹",
|
||||||
|
"downloadSelected": "下载已选"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,15 +116,22 @@
|
|||||||
"size": "大小",
|
"size": "大小",
|
||||||
"schedule": "計畫",
|
"schedule": "計畫",
|
||||||
"scheduleMessage": "請選擇發佈這篇貼文的日期。",
|
"scheduleMessage": "請選擇發佈這篇貼文的日期。",
|
||||||
"newArchetype": "建立一個基於原型的新貼文。您的檔案將會建立在內容資料夾中。"
|
"newArchetype": "建立一個基於原型的新貼文。您的檔案將會建立在內容資料夾中。",
|
||||||
|
"upload": "上傳",
|
||||||
|
"uploadMessage": "選擇上傳項。"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"instanceName": "Instance name",
|
"themes": {
|
||||||
"brandingDirectoryPath": "Branding directory path",
|
"title": "主題",
|
||||||
"documentation": "documentation",
|
"light": "淺色",
|
||||||
"branding": "Branding",
|
"dark": "深色"
|
||||||
"disableExternalLinks": "Disable external links (except documentation)",
|
},
|
||||||
"brandingHelp": "You can costumize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
|
"instanceName": "例項名稱",
|
||||||
|
"brandingDirectoryPath": "品牌資訊資料夾路徑",
|
||||||
|
"documentation": "幫助文件",
|
||||||
|
"branding": "品牌",
|
||||||
|
"disableExternalLinks": "禁止外部連結(幫助文件除外)",
|
||||||
|
"brandingHelp": "您可以通過改變例項名稱,更換Logo,加入自定義樣式,甚至禁用到Github的外部連結來自定義File Browser的外觀和給人的感覺。\n想獲得更多資訊,請檢視 {0} 。",
|
||||||
"admin": "管理員",
|
"admin": "管理員",
|
||||||
"administrator": "管理員",
|
"administrator": "管理員",
|
||||||
"allowCommands": "執行命令",
|
"allowCommands": "執行命令",
|
||||||
@@ -133,8 +140,8 @@
|
|||||||
"allowPublish": "發佈新的貼文與頁面",
|
"allowPublish": "發佈新的貼文與頁面",
|
||||||
"avoidChanges": "(留空以避免更改)",
|
"avoidChanges": "(留空以避免更改)",
|
||||||
"changePassword": "更改密碼",
|
"changePassword": "更改密碼",
|
||||||
"commandRunner": "Command runner",
|
"commandRunner": "命令執行器",
|
||||||
"commandRunnerHelp": "Here you can set commands that are executed in the named events. You must write one per line. The environment variables {0} and {1} will be available, being {0} relative to {1}. For more information about this feature and the available environment variables, please read the {2}.",
|
"commandRunnerHelp": "在這裡你可以設定在下面的事件中執行的命令。每行必須寫一條命令。可以在命令中使用環境變數 {0} 和 {1}。關於此功能和可用環境變數的更多資訊,請閱讀{2}.",
|
||||||
"commandsUpdated": "命令已更新!",
|
"commandsUpdated": "命令已更新!",
|
||||||
"customStylesheet": "自定義樣式表",
|
"customStylesheet": "自定義樣式表",
|
||||||
"examples": "範例",
|
"examples": "範例",
|
||||||
@@ -163,22 +170,22 @@
|
|||||||
"userManagement": "使用者管理",
|
"userManagement": "使用者管理",
|
||||||
"username": "使用者名稱",
|
"username": "使用者名稱",
|
||||||
"users": "使用者",
|
"users": "使用者",
|
||||||
"globalRules": "This is a global set of allow and disallow rules. They apply to every user. You can define specific rules on each user's settings to override this ones.",
|
"globalRules": "這是全局允許與禁止規則。它們作用於所有使用者。您可以給每個使用者定義單獨的特殊規則來覆蓋全局規則。",
|
||||||
"allowSignup": "Allow users to signup",
|
"allowSignup": "允許使用者註冊",
|
||||||
"createUserDir": "Auto create user home dir while adding new user",
|
"createUserDir": "在新增新使用者的同時自動建立使用者的個人目錄",
|
||||||
"insertRegex": "Insert regex expression",
|
"insertRegex": "插入正規表示式",
|
||||||
"insertPath": "Insert the path",
|
"insertPath": "插入路徑",
|
||||||
"userUpdated": "使用者已更新!",
|
"userUpdated": "使用者已更新!",
|
||||||
"userDefaults": "User default settings",
|
"userDefaults": "使用者預設選項",
|
||||||
"defaultUserDescription": "This are the default settings for new users.",
|
"defaultUserDescription": "這些是新使用者的預設設定。",
|
||||||
"executeOnShell": "Execute on shell",
|
"executeOnShell": "在Shell中執行",
|
||||||
"executeOnShellDescription": "By default, File Browser executes the commands by calling their binaries directly. If you want to run them on a shell instead (such as Bash or PowerShell), you can define it here with the required arguments and flags. If set, the command you execute will be appended as an argument. This apply to both user commands and event hooks.",
|
"executeOnShellDescription": "預設情況下,File Browser通過直接呼叫命令的二進位制包來執行命令,如果想在shell中執行(如Bash、PowerShell),你可以在這裡定義所使用的shell和參數。如果設定了這個選項,所執行的命令會作為參數追加在後面。本選項對使用者命令和事件鉤子都生效。",
|
||||||
"perm": {
|
"perm": {
|
||||||
"create": "建立檔案和資料夾",
|
"create": "建立檔案和資料夾",
|
||||||
"delete": "刪除檔案和資料夾",
|
"delete": "刪除檔案和資料夾",
|
||||||
"download": "下載",
|
"download": "下載",
|
||||||
"modify": "編輯檔案",
|
"modify": "編輯檔案",
|
||||||
"execute": "Execute commands",
|
"execute": "執行命令",
|
||||||
"rename": "重命名或移動檔案/資料夾",
|
"rename": "重命名或移動檔案/資料夾",
|
||||||
"share": "分享檔案"
|
"share": "分享檔案"
|
||||||
}
|
}
|
||||||
@@ -203,12 +210,13 @@
|
|||||||
"types": "類型",
|
"types": "類型",
|
||||||
"video": "影片",
|
"video": "影片",
|
||||||
"search": "搜尋...",
|
"search": "搜尋...",
|
||||||
"typeToSearch": "Type to search...",
|
"typeToSearch": "輸入以搜尋...",
|
||||||
"pressToSearch": "Press enter to search..."
|
"pressToSearch": "按確認鍵搜尋..."
|
||||||
},
|
},
|
||||||
"languages": {
|
"languages": {
|
||||||
"ar": "العربية",
|
"ar": "العربية",
|
||||||
"en": "English",
|
"en": "English",
|
||||||
|
"is": "Icelandic",
|
||||||
"it": "Italiano",
|
"it": "Italiano",
|
||||||
"fr": "Français",
|
"fr": "Français",
|
||||||
"pt": "Português",
|
"pt": "Português",
|
||||||
@@ -220,7 +228,10 @@
|
|||||||
"de": "Deutsch",
|
"de": "Deutsch",
|
||||||
"ru": "Русский",
|
"ru": "Русский",
|
||||||
"pl": "Polski",
|
"pl": "Polski",
|
||||||
"ko": "한국어"
|
"ko": "한국어",
|
||||||
|
"nlBE": "Dutch(Belgium)",
|
||||||
|
"ro": "Romanian",
|
||||||
|
"svSE": "Swedish(Sweden)"
|
||||||
},
|
},
|
||||||
"time": {
|
"time": {
|
||||||
"unit": "時間單位",
|
"unit": "時間單位",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import User from '@/views/settings/User'
|
|||||||
import Settings from '@/views/Settings'
|
import Settings from '@/views/Settings'
|
||||||
import GlobalSettings from '@/views/settings/Global'
|
import GlobalSettings from '@/views/settings/Global'
|
||||||
import ProfileSettings from '@/views/settings/Profile'
|
import ProfileSettings from '@/views/settings/Profile'
|
||||||
|
import Shares from '@/views/settings/Shares'
|
||||||
import Error403 from '@/views/errors/403'
|
import Error403 from '@/views/errors/403'
|
||||||
import Error404 from '@/views/errors/404'
|
import Error404 from '@/views/errors/404'
|
||||||
import Error500 from '@/views/errors/500'
|
import Error500 from '@/views/errors/500'
|
||||||
@@ -67,6 +68,11 @@ const router = new Router({
|
|||||||
name: 'Profile Settings',
|
name: 'Profile Settings',
|
||||||
component: ProfileSettings
|
component: ProfileSettings
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/settings/shares',
|
||||||
|
name: 'Shares',
|
||||||
|
component: Shares
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/settings/global',
|
path: '/settings/global',
|
||||||
name: 'Global Settings',
|
name: 'Global Settings',
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ const getters = {
|
|||||||
isFiles: state => !state.loading && state.route.name === 'Files',
|
isFiles: state => !state.loading && state.route.name === 'Files',
|
||||||
isListing: (state, getters) => getters.isFiles && state.req.isDir,
|
isListing: (state, getters) => getters.isFiles && state.req.isDir,
|
||||||
isEditor: (state, getters) => getters.isFiles && (state.req.type === 'text' || state.req.type === 'textImmutable'),
|
isEditor: (state, getters) => getters.isFiles && (state.req.type === 'text' || state.req.type === 'textImmutable'),
|
||||||
|
isPreview: state => state.previewMode,
|
||||||
|
isSharing: state => !state.loading && state.route.name === 'Share',
|
||||||
selectedCount: state => state.selected.length,
|
selectedCount: state => state.selected.length,
|
||||||
progress : state => {
|
progress : state => {
|
||||||
if (state.upload.progress.length == 0) {
|
if (state.upload.progress.length == 0) {
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ const state = {
|
|||||||
showShell: false,
|
showShell: false,
|
||||||
showMessage: null,
|
showMessage: null,
|
||||||
showConfirm: null,
|
showConfirm: null,
|
||||||
previewMode: false
|
previewMode: false,
|
||||||
|
hash: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ const mutations = {
|
|||||||
},
|
},
|
||||||
setPreviewMode(state, value) {
|
setPreviewMode(state, value) {
|
||||||
state.previewMode = value
|
state.previewMode = value
|
||||||
}
|
},
|
||||||
|
setHash: (state, value) => (state.hash = value),
|
||||||
}
|
}
|
||||||
|
|
||||||
export default mutations
|
export default mutations
|
||||||
@@ -12,6 +12,8 @@ const authMethod = window.FileBrowser.AuthMethod
|
|||||||
const loginPage = window.FileBrowser.LoginPage
|
const loginPage = window.FileBrowser.LoginPage
|
||||||
const theme = window.FileBrowser.Theme
|
const theme = window.FileBrowser.Theme
|
||||||
const enableThumbs = window.FileBrowser.EnableThumbs
|
const enableThumbs = window.FileBrowser.EnableThumbs
|
||||||
|
const resizePreview = window.FileBrowser.ResizePreview
|
||||||
|
const enableExec = window.FileBrowser.EnableExec
|
||||||
|
|
||||||
export {
|
export {
|
||||||
name,
|
name,
|
||||||
@@ -26,5 +28,7 @@ export {
|
|||||||
authMethod,
|
authMethod,
|
||||||
loginPage,
|
loginPage,
|
||||||
theme,
|
theme,
|
||||||
enableThumbs
|
enableThumbs,
|
||||||
|
resizePreview,
|
||||||
|
enableExec
|
||||||
}
|
}
|
||||||
@@ -96,31 +96,25 @@ export function scanFiles(dt) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleFiles(files, path, overwrite = false) {
|
export function handleFiles(files, base, overwrite = false) {
|
||||||
for (let i = 0; i < files.length; i++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
let id = store.state.upload.id
|
||||||
|
let path = base
|
||||||
let file = files[i]
|
let file = files[i]
|
||||||
|
|
||||||
let filename = (file.fullPath !== undefined) ? file.fullPath : file.name
|
if (file.fullPath !== undefined) {
|
||||||
let filenameEncoded = url.encodeRFC5987ValueChars(filename)
|
path += url.encodePath(file.fullPath)
|
||||||
|
} else {
|
||||||
let id = store.state.upload.id
|
path += url.encodeRFC5987ValueChars(file.name)
|
||||||
|
}
|
||||||
let itemPath = path + filenameEncoded
|
|
||||||
|
|
||||||
if (file.isDir) {
|
if (file.isDir) {
|
||||||
itemPath = path
|
path += '/'
|
||||||
let folders = file.fullPath.split("/")
|
|
||||||
|
|
||||||
for (let i = 0; i < folders.length; i++) {
|
|
||||||
let folder = folders[i]
|
|
||||||
let folderEncoded = encodeURIComponent(folder)
|
|
||||||
itemPath += folderEncoded + "/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const item = {
|
const item = {
|
||||||
id,
|
id,
|
||||||
path: itemPath,
|
path,
|
||||||
file,
|
file,
|
||||||
overwrite
|
overwrite
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<sidebar></sidebar>
|
<sidebar></sidebar>
|
||||||
<main>
|
<main>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
<shell v-if="isLogged && user.perm.execute" />
|
<shell v-if="isExecEnabled && isLogged && user.perm.execute" />
|
||||||
</main>
|
</main>
|
||||||
<prompts></prompts>
|
<prompts></prompts>
|
||||||
</div>
|
</div>
|
||||||
@@ -19,6 +19,7 @@ import Sidebar from '@/components/Sidebar'
|
|||||||
import Prompts from '@/components/prompts/Prompts'
|
import Prompts from '@/components/prompts/Prompts'
|
||||||
import SiteHeader from '@/components/Header'
|
import SiteHeader from '@/components/Header'
|
||||||
import Shell from '@/components/Shell'
|
import Shell from '@/components/Shell'
|
||||||
|
import { enableExec } from '@/utils/constants'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'layout',
|
name: 'layout',
|
||||||
@@ -30,7 +31,8 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([ 'isLogged', 'progress' ]),
|
...mapGetters([ 'isLogged', 'progress' ]),
|
||||||
...mapState([ 'user' ])
|
...mapState([ 'user' ]),
|
||||||
|
isExecEnabled: () => enableExec
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'$route': function () {
|
'$route': function () {
|
||||||
|
|||||||
@@ -41,8 +41,10 @@ export default {
|
|||||||
mounted () {
|
mounted () {
|
||||||
if (!recaptcha) return
|
if (!recaptcha) return
|
||||||
|
|
||||||
window.grecaptcha.render('recaptcha', {
|
window.grecaptcha.ready(function () {
|
||||||
sitekey: recaptchaKey
|
window.grecaptcha.render('recaptcha', {
|
||||||
|
sitekey: recaptchaKey
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="dashboard">
|
<div class="dashboard">
|
||||||
<ul id="nav" v-if="user.perm.admin">
|
<ul id="nav">
|
||||||
<li :class="{ active: $route.path === '/settings/profile' }"><router-link to="/settings/profile">{{ $t('settings.profileSettings') }}</router-link></li>
|
<li :class="{ active: $route.path === '/settings/profile' }"><router-link to="/settings/profile">{{ $t('settings.profileSettings') }}</router-link></li>
|
||||||
<li :class="{ active: $route.path === '/settings/global' }"><router-link to="/settings/global">{{ $t('settings.globalSettings') }}</router-link></li>
|
<li :class="{ active: $route.path === '/settings/shares' }"><router-link to="/settings/shares">{{ $t('settings.shareManagement') }}</router-link></li>
|
||||||
<li :class="{ active: $route.path === '/settings/users' }"><router-link to="/settings/users">{{ $t('settings.userManagement') }}</router-link></li>
|
<li v-if="user.perm.admin" :class="{ active: $route.path === '/settings/global' }"><router-link to="/settings/global">{{ $t('settings.globalSettings') }}</router-link></li>
|
||||||
|
<li v-if="user.perm.admin" :class="{ active: $route.path === '/settings/users' }"><router-link to="/settings/users">{{ $t('settings.userManagement') }}</router-link></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
|
|||||||
+185
-28
@@ -1,66 +1,223 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="share" v-if="loaded">
|
<div v-if="!loading">
|
||||||
<a target="_blank" :href="link">
|
<div id="breadcrumbs">
|
||||||
<div class="share__box">
|
<router-link :to="'/share/' + hash" :aria-label="$t('files.home')" :title="$t('files.home')">
|
||||||
<div class="share__box__download" v-if="file.isDir">{{ $t('download.downloadFolder') }}</div>
|
<i class="material-icons">home</i>
|
||||||
<div class="share__box__download" v-else>{{ $t('download.downloadFile') }}</div>
|
</router-link>
|
||||||
<div class="share__box__info">
|
|
||||||
<svg v-if="file.isDir" fill="#40c4ff" height="150" viewBox="0 0 24 24" width="150" xmlns="http://www.w3.org/2000/svg">
|
<span v-for="(link, index) in breadcrumbs" :key="index">
|
||||||
<path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"/>
|
<span class="chevron"><i class="material-icons">keyboard_arrow_right</i></span>
|
||||||
<path d="M0 0h24v24H0z" fill="none"/>
|
<router-link :to="link.url">{{ link.name }}</router-link>
|
||||||
</svg>
|
</span>
|
||||||
<svg v-else fill="#40c4ff" height="150" viewBox="0 0 24 24" width="150" xmlns="http://www.w3.org/2000/svg">
|
</div>
|
||||||
<path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"/>
|
<div class="share">
|
||||||
<path d="M0 0h24v24H0z" fill="none"/>
|
<div class="share__box share__box__info">
|
||||||
</svg>
|
<div class="share__box__header">
|
||||||
<h1 class="share__box__title">{{ file.name }}</h1>
|
{{ req.isDir ? $t('download.downloadFolder') : $t('download.downloadFile') }}
|
||||||
<qrcode-vue :value="fullLink" size="200" level="M"></qrcode-vue>
|
</div>
|
||||||
|
<div class="share__box__element share__box__center share__box__icon">
|
||||||
|
<i class="material-icons">{{ icon }}</i>
|
||||||
|
</div>
|
||||||
|
<div class="share__box__element">
|
||||||
|
<strong>{{ $t('prompts.displayName') }}</strong> {{ req.name }}
|
||||||
|
</div>
|
||||||
|
<div class="share__box__element">
|
||||||
|
<strong>{{ $t('prompts.lastModified') }}:</strong> {{ humanTime }}
|
||||||
|
</div>
|
||||||
|
<div class="share__box__element">
|
||||||
|
<strong>{{ $t('prompts.size') }}:</strong> {{ humanSize }}
|
||||||
|
</div>
|
||||||
|
<div class="share__box__element share__box__center">
|
||||||
|
<a target="_blank" :href="link" class="button button--flat">{{ $t('buttons.download') }}</a>
|
||||||
|
</div>
|
||||||
|
<div class="share__box__element share__box__center">
|
||||||
|
<qrcode-vue :value="fullLink" size="200" level="M"></qrcode-vue>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="req.isDir && req.items.length > 0" class="share__box share__box__items">
|
||||||
|
<div class="share__box__header" v-if="req.isDir">
|
||||||
|
{{ $t('files.files') }}
|
||||||
|
</div>
|
||||||
|
<div id="listing" class="list">
|
||||||
|
<item v-for="(item) in req.items.slice(0, this.showLimit)"
|
||||||
|
:key="base64(item.name)"
|
||||||
|
v-bind:index="item.index"
|
||||||
|
v-bind:name="item.name"
|
||||||
|
v-bind:isDir="item.isDir"
|
||||||
|
v-bind:url="item.url"
|
||||||
|
v-bind:modified="item.modified"
|
||||||
|
v-bind:type="item.type"
|
||||||
|
v-bind:size="item.size">
|
||||||
|
</item>
|
||||||
|
<div v-if="req.items.length > showLimit" class="item">
|
||||||
|
<div>
|
||||||
|
<p class="name"> + {{ req.items.length - showLimit }} </p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div :class="{ active: $store.state.multiple }" id="multiple-selection">
|
||||||
|
<p>{{ $t('files.multipleSelectionEnabled') }}</p>
|
||||||
|
<div @click="$store.commit('multiple', false)" tabindex="0" role="button" :title="$t('files.clear')" :aria-label="$t('files.clear')" class="action">
|
||||||
|
<i class="material-icons">clear</i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
<div v-else-if="req.isDir && req.items.length === 0" class="share__box share__box__items">
|
||||||
|
<h2 class="message">
|
||||||
|
<i class="material-icons">sentiment_dissatisfied</i>
|
||||||
|
<span>{{ $t('files.lonely') }}</span>
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="error">
|
||||||
|
<not-found v-if="error.message === '404'"></not-found>
|
||||||
|
<forbidden v-else-if="error.message === '403'"></forbidden>
|
||||||
|
<internal-error v-else></internal-error>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {mapState, mapMutations, mapGetters} from 'vuex';
|
||||||
import { share as api } from '@/api'
|
import { share as api } from '@/api'
|
||||||
import { baseURL } from '@/utils/constants'
|
import { baseURL } from '@/utils/constants'
|
||||||
|
import filesize from 'filesize'
|
||||||
|
import moment from 'moment'
|
||||||
import QrcodeVue from 'qrcode.vue'
|
import QrcodeVue from 'qrcode.vue'
|
||||||
|
import Item from "@/components/files/ListingItem"
|
||||||
|
import Forbidden from './errors/403'
|
||||||
|
import NotFound from './errors/404'
|
||||||
|
import InternalError from './errors/500'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'share',
|
name: 'share',
|
||||||
components: {
|
components: {
|
||||||
|
Item,
|
||||||
|
Forbidden,
|
||||||
|
NotFound,
|
||||||
|
InternalError,
|
||||||
QrcodeVue
|
QrcodeVue
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
loaded: false,
|
error: null,
|
||||||
notFound: false,
|
path: '',
|
||||||
file: null
|
showLimit: 500
|
||||||
}),
|
}),
|
||||||
watch: {
|
watch: {
|
||||||
'$route': 'fetchData'
|
'$route': 'fetchData'
|
||||||
},
|
},
|
||||||
created: function () {
|
created: async function () {
|
||||||
this.fetchData()
|
const hash = this.$route.params.pathMatch.split('/')[0]
|
||||||
|
this.setHash(hash)
|
||||||
|
await this.fetchData()
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
window.addEventListener('keydown', this.keyEvent)
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
window.removeEventListener('keydown', this.keyEvent)
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
hash: function () {
|
...mapState(['hash', 'req', 'loading', 'multiple']),
|
||||||
return this.$route.params.pathMatch
|
...mapGetters(['selectedCount']),
|
||||||
|
icon: function () {
|
||||||
|
if (this.req.isDir) return 'folder'
|
||||||
|
if (this.req.type === 'image') return 'insert_photo'
|
||||||
|
if (this.req.type === 'audio') return 'volume_up'
|
||||||
|
if (this.req.type === 'video') return 'movie'
|
||||||
|
return 'insert_drive_file'
|
||||||
},
|
},
|
||||||
link: function () {
|
link: function () {
|
||||||
return `${baseURL}/api/public/dl/${this.hash}/${encodeURI(this.file.name)}`
|
return `${baseURL}/api/public/dl/${this.hash}${this.path}`
|
||||||
},
|
},
|
||||||
fullLink: function () {
|
fullLink: function () {
|
||||||
return window.location.origin + this.link
|
return window.location.origin + this.link
|
||||||
},
|
},
|
||||||
|
humanSize: function () {
|
||||||
|
if (this.req.isDir) {
|
||||||
|
return this.req.items.length
|
||||||
|
}
|
||||||
|
|
||||||
|
return filesize(this.req.size)
|
||||||
|
},
|
||||||
|
humanTime: function () {
|
||||||
|
return moment(this.req.modified).fromNow()
|
||||||
|
},
|
||||||
|
breadcrumbs () {
|
||||||
|
let parts = this.path.split('/')
|
||||||
|
|
||||||
|
if (parts[0] === '') {
|
||||||
|
parts.shift()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parts[parts.length - 1] === '') {
|
||||||
|
parts.pop()
|
||||||
|
}
|
||||||
|
|
||||||
|
let breadcrumbs = []
|
||||||
|
|
||||||
|
for (let i = 0; i < parts.length; i++) {
|
||||||
|
if (i === 0) {
|
||||||
|
breadcrumbs.push({ name: decodeURIComponent(parts[i]), url: '/share/' + this.hash + '/' + parts[i] + '/' })
|
||||||
|
} else {
|
||||||
|
breadcrumbs.push({ name: decodeURIComponent(parts[i]), url: breadcrumbs[i - 1].url + parts[i] + '/' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (breadcrumbs.length > 3) {
|
||||||
|
while (breadcrumbs.length !== 4) {
|
||||||
|
breadcrumbs.shift()
|
||||||
|
}
|
||||||
|
|
||||||
|
breadcrumbs[0].name = '...'
|
||||||
|
}
|
||||||
|
|
||||||
|
return breadcrumbs
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapMutations([ 'setHash', 'resetSelected', 'updateRequest', 'setLoading' ]),
|
||||||
|
base64: function (name) {
|
||||||
|
return window.btoa(unescape(encodeURIComponent(name)))
|
||||||
|
},
|
||||||
fetchData: async function () {
|
fetchData: async function () {
|
||||||
|
// Reset view information.
|
||||||
|
this.$store.commit('setReload', false)
|
||||||
|
this.$store.commit('resetSelected')
|
||||||
|
this.$store.commit('multiple', false)
|
||||||
|
this.$store.commit('closeHovers')
|
||||||
|
|
||||||
|
// Set loading to true and reset the error.
|
||||||
|
this.setLoading(true)
|
||||||
|
this.error = null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.file = await api.getHash(this.hash)
|
let file = await api.getHash(encodeURIComponent(this.$route.params.pathMatch))
|
||||||
this.loaded = true
|
this.path = file.path
|
||||||
|
if (file.isDir) file.items = file.items.map((item, index) => {
|
||||||
|
item.index = index
|
||||||
|
item.url = `/share/${this.hash}${this.path}/${encodeURIComponent(item.name)}`
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
this.updateRequest(file)
|
||||||
|
this.setLoading(false)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.notFound = true
|
this.error = e
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
keyEvent (event) {
|
||||||
|
// Esc!
|
||||||
|
if (event.keyCode === 27) {
|
||||||
|
// If we're on a listing, unselect all
|
||||||
|
// files and folders.
|
||||||
|
if (this.selectedCount > 0) {
|
||||||
|
this.resetSelected()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleMultipleSelection () {
|
||||||
|
this.$store.commit('multiple', !this.multiple)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,11 @@
|
|||||||
<p class="small">{{ $t('settings.globalRules') }}</p>
|
<p class="small">{{ $t('settings.globalRules') }}</p>
|
||||||
<rules :rules.sync="settings.rules" />
|
<rules :rules.sync="settings.rules" />
|
||||||
|
|
||||||
<h3>{{ $t('settings.executeOnShell') }}</h3>
|
<div v-if="isExecEnabled">
|
||||||
<p class="small">{{ $t('settings.executeOnShellDescription') }}</p>
|
<h3>{{ $t('settings.executeOnShell') }}</h3>
|
||||||
<input class="input input--block" type="text" placeholder="bash -c, cmd /c, ..." v-model="settings.shell" />
|
<p class="small">{{ $t('settings.executeOnShellDescription') }}</p>
|
||||||
|
<input class="input input--block" type="text" placeholder="bash -c, cmd /c, ..." v-model="settings.shell" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3>{{ $t('settings.branding') }}</h3>
|
<h3>{{ $t('settings.branding') }}</h3>
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form class="card" @submit.prevent="save">
|
<form v-if="isExecEnabled" class="card" @submit.prevent="save">
|
||||||
<div class="card-title">
|
<div class="card-title">
|
||||||
<h2>{{ $t('settings.commandRunner') }}</h2>
|
<h2>{{ $t('settings.commandRunner') }}</h2>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,6 +106,7 @@ import { settings as api } from '@/api'
|
|||||||
import UserForm from '@/components/settings/UserForm'
|
import UserForm from '@/components/settings/UserForm'
|
||||||
import Rules from '@/components/settings/Rules'
|
import Rules from '@/components/settings/Rules'
|
||||||
import Themes from '@/components/settings/Themes'
|
import Themes from '@/components/settings/Themes'
|
||||||
|
import { enableExec } from '@/utils/constants'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
@@ -119,7 +122,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([ 'user' ])
|
...mapState([ 'user' ]),
|
||||||
|
isExecEnabled: () => enableExec
|
||||||
},
|
},
|
||||||
async created () {
|
async created () {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
<p><input type="checkbox" v-model="hideDotfiles"> {{ $t('settings.hideDotfiles') }}</p>
|
||||||
<h3>{{ $t('settings.language') }}</h3>
|
<h3>{{ $t('settings.language') }}</h3>
|
||||||
<languages class="input input--block" :locale.sync="locale"></languages>
|
<languages class="input input--block" :locale.sync="locale"></languages>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,6 +68,7 @@ export default {
|
|||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.locale = this.user.locale
|
this.locale = this.user.locale
|
||||||
|
this.hideDotfiles = this.user.hideDotfiles
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations([ 'updateUser' ]),
|
...mapMutations([ 'updateUser' ]),
|
||||||
@@ -90,8 +92,8 @@ export default {
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = { id: this.user.id, locale: this.locale }
|
const data = { id: this.user.id, locale: this.locale, hideDotfiles: this.hideDotfiles }
|
||||||
await api.update(data, ['locale'])
|
await api.update(data, ['locale', 'hideDotfiles'])
|
||||||
this.updateUser(data)
|
this.updateUser(data)
|
||||||
this.$showSuccess(this.$t('settings.settingsUpdated'))
|
this.$showSuccess(this.$t('settings.settingsUpdated'))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<template>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-title">
|
||||||
|
<h2>{{ $t('settings.shareManagement') }}</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-content full">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>{{ $t('settings.path') }}</th>
|
||||||
|
<th>{{ $t('settings.shareDuration') }}</th>
|
||||||
|
<th v-if="user.perm.admin">{{ $t('settings.username') }}</th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr v-for="link in links" :key="link.hash">
|
||||||
|
<td><a :href="buildLink(link.hash)" target="_blank">{{ link.path }}</a></td>
|
||||||
|
<td>
|
||||||
|
<template v-if="link.expire !== 0">{{ humanTime(link.expire) }}</template>
|
||||||
|
<template v-else>{{ $t('permanent') }}</template>
|
||||||
|
</td>
|
||||||
|
<td v-if="user.perm.admin">{{ link.username }}</td>
|
||||||
|
<td class="small">
|
||||||
|
<button class="action"
|
||||||
|
@click="deleteLink($event, link)"
|
||||||
|
:aria-label="$t('buttons.delete')"
|
||||||
|
:title="$t('buttons.delete')"><i class="material-icons">delete</i></button>
|
||||||
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<button class="action copy-clipboard"
|
||||||
|
:data-clipboard-text="buildLink(link.hash)"
|
||||||
|
:aria-label="$t('buttons.copyToClipboard')"
|
||||||
|
:title="$t('buttons.copyToClipboard')"><i class="material-icons">content_paste</i></button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { share as api, users } from '@/api'
|
||||||
|
import moment from 'moment'
|
||||||
|
import {baseURL} from "@/utils/constants"
|
||||||
|
import Clipboard from 'clipboard'
|
||||||
|
import {mapState} from "vuex";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'shares',
|
||||||
|
computed: mapState([ 'user' ]),
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
links: [],
|
||||||
|
clip: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async created () {
|
||||||
|
try {
|
||||||
|
let links = await api.list()
|
||||||
|
if (this.user.perm.admin) {
|
||||||
|
let userMap = new Map()
|
||||||
|
for (let user of await users.getAll()) userMap.set(user.id, user.username)
|
||||||
|
for (let link of links) link.username = userMap.has(link.userID) ? userMap.get(link.userID) : ''
|
||||||
|
}
|
||||||
|
this.links = links
|
||||||
|
} catch (e) {
|
||||||
|
this.$showError(e)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.clip = new Clipboard('.copy-clipboard')
|
||||||
|
this.clip.on('success', () => {
|
||||||
|
this.$showSuccess(this.$t('success.linkCopied'))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
this.clip.destroy()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
deleteLink: async function (event, link) {
|
||||||
|
event.preventDefault()
|
||||||
|
try {
|
||||||
|
await api.remove(link.hash)
|
||||||
|
this.links = this.links.filter(item => item.hash !== link.hash)
|
||||||
|
} catch (e) {
|
||||||
|
this.$showError(e)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
humanTime (time) {
|
||||||
|
return moment(time * 1000).fromNow()
|
||||||
|
},
|
||||||
|
buildLink (hash) {
|
||||||
|
return `${window.location.origin}${baseURL}/share/${hash}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -23,9 +23,11 @@ type userInfo struct {
|
|||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
Locale string `json:"locale"`
|
Locale string `json:"locale"`
|
||||||
ViewMode users.ViewMode `json:"viewMode"`
|
ViewMode users.ViewMode `json:"viewMode"`
|
||||||
|
SingleClick bool `json:"singleClick"`
|
||||||
Perm users.Permissions `json:"perm"`
|
Perm users.Permissions `json:"perm"`
|
||||||
Commands []string `json:"commands"`
|
Commands []string `json:"commands"`
|
||||||
LockPassword bool `json:"lockPassword"`
|
LockPassword bool `json:"lockPassword"`
|
||||||
|
HideDotfiles bool `json:"hideDotfiles"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type authToken struct {
|
type authToken struct {
|
||||||
@@ -172,9 +174,11 @@ func printToken(w http.ResponseWriter, _ *http.Request, d *data, user *users.Use
|
|||||||
ID: user.ID,
|
ID: user.ID,
|
||||||
Locale: user.Locale,
|
Locale: user.Locale,
|
||||||
ViewMode: user.ViewMode,
|
ViewMode: user.ViewMode,
|
||||||
|
SingleClick: user.SingleClick,
|
||||||
Perm: user.Perm,
|
Perm: user.Perm,
|
||||||
LockPassword: user.LockPassword,
|
LockPassword: user.LockPassword,
|
||||||
Commands: user.Commands,
|
Commands: user.Commands,
|
||||||
|
HideDotfiles: user.HideDotfiles,
|
||||||
},
|
},
|
||||||
StandardClaims: jwt.StandardClaims{
|
StandardClaims: jwt.StandardClaims{
|
||||||
IssuedAt: time.Now().Unix(),
|
IssuedAt: time.Now().Unix(),
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ var commandsHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !d.user.CanExecute(strings.Split(raw, " ")[0]) {
|
if !d.server.EnableExec || !d.user.CanExecute(strings.Split(raw, " ")[0]) {
|
||||||
if err := conn.WriteMessage(websocket.TextMessage, cmdNotAllowed); err != nil { //nolint:shadow
|
if err := conn.WriteMessage(websocket.TextMessage, cmdNotAllowed); err != nil { //nolint:shadow
|
||||||
wsErr(conn, r, http.StatusInternalServerError, err)
|
wsErr(conn, r, http.StatusInternalServerError, err)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/tomasen/realip"
|
"github.com/tomasen/realip"
|
||||||
|
|
||||||
|
"github.com/filebrowser/filebrowser/v2/rules"
|
||||||
"github.com/filebrowser/filebrowser/v2/runner"
|
"github.com/filebrowser/filebrowser/v2/runner"
|
||||||
"github.com/filebrowser/filebrowser/v2/settings"
|
"github.com/filebrowser/filebrowser/v2/settings"
|
||||||
"github.com/filebrowser/filebrowser/v2/storage"
|
"github.com/filebrowser/filebrowser/v2/storage"
|
||||||
@@ -26,6 +27,10 @@ type data struct {
|
|||||||
|
|
||||||
// Check implements rules.Checker.
|
// Check implements rules.Checker.
|
||||||
func (d *data) Check(path string) bool {
|
func (d *data) Check(path string) bool {
|
||||||
|
if d.user.HideDotfiles && rules.MatchHidden(path) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
allow := true
|
allow := true
|
||||||
for _, rule := range d.settings.Rules {
|
for _, rule := range d.settings.Rules {
|
||||||
if rule.Matches(path) {
|
if rule.Matches(path) {
|
||||||
@@ -51,7 +56,7 @@ func handle(fn handleFunc, prefix string, store *storage.Storage, server *settin
|
|||||||
}
|
}
|
||||||
|
|
||||||
status, err := fn(w, r, &data{
|
status, err := fn(w, r, &data{
|
||||||
Runner: &runner.Runner{Settings: settings},
|
Runner: &runner.Runner{Enabled: server.EnableExec, Settings: settings},
|
||||||
store: store,
|
store: store,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
server: server,
|
server: server,
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ func NewHandler(imgSvc ImgService, fileCache FileCache, store *storage.Storage,
|
|||||||
api.PathPrefix("/resources").Handler(monkey(resourcePostPutHandler, "/api/resources")).Methods("PUT")
|
api.PathPrefix("/resources").Handler(monkey(resourcePostPutHandler, "/api/resources")).Methods("PUT")
|
||||||
api.PathPrefix("/resources").Handler(monkey(resourcePatchHandler, "/api/resources")).Methods("PATCH")
|
api.PathPrefix("/resources").Handler(monkey(resourcePatchHandler, "/api/resources")).Methods("PATCH")
|
||||||
|
|
||||||
|
api.Path("/shares").Handler(monkey(shareListHandler, "/api/shares")).Methods("GET")
|
||||||
api.PathPrefix("/share").Handler(monkey(shareGetsHandler, "/api/share")).Methods("GET")
|
api.PathPrefix("/share").Handler(monkey(shareGetsHandler, "/api/share")).Methods("GET")
|
||||||
api.PathPrefix("/share").Handler(monkey(sharePostHandler, "/api/share")).Methods("POST")
|
api.PathPrefix("/share").Handler(monkey(sharePostHandler, "/api/share")).Methods("POST")
|
||||||
api.PathPrefix("/share").Handler(monkey(shareDeleteHandler, "/api/share")).Methods("DELETE")
|
api.PathPrefix("/share").Handler(monkey(shareDeleteHandler, "/api/share")).Methods("DELETE")
|
||||||
|
|||||||
+40
-12
@@ -2,19 +2,21 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/afero"
|
||||||
|
|
||||||
"github.com/filebrowser/filebrowser/v2/files"
|
"github.com/filebrowser/filebrowser/v2/files"
|
||||||
)
|
)
|
||||||
|
|
||||||
var withHashFile = func(fn handleFunc) handleFunc {
|
var withHashFile = func(fn handleFunc) handleFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
return func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||||
link, err := d.store.Share.GetByHash(r.URL.Path)
|
id, path := ifPathWithName(r)
|
||||||
|
link, err := d.store.Share.GetByHash(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
link, err = d.store.Share.GetByHash(ifPathWithName(r))
|
return errToStatus(err), err
|
||||||
if err != nil {
|
|
||||||
return errToStatus(err), err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := d.store.Users.Get(d.server.Root, link.UserID)
|
user, err := d.store.Users.Get(d.server.Root, link.UserID)
|
||||||
@@ -28,13 +30,29 @@ var withHashFile = func(fn handleFunc) handleFunc {
|
|||||||
Fs: d.user.Fs,
|
Fs: d.user.Fs,
|
||||||
Path: link.Path,
|
Path: link.Path,
|
||||||
Modify: d.user.Perm.Modify,
|
Modify: d.user.Perm.Modify,
|
||||||
Expand: false,
|
Expand: true,
|
||||||
Checker: d,
|
Checker: d,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errToStatus(err), err
|
return errToStatus(err), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if file.IsDir {
|
||||||
|
// set fs root to the shared folder
|
||||||
|
d.user.Fs = afero.NewBasePathFs(d.user.Fs, filepath.Dir(link.Path))
|
||||||
|
|
||||||
|
file, err = files.NewFileInfo(files.FileOptions{
|
||||||
|
Fs: d.user.Fs,
|
||||||
|
Path: path,
|
||||||
|
Modify: d.user.Perm.Modify,
|
||||||
|
Expand: true,
|
||||||
|
Checker: d,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return errToStatus(err), err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
d.raw = file
|
d.raw = file
|
||||||
return fn(w, r, d)
|
return fn(w, r, d)
|
||||||
}
|
}
|
||||||
@@ -42,19 +60,29 @@ var withHashFile = func(fn handleFunc) handleFunc {
|
|||||||
|
|
||||||
// ref to https://github.com/filebrowser/filebrowser/pull/727
|
// ref to https://github.com/filebrowser/filebrowser/pull/727
|
||||||
// `/api/public/dl/MEEuZK-v/file-name.txt` for old browsers to save file with correct name
|
// `/api/public/dl/MEEuZK-v/file-name.txt` for old browsers to save file with correct name
|
||||||
func ifPathWithName(r *http.Request) string {
|
func ifPathWithName(r *http.Request) (id, filePath string) {
|
||||||
pathElements := strings.Split(r.URL.Path, "/")
|
pathElements := strings.Split(r.URL.Path, "/")
|
||||||
// prevent maliciously constructed parameters like `/api/public/dl/XZzCDnK2_not_exists_hash_name`
|
// prevent maliciously constructed parameters like `/api/public/dl/XZzCDnK2_not_exists_hash_name`
|
||||||
// len(pathElements) will be 1, and golang will panic `runtime error: index out of range`
|
// len(pathElements) will be 1, and golang will panic `runtime error: index out of range`
|
||||||
if len(pathElements) < 2 { //nolint: mnd
|
|
||||||
return r.URL.Path
|
switch len(pathElements) {
|
||||||
|
case 1:
|
||||||
|
return r.URL.Path, "/"
|
||||||
|
default:
|
||||||
|
return pathElements[0], path.Join("/", path.Join(pathElements[1:]...))
|
||||||
}
|
}
|
||||||
id := pathElements[len(pathElements)-2]
|
|
||||||
return id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var publicShareHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
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) {
|
var publicDlHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||||
|
|||||||
+38
-16
@@ -1,7 +1,9 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
gopath "path"
|
gopath "path"
|
||||||
@@ -9,8 +11,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mholt/archiver"
|
"github.com/mholt/archiver"
|
||||||
|
"github.com/spf13/afero"
|
||||||
|
|
||||||
"github.com/filebrowser/filebrowser/v2/files"
|
"github.com/filebrowser/filebrowser/v2/files"
|
||||||
|
"github.com/filebrowser/filebrowser/v2/fileutils"
|
||||||
"github.com/filebrowser/filebrowser/v2/users"
|
"github.com/filebrowser/filebrowser/v2/users"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -90,6 +94,11 @@ var rawHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data)
|
|||||||
return errToStatus(err), err
|
return errToStatus(err), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if files.IsNamedPipe(file.Mode) {
|
||||||
|
setContentDisposition(w, r, file)
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
if !file.IsDir {
|
if !file.IsDir {
|
||||||
return rawFileHandler(w, r, file)
|
return rawFileHandler(w, r, file)
|
||||||
}
|
}
|
||||||
@@ -97,7 +106,7 @@ var rawHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data)
|
|||||||
return rawDirHandler(w, r, d, file)
|
return rawDirHandler(w, r, d, file)
|
||||||
})
|
})
|
||||||
|
|
||||||
func addFile(ar archiver.Writer, d *data, path string) error {
|
func addFile(ar archiver.Writer, d *data, path, commonPath string) error {
|
||||||
// Checks are always done with paths with "/" as path separator.
|
// Checks are always done with paths with "/" as path separator.
|
||||||
path = strings.Replace(path, "\\", "/", -1)
|
path = strings.Replace(path, "\\", "/", -1)
|
||||||
if !d.Check(path) {
|
if !d.Check(path) {
|
||||||
@@ -109,21 +118,32 @@ func addFile(ar archiver.Writer, d *data, path string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
file, err := d.user.Fs.Open(path)
|
var (
|
||||||
if err != nil {
|
file afero.File
|
||||||
return err
|
arcReadCloser = ioutil.NopCloser(&bytes.Buffer{})
|
||||||
|
)
|
||||||
|
if !files.IsNamedPipe(info.Mode()) {
|
||||||
|
file, err = d.user.Fs.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
arcReadCloser = file
|
||||||
}
|
}
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
err = ar.Write(archiver.File{
|
if path != commonPath {
|
||||||
FileInfo: archiver.FileInfo{
|
filename := strings.TrimPrefix(path, commonPath)
|
||||||
FileInfo: info,
|
filename = strings.TrimPrefix(filename, "/")
|
||||||
CustomName: strings.TrimPrefix(path, "/"),
|
err = ar.Write(archiver.File{
|
||||||
},
|
FileInfo: archiver.FileInfo{
|
||||||
ReadCloser: file,
|
FileInfo: info,
|
||||||
})
|
CustomName: filename,
|
||||||
if err != nil {
|
},
|
||||||
return err
|
ReadCloser: arcReadCloser,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
@@ -133,7 +153,7 @@ func addFile(ar archiver.Writer, d *data, path string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
err = addFile(ar, d, filepath.Join(path, name))
|
err = addFile(ar, d, filepath.Join(path, name), commonPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -167,8 +187,10 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.
|
|||||||
}
|
}
|
||||||
defer ar.Close()
|
defer ar.Close()
|
||||||
|
|
||||||
|
commonDir := fileutils.CommonPrefix('/', filenames...)
|
||||||
|
|
||||||
for _, fname := range filenames {
|
for _, fname := range filenames {
|
||||||
err = addFile(ar, d, fname)
|
err = addFile(ar, d, fname, commonDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-8
@@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ var resourcePostPutHandler = withUser(func(w http.ResponseWriter, r *http.Reques
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := d.RunHook(func() error {
|
err := d.RunHook(func() error {
|
||||||
dir, _ := filepath.Split(r.URL.Path)
|
dir, _ := path.Split(r.URL.Path)
|
||||||
err := d.user.Fs.MkdirAll(dir, 0775)
|
err := d.user.Fs.MkdirAll(dir, 0775)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -196,9 +197,10 @@ var resourcePatchHandler = withUser(func(w http.ResponseWriter, r *http.Request,
|
|||||||
if !d.user.Perm.Rename {
|
if !d.user.Perm.Rename {
|
||||||
return errors.ErrPermissionDenied
|
return errors.ErrPermissionDenied
|
||||||
}
|
}
|
||||||
dst = filepath.Clean("/" + dst)
|
src = path.Clean("/" + src)
|
||||||
|
dst = path.Clean("/" + dst)
|
||||||
|
|
||||||
return d.user.Fs.Rename(src, dst)
|
return fileutils.MoveFile(d.user.Fs, src, dst)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported action %s: %w", action, errors.ErrInvalidRequestParams)
|
return fmt.Errorf("unsupported action %s: %w", action, errors.ErrInvalidRequestParams)
|
||||||
}
|
}
|
||||||
@@ -221,20 +223,20 @@ func checkParent(src, dst string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func addVersionSuffix(path string, fs afero.Fs) string {
|
func addVersionSuffix(source string, fs afero.Fs) string {
|
||||||
counter := 1
|
counter := 1
|
||||||
dir, name := filepath.Split(path)
|
dir, name := path.Split(source)
|
||||||
ext := filepath.Ext(name)
|
ext := filepath.Ext(name)
|
||||||
base := strings.TrimSuffix(name, ext)
|
base := strings.TrimSuffix(name, ext)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if _, err := fs.Stat(path); err != nil {
|
if _, err := fs.Stat(source); err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
renamed := fmt.Sprintf("%s(%d)%s", base, counter, ext)
|
renamed := fmt.Sprintf("%s(%d)%s", base, counter, ext)
|
||||||
path = filepath.ToSlash(dir) + renamed
|
source = path.Join(dir, renamed)
|
||||||
counter++
|
counter++
|
||||||
}
|
}
|
||||||
|
|
||||||
return path
|
return source
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -23,6 +24,34 @@ func withPermShare(fn handleFunc) handleFunc {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var shareListHandler = withPermShare(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||||
|
var (
|
||||||
|
s []*share.Link
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if d.user.Perm.Admin {
|
||||||
|
s, err = d.store.Share.All()
|
||||||
|
} else {
|
||||||
|
s, err = d.store.Share.FindByUserID(d.user.ID)
|
||||||
|
}
|
||||||
|
if err == errors.ErrNotExist {
|
||||||
|
return renderJSON(w, r, []*share.Link{})
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(s, func(i, j int) bool {
|
||||||
|
if s[i].UserID != s[j].UserID {
|
||||||
|
return s[i].UserID < s[j].UserID
|
||||||
|
}
|
||||||
|
return s[i].Expire < s[j].Expire
|
||||||
|
})
|
||||||
|
|
||||||
|
return renderJSON(w, r, s)
|
||||||
|
})
|
||||||
|
|
||||||
var shareGetsHandler = withPermShare(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
var shareGetsHandler = withPermShare(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||||
s, err := d.store.Share.Gets(r.URL.Path, d.user.ID)
|
s, err := d.store.Share.Gets(r.URL.Path, d.user.ID)
|
||||||
if err == errors.ErrNotExist {
|
if err == errors.ErrNotExist {
|
||||||
|
|||||||
+10
-1
@@ -40,6 +40,8 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, box *
|
|||||||
"ReCaptcha": false,
|
"ReCaptcha": false,
|
||||||
"Theme": d.settings.Branding.Theme,
|
"Theme": d.settings.Branding.Theme,
|
||||||
"EnableThumbs": d.server.EnableThumbnails,
|
"EnableThumbs": d.server.EnableThumbnails,
|
||||||
|
"ResizePreview": d.server.ResizePreview,
|
||||||
|
"EnableExec": d.server.EnableExec,
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.settings.Branding.Files != "" {
|
if d.settings.Branding.Files != "" {
|
||||||
@@ -77,7 +79,14 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, box *
|
|||||||
|
|
||||||
data["Json"] = string(b)
|
data["Json"] = string(b)
|
||||||
|
|
||||||
index := template.Must(template.New("index").Delims("[{[", "]}]").Parse(box.MustString(file)))
|
fileContents, err := box.String(file)
|
||||||
|
if err != nil {
|
||||||
|
if err == os.ErrNotExist {
|
||||||
|
return http.StatusNotFound, err
|
||||||
|
}
|
||||||
|
return http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
|
index := template.Must(template.New("index").Delims("[{[", "]}]").Parse(fileContents))
|
||||||
err = index.Execute(w, data)
|
err = index.Execute(w, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
|
|||||||
+14
-7
@@ -14,6 +14,10 @@ import (
|
|||||||
"github.com/filebrowser/filebrowser/v2/users"
|
"github.com/filebrowser/filebrowser/v2/users"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
NonModifiableFieldsForNonAdmin = []string{"Username", "Scope", "LockPassword", "Perm", "Commands", "Rules"}
|
||||||
|
)
|
||||||
|
|
||||||
type modifyUserRequest struct {
|
type modifyUserRequest struct {
|
||||||
modifyRequest
|
modifyRequest
|
||||||
Data *users.User `json:"data"`
|
Data *users.User `json:"data"`
|
||||||
@@ -148,9 +152,9 @@ var userPutHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request
|
|||||||
return http.StatusBadRequest, nil
|
return http.StatusBadRequest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.Which) == 1 && req.Which[0] == "all" {
|
if len(req.Which) == 0 || (len(req.Which) == 1 && req.Which[0] == "all") {
|
||||||
if !d.user.Perm.Admin {
|
if !d.user.Perm.Admin {
|
||||||
return http.StatusForbidden, err
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Data.Password != "" {
|
if req.Data.Password != "" {
|
||||||
@@ -169,7 +173,10 @@ var userPutHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range req.Which {
|
for k, v := range req.Which {
|
||||||
if v == "password" {
|
v = strings.Title(v)
|
||||||
|
req.Which[k] = v
|
||||||
|
|
||||||
|
if v == "Password" {
|
||||||
if !d.user.Perm.Admin && d.user.LockPassword {
|
if !d.user.Perm.Admin && d.user.LockPassword {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
@@ -180,11 +187,11 @@ var userPutHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !d.user.Perm.Admin && (v == "scope" || v == "perm" || v == "username") {
|
for _, f := range NonModifiableFieldsForNonAdmin {
|
||||||
return http.StatusForbidden, nil
|
if !d.user.Perm.Admin && v == f {
|
||||||
|
return http.StatusForbidden, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Which[k] = strings.Title(v)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = d.store.Users.Update(req.Data, req.Which...)
|
err = d.store.Users.Update(req.Data, req.Which...)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -18,6 +19,12 @@ type Rule struct {
|
|||||||
Regexp *Regexp `json:"regexp"`
|
Regexp *Regexp `json:"regexp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MatchHidden matches paths with a basename
|
||||||
|
// that begins with a dot.
|
||||||
|
func MatchHidden(path string) bool {
|
||||||
|
return strings.HasPrefix(filepath.Base(path), ".")
|
||||||
|
}
|
||||||
|
|
||||||
// Matches matches a path against a rule.
|
// Matches matches a path against a rule.
|
||||||
func (r *Rule) Matches(path string) bool {
|
func (r *Rule) Matches(path string) bool {
|
||||||
if r.Regex {
|
if r.Regex {
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestMatchHidden(t *testing.T) {
|
||||||
|
cases := map[string]bool{
|
||||||
|
"/": false,
|
||||||
|
"/src": false,
|
||||||
|
"/src/": false,
|
||||||
|
"/.circleci": true,
|
||||||
|
"/a/b/c/.docker.json": true,
|
||||||
|
".docker.json": true,
|
||||||
|
"Dockerfile": false,
|
||||||
|
"/Dockerfile": false,
|
||||||
|
}
|
||||||
|
|
||||||
|
for path, want := range cases {
|
||||||
|
got := MatchHidden(path)
|
||||||
|
if got != want {
|
||||||
|
t.Errorf("MatchHidden(%s)=%v; want %v", path, got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-10
@@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
// Runner is a commands runner.
|
// Runner is a commands runner.
|
||||||
type Runner struct {
|
type Runner struct {
|
||||||
|
Enabled bool
|
||||||
*settings.Settings
|
*settings.Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,11 +22,13 @@ func (r *Runner) RunHook(fn func() error, evt, path, dst string, user *users.Use
|
|||||||
path = user.FullPath(path)
|
path = user.FullPath(path)
|
||||||
dst = user.FullPath(dst)
|
dst = user.FullPath(dst)
|
||||||
|
|
||||||
if val, ok := r.Commands["before_"+evt]; ok {
|
if r.Enabled {
|
||||||
for _, command := range val {
|
if val, ok := r.Commands["before_"+evt]; ok {
|
||||||
err := r.exec(command, "before_"+evt, path, dst, user)
|
for _, command := range val {
|
||||||
if err != nil {
|
err := r.exec(command, "before_"+evt, path, dst, user)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,11 +38,13 @@ func (r *Runner) RunHook(fn func() error, evt, path, dst string, user *users.Use
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := r.Commands["after_"+evt]; ok {
|
if r.Enabled {
|
||||||
for _, command := range val {
|
if val, ok := r.Commands["after_"+evt]; ok {
|
||||||
err := r.exec(command, "after_"+evt, path, dst, user)
|
for _, command := range val {
|
||||||
if err != nil {
|
err := r.exec(command, "after_"+evt, path, dst, user)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -60,7 +60,9 @@ func Search(fs afero.Fs, scope, query string, checker rules.Checker, found func(
|
|||||||
if len(search.Terms) > 0 {
|
if len(search.Terms) > 0 {
|
||||||
for _, term := range search.Terms {
|
for _, term := range search.Terms {
|
||||||
if strings.Contains(path, term) {
|
if strings.Contains(path, term) {
|
||||||
return found(strings.TrimPrefix(originalPath, scope), f)
|
originalPath = strings.TrimPrefix(originalPath, scope)
|
||||||
|
originalPath = strings.TrimPrefix(originalPath, "/")
|
||||||
|
return found(originalPath, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -8,12 +8,14 @@ import (
|
|||||||
// UserDefaults is a type that holds the default values
|
// UserDefaults is a type that holds the default values
|
||||||
// for some fields on User.
|
// for some fields on User.
|
||||||
type UserDefaults struct {
|
type UserDefaults struct {
|
||||||
Scope string `json:"scope"`
|
Scope string `json:"scope"`
|
||||||
Locale string `json:"locale"`
|
Locale string `json:"locale"`
|
||||||
ViewMode users.ViewMode `json:"viewMode"`
|
ViewMode users.ViewMode `json:"viewMode"`
|
||||||
Sorting files.Sorting `json:"sorting"`
|
SingleClick bool `json:"singleClick"`
|
||||||
Perm users.Permissions `json:"perm"`
|
Sorting files.Sorting `json:"sorting"`
|
||||||
Commands []string `json:"commands"`
|
Perm users.Permissions `json:"perm"`
|
||||||
|
Commands []string `json:"commands"`
|
||||||
|
HideDotfiles bool `json:"hideDotfiles"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply applies the default options to a user.
|
// Apply applies the default options to a user.
|
||||||
@@ -21,7 +23,9 @@ func (d *UserDefaults) Apply(u *users.User) {
|
|||||||
u.Scope = d.Scope
|
u.Scope = d.Scope
|
||||||
u.Locale = d.Locale
|
u.Locale = d.Locale
|
||||||
u.ViewMode = d.ViewMode
|
u.ViewMode = d.ViewMode
|
||||||
|
u.SingleClick = d.SingleClick
|
||||||
u.Perm = d.Perm
|
u.Perm = d.Perm
|
||||||
u.Sorting = d.Sorting
|
u.Sorting = d.Sorting
|
||||||
u.Commands = d.Commands
|
u.Commands = d.Commands
|
||||||
|
u.HideDotfiles = d.HideDotfiles
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@ type Server struct {
|
|||||||
Log string `json:"log"`
|
Log string `json:"log"`
|
||||||
EnableThumbnails bool `json:"enableThumbnails"`
|
EnableThumbnails bool `json:"enableThumbnails"`
|
||||||
ResizePreview bool `json:"resizePreview"`
|
ResizePreview bool `json:"resizePreview"`
|
||||||
|
EnableExec bool `json:"enableExec"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean cleans any variables that might need cleaning.
|
// Clean cleans any variables that might need cleaning.
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import (
|
|||||||
|
|
||||||
// StorageBackend is the interface to implement for a share storage.
|
// StorageBackend is the interface to implement for a share storage.
|
||||||
type StorageBackend interface {
|
type StorageBackend interface {
|
||||||
|
All() ([]*Link, error)
|
||||||
|
FindByUserID(id uint) ([]*Link, error)
|
||||||
GetByHash(hash string) (*Link, error)
|
GetByHash(hash string) (*Link, error)
|
||||||
GetPermanent(path string, id uint) (*Link, error)
|
GetPermanent(path string, id uint) (*Link, error)
|
||||||
Gets(path string, id uint) ([]*Link, error)
|
Gets(path string, id uint) ([]*Link, error)
|
||||||
@@ -25,6 +27,46 @@ func NewStorage(back StorageBackend) *Storage {
|
|||||||
return &Storage{back: back}
|
return &Storage{back: back}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All wraps a StorageBackend.All.
|
||||||
|
func (s *Storage) All() ([]*Link, error) {
|
||||||
|
links, err := s.back.All()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, link := range links {
|
||||||
|
if link.Expire != 0 && link.Expire <= time.Now().Unix() {
|
||||||
|
if err := s.Delete(link.Hash); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
links = append(links[:i], links[i+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return links, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindByUserID wraps a StorageBackend.FindByUserID.
|
||||||
|
func (s *Storage) FindByUserID(id uint) ([]*Link, error) {
|
||||||
|
links, err := s.back.FindByUserID(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, link := range links {
|
||||||
|
if link.Expire != 0 && link.Expire <= time.Now().Unix() {
|
||||||
|
if err := s.Delete(link.Hash); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
links = append(links[:i], links[i+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return links, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetByHash wraps a StorageBackend.GetByHash.
|
// GetByHash wraps a StorageBackend.GetByHash.
|
||||||
func (s *Storage) GetByHash(hash string) (*Link, error) {
|
func (s *Storage) GetByHash(hash string) (*Link, error) {
|
||||||
link, err := s.back.GetByHash(hash)
|
link, err := s.back.GetByHash(hash)
|
||||||
|
|||||||
@@ -12,6 +12,26 @@ type shareBackend struct {
|
|||||||
db *storm.DB
|
db *storm.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s shareBackend) All() ([]*share.Link, error) {
|
||||||
|
var v []*share.Link
|
||||||
|
err := s.db.All(&v)
|
||||||
|
if err == storm.ErrNotFound {
|
||||||
|
return v, errors.ErrNotExist
|
||||||
|
}
|
||||||
|
|
||||||
|
return v, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s shareBackend) FindByUserID(id uint) ([]*share.Link, error) {
|
||||||
|
var v []*share.Link
|
||||||
|
err := s.db.Select(q.Eq("UserID", id)).Find(&v)
|
||||||
|
if err == storm.ErrNotFound {
|
||||||
|
return v, errors.ErrNotExist
|
||||||
|
}
|
||||||
|
|
||||||
|
return v, err
|
||||||
|
}
|
||||||
|
|
||||||
func (s shareBackend) GetByHash(hash string) (*share.Link, error) {
|
func (s shareBackend) GetByHash(hash string) (*share.Link, error) {
|
||||||
var v share.Link
|
var v share.Link
|
||||||
err := s.db.One("Hash", hash, &v)
|
err := s.db.One("Hash", hash, &v)
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ type User struct {
|
|||||||
Locale string `json:"locale"`
|
Locale string `json:"locale"`
|
||||||
LockPassword bool `json:"lockPassword"`
|
LockPassword bool `json:"lockPassword"`
|
||||||
ViewMode ViewMode `json:"viewMode"`
|
ViewMode ViewMode `json:"viewMode"`
|
||||||
|
SingleClick bool `json:"singleClick"`
|
||||||
Perm Permissions `json:"perm"`
|
Perm Permissions `json:"perm"`
|
||||||
Commands []string `json:"commands"`
|
Commands []string `json:"commands"`
|
||||||
Sorting files.Sorting `json:"sorting"`
|
Sorting files.Sorting `json:"sorting"`
|
||||||
Fs afero.Fs `json:"-" yaml:"-"`
|
Fs afero.Fs `json:"-" yaml:"-"`
|
||||||
Rules []rules.Rule `json:"rules"`
|
Rules []rules.Rule `json:"rules"`
|
||||||
|
HideDotfiles bool `json:"hideDotfiles"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRules implements rules.Provider.
|
// GetRules implements rules.Provider.
|
||||||
|
|||||||
Reference in new issue
Block a user