Browse Source

Default index page via template engine, repack sys pages

Vova Tkach 6 years ago
parent
commit
c55197f035

+ 1 - 1
engine/wrapper/resources/templates/page.default.go

@@ -1,3 +1,3 @@
 package templates
 
-var PageDefault = []byte(`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><meta name="theme-color" content="#205081" /><title>Default Page</title><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8" /><link rel="shortcut icon" href="/assets/sys/fave.ico" type="image/x-icon" /><link rel="stylesheet" type="text/css" media="all" href="/assets/sys/styles.css" /></head><body><div class="wrapper"><div class="logo"><div class="svg"><img src="/assets/sys/logo.svg" width="150" height="150" /></div></div><h1>Default Page</h1><h2><script>document.write(document.location.host);</script><noscript>fave.pro</noscript></h2></div></body></html>`)
+var PageDefault = []byte(`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><meta name="theme-color" content="#205081" /><title>Default Page</title><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8" /><link rel="shortcut icon" href="{{$.System.PathIcoFav}}" type="image/x-icon" /><link rel="stylesheet" type="text/css" media="all" href="{{$.System.PathCssStyles}}" /></head><body><div class="wrapper"><div class="logo"><div class="svg"><img src="{{$.System.PathSvgLogo}}" width="150" height="150" /></div></div><h1>Default Page</h1><h2><script>document.write(document.location.host);</script><noscript>fave.pro</noscript></h2></div></body></html>`)

+ 3 - 3
engine/wrapper/resources/templates/page.default.html

@@ -6,14 +6,14 @@
 		<title>Default Page</title>
 		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
 		<meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8" />
-		<link rel="shortcut icon" href="/assets/sys/fave.ico" type="image/x-icon" />
-		<link rel="stylesheet" type="text/css" media="all" href="/assets/sys/styles.css" />
+		<link rel="shortcut icon" href="{{$.System.PathIcoFav}}" type="image/x-icon" />
+		<link rel="stylesheet" type="text/css" media="all" href="{{$.System.PathCssStyles}}" />
 	</head>
 	<body>
 		<div class="wrapper">
 			<div class="logo">
 				<div class="svg">
-					<img src="/assets/sys/logo.svg" width="150" height="150" />
+					<img src="{{$.System.PathSvgLogo}}" width="150" height="150" />
 				</div>
 			</div>
 			<h1>Default Page</h1>

+ 1 - 1
engine/wrapper/resources/templates/page.error.404.go

@@ -1,3 +1,3 @@
 package templates
 
-var PageError404 = []byte(`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><meta name="theme-color" content="#205081" /><title>404 Not Found</title><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8" /><link rel="shortcut icon" href="/assets/sys/fave.ico" type="image/x-icon" /><link rel="stylesheet" type="text/css" media="all" href="/assets/sys/styles.css" /></head><body><div class="wrapper"><div class="logo"><div class="svg"><img src="/assets/sys/logo.svg" width="150" height="150" /></div></div><h1>404 Not Found</h1><h2><script>document.write(document.location.host);</script><noscript>fave.pro</noscript></h2></div></body></html>`)
+var PageError404 = []byte(`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><meta name="theme-color" content="#205081" /><title>404 Not Found</title><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8" /><link rel="shortcut icon" href="{{$.System.PathIcoFav}}" type="image/x-icon" /><link rel="stylesheet" type="text/css" media="all" href="{{$.System.PathCssStyles}}" /></head><body><div class="wrapper"><div class="logo"><div class="svg"><img src="{{$.System.PathSvgLogo}}" width="150" height="150" /></div></div><h1>404 Not Found</h1><h2><script>document.write(document.location.host);</script><noscript>fave.pro</noscript></h2></div></body></html>`)

+ 3 - 3
engine/wrapper/resources/templates/page.error.404.html

@@ -6,14 +6,14 @@
 		<title>404 Not Found</title>
 		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
 		<meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8" />
-		<link rel="shortcut icon" href="/assets/sys/fave.ico" type="image/x-icon" />
-		<link rel="stylesheet" type="text/css" media="all" href="/assets/sys/styles.css" />
+		<link rel="shortcut icon" href="{{$.System.PathIcoFav}}" type="image/x-icon" />
+		<link rel="stylesheet" type="text/css" media="all" href="{{$.System.PathCssStyles}}" />
 	</head>
 	<body>
 		<div class="wrapper">
 			<div class="logo">
 				<div class="svg">
-					<img src="/assets/sys/logo.svg" width="150" height="150" />
+					<img src="{{$.System.PathSvgLogo}}" width="150" height="150" />
 				</div>
 			</div>
 			<h1>404 Not Found</h1>

+ 8 - 1
engine/wrapper/static.go

@@ -89,8 +89,15 @@ func (e *Wrapper) printPageDefault() {
 	}
 
 	// Default page
+	tmpl, err := template.New("template").Parse(string(Templates.PageDefault))
+	if err != nil {
+		e.printTmplPageError(err)
+		return
+	}
 	(*e.W).Header().Set("Content-Type", "text/html")
-	(*e.W).Write(Templates.PageDefault)
+	tmpl.Execute(*e.W, tmplDataAll{
+		System: e.tmplGetSystemData(),
+	})
 }
 
 func (e *Wrapper) printPage404() {

+ 2 - 0
engine/wrapper/wrapper.go

@@ -15,6 +15,7 @@ type handleRun func(e *Wrapper) bool
 
 type tmplDataSystem struct {
 	PathIcoFav       string
+	PathSvgLogo      string
 	PathCssStyles    string
 	PathCssCpStyles  string
 	PathCssBootstrap string
@@ -45,6 +46,7 @@ type Wrapper struct {
 func (e *Wrapper) tmplGetSystemData() tmplDataSystem {
 	return tmplDataSystem{
 		PathIcoFav:       e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/fave.ico",
+		PathSvgLogo:      e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/logo.svg",
 		PathCssStyles:    e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/styles.css",
 		PathCssCpStyles:  e.R.URL.Scheme + "://" + e.R.Host + "/assets/cp/styles.css",
 		PathCssBootstrap: e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/bootstrap.css",