ref: 8299e0d65f1068f09c04eb9772fceade472d8dc1
parent: 2df8bdd3d9687dcac666bedab5ea1b41fe72b4a7
author: Michael Misch <michaelmisch1985@gmail.com>
date: Thu Nov 7 01:57:48 PST 2019
AddPage to avoid confusing with other Add functions
--- a/pages/doctor/application.go
+++ b/pages/doctor/application.go
@@ -13,7 +13,7 @@
Data: Application,
Extra: router.ListCountries | router.ListServices | router.FormErrors | router.FormToken,
}
- router.Add(b)
+ router.AddPage(b)
}
// Application - olmaxmedical.com/doctor/application.html
--- a/pages/doctor/bookings.go
+++ b/pages/doctor/bookings.go
@@ -13,7 +13,7 @@
Data: Bookings,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Bookings - olmaxmedical.com/doctor/bookings.html
--- a/pages/doctor/findpatients.go
+++ b/pages/doctor/findpatients.go
@@ -13,7 +13,7 @@
Data: Findpatients,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Findpatients - olmaxmedical.com/doctor/findpatients.html
--- a/pages/doctor/profile.go
+++ b/pages/doctor/profile.go
@@ -13,7 +13,7 @@
Data: Profile,
Extra: router.FormErrors | router.FormToken,
}
- router.Add(b)
+ router.AddPage(b)
}
// Profile - olmaxmedical.com/doctor/profile.html
--- a/pages/help/appointments.go
+++ b/pages/help/appointments.go
@@ -13,7 +13,7 @@
Data: Appointments,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Appointments - olmaxmedical.com/help/appointments.html
--- a/pages/help/catalog.go
+++ b/pages/help/catalog.go
@@ -13,7 +13,7 @@
Data: Catalog,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Catalog - olmaxmedical.com/help/catalog.html
--- a/pages/help/contacting.go
+++ b/pages/help/contacting.go
@@ -13,7 +13,7 @@
Data: Contacting,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Contacting - olmaxmedical.com/help/contacting.html
--- a/pages/help/help.go
+++ b/pages/help/help.go
@@ -13,7 +13,7 @@
Data: Faq,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Faq - olmaxmedical.com/help/faq.html
--- a/pages/help/paymentmethods.go
+++ b/pages/help/paymentmethods.go
@@ -13,7 +13,7 @@
Data: Paymethod,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Paymethod - olmaxmedical.com/help/paymentmethods.html
--- a/pages/help/pricesandfees.go
+++ b/pages/help/pricesandfees.go
@@ -13,7 +13,7 @@
Data: Pricefee,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Pricefee - olmaxmedical.com/help/pricesandfees.html
--- a/pages/help/provider.go
+++ b/pages/help/provider.go
@@ -13,7 +13,7 @@
Data: Provider,
Extra: router.ListServices,
}
- router.Add(b)
+ router.AddPage(b)
}
// Provider - olmaxmedical.com/help/provider.html
--- a/pages/help/verification.go
+++ b/pages/help/verification.go
@@ -13,7 +13,7 @@
Data: Verification,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Verification - olmaxmedical.com/help/verification.html
--- a/pages/index.go
+++ b/pages/index.go
@@ -13,7 +13,7 @@
Data: Index,
Extra: router.ListDoctors | router.FormErrors,
}
- router.Add(b)
+ router.AddPage(b)
}
// Index - olmaxmedical.com/index.html
--- a/pages/login.go
+++ b/pages/login.go
@@ -14,7 +14,7 @@
Extra: router.FormErrors,
}
//router.AddGet(b)
- router.Add(b)
+ router.AddPage(b)
}
// Login - olmaxmedical.com/login.html
--- a/pages/messages.go
+++ b/pages/messages.go
@@ -13,7 +13,7 @@
Data: Messages,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Messages - olmaxmedical.com/messages.html
--- a/pages/newpassword.go
+++ b/pages/newpassword.go
@@ -13,7 +13,7 @@
Data: NewPassword,
Extra: router.FormToken | router.FormErrors,
}
- router.Add(b)
+ router.AddPage(b)
}
// NewPassword - olmaxmedical.com/newpassword.html
--- a/pages/patient/appointments.go
+++ b/pages/patient/appointments.go
@@ -15,7 +15,7 @@
Data: Appointments,
Extra: 0, // call function to look up appointments here
}
- router.Add(b)
+ router.AddPage(b)
}
// Appointments - olmaxmedical.com/patient/appointments.html
--- a/pages/patient/offer.go
+++ b/pages/patient/offer.go
@@ -13,7 +13,7 @@
Data: Createoffer,
Extra: router.ListServices | router.FormErrors,
}
- router.Add(b)
+ router.AddPage(b)
}
// Createoffer - olmaxmedical.com/patient/offer.html
--- a/pages/patient/profile.go
+++ b/pages/patient/profile.go
@@ -13,7 +13,7 @@
Data: Profile,
Extra: 0, // listPendingAppointments
}
- router.Add(b)
+ router.AddPage(b)
}
// Profile - olmaxmedical.com/patient/profile.html
--- a/pages/patient/symptoms.go
+++ b/pages/patient/symptoms.go
@@ -13,7 +13,7 @@
Data: Symptoms,
Extra: router.FormErrors | router.SessionToken,
}
- router.Add(b)
+ router.AddPage(b)
}
// Symptoms - olmaxmedical.com/patient/symptoms.html
--- a/pages/resetpassword.go
+++ b/pages/resetpassword.go
@@ -13,7 +13,7 @@
Data: ResetPassword,
Extra: router.FormErrors,
}
- router.Add(b)
+ router.AddPage(b)
}
// ResetPassword - olmaxmedical.com/resetpassword.html
--- a/pages/signup.go
+++ b/pages/signup.go
@@ -13,7 +13,7 @@
Data: Signup,
Extra: router.FormErrors,
}
- router.Add(b)
+ router.AddPage(b)
}
// Signup - olmaxmedical.com/signup.html
--- a/pages/wallet.go
+++ b/pages/wallet.go
@@ -13,7 +13,7 @@
Data: Wallet,
Extra: 0,
}
- router.Add(b)
+ router.AddPage(b)
}
// Wallet - olmaxmedical.com/wallet.html
--- a/router/forms.go
+++ b/router/forms.go
@@ -55,7 +55,7 @@
// Ideally, the *page abstraction will never leak into the form validation
func parseform(p *page, w http.ResponseWriter, r *http.Request) (*Form, []string) {
var errors, errs []string
- var e, msg string
+ var msg string
form, ok := formlist[p.path]
if !ok {
errors = append(errors, "No such page")
--- a/router/pages.go
+++ b/router/pages.go
@@ -13,8 +13,9 @@
)
var pagecache map[string]*Page
-var countrylist []Country
+//var countrylist []Country
+
func init() {
pagecache = make(map[string]*Page)
//countrylist = listcountries()
@@ -51,8 +52,8 @@
tmpl *template.Template
}
-// Add - register a *Page to the cache
-func Add(p *Page) {
+// AddPage - register a *Page to the cache
+func AddPage(p *Page) {
pagecache[p.Path+".html"] = p
}
--- a/router/plugins.go
+++ b/router/plugins.go
@@ -1,7 +1,19 @@
package router
-//var pluginCache map[string]*plugin
+import (
+ "golang.org/x/text/message"
+)
+var pluginCache map[int]*Plugin
+
+type Plugin struct {
+ Run func(p *message.Printer) map[string]interface{}
+}
+
+func init() {
+ pluginCache = make(map[int]*Plugin)
+}
+
// ValidatePlugins - Run through each plugin
// make sure that its mapping isn't redundant with any other
// Make sure the code runs accurately without error
@@ -8,4 +20,8 @@
func ValidatePlugins() []error {
errs := []error{}
return errs
+}
+
+func Register(p *Plugin, key int) {
+ pluginCache[key] = p
}