Skip to content

Commit

Permalink
log execution steps
Browse files Browse the repository at this point in the history
  • Loading branch information
kazhuravlev authored and avelino committed Apr 3, 2023
1 parent f0dbbd1 commit d90b18f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
}
2 changes: 2 additions & 0 deletions scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"fmt"
"html/template"
"os"

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit d90b18f

Please sign in to comment.