From 8b819d98d2c408a8eff566ded02e444e64427633 Mon Sep 17 00:00:00 2001 From: Kirill Zhuravlev Date: Tue, 14 Feb 2023 18:50:14 +0100 Subject: [PATCH] log execution steps --- main.go | 13 ++++++++++--- scripts.go | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index f4e56112..a2a3a173 100644 --- a/main.go +++ b/main.go @@ -139,11 +139,14 @@ func makeSiteStruct(objs map[string]*Object) error { // FIXME: embed templates // FIXME: parse templates once at start t := template.Must(template.ParseFiles(tmplCategory)) - f, err := os.Create(filepath.Join(categoryDir, "index.html")) + categoryIndexFilename := filepath.Join(categoryDir, "index.html") + f, err := os.Create(categoryIndexFilename) if err != nil { return err } + fmt.Printf("Write category Index file: %s\n", categoryIndexFilename) + if err := t.Execute(f, obj); err != nil { return err } @@ -154,8 +157,11 @@ func makeSiteStruct(objs map[string]*Object) error { func makeSitemap(objs map[string]*Object) { t := template.Must(template.ParseFiles(tmplSitemap)) + // FIXME: handle error f, _ := os.Create(outSitemapFile) - t.Execute(f, objs) + fmt.Printf("Render Sitemap to: %s\n", outSitemapFile) + + _ = t.Execute(f, objs) } func makeObjByID(selector string, s *goquery.Selection) (obj *Object) { @@ -206,5 +212,6 @@ func changeLinksInIndex(html string, query *goquery.Document, objs map[string]*O } }) - os.WriteFile(outIndexFile, []byte(html), 0644) + fmt.Printf("Rewrite links in Index file: %s\n", outIndexFile) + _ = os.WriteFile(outIndexFile, []byte(html), 0644) } diff --git a/scripts.go b/scripts.go index db788316..876c881b 100644 --- a/scripts.go +++ b/scripts.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "fmt" "html/template" "os" @@ -53,6 +54,7 @@ func GenerateHTML(srcFilename, outFilename string) error { return err } + fmt.Printf("Write Index file: %s\n", outIndexFile) if err := t.Execute(f, c); err != nil { return err }