hlfw.ca

webbing

Download patch

ref: 0560cdb3a0c7abf0a097d7c2bb2990df6ad15e9a
parent: eaca3d7278e2fa34b99c2f1d03b99037a828a2b6
author: halfwit <michaelmisch1985@gmail.com>
date: Mon Mar 30 04:20:48 PDT 2020

Add a helper func to run the Data func of each page in our cache

--- a/go.sum
+++ b/go.sum
@@ -1,6 +1,5 @@
 github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/olmaxmedical/database v0.0.0 h1:VLMZr5vMYXq5NcljKKlSebtHNG3NuYxhqloUW17Wxkc=
 github.com/olmaxmedical/database v0.0.0/go.mod h1:BPYEBAP3GYeSeqg5hOaH7GC8+P/VnD2OuHYounbVjQs=
 github.com/olmaxmedical/database v0.0.1 h1:cuocVljXq7cPRS9HygFg2B/WSdzWAZEHrc5uMnN+A0A=
 github.com/olmaxmedical/database v0.0.1/go.mod h1:/5Tl6/p0jpvLpj4GaoFki3wRG/3b+ipNNhM5Dyi6Zf8=
--- a/pages.go
+++ b/pages.go
@@ -54,15 +54,22 @@
 	hd := path.Join("templates", "header.tpl")
 	fd := path.Join("templates", "footer.tpl")
 	ld := path.Join("templates", "layout.tpl")
+
 	extra, err := os.Open(path.Join("templates", "plugins"))
 	if err != nil {
 		errs = append(errs, errors.New("Unable to locate templates/plugins"))
 		return errs
 	}
+
 	dirs, err := extra.Readdirnames(0)
+	if err != nil {
+		errs = append(errs, errors.New("Unable to read plugin dir"))
+	}
+
 	for n, dir := range dirs {
 		dirs[n] = path.Join("templates", "plugins", dir)
 	}
+
 	// TODO(halfwit) Validate our plugin templates here as well
 	dirs = append(dirs, hd, fd, ld)
 	printer := message.NewPrinter(message.MatchLanguage("en"))
@@ -82,6 +89,7 @@
 			path:    item.Path + ".html",
 			role:    database.PatientAuth | database.DoctorAuth | database.GuestAuth,
 		}
+
 		_, err = getData(p, "")
 		if err != nil {
 			errs = append(errs, err)
@@ -88,6 +96,19 @@
 		}
 	}
 	return errs
+}
+
+func RunPages() error {
+	printer := message.NewPrinter(message.MatchLanguage("en"))
+
+	for _, page := range pagecache {
+		data := page.Data(printer)
+		if len(data) < 1 {
+			return errors.New("no data from page")
+		}
+	}
+
+	return nil
 }
 
 func getpage(p *Request, w http.ResponseWriter) {