feat: add hidden files flag (#2)
parent
11092eed3c
commit
847d870782
|
@ -28,4 +28,5 @@ yarn-error.log*
|
||||||
*.sln
|
*.sln
|
||||||
*.sw*
|
*.sw*
|
||||||
bin/
|
bin/
|
||||||
|
dist/
|
||||||
build/
|
build/
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -92,3 +92,8 @@ bump-version: | ; $(info $(M) creating a new release…)
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help:
|
help:
|
||||||
@sed -n 's/^## //p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /' | sort
|
@sed -n 's/^## //p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /' | sort
|
||||||
|
|
||||||
|
.PHONY: build-release-bin
|
||||||
|
build-release-bin:
|
||||||
|
GO111MODULE=on GOOS=linux GOARCH=amd64 $(GO) build -ldflags '$(LDFLAGS)' -o bin/filebrowser-$(VERSION)
|
||||||
|
tar -C bin -czf "dist/filebrowser-$(VERSION).tar.gz" "filebrowser-$(VERSION)"
|
||||||
|
|
|
@ -43,6 +43,8 @@ you want to change. Other options will remain unchanged.`,
|
||||||
ser.Port = mustGetString(flags, flag.Name)
|
ser.Port = mustGetString(flags, flag.Name)
|
||||||
case "log":
|
case "log":
|
||||||
ser.Log = mustGetString(flags, flag.Name)
|
ser.Log = mustGetString(flags, flag.Name)
|
||||||
|
case "hidden-files":
|
||||||
|
ser.HiddenFiles = convertFileStrToFileMap(mustGetString(flags, flag.Name))
|
||||||
case "signup":
|
case "signup":
|
||||||
set.Signup = mustGetBool(flags, flag.Name)
|
set.Signup = mustGetBool(flags, flag.Name)
|
||||||
case "auth.method":
|
case "auth.method":
|
||||||
|
|
|
@ -69,6 +69,7 @@ func addServerFlags(flags *pflag.FlagSet) {
|
||||||
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")
|
flags.Bool("disable-exec", false, "disables Command Runner feature")
|
||||||
flags.Bool("disable-type-detection-by-header", false, "disables type detection by reading file headers")
|
flags.Bool("disable-type-detection-by-header", false, "disables type detection by reading file headers")
|
||||||
|
flags.String("hidden-files", "", "comma separated list of files that should be hidden")
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
|
@ -260,6 +261,10 @@ func getRunParams(flags *pflag.FlagSet, st *storage.Storage) *settings.Server {
|
||||||
_, disableExec := getParamB(flags, "disable-exec")
|
_, disableExec := getParamB(flags, "disable-exec")
|
||||||
server.EnableExec = !disableExec
|
server.EnableExec = !disableExec
|
||||||
|
|
||||||
|
if val, set := getParamB(flags, "hidden-files"); set {
|
||||||
|
server.HiddenFiles = convertFileStrToFileMap(val)
|
||||||
|
}
|
||||||
|
|
||||||
return server
|
return server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
cmd/utils.go
14
cmd/utils.go
|
@ -191,3 +191,17 @@ func convertCmdStrToCmdArray(cmd string) []string {
|
||||||
}
|
}
|
||||||
return cmdArray
|
return cmdArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convertFileStrToFileMap parses a comma-separated file list string
|
||||||
|
// into a map where each key is a separate file
|
||||||
|
func convertFileStrToFileMap(files string) map[string]struct{} {
|
||||||
|
fileMap := make(map[string]struct{})
|
||||||
|
files = strings.TrimSpace(files)
|
||||||
|
if files != "" {
|
||||||
|
fileParts := strings.Split(files, ",")
|
||||||
|
for _, file := range fileParts {
|
||||||
|
fileMap[file] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fileMap
|
||||||
|
}
|
||||||
|
|
|
@ -108,3 +108,13 @@ func (l byModified) Less(i, j int) bool {
|
||||||
iModified, jModified := l.Items[i].ModTime, l.Items[j].ModTime
|
iModified, jModified := l.Items[i].ModTime, l.Items[j].ModTime
|
||||||
return iModified.Sub(jModified) < 0
|
return iModified.Sub(jModified) < 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Listing) FilterItems(fn func(fi *FileInfo) bool) {
|
||||||
|
var filtered []*FileInfo
|
||||||
|
for _, item := range l.Items {
|
||||||
|
if fn(item) {
|
||||||
|
filtered = append(filtered, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l.Items = filtered
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
:disabled="loading"
|
||||||
v-for="(ext, format) in formats"
|
v-for="(ext, format) in formats"
|
||||||
:key="format"
|
:key="format"
|
||||||
class="button button--block"
|
class="button button--block"
|
||||||
|
@ -38,6 +39,7 @@ export default {
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
name: "",
|
name: "",
|
||||||
|
loading: false,
|
||||||
formats: {
|
formats: {
|
||||||
zip: "zip",
|
zip: "zip",
|
||||||
tar: "tar",
|
tar: "tar",
|
||||||
|
@ -74,11 +76,14 @@ export default {
|
||||||
uri = uri.replace("//", "/");
|
uri = uri.replace("//", "/");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
this.loading = true
|
||||||
await api.archive(uri, this.name, format, ...items);
|
await api.archive(uri, this.name, format, ...items);
|
||||||
|
|
||||||
this.$store.commit("setReload", true);
|
this.$store.commit("setReload", true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.$showError(e);
|
this.$showError(e);
|
||||||
|
} finally {
|
||||||
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$store.commit("closeHovers");
|
this.$store.commit("closeHovers");
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
type="submit"
|
type="submit"
|
||||||
:aria-label="$t('buttons.unarchive')"
|
:aria-label="$t('buttons.unarchive')"
|
||||||
:title="$t('buttons.unarchive')"
|
:title="$t('buttons.unarchive')"
|
||||||
|
:disabled="loading"
|
||||||
>
|
>
|
||||||
{{ $t("buttons.unarchive") }}
|
{{ $t("buttons.unarchive") }}
|
||||||
</button>
|
</button>
|
||||||
|
@ -45,6 +46,7 @@ export default {
|
||||||
name: "rename",
|
name: "rename",
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
|
loading: false,
|
||||||
name: "",
|
name: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -63,11 +65,14 @@ export default {
|
||||||
dst = dst.replace("//", "/");
|
dst = dst.replace("//", "/");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
this.loading = true;
|
||||||
await api.unarchive(item.url, dst, false);
|
await api.unarchive(item.url, dst, false);
|
||||||
|
|
||||||
this.$store.commit("setReload", true);
|
this.$store.commit("setReload", true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.$showError(e);
|
this.$showError(e);
|
||||||
|
} finally {
|
||||||
|
this.loading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$store.commit("closeHovers");
|
this.$store.commit("closeHovers");
|
||||||
|
|
|
@ -7,14 +7,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<p>
|
|
||||||
<input type="checkbox" v-model="hideDotfiles" />
|
|
||||||
{{ $t("settings.hideDotfiles") }}
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<input type="checkbox" v-model="singleClick" />
|
|
||||||
{{ $t("settings.singleClick") }}
|
|
||||||
</p>
|
|
||||||
<h3>{{ $t("settings.language") }}</h3>
|
<h3>{{ $t("settings.language") }}</h3>
|
||||||
<languages
|
<languages
|
||||||
class="input input--block"
|
class="input input--block"
|
||||||
|
|
|
@ -48,6 +48,10 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
|
||||||
if file.IsDir {
|
if file.IsDir {
|
||||||
file.Listing.Sorting = d.user.Sorting
|
file.Listing.Sorting = d.user.Sorting
|
||||||
file.Listing.ApplySort()
|
file.Listing.ApplySort()
|
||||||
|
file.Listing.FilterItems(func(fi *files.FileInfo) bool {
|
||||||
|
_, exists := d.server.HiddenFiles[fi.Name]
|
||||||
|
return !exists
|
||||||
|
})
|
||||||
return renderJSON(w, r, file)
|
return renderJSON(w, r, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ type Server struct {
|
||||||
ResizePreview bool `json:"resizePreview"`
|
ResizePreview bool `json:"resizePreview"`
|
||||||
EnableExec bool `json:"enableExec"`
|
EnableExec bool `json:"enableExec"`
|
||||||
TypeDetectionByHeader bool `json:"typeDetectionByHeader"`
|
TypeDetectionByHeader bool `json:"typeDetectionByHeader"`
|
||||||
|
HiddenFiles map[string]struct{} `json:"hiddenFiles"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean cleans any variables that might need cleaning.
|
// Clean cleans any variables that might need cleaning.
|
||||||
|
|
Loading…
Reference in New Issue