diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c620c20..4b1b1540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,29 @@ 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.27.0](https://github.com/filebrowser/filebrowser/compare/v2.26.0...v2.27.0) (2024-01-02) + + +### Features + +* allow setting theme via cli ([#2881](https://github.com/filebrowser/filebrowser/issues/2881)) ([748af71](https://github.com/filebrowser/filebrowser/commit/748af7172ce96f0b66c394e88839bd57c194ffc7)) +* display image resolutions in file details ([#2830](https://github.com/filebrowser/filebrowser/issues/2830)) ([a09dfa8](https://github.com/filebrowser/filebrowser/commit/a09dfa8d9f190243d811a841de44c4abb4403d87)) +* make user session timeout configurable by flags ([#2845](https://github.com/filebrowser/filebrowser/issues/2845)) ([391a078](https://github.com/filebrowser/filebrowser/commit/391a078cd486e618c95a0c5850326076cbc025b6)) + + +### Bug Fixes + +* delete message when delete file from preview ([3264cea](https://github.com/filebrowser/filebrowser/commit/3264cea8307dca9ab5463dc81f2a10a817eb3d54)) +* fix typo ([#2843](https://github.com/filebrowser/filebrowser/issues/2843)) ([4dbc802](https://github.com/filebrowser/filebrowser/commit/4dbc802972c930f5f42fc27507fac35c28c42afd)) +* set correct port in docker healthcheck ([#2812](https://github.com/filebrowser/filebrowser/issues/2812)) ([d59ad59](https://github.com/filebrowser/filebrowser/commit/d59ad594b8649f57f61453b0dfbc350c57b690a2)) +* typo in build error [#2903](https://github.com/filebrowser/filebrowser/issues/2903) ([#2904](https://github.com/filebrowser/filebrowser/issues/2904)) ([c4e955a](https://github.com/filebrowser/filebrowser/commit/c4e955acf4a1a8f8e8e94f697ffc838515e69a60)) + + +### Build + +* **deps-dev:** bump vite from 4.4.9 to 4.4.12 in /frontend ([#2862](https://github.com/filebrowser/filebrowser/issues/2862)) ([fc2ee37](https://github.com/filebrowser/filebrowser/commit/fc2ee373536584d024f7def62f350bdbb712d927)) +* **deps:** bump golang.org/x/crypto from 0.14.0 to 0.17.0 ([#2890](https://github.com/filebrowser/filebrowser/issues/2890)) ([821fba4](https://github.com/filebrowser/filebrowser/commit/821fba41a25ba99d47641f01b10ac51960157888)) + ## [2.26.0](https://github.com/filebrowser/filebrowser/compare/v2.25.0...v2.26.0) (2023-11-02) diff --git a/cmd/config.go b/cmd/config.go index 4287f3c2..ed3cc772 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -42,6 +42,7 @@ func addConfigFlags(flags *pflag.FlagSet) { flags.String("recaptcha.secret", "", "ReCaptcha secret") flags.String("branding.name", "", "replace 'File Browser' by this name") + flags.String("branding.theme", "", "set the theme") flags.String("branding.color", "", "set the theme color") flags.String("branding.files", "", "path to directory with images and custom styles") flags.Bool("branding.disableExternal", false, "disable external links such as GitHub links") @@ -150,6 +151,7 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut fmt.Fprintf(w, "\tDisable external links:\t%t\n", set.Branding.DisableExternal) fmt.Fprintf(w, "\tDisable used disk percentage graph:\t%t\n", set.Branding.DisableUsedPercentage) fmt.Fprintf(w, "\tColor:\t%s\n", set.Branding.Color) + fmt.Fprintf(w, "\tTheme:\t%s\n", set.Branding.Theme) fmt.Fprintln(w, "\nServer:") fmt.Fprintf(w, "\tLog:\t%s\n", ser.Log) fmt.Fprintf(w, "\tPort:\t%s\n", ser.Port) diff --git a/cmd/config_init.go b/cmd/config_init.go index 22d628a1..7d183368 100644 --- a/cmd/config_init.go +++ b/cmd/config_init.go @@ -38,6 +38,7 @@ override the options.`, Name: mustGetString(flags, "branding.name"), DisableExternal: mustGetBool(flags, "branding.disableExternal"), DisableUsedPercentage: mustGetBool(flags, "branding.disableUsedPercentage"), + Theme: mustGetString(flags, "branding.theme"), Files: mustGetString(flags, "branding.files"), }, } diff --git a/cmd/config_set.go b/cmd/config_set.go index 5a02288f..ba800adb 100644 --- a/cmd/config_set.go +++ b/cmd/config_set.go @@ -53,6 +53,8 @@ you want to change. Other options will remain unchanged.`, set.Branding.Name = mustGetString(flags, flag.Name) case "branding.color": set.Branding.Color = mustGetString(flags, flag.Name) + case "branding.theme": + set.Branding.Theme = mustGetString(flags, flag.Name) case "branding.disableExternal": set.Branding.DisableExternal = mustGetBool(flags, flag.Name) case "branding.disableUsedPercentage": diff --git a/cmd/root.go b/cmd/root.go index dc8b57e8..7ec4d441 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -64,6 +64,7 @@ func addServerFlags(flags *pflag.FlagSet) { flags.Uint32("socket-perm", 0666, "unix socket file permissions") //nolint:gomnd flags.StringP("baseurl", "b", "", "base url") flags.String("cache-dir", "", "file cache directory (disabled if empty)") + flags.String("token-expiration-time", "2h", "user session timeout") flags.Int("img-processors", 4, "image processors count") //nolint:gomnd flags.Bool("disable-thumbnails", false, "disable image thumbnails") flags.Bool("disable-preview-resize", false, "disable resize of image previews") @@ -261,6 +262,10 @@ func getRunParams(flags *pflag.FlagSet, st *storage.Storage) *settings.Server { _, disableExec := getParamB(flags, "disable-exec") server.EnableExec = !disableExec + if val, set := getParamB(flags, "token-expiration-time"); set { + server.TokenExpirationTime = val + } + return server } diff --git a/files/file.go b/files/file.go index e0fdb162..f181f185 100644 --- a/files/file.go +++ b/files/file.go @@ -7,6 +7,7 @@ import ( "crypto/sha512" "encoding/hex" "hash" + "image" "io" "log" "mime" @@ -44,6 +45,7 @@ type FileInfo struct { Checksums map[string]string `json:"checksums,omitempty"` Token string `json:"token,omitempty"` currentDir []os.FileInfo `json:"-"` + Resolution *ImageResolution `json:"resolution,omitempty"` } // FileOptions are the options when getting a file info. @@ -58,6 +60,11 @@ type FileOptions struct { Content bool } +type ImageResolution struct { + Width int `json:"width"` + Height int `json:"height"` +} + // NewFileInfo creates a File object from a path and a given user. This File // object will be automatically filled depending on if it is a directory // or a file. If it's a video file, it will also detect any subtitles. @@ -236,6 +243,12 @@ func (i *FileInfo) detectType(modify, saveContent, readHeader bool) error { return nil case strings.HasPrefix(mimetype, "image"): i.Type = "image" + resolution, err := calculateImageResolution(i.Fs, i.Path) + if err != nil { + log.Printf("Error calculating image resolution: %v", err) + } else { + i.Resolution = resolution + } return nil case strings.HasSuffix(mimetype, "pdf"): i.Type = "pdf" @@ -264,6 +277,28 @@ func (i *FileInfo) detectType(modify, saveContent, readHeader bool) error { return nil } +func calculateImageResolution(fs afero.Fs, filePath string) (*ImageResolution, error) { + file, err := fs.Open(filePath) + if err != nil { + return nil, err + } + defer func() { + if cErr := file.Close(); cErr != nil { + log.Printf("Failed to close file: %v", cErr) + } + }() + + config, _, err := image.DecodeConfig(file) + if err != nil { + return nil, err + } + + return &ImageResolution{ + Width: config.Width, + Height: config.Height, + }, nil +} + func (i *FileInfo) readFirstBytes() []byte { reader, err := i.Fs.Open(i.Path) if err != nil { @@ -361,6 +396,15 @@ func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error { currentDir: dir, } + if !file.IsDir && strings.HasPrefix(mime.TypeByExtension(file.Extension), "image/") { + resolution, err := calculateImageResolution(file.Fs, file.Path) + if err != nil { + log.Printf("Error calculating resolution for image %s: %v", file.Path, err) + } else { + file.Resolution = resolution + } + } + if file.IsDir { listing.NumDirs++ } else { diff --git a/frontend/package-lock.json b/frontend/package-lock.json index ff54d3d6..d898e595 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -46,7 +46,7 @@ "postcss": "^8.4.31", "prettier": "^3.0.1", "terser": "^5.19.2", - "vite": "^4.4.9", + "vite": "^4.4.12", "vite-plugin-compression2": "^0.10.3", "vite-plugin-rewrite-all": "^1.0.1" } @@ -5663,9 +5663,9 @@ "dev": true }, "node_modules/vite": { - "version": "4.4.9", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.4.9.tgz", - "integrity": "sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==", + "version": "4.4.12", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.4.12.tgz", + "integrity": "sha512-KtPlUbWfxzGVul8Nut8Gw2Qe8sBzWY+8QVc5SL8iRFnpnrcoCaNlzO40c1R6hPmcdTwIPEDkq0Y9+27a5tVbdQ==", "dev": true, "dependencies": { "esbuild": "^0.18.10", diff --git a/frontend/package.json b/frontend/package.json index bea7fed0..4449a5f5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -52,7 +52,7 @@ "postcss": "^8.4.31", "prettier": "^3.0.1", "terser": "^5.19.2", - "vite": "^4.4.9", + "vite": "^4.4.12", "vite-plugin-compression2": "^0.10.3", "vite-plugin-rewrite-all": "^1.0.1" }, diff --git a/frontend/src/components/prompts/Delete.vue b/frontend/src/components/prompts/Delete.vue index 8e319846..f65e69b7 100644 --- a/frontend/src/components/prompts/Delete.vue +++ b/frontend/src/components/prompts/Delete.vue @@ -1,7 +1,7 @@