Browse Source

Theme assets files to non root folder

Vova Tkach 6 years ago
parent
commit
37ad29366a
2 changed files with 5 additions and 5 deletions
  1. 1 1
      hosts/localhost/template/header.html
  2. 4 4
      main.go

+ 1 - 1
hosts/localhost/template/header.html

@@ -15,7 +15,7 @@
 		<link rel="shortcut icon" href="{{$.System.PathIcoFav}}" type="image/x-icon" />
 
 		<!-- Template CSS file from public folder -->
-		<link rel="stylesheet" href="/styles.css">
+		<link rel="stylesheet" href="/assets/theme/styles.css">
 	</head>
 	<body class="fixed-top-bar1">
 		<div id="wrap">

+ 4 - 4
main.go

@@ -142,10 +142,10 @@ func main() {
 		}
 
 		// Robots.txt and styles.css from template dir
-		if ServeTemplateFile(w, r, "robots.txt", vhost_dir_template) {
+		if ServeTemplateFile(w, r, "robots.txt", "", vhost_dir_template) {
 			return
 		}
-		if ServeTemplateFile(w, r, "styles.css", vhost_dir_template) {
+		if ServeTemplateFile(w, r, "styles.css", "assets/theme/", vhost_dir_template) {
 			return
 		}
 
@@ -165,8 +165,8 @@ func main() {
 	})
 }
 
-func ServeTemplateFile(w http.ResponseWriter, r *http.Request, file string, dir string) bool {
-	if r.URL.Path == "/"+file {
+func ServeTemplateFile(w http.ResponseWriter, r *http.Request, file string, path string, dir string) bool {
+	if r.URL.Path == "/"+path+file {
 		f, err := os.Open(dir + string(os.PathSeparator) + file)
 		if err == nil {
 			defer f.Close()