ref: 97bb36f2aa4bd64e6dd527c240215ceb53d01e1f
parent: 97f1232db4cc0c8db4975d8af76701f82a9bfce7
author: Michael Misch <michaelmisch1985@gmail.com>
date: Mon Oct 28 09:57:38 PDT 2019
Add a few small changes, get ready for plugins
--- a/client.go
+++ b/client.go
@@ -12,6 +12,7 @@
_ "github.com/olmaxmedical/olmax_go/pages/help"
_ "github.com/olmaxmedical/olmax_go/pages/patient"
"github.com/olmaxmedical/olmax_go/router"
+ //"github.com/olmaxmedical/olmax_go/plugins"
"github.com/olmaxmedical/olmax_go/session"
)
@@ -22,10 +23,10 @@
if err != nil {
log.Fatalf("Unable to initialize manager %v", err)
}
- // This is session timeouts, I didn't write this logic and it's very, very broken
+ //BUG(halfwit) This is session timeouts, I didn't write this logic and it's very, very broken
//go sessions.GC()
- errs := router.ValidateAndCache()
+ errs := router.ValidatePages()
if len(errs) > 0 {
for _, err := range errs {
log.Print(err)
@@ -32,6 +33,7 @@
}
log.Fatal("Unable to continue due to template errors")
}
+ errs := router.ValidatePlugins()
go func() {
http.ListenAndServe(":6060", nil)
}()
--- a/pages/doctor/application.go
+++ b/pages/doctor/application.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth,
- Css: "",
+ CSS: "",
Path: "doctor/application",
Data: Application,
Extra: router.ListCountries | router.ListServices | router.FormErrors | router.FormToken,
--- a/pages/doctor/bookings.go
+++ b/pages/doctor/bookings.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "doctor/bookings",
Data: Bookings,
Extra: 0,
--- a/pages/doctor/findpatients.go
+++ b/pages/doctor/findpatients.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "doctor/findpatients",
Data: Findpatients,
Extra: 0,
--- a/pages/doctor/profile.go
+++ b/pages/doctor/profile.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "doctor/profile",
Data: Profile,
Extra: router.FormErrors | router.FormToken,
--- a/pages/help/appointments.go
+++ b/pages/help/appointments.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth | router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "help/appointments",
Data: Appointments,
Extra: 0,
--- a/pages/help/catalog.go
+++ b/pages/help/catalog.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth | router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "help/catalog",
Data: Catalog,
Extra: 0,
--- a/pages/help/contacting.go
+++ b/pages/help/contacting.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth | router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "help/contacting",
Data: Contacting,
Extra: 0,
--- a/pages/help/help.go
+++ b/pages/help/help.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth | router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "help/faq",
Data: Faq,
Extra: 0,
--- a/pages/help/paymentmethods.go
+++ b/pages/help/paymentmethods.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth | router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "help/paymentmethods",
Data: Paymethod,
Extra: 0,
--- a/pages/help/pricesandfees.go
+++ b/pages/help/pricesandfees.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth | router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "help/pricesandfees",
Data: Pricefee,
Extra: 0,
--- a/pages/help/provider.go
+++ b/pages/help/provider.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth | router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "help/provider",
Data: Provider,
Extra: router.ListServices,
--- a/pages/help/verification.go
+++ b/pages/help/verification.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth | router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "help/verification",
Data: Verification,
Extra: 0,
--- a/pages/index.go
+++ b/pages/index.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth | router.DoctorAuth | router.PatientAuth,
- Css: "index.css",
+ CSS: "index.css",
Path: "index",
Data: Index,
Extra: router.ListDoctors | router.FormErrors,
--- a/pages/login.go
+++ b/pages/login.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth,
- Css: "",
+ CSS: "",
Path: "login",
Data: Login,
Extra: router.FormErrors,
--- a/pages/messages.go
+++ b/pages/messages.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "messages",
Data: Messages,
Extra: 0,
--- a/pages/newpassword.go
+++ b/pages/newpassword.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth,
- Css: "",
+ CSS: "",
Path: "newpassword",
Data: NewPassword,
Extra: router.FormToken | router.FormErrors,
--- a/pages/patient/appointments.go
+++ b/pages/patient/appointments.go
@@ -10,7 +10,7 @@
func init() {
b := &router.Page{
Access: router.PatientAuth,
- Css: "",
+ CSS: "",
Path: "patient/appointments",
Data: Appointments,
Extra: 0,
--- a/pages/patient/offer.go
+++ b/pages/patient/offer.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.PatientAuth,
- Css: "",
+ CSS: "",
Path: "patient/offer",
Data: Createoffer,
Extra: router.ListServices | router.FormErrors,
--- a/pages/patient/profile.go
+++ b/pages/patient/profile.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.PatientAuth,
- Css: "",
+ CSS: "",
Path: "patient/profile",
Data: Profile,
Extra: 0, // listPendingAppointments
--- a/pages/patient/symptoms.go
+++ b/pages/patient/symptoms.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.PatientAuth,
- Css: "",
+ CSS: "",
Path: "patient/symptoms",
Data: Symptoms,
Extra: router.FormErrors | router.SessionToken,
--- a/pages/resetpassword.go
+++ b/pages/resetpassword.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth,
- Css: "",
+ CSS: "",
Path: "resetpassword",
Data: ResetPassword,
Extra: router.FormErrors,
--- a/pages/signup.go
+++ b/pages/signup.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.GuestAuth,
- Css: "",
+ CSS: "",
Path: "signup",
Data: Signup,
Extra: router.FormErrors,
--- a/pages/wallet.go
+++ b/pages/wallet.go
@@ -8,7 +8,7 @@
func init() {
b := &router.Page{
Access: router.PatientAuth | router.DoctorAuth,
- Css: "",
+ CSS: "",
Path: "wallet",
Data: Wallet,
Extra: 0,
--- /dev/null
+++ b/plugins/plugins.go
@@ -1,0 +1,5 @@
+package plugins
+
+func ValidateAndRegister() []string {
+
+}
\ No newline at end of file
--- a/router/countries.go
+++ b/router/countries.go
@@ -8,6 +8,7 @@
"golang.org/x/text/message"
)
+// Country - Mapping token to internationalized country code
type Country struct {
ID string
Name string
--- a/router/forms.go
+++ b/router/forms.go
@@ -14,8 +14,8 @@
var formlist map[string]*Form
+// After will go away when with plugins
type After uint16
-
const (
ValidateLogin After = 1 << iota
ValidateCountry
--- a/router/pages.go
+++ b/router/pages.go
@@ -20,6 +20,7 @@
countrylist = listcountries()
}
+// Access defines the access rights for a specific page
type Access uint8
const (
@@ -28,6 +29,7 @@
DoctorAuth
)
+// IncludeExtra - helper bitmasks to populate common elements across the site
type IncludeExtra uint8
const (
@@ -39,21 +41,23 @@
SessionToken
)
+// Page defines what a client receives from a GET request
type Page struct {
Access Access
Extra IncludeExtra
- Css string
+ CSS string
Path string
Data func(p *message.Printer) map[string]interface{}
tmpl *template.Template
}
+// Add - register a *Page to the cache
func Add(p *Page) {
pagecache[p.Path+".html"] = p
}
-// Walk all our templates and finally return applicable errors as an array
-func ValidateAndCache() []error {
+// ValidatePages - Walk all our templates and finally return applicable errors as an array
+func ValidatePages() []error {
var errs []error
hd := path.Join("templates", "header.tpl")
fd := path.Join("templates", "footer.tpl")
@@ -80,6 +84,13 @@
errs = append(errs, err)
}
}
+ return errs
+}
+
+// ValidatePlugins will register each plugin and do a test load, returning all errors encountered
+// If any plugin tries to register with the same key it will be a fatal error
+func ValidatePlugins() []error {
+ var errs []error
return errs
}
--- a/router/run.go
+++ b/router/run.go
@@ -14,6 +14,7 @@
manager *session.Manager
}
+// Route - All requests pass through here firstßß
func Route(manager *session.Manager) error {
d := &handle{
manager: manager,
--- a/router/specialties.go
+++ b/router/specialties.go
@@ -5,6 +5,8 @@
)
// TODO: inverse function to get the actual specialty back from a whitelist
+
+// Specialty - mapping our token to internationalized string
type Specialty struct {
ID string
Name string