diff --git a/main.go b/main.go index 5e37e11..c24a9a5 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,7 @@ done */ import ( + _ "embed" "encoding/base64" "flag" "fmt" @@ -103,59 +104,14 @@ func getSites(largest int, wd selenium.WebDriver) (sites []HatsSite, err error) return sites, nil } +//go:embed template.html +var rawtmpl string + func generateHTML(sites []HatsSite, w io.Writer) error { funcs := template.FuncMap{ "parseTime": func(s string) time.Time { time, _ := time.Parse(time.RFC3339, s); return time }, } - tmpl, err := template.New("main").Funcs(funcs).Parse(` - - - - - - {n}hats.com domains - - - -

{n}hats.com domains

-

Summary

- - {{range .}} -

{{.DomainName}}

-
-
Fetched
-
{{.FetchTime.Format "Mon Jan 2 15:04:05 -0700 MST 2006" }}
-
Owner
-
{{.Registrant.Name}} <{{.Registrant.Email}}>
- {{if not .Available}} -
Since
-
{{(parseTime .DomainInfo.CreatedDate).Format "Mon Jan 2 2006" }}
- {{end}} - {{with .Title}} -
Title
-
{{.}}
- {{end}} -
- {{if .ScreenshotURL}} - screenshot of {{.DomainName}} as of {{.FetchTime.Format - {{end}} - {{end}} - - `) + tmpl, err := template.New("main").Funcs(funcs).Parse(rawtmpl) if err != nil { return err } diff --git a/template.html b/template.html new file mode 100644 index 0000000..d43705a --- /dev/null +++ b/template.html @@ -0,0 +1,49 @@ + + + + + + + {n}hats.com domains + + + +

{n}hats.com domains

+

Summary

+ + {{range .}} +

{{.DomainName}}

+
+
Fetched
+
{{.FetchTime.Format "Mon Jan 2 15:04:05 -0700 MST 2006" }}
+
Owner
+
{{.Registrant.Name}} <{{.Registrant.Email}}>
+ {{if not .Available}} +
Since
+
{{(parseTime .DomainInfo.CreatedDate).Format "Mon Jan 2 2006" }}
+ {{end}} + {{with .Title}} +
Title
+
{{.}}
+ {{end}} +
+ {{if .ScreenshotURL}} + screenshot of {{.DomainName}} as of {{.FetchTime.Format + {{end}} + {{end}} + +