view settings and images

This commit is contained in:
nahakubuilde
2025-08-25 18:15:51 +01:00
parent da71deb7e2
commit c85372e695
7 changed files with 132 additions and 8 deletions

View File

@@ -29,6 +29,12 @@ type Config struct {
ImageSubfolderName string
AllowedImageExtensions []string
AllowedFileExtensions []string
// Visibility settings
ShowImagesInTree bool
ShowFilesInTree bool
ShowImagesInFolder bool
ShowFilesInFolder bool
}
var defaultConfig = map[string]map[string]string{
@@ -50,6 +56,11 @@ var defaultConfig = map[string]map[string]string{
"IMAGE_SUBFOLDER_NAME": "attached",
"ALLOWED_IMAGE_EXTENSIONS": "jpg, jpeg, png, webp, gif",
"ALLOWED_FILE_EXTENSIONS": "txt, pdf, html, json, yaml, yml, conf, csv, cmd, bat, sh",
// Visibility defaults
"SHOW_IMAGES_IN_TREE": "false",
"SHOW_FILES_IN_TREE": "true",
"SHOW_IMAGES_IN_FOLDER": "true",
"SHOW_FILES_IN_FOLDER": "true",
},
}
@@ -90,6 +101,20 @@ func Load() (*Config, error) {
config.AllowedFileExtensions = parseCommaSeparated(notesSection.Key("ALLOWED_FILE_EXTENSIONS").String())
config.ImagesHide, _ = notesSection.Key("IMAGES_HIDE").Bool()
// New visibility flags (fallback to legacy IMAGES_HIDE for folder images if keys missing)
config.ShowImagesInTree, _ = notesSection.Key("SHOW_IMAGES_IN_TREE").Bool()
config.ShowFilesInTree, _ = notesSection.Key("SHOW_FILES_IN_TREE").Bool()
if key := notesSection.Key("SHOW_IMAGES_IN_FOLDER"); key.String() != "" {
config.ShowImagesInFolder, _ = key.Bool()
} else {
// fallback: if IMAGES_HIDE true => not shown
config.ShowImagesInFolder = !config.ImagesHide
}
if key := notesSection.Key("SHOW_FILES_IN_FOLDER"); key.String() != "" {
config.ShowFilesInFolder, _ = key.Bool()
} else {
config.ShowFilesInFolder = true
}
config.ImageStorageMode, _ = notesSection.Key("IMAGE_STORAGE_MODE").Int()
config.ImageStoragePath = notesSection.Key("IMAGE_STORAGE_PATH").String()
config.ImageSubfolderName = notesSection.Key("IMAGE_SUBFOLDER_NAME").String()
@@ -231,6 +256,14 @@ func (c *Config) SaveSetting(section, key, value string) error {
c.AllowedImageExtensions = parseCommaSeparated(value)
case "ALLOWED_FILE_EXTENSIONS":
c.AllowedFileExtensions = parseCommaSeparated(value)
case "SHOW_IMAGES_IN_TREE":
c.ShowImagesInTree = value == "true"
case "SHOW_FILES_IN_TREE":
c.ShowFilesInTree = value == "true"
case "SHOW_IMAGES_IN_FOLDER":
c.ShowImagesInFolder = value == "true"
case "SHOW_FILES_IN_FOLDER":
c.ShowFilesInFolder = value == "true"
}
}