mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 01:05:32 +00:00
BUGFIX: Almanach-Bilder-Import mit Kommas
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@ tmp/
|
||||
bin/
|
||||
cache/
|
||||
data_bilder/
|
||||
Almanach-Bilder/
|
||||
config.json
|
||||
out.log
|
||||
*.log
|
||||
|
||||
36
;
36
;
@@ -1,36 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/app"
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/cmd"
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/helpers"
|
||||
_ "github.com/Theodor-Springmann-Stiftung/musenalm/migrations"
|
||||
_ "github.com/Theodor-Springmann-Stiftung/musenalm/pages"
|
||||
"github.com/pocketbase/pocketbase/plugins/migratecmd"
|
||||
)
|
||||
|
||||
const (
|
||||
DEV_CONFIG = "config.dev.json"
|
||||
DEFAULT_CONFIG = "config.json"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := app.NewConfigProvider([]string{DEFAULT_CONFIG}, []string{DEV_CONFIG})
|
||||
if err := cfg.Read(); err != nil {
|
||||
helpers.Assert(err, "Error reading config")
|
||||
}
|
||||
|
||||
app := app.New(*cfg.Config)
|
||||
app.PB.RootCmd.AddCommand(cmd.AddResetPagesCommand(app.PB, &app))
|
||||
|
||||
migratecmd.MustRegister(app.PB, app.PB.RootCmd, migratecmd.Config{
|
||||
Automigrate: false,
|
||||
TemplateLang: migratecmd.TemplateLangGo,
|
||||
})
|
||||
|
||||
if err := app.Serve(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func commatizeArray(array []string) string {
|
||||
}
|
||||
|
||||
func getImages(path string) map[string][]string {
|
||||
/// BUG: there is a bug somewhere, where files ending with numbers after a comma (",001") etc dont get added
|
||||
/// FIXED: there is a bug somewhere, where files ending with numbers after a comma (",001") etc dont get added
|
||||
ret := make(map[string][]string)
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
return ret
|
||||
@@ -136,18 +136,16 @@ func getImages(path string) map[string][]string {
|
||||
|
||||
e := func(path string, fileInfo os.FileInfo, inpErr error) (err error) {
|
||||
if !fileInfo.IsDir() {
|
||||
basesplit := strings.Split(fileInfo.Name(), "-")
|
||||
if len(basesplit) == 3 {
|
||||
extensionsplit := strings.Split(basesplit[2], ".")
|
||||
if len(extensionsplit) == 2 {
|
||||
// BUG: prob here
|
||||
commaseperatorsplit := strings.Split(extensionsplit[0], ",")
|
||||
id := commaseperatorsplit[1]
|
||||
if _, ok := ret[id]; !ok {
|
||||
ret[id] = make([]string, 0)
|
||||
}
|
||||
ret[id] = append(ret[id], path)
|
||||
ext := filepath.Ext(fileInfo.Name())
|
||||
filename := strings.TrimSuffix(fileInfo.Name(), ext)
|
||||
basesplit := strings.Split(filename, "-")
|
||||
if len(basesplit) >= 3 {
|
||||
commaseperatorsplit := strings.Split(basesplit[2], ",")
|
||||
id := commaseperatorsplit[0]
|
||||
if _, ok := ret[id]; !ok {
|
||||
ret[id] = make([]string, 0)
|
||||
}
|
||||
ret[id] = append(ret[id], path)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user