mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-07 16:33:40 +00:00
log execution steps
This commit is contained in:
parent
43fe5dbe66
commit
8b819d98d2
13
main.go
13
main.go
@ -139,11 +139,14 @@ func makeSiteStruct(objs map[string]*Object) error {
|
|||||||
// FIXME: embed templates
|
// FIXME: embed templates
|
||||||
// FIXME: parse templates once at start
|
// FIXME: parse templates once at start
|
||||||
t := template.Must(template.ParseFiles(tmplCategory))
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Write category Index file: %s\n", categoryIndexFilename)
|
||||||
|
|
||||||
if err := t.Execute(f, obj); err != nil {
|
if err := t.Execute(f, obj); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -154,8 +157,11 @@ func makeSiteStruct(objs map[string]*Object) error {
|
|||||||
|
|
||||||
func makeSitemap(objs map[string]*Object) {
|
func makeSitemap(objs map[string]*Object) {
|
||||||
t := template.Must(template.ParseFiles(tmplSitemap))
|
t := template.Must(template.ParseFiles(tmplSitemap))
|
||||||
|
// FIXME: handle error
|
||||||
f, _ := os.Create(outSitemapFile)
|
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) {
|
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)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -53,6 +54,7 @@ func GenerateHTML(srcFilename, outFilename string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Write Index file: %s\n", outIndexFile)
|
||||||
if err := t.Execute(f, c); err != nil {
|
if err := t.Execute(f, c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user