Browse Source

Actual hostname in CP title

Vova Tkach 6 years ago
parent
commit
1ee787fdea
4 changed files with 11 additions and 7 deletions
  1. 2 2
      engine/engine.go
  2. 5 3
      engine/wrapper/wrapper.go
  3. 3 1
      main.go
  4. 1 1
      modules/modules.go

+ 2 - 2
engine/engine.go

@@ -19,8 +19,8 @@ type Engine struct {
 	Mods *modules.Modules
 }
 
-func Response(l *logger.Logger, m *modules.Modules, w http.ResponseWriter, r *http.Request, s *session.Session, host, port, dirConfig, dirHtdocs, dirLogs, dirTemplate, dirTmp string) bool {
-	wrap := wrapper.New(l, w, r, s, host, port, dirConfig, dirHtdocs, dirLogs, dirTemplate, dirTmp)
+func Response(l *logger.Logger, m *modules.Modules, w http.ResponseWriter, r *http.Request, s *session.Session, host, port, chost, dirConfig, dirHtdocs, dirLogs, dirTemplate, dirTmp string) bool {
+	wrap := wrapper.New(l, w, r, s, host, port, chost, dirConfig, dirHtdocs, dirLogs, dirTemplate, dirTmp)
 	eng := &Engine{
 		Wrap: wrap,
 		Mods: m,

+ 5 - 3
engine/wrapper/wrapper.go

@@ -24,8 +24,9 @@ type Wrapper struct {
 	R *http.Request
 	S *session.Session
 
-	Host string
-	Port string
+	Host     string
+	Port     string
+	CurrHost string
 
 	DConfig   string
 	DHtdocs   string
@@ -43,7 +44,7 @@ type Wrapper struct {
 	User *utils.MySql_user
 }
 
-func New(l *logger.Logger, w http.ResponseWriter, r *http.Request, s *session.Session, host, port, dirConfig, dirHtdocs, dirLogs, dirTemplate, dirTmp string) *Wrapper {
+func New(l *logger.Logger, w http.ResponseWriter, r *http.Request, s *session.Session, host, port, chost, dirConfig, dirHtdocs, dirLogs, dirTemplate, dirTmp string) *Wrapper {
 	return &Wrapper{
 		l:             l,
 		W:             w,
@@ -51,6 +52,7 @@ func New(l *logger.Logger, w http.ResponseWriter, r *http.Request, s *session.Se
 		S:             s,
 		Host:          host,
 		Port:          port,
+		CurrHost:      chost,
 		DConfig:       dirConfig,
 		DHtdocs:       dirHtdocs,
 		DLogs:         dirLogs,

+ 3 - 1
main.go

@@ -83,8 +83,10 @@ func main() {
 
 		// Host and port
 		host, port := utils.ExtractHostPort(r.Host, false)
+		curr_host := host
 		vhost_dir := ParamWwwDir + string(os.PathSeparator) + host
 		if !utils.IsDirExists(vhost_dir) {
+			curr_host = "localhost"
 			vhost_dir = ParamWwwDir + string(os.PathSeparator) + "localhost"
 		}
 
@@ -125,7 +127,7 @@ func main() {
 		defer sess.Close()
 
 		// Logic
-		if engine.Response(lg, mods, w, r, sess, host, port, vhost_dir_config, vhost_dir_htdocs, vhost_dir_logs, vhost_dir_template, vhost_dir_tmp) {
+		if engine.Response(lg, mods, w, r, sess, host, port, curr_host, vhost_dir_config, vhost_dir_htdocs, vhost_dir_logs, vhost_dir_template, vhost_dir_tmp) {
 			return
 		}
 

+ 1 - 1
modules/modules.go

@@ -336,7 +336,7 @@ func (this *Modules) XXXBackEnd(wrap *wrapper.Wrapper) bool {
 			}
 
 			wrap.RenderBackEnd(assets.TmplCpBase, consts.TmplDataCpBase{
-				Title:              "Fave " + consts.ServerVersion,
+				Title:              wrap.CurrHost + " - Fave " + consts.ServerVersion,
 				BodyClasses:        body_class,
 				UserId:             wrap.User.A_id,
 				UserFirstName:      wrap.User.A_first_name,