diff options
-rw-r--r-- | main.go | 14 | ||||
-rw-r--r-- | render/render.go | 6 |
2 files changed, 16 insertions, 4 deletions
@@ -47,7 +47,6 @@ func main() { if verbose { config.Config.Verbose = true } - render.Init() if build { buildSite() @@ -61,7 +60,6 @@ func main() { } if watch { - fmt.Printf("watching %s\n", config.Config.TxtDir) watchSite() } @@ -73,11 +71,14 @@ func main() { } func buildSite() { + vlog.Printf("reading templates...\n") + render.Init() var s site.Site vlog.Printf("reading posts...\n") s.Read() vlog.Printf("writing posts and archives...\n") s.Write() + vlog.Printf("done...\n") } func watchSite() { @@ -93,8 +94,9 @@ func watchSite() { select { case event := <-watcher.Events: if event.Op&fsnotify.Write == fsnotify.Write { - fmt.Printf("rebuilding\n") + fmt.Printf("rebuilding... ") buildSite() + fmt.Printf("done\n") } case err := <-watcher.Errors: vlog.Printf("error: %v", err) @@ -102,9 +104,15 @@ func watchSite() { } }() + fmt.Printf("watching %s\n", config.Config.TxtDir) err = watcher.Add(config.Config.TxtDir) if err != nil { panic(err) } + fmt.Printf("watching %s\n", config.Config.TmplDir) + err = watcher.Add(config.Config.TmplDir) + if err != nil { + panic(err) + } <-done } diff --git a/render/render.go b/render/render.go index ba8e52b..bf53208 100644 --- a/render/render.go +++ b/render/render.go @@ -77,7 +77,11 @@ func Init() { tx := template.New("t").Funcs(tmplFuncs) templates[tf], err = tx.ParseFiles(base, t) if err != nil { - panic(err) + // temporary files can confuse this, especially when + // running the file system watcher so we silently + // ignore any templates that disappeared since we started + // since this is usually not a real error condition + delete(templates, tf) } } rel_href = regexp.MustCompile(`href="/(.+)"`) |