mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +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/
|
bin/
|
||||||
cache/
|
cache/
|
||||||
data_bilder/
|
data_bilder/
|
||||||
|
Almanach-Bilder/
|
||||||
config.json
|
config.json
|
||||||
out.log
|
out.log
|
||||||
*.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 {
|
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)
|
ret := make(map[string][]string)
|
||||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||||
return ret
|
return ret
|
||||||
@@ -136,18 +136,16 @@ func getImages(path string) map[string][]string {
|
|||||||
|
|
||||||
e := func(path string, fileInfo os.FileInfo, inpErr error) (err error) {
|
e := func(path string, fileInfo os.FileInfo, inpErr error) (err error) {
|
||||||
if !fileInfo.IsDir() {
|
if !fileInfo.IsDir() {
|
||||||
basesplit := strings.Split(fileInfo.Name(), "-")
|
ext := filepath.Ext(fileInfo.Name())
|
||||||
if len(basesplit) == 3 {
|
filename := strings.TrimSuffix(fileInfo.Name(), ext)
|
||||||
extensionsplit := strings.Split(basesplit[2], ".")
|
basesplit := strings.Split(filename, "-")
|
||||||
if len(extensionsplit) == 2 {
|
if len(basesplit) >= 3 {
|
||||||
// BUG: prob here
|
commaseperatorsplit := strings.Split(basesplit[2], ",")
|
||||||
commaseperatorsplit := strings.Split(extensionsplit[0], ",")
|
id := commaseperatorsplit[0]
|
||||||
id := commaseperatorsplit[1]
|
if _, ok := ret[id]; !ok {
|
||||||
if _, ok := ret[id]; !ok {
|
ret[id] = make([]string, 0)
|
||||||
ret[id] = make([]string, 0)
|
|
||||||
}
|
|
||||||
ret[id] = append(ret[id], path)
|
|
||||||
}
|
}
|
||||||
|
ret[id] = append(ret[id], path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user