Vova Tkach 6 years ago
parent
commit
e2431dd495
3 changed files with 9 additions and 38 deletions
  1. 3 36
      engine/engine.go
  2. 3 1
      modules/module_index.go
  3. 3 1
      modules/module_some.go

+ 3 - 36
engine/engine.go

@@ -42,10 +42,6 @@ func (this *Engine) Process() bool {
 		return true
 	}
 
-	//
-	// TODO: make a redirect or display error page?
-	//
-
 	// Redirect to CP for creating MySQL config file
 	if !this.Wrap.IsBackend && !this.Wrap.ConfMysqlExists {
 		this.Wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
@@ -53,44 +49,15 @@ func (this *Engine) Process() bool {
 		return true
 	}
 
-	//
-	// TODO: show or not show configure MySQL form?
-	//
-
 	// Display MySQL install page on backend
 	if this.Wrap.IsBackend && !this.Wrap.ConfMysqlExists {
 		utils.SystemRenderTemplate(this.Wrap.W, assets.TmplCpMySql, nil)
 		return true
 	}
 
-	/*
-		// Read MySQL settings file
-		mc, err := utils.MySqlConfigRead(this.Wrap.DConfig + string(os.PathSeparator) + "mysql.json")
-		if err != nil {
-			utils.SystemErrorPageEngine(this.Wrap.W, err)
-			return true
-		}
-
-		// Connect to MySQL server
-		db, err := sql.Open("mysql", mc.User+":"+mc.Password+"@tcp("+mc.Host+":"+mc.Port+")/"+mc.Name)
-		if err != nil {
-			utils.SystemErrorPageEngine(this.Wrap.W, err)
-			return true
-		}
-		this.Wrap.DB = db
-		defer db.Close()
-		err = db.Ping()
-
-		// Check if MySQL server alive
-		if err != nil {
-			utils.SystemErrorPageEngine(this.Wrap.W, err)
-			return true
-		}
-	*/
-
 	// Separated logic
-	if this.Wrap.IsBackend {
-		return this.Mods.XXXBackEnd(this.Wrap)
+	if !this.Wrap.IsBackend {
+		return this.Mods.XXXFrontEnd(this.Wrap)
 	}
-	return this.Mods.XXXFrontEnd(this.Wrap)
+	return this.Mods.XXXBackEnd(this.Wrap)
 }

+ 3 - 1
modules/module_index.go

@@ -12,11 +12,13 @@ func (this *Modules) RegisterModule_Index() *Module {
 		Mount:  "index",
 		Name:   "Pages",
 	}, func(wrap *wrapper.Wrapper) {
+		// Front-end
 		wrap.W.WriteHeader(http.StatusOK)
 		wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
 		wrap.W.Header().Set("Content-Type", "text/html; charset=utf-8")
 		wrap.W.Write([]byte(`INDEX FrontEnd func call (` + wrap.CurrModule + `)`))
 	}, func(wrap *wrapper.Wrapper) {
+		// Back-end
 		wrap.W.WriteHeader(http.StatusOK)
 		wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
 		wrap.W.Header().Set("Content-Type", "text/html; charset=utf-8")
@@ -29,7 +31,7 @@ func (this *Modules) RegisterAction_MysqlSetup() *Action {
 		WantDB: false,
 		Mount:  "mysql",
 	}, func(wrap *wrapper.Wrapper) {
-		wrap.MsgError(`Some error`)
+		wrap.MsgError(`Install`)
 	})
 }
 

+ 3 - 1
modules/module_some.go

@@ -9,16 +9,18 @@ import (
 
 func (this *Modules) RegisterModule_Some() *Module {
 	return this.newModule(MInfo{
-		WantDB: false,
+		WantDB: true,
 		Mount:  "some",
 		Name:   "Some Module",
 	}, func(wrap *wrapper.Wrapper) {
+		// Front-end
 		fmt.Printf("SOME FrontEnd func call\n")
 		wrap.W.WriteHeader(http.StatusOK)
 		wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
 		wrap.W.Header().Set("Content-Type", "text/html; charset=utf-8")
 		wrap.W.Write([]byte(`SOME FrontEnd func call (` + wrap.CurrModule + `)`))
 	}, func(wrap *wrapper.Wrapper) {
+		// Back-end
 		fmt.Printf("SOME BackEnd func call\n")
 		wrap.W.WriteHeader(http.StatusOK)
 		wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")