BUGFIX: invalid toml, hence live reload didnt work

This commit is contained in:
Simon Martens
2024-12-04 16:02:52 +01:00
parent a39d6be822
commit 7f3e3d1926
3 changed files with 64 additions and 44 deletions

View File

@@ -3,49 +3,58 @@ testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
args_bin = []
full_bin = "export KGPZ_WATCH=false; ./tmp/main"
cmd = "go build -tags=\"dev\" -o ./tmp/main ."
delay = 400
exclude_dir = ["views/public", "views/node_modules", "tmp", "vendor", "testdata", "data_git", "cache_gnd", "cache_geonames"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html", "gohtml" ]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = true
stop_on_error = true
args_bin = []
full_bin = "export KGPZ_WATCH=false; ./tmp/main"
cmd = "go build -tags=\"dev\" -o ./tmp/main ."
delay = 400
exclude_dir = [
"views/public",
"views/node_modules",
"views/transform",
"tmp",
"vendor",
"testdata",
"data_git",
"cache_gnd",
"cache_geonames",
]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html", "gohtml"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = true
stop_on_error = true
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
main_only = false
time = false
main_only = false
time = false
[misc]
clean_on_exit = true
clean_on_exit = true
[proxy]
app_port = 8080
enabled = true
proxy_port = 8081
app_port = 8080
enabled = true
proxy_port = 8081
[screen]
clear_on_rebuild = true
keep_scroll = true
clear_on_rebuild = true
keep_scroll = true

View File

@@ -7,6 +7,7 @@ import (
"sync"
"time"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers/logging"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
)
@@ -80,11 +81,13 @@ func (g *GitProvider) Pull() (error, bool) {
branch := plumbing.NewBranchReferenceName(g.Branch)
repo, err := git.PlainOpen(g.Path)
if err != nil {
logging.Error(err, "Error opening repository")
return err, false
}
wt, err := repo.Worktree()
if err != nil {
logging.Error(err, "Error getting worktree")
return err, false
}
@@ -96,12 +99,14 @@ func (g *GitProvider) Pull() (error, bool) {
if err == git.NoErrAlreadyUpToDate {
return nil, false
}
logging.Error(err, "Error pulling repository")
return err, false
}
defer wt.Clean(&git.CleanOptions{Dir: true})
oldCommit := g.Commit
if err := g.setValues(repo); err != nil {
logging.Error(err, "Error setting values for new commit")
return err, false
}
@@ -125,9 +130,6 @@ func (g *GitProvider) Clone() error {
repo, err := git.PlainClone(g.Path, false, &git.CloneOptions{
URL: g.URL,
Progress: os.Stdout,
SingleBranch: true,
ReferenceName: branch,
Depth: 1,
})
if err != nil {

View File

@@ -91,7 +91,7 @@ func (s *Server) Start() {
// Maybe we turn that behavior permanently off and differentiate HTMX from "normal" reuqests only by headers.
StrictRouting: true,
EnablePrintRoutes: s.Config.Debug,
// EnablePrintRoutes: s.Config.Debug,
// TODO: Error handler, which sadly, is global:
ErrorHandler: fiber.DefaultErrorHandler,
@@ -135,7 +135,17 @@ func (s *Server) Start() {
}))
}
srv.Get("/:year?", controllers.GetYear(s.kgpz))
// TODO: this is probably a bad idea, since it basically applies to every /XXXX URL
// And probably creates problems with static files, and in case we add a front page later.
// That's why we redirect to /1764 on "/ " and don´t use an optional /:year?
srv.Get("/", func(c *fiber.Ctx) error {
c.Redirect("/1764")
return nil
})
srv.Get("/:year", controllers.GetYear(s.kgpz))
// TODO: Same here, this prob applies to all paths with two or three segments, which is bad.
// Prob better to do /ausgabe/:year/:issue/:page? here and /jahrgang/:year? above.
srv.Get("/:year/:issue/:page?", controllers.GetIssue(s.kgpz))
srv.Get("/:year/:issue/beilage/:page?", controllers.GetIssue(s.kgpz))
@@ -187,7 +197,6 @@ func (s *Server) runner(srv *fiber.App) {
go func() {
defer s.shutdown.Done()
logging.Info("Starting server on ", s.Config.Address+":"+s.Config.Port)
if err := srv.Listen(s.Config.Address + ":" + s.Config.Port); err != nil {
logging.Error(err, "Error starting server")
return