Browse Source

Code refactoring

Vova Tkach 6 years ago
parent
commit
b7bb4e4ab1
3 changed files with 163 additions and 163 deletions
  1. 13 13
      engine/wrapper/redirects.go
  2. 83 83
      engine/wrapper/static.go
  3. 67 67
      engine/wrapper/wrapper.go

+ 13 - 13
engine/wrapper/redirects.go

@@ -6,29 +6,29 @@ import (
 	"strings"
 )
 
-func (e *Wrapper) redirectToMainDomain() bool {
-	file, err := ioutil.ReadFile(e.DirVhostHome + "/config/domain")
+func (this *Wrapper) redirectToMainDomain() bool {
+	file, err := ioutil.ReadFile(this.DirVhostHome + "/config/domain")
 	if err == nil {
 		maindomain := strings.TrimSpace(string(file))
 		port := ""
-		if e.Port != "80" {
-			port = ":" + e.Port
+		if this.Port != "80" {
+			port = ":" + this.Port
 		}
-		if maindomain+port != e.R.Host {
-			http.Redirect(*e.W, e.R, e.R.URL.Scheme+"://"+maindomain+
-				port+e.R.URL.RequestURI(), 301)
+		if maindomain+port != this.R.Host {
+			http.Redirect(*this.W, this.R, this.R.URL.Scheme+"://"+maindomain+
+				port+this.R.URL.RequestURI(), 301)
 			return true
 		}
 	}
 	return false
 }
 
-func (e *Wrapper) redirectSeoFix() bool {
-	full := e.R.URL.RequestURI()
-	uris := full[len(e.R.URL.Path):]
-	if len(e.R.URL.Path) > 0 {
-		if e.R.URL.Path[len(e.R.URL.Path)-1] != '/' {
-			http.Redirect(*e.W, e.R, e.R.URL.Path+"/"+uris, 301)
+func (this *Wrapper) redirectSeoFix() bool {
+	full := this.R.URL.RequestURI()
+	uris := full[len(this.R.URL.Path):]
+	if len(this.R.URL.Path) > 0 {
+		if this.R.URL.Path[len(this.R.URL.Path)-1] != '/' {
+			http.Redirect(*this.W, this.R, this.R.URL.Path+"/"+uris, 301)
 			return true
 		}
 	} else {

+ 83 - 83
engine/wrapper/static.go

@@ -17,161 +17,161 @@ type tmplDataErrorMsg struct {
 	ErrorMessage string
 }
 
-func (e *Wrapper) staticResource() bool {
-	if e.R.URL.Path == "/assets/sys/styles.css" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "text/css")
-		(*e.W).Write(styles.File_assets_sys_styles_css)
+func (this *Wrapper) staticResource() bool {
+	if this.R.URL.Path == "/assets/sys/styles.css" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "text/css")
+		(*this.W).Write(styles.File_assets_sys_styles_css)
 		return true
-	} else if e.R.URL.Path == "/assets/cp/styles.css" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "text/css")
-		(*e.W).Write(styles.File_assets_cp_styles_css)
+	} else if this.R.URL.Path == "/assets/cp/styles.css" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "text/css")
+		(*this.W).Write(styles.File_assets_cp_styles_css)
 		return true
-	} else if e.R.URL.Path == "/assets/sys/bootstrap.css" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "text/css")
-		(*e.W).Write(styles.File_assets_sys_bootstrap_css)
+	} else if this.R.URL.Path == "/assets/sys/bootstrap.css" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "text/css")
+		(*this.W).Write(styles.File_assets_sys_bootstrap_css)
 		return true
-	} else if e.R.URL.Path == "/assets/sys/jquery.js" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "application/javascript; charset=utf-8")
-		(*e.W).Write(scripts.File_assets_sys_jquery_js)
+	} else if this.R.URL.Path == "/assets/sys/jquery.js" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "application/javascript; charset=utf-8")
+		(*this.W).Write(scripts.File_assets_sys_jquery_js)
 		return true
-	} else if e.R.URL.Path == "/assets/sys/popper.js" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "application/javascript; charset=utf-8")
-		(*e.W).Write(scripts.File_assets_sys_popper_js)
+	} else if this.R.URL.Path == "/assets/sys/popper.js" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "application/javascript; charset=utf-8")
+		(*this.W).Write(scripts.File_assets_sys_popper_js)
 		return true
-	} else if e.R.URL.Path == "/assets/sys/bootstrap.js" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "application/javascript; charset=utf-8")
-		(*e.W).Write(scripts.File_assets_sys_bootstrap_js)
+	} else if this.R.URL.Path == "/assets/sys/bootstrap.js" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "application/javascript; charset=utf-8")
+		(*this.W).Write(scripts.File_assets_sys_bootstrap_js)
 		return true
-	} else if e.R.URL.Path == "/assets/cp/scripts.js" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "application/javascript; charset=utf-8")
-		(*e.W).Write(scripts.File_assets_cp_scripts_js)
+	} else if this.R.URL.Path == "/assets/cp/scripts.js" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "application/javascript; charset=utf-8")
+		(*this.W).Write(scripts.File_assets_cp_scripts_js)
 		return true
-	} else if e.R.URL.Path == "/assets/sys/logo.svg" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "image/svg+xml")
-		(*e.W).Write(others.File_assets_sys_logo_svg)
+	} else if this.R.URL.Path == "/assets/sys/logo.svg" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "image/svg+xml")
+		(*this.W).Write(others.File_assets_sys_logo_svg)
 		return true
-	} else if e.R.URL.Path == "/assets/sys/bg.png" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "image/png")
-		(*e.W).Write(images.File_assets_sys_bg_png)
+	} else if this.R.URL.Path == "/assets/sys/bg.png" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "image/png")
+		(*this.W).Write(images.File_assets_sys_bg_png)
 		return true
-	} else if e.R.URL.Path == "/assets/sys/logo.png" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "image/png")
-		(*e.W).Write(images.File_assets_sys_logo_png)
+	} else if this.R.URL.Path == "/assets/sys/logo.png" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "image/png")
+		(*this.W).Write(images.File_assets_sys_logo_png)
 		return true
-	} else if e.R.URL.Path == "/assets/sys/fave.ico" {
-		(*e.W).Header().Set("Cache-Control", "public, max-age=31536000")
-		(*e.W).Header().Set("Content-Type", "image/x-icon")
-		(*e.W).Write(others.File_assets_sys_fave_ico)
+	} else if this.R.URL.Path == "/assets/sys/fave.ico" {
+		(*this.W).Header().Set("Cache-Control", "public, max-age=31536000")
+		(*this.W).Header().Set("Content-Type", "image/x-icon")
+		(*this.W).Write(others.File_assets_sys_fave_ico)
 		return true
 	}
 	return false
 }
 
-func (e *Wrapper) staticFile() bool {
-	file := e.R.URL.Path
+func (this *Wrapper) staticFile() bool {
+	file := this.R.URL.Path
 	if file != "/" {
-		f, err := os.Open(e.DirVhostHome + "/htdocs" + file)
+		f, err := os.Open(this.DirVhostHome + "/htdocs" + file)
 		if err == nil {
 			defer f.Close()
-			st, err := os.Stat(e.DirVhostHome + "/htdocs" + file)
+			st, err := os.Stat(this.DirVhostHome + "/htdocs" + file)
 			if err != nil {
 				return false
 			}
 			if st.Mode().IsDir() {
 				return false
 			}
-			http.ServeFile(*e.W, e.R, e.DirVhostHome+"/htdocs"+file)
+			http.ServeFile(*this.W, this.R, this.DirVhostHome+"/htdocs"+file)
 			return true
 		}
 	} else {
-		f, err := os.Open(e.DirVhostHome + "/htdocs/index.html")
+		f, err := os.Open(this.DirVhostHome + "/htdocs/index.html")
 		if err == nil {
 			defer f.Close()
-			st, err := os.Stat(e.DirVhostHome + "/htdocs/index.html")
+			st, err := os.Stat(this.DirVhostHome + "/htdocs/index.html")
 			if err != nil {
 				return false
 			}
 			if st.Mode().IsDir() {
 				return false
 			}
-			http.ServeFile(*e.W, e.R, e.DirVhostHome+"/htdocs/index.html")
+			http.ServeFile(*this.W, this.R, this.DirVhostHome+"/htdocs/index.html")
 			return true
 		}
 	}
 	return false
 }
 
-func (e *Wrapper) printPageDefault() {
+func (this *Wrapper) printPageDefault() {
 	// Custom page
-	f, err := os.Open(e.DirVhostHome + "/htdocs" + "/index.html")
+	f, err := os.Open(this.DirVhostHome + "/htdocs" + "/index.html")
 	if err == nil {
 		defer f.Close()
-		http.ServeFile(*e.W, e.R, e.DirVhostHome+"/htdocs"+"/index.html")
+		http.ServeFile(*this.W, this.R, this.DirVhostHome+"/htdocs"+"/index.html")
 		return
 	}
 
 	// Default page
 	tmpl, err := template.New("template").Parse(string(templates.PageDefault))
 	if err != nil {
-		e.printTmplPageError(err)
+		this.printTmplPageError(err)
 		return
 	}
-	(*e.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
-	(*e.W).Header().Set("Content-Type", "text/html")
-	tmpl.Execute(*e.W, tmplDataAll{
-		System: e.tmplGetSystemData(),
+	(*this.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+	(*this.W).Header().Set("Content-Type", "text/html")
+	tmpl.Execute(*this.W, tmplDataAll{
+		System: this.tmplGetSystemData(),
 	})
 }
 
-func (e *Wrapper) printPage404() {
+func (this *Wrapper) printPage404() {
 	// Custom 404 error page
-	f, err := ioutil.ReadFile(e.DirVhostHome + "/htdocs" + "/404.html")
+	f, err := ioutil.ReadFile(this.DirVhostHome + "/htdocs" + "/404.html")
 	if err == nil {
-		(*e.W).WriteHeader(http.StatusNotFound)
-		(*e.W).Header().Set("Content-Type", "text/html")
-		(*e.W).Write(f)
+		(*this.W).WriteHeader(http.StatusNotFound)
+		(*this.W).Header().Set("Content-Type", "text/html")
+		(*this.W).Write(f)
 		return
 	}
 
 	// Default error page
 	tmpl, err := template.New("template").Parse(string(templates.PageError404))
 	if err != nil {
-		e.printTmplPageError(err)
+		this.printTmplPageError(err)
 		return
 	}
-	(*e.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
-	(*e.W).WriteHeader(http.StatusNotFound)
-	(*e.W).Header().Set("Content-Type", "text/html")
-	tmpl.Execute(*e.W, tmplDataAll{
-		System: e.tmplGetSystemData(),
+	(*this.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+	(*this.W).WriteHeader(http.StatusNotFound)
+	(*this.W).Header().Set("Content-Type", "text/html")
+	tmpl.Execute(*this.W, tmplDataAll{
+		System: this.tmplGetSystemData(),
 	})
 }
 
-func (e *Wrapper) printTmplPageError(perr error) {
+func (this *Wrapper) printTmplPageError(perr error) {
 	tmpl, err := template.New("template").Parse(string(templates.PageTmplError))
 	if err != nil {
-		(*e.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
-		(*e.W).WriteHeader(http.StatusInternalServerError)
-		(*e.W).Header().Set("Content-Type", "text/html")
-		(*e.W).Write([]byte("<h1>Critical engine error!</h1>"))
-		(*e.W).Write([]byte("<h2>" + perr.Error() + "</h2>"))
+		(*this.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+		(*this.W).WriteHeader(http.StatusInternalServerError)
+		(*this.W).Header().Set("Content-Type", "text/html")
+		(*this.W).Write([]byte("<h1>Critical engine error!</h1>"))
+		(*this.W).Write([]byte("<h2>" + perr.Error() + "</h2>"))
 		return
 	}
-	(*e.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
-	(*e.W).WriteHeader(http.StatusInternalServerError)
-	(*e.W).Header().Set("Content-Type", "text/html")
-	tmpl.Execute(*e.W, tmplDataAll{
-		System: e.tmplGetSystemData(),
+	(*this.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+	(*this.W).WriteHeader(http.StatusInternalServerError)
+	(*this.W).Header().Set("Content-Type", "text/html")
+	tmpl.Execute(*this.W, tmplDataAll{
+		System: this.tmplGetSystemData(),
 		Data: tmplDataErrorMsg{
 			ErrorMessage: perr.Error(),
 		},

+ 67 - 67
engine/wrapper/wrapper.go

@@ -14,7 +14,7 @@ import (
 
 const C_AssetsVersion = "3"
 
-type handleRun func(e *Wrapper) bool
+type handleRun func(wrapper *Wrapper) bool
 
 type tmplDataSystem struct {
 	PathIcoFav       string
@@ -48,18 +48,18 @@ type Wrapper struct {
 	Debug        bool
 }
 
-func (e *Wrapper) tmplGetSystemData() tmplDataSystem {
+func (this *Wrapper) tmplGetSystemData() tmplDataSystem {
 	version := "?v=" + C_AssetsVersion
 	return tmplDataSystem{
-		PathIcoFav:       e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/fave.ico" + version,
-		PathSvgLogo:      e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/logo.svg" + version,
-		PathCssStyles:    e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/styles.css" + version,
-		PathCssCpStyles:  e.R.URL.Scheme + "://" + e.R.Host + "/assets/cp/styles.css" + version,
-		PathCssBootstrap: e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/bootstrap.css" + version,
-		PathJsJquery:     e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/jquery.js" + version,
-		PathJsPopper:     e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/popper.js" + version,
-		PathJsBootstrap:  e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/bootstrap.js" + version,
-		PathJsCpScripts:  e.R.URL.Scheme + "://" + e.R.Host + "/assets/cp/scripts.js" + version,
+		PathIcoFav:       this.R.URL.Scheme + "://" + this.R.Host + "/assets/sys/fave.ico" + version,
+		PathSvgLogo:      this.R.URL.Scheme + "://" + this.R.Host + "/assets/sys/logo.svg" + version,
+		PathCssStyles:    this.R.URL.Scheme + "://" + this.R.Host + "/assets/sys/styles.css" + version,
+		PathCssCpStyles:  this.R.URL.Scheme + "://" + this.R.Host + "/assets/cp/styles.css" + version,
+		PathCssBootstrap: this.R.URL.Scheme + "://" + this.R.Host + "/assets/sys/bootstrap.css" + version,
+		PathJsJquery:     this.R.URL.Scheme + "://" + this.R.Host + "/assets/sys/jquery.js" + version,
+		PathJsPopper:     this.R.URL.Scheme + "://" + this.R.Host + "/assets/sys/popper.js" + version,
+		PathJsBootstrap:  this.R.URL.Scheme + "://" + this.R.Host + "/assets/sys/bootstrap.js" + version,
+		PathJsCpScripts:  this.R.URL.Scheme + "://" + this.R.Host + "/assets/cp/scripts.js" + version,
 		BlockModalSysMsg: template.HTML(templates.BlockModalSysMsg),
 	}
 }
@@ -76,132 +76,132 @@ func New(w *http.ResponseWriter, r *http.Request, vhost string, port string, www
 	}
 }
 
-func (e *Wrapper) Run(hRun handleRun) {
+func (this *Wrapper) Run(hRun handleRun) {
 	// Populate some values
-	e.RemoteIp = e.R.RemoteAddr
+	this.RemoteIp = this.R.RemoteAddr
 
 	// Create loggers
-	e.LoggerAcc = log.New(os.Stdout, e.VHost+", ", log.LstdFlags)
-	e.LoggerErr = log.New(os.Stdout, e.VHost+", ", log.LstdFlags)
+	this.LoggerAcc = log.New(os.Stdout, this.VHost+", ", log.LstdFlags)
+	this.LoggerErr = log.New(os.Stdout, this.VHost+", ", log.LstdFlags)
 
 	// Attach file for access log
-	if !e.Debug {
-		acclogfile, acclogfileerr := os.OpenFile(e.DirVhostHome+"/logs/access.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
+	if !this.Debug {
+		acclogfile, acclogfileerr := os.OpenFile(this.DirVhostHome+"/logs/access.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
 		if acclogfileerr == nil {
 			defer acclogfile.Close()
-			e.LoggerAcc.SetOutput(acclogfile)
+			this.LoggerAcc.SetOutput(acclogfile)
 		}
 	}
 
 	// Attach file for access log
-	if !e.Debug {
-		errlogfile, errlogfileerr := os.OpenFile(e.DirVhostHome+"/logs/error.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
+	if !this.Debug {
+		errlogfile, errlogfileerr := os.OpenFile(this.DirVhostHome+"/logs/error.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
 		if errlogfileerr == nil {
 			defer errlogfile.Close()
-			e.LoggerErr.SetOutput(errlogfile)
+			this.LoggerErr.SetOutput(errlogfile)
 		}
 	}
 
 	// Fix remote IP
-	if strings.ContainsRune(e.R.RemoteAddr, ':') {
-		e.RemoteIp, _, _ = net.SplitHostPort(e.R.RemoteAddr)
+	if strings.ContainsRune(this.R.RemoteAddr, ':') {
+		this.RemoteIp, _, _ = net.SplitHostPort(this.R.RemoteAddr)
 	}
 
 	// Redirect to main domain
-	if e.redirectToMainDomain() {
-		e.Log("301")
+	if this.redirectToMainDomain() {
+		this.Log("301")
 		return
 	}
 
 	// Static resource
-	if e.staticResource() {
-		e.Log("200")
+	if this.staticResource() {
+		this.Log("200")
 		return
 	}
 
 	// Static file
-	if e.staticFile() {
-		e.Log("200")
+	if this.staticFile() {
+		this.Log("200")
 		return
 	}
 
 	// Friendly search engine url
-	if e.redirectSeoFix() {
-		e.Log("301")
+	if this.redirectSeoFix() {
+		this.Log("301")
 		return
 	}
 
 	// Create and load session
-	e.Session = sessions.New(e.W, e.R, e.VHost, e.DirVhostHome, e.RemoteIp)
-	e.Session.Load()
+	this.Session = sessions.New(this.W, this.R, this.VHost, this.DirVhostHome, this.RemoteIp)
+	this.Session.Load()
 
 	// Set session vars
-	if !e.Session.IsSetInt("UserId") {
-		e.Session.SetInt("UserId", 0)
+	if !this.Session.IsSetInt("UserId") {
+		this.Session.SetInt("UserId", 0)
 	}
-	if !e.Session.IsSetBool("IsLogged") {
-		e.Session.SetBool("IsLogged", false)
+	if !this.Session.IsSetBool("IsLogged") {
+		this.Session.SetBool("IsLogged", false)
 	}
 
 	// Logic
 	if hRun != nil {
-		if hRun(e) {
-			e.Log("200")
-			e.Session.Save()
+		if hRun(this) {
+			this.Log("200")
+			this.Session.Save()
 			return
 		}
 	}
 
 	// Show default page
-	if e.R.URL.Path == "/" {
-		e.Log("200")
-		e.printPageDefault()
+	if this.R.URL.Path == "/" {
+		this.Log("200")
+		this.printPageDefault()
 	} else {
-		e.LogError("404")
-		e.printPage404()
+		this.LogError("404")
+		this.printPage404()
 	}
 }
 
-func (e *Wrapper) Log(value string) {
-	e.LoggerAcc.Println("[ACC] [" + e.R.Method + "] [" + value + "] [" + e.RemoteIp +
-		"] [" + e.R.URL.Scheme + "://" + e.R.Host + e.R.URL.RequestURI() +
-		"] [" + e.R.Header.Get("User-Agent") + "]")
+func (this *Wrapper) Log(value string) {
+	this.LoggerAcc.Println("[ACC] [" + this.R.Method + "] [" + value + "] [" + this.RemoteIp +
+		"] [" + this.R.URL.Scheme + "://" + this.R.Host + this.R.URL.RequestURI() +
+		"] [" + this.R.Header.Get("User-Agent") + "]")
 }
 
-func (e *Wrapper) LogError(value string) {
-	e.LoggerErr.Println("[ERR] [" + e.R.Method + "] [" + value + "] [" + e.RemoteIp +
-		"] [" + e.R.URL.Scheme + "://" + e.R.Host + e.R.URL.RequestURI() +
-		"] [" + e.R.Header.Get("User-Agent") + "]")
+func (this *Wrapper) LogError(value string) {
+	this.LoggerErr.Println("[ERR] [" + this.R.Method + "] [" + value + "] [" + this.RemoteIp +
+		"] [" + this.R.URL.Scheme + "://" + this.R.Host + this.R.URL.RequestURI() +
+		"] [" + this.R.Header.Get("User-Agent") + "]")
 }
 
-func (e *Wrapper) TmplFrontEnd(tname string, data interface{}) bool {
+func (this *Wrapper) TmplFrontEnd(tname string, data interface{}) bool {
 	tmpl, err := template.ParseFiles(
-		e.DirVhostHome+"/template"+"/"+tname+".html",
-		e.DirVhostHome+"/template"+"/header.html",
-		e.DirVhostHome+"/template"+"/sidebar.html",
-		e.DirVhostHome+"/template"+"/footer.html",
+		this.DirVhostHome+"/template"+"/"+tname+".html",
+		this.DirVhostHome+"/template"+"/header.html",
+		this.DirVhostHome+"/template"+"/sidebar.html",
+		this.DirVhostHome+"/template"+"/footer.html",
 	)
 	if err != nil {
-		e.printTmplPageError(err)
+		this.printTmplPageError(err)
 		return true
 	}
-	(*e.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
-	tmpl.Execute(*e.W, tmplDataAll{
-		System: e.tmplGetSystemData(),
+	(*this.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+	tmpl.Execute(*this.W, tmplDataAll{
+		System: this.tmplGetSystemData(),
 		Data:   data,
 	})
 	return true
 }
 
-func (e *Wrapper) TmplBackEnd(tcont []byte, data interface{}) bool {
+func (this *Wrapper) TmplBackEnd(tcont []byte, data interface{}) bool {
 	tmpl, err := template.New("template").Parse(string(tcont))
 	if err != nil {
-		e.printTmplPageError(err)
+		this.printTmplPageError(err)
 		return true
 	}
-	(*e.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
-	tmpl.Execute(*e.W, tmplDataAll{
-		System: e.tmplGetSystemData(),
+	(*this.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+	tmpl.Execute(*this.W, tmplDataAll{
+		System: this.tmplGetSystemData(),
 		Data:   data,
 	})
 	return true