Commits

Julian Brost committed 574508d

Symlinked theme from the environment and use this from the code.

Comments (0)

Files changed (4)

 	app.Config = config
 
 	// load theme
-	theme, err := NewTheme("theme")
+	theme, err := NewTheme(app.JoinEnv("theme"))
 	if err != nil {
 		return nil, err
 	}
+../theme
 import (
 	"io/ioutil"
 	"strings"
+	"path"
 )
 
-const themeDir = "theme"
-
 type Theme struct {
 	path  string
 	cache map[string]string
 	if found {
 		return template, nil
 	}
-	rawTemplate, err := ioutil.ReadFile(themeDir + "/" + name + ".html")
+	rawTemplate, err := ioutil.ReadFile(path.Join(theme.path, name))
 	if err != nil {
 		return "", err
 	}
 	} else if r.URL.Path == "/feed" {
 		handleFeed(w, r)
 	} else if r.URL.Path == "/style.css" {
-		http.ServeFile(w, r, themeDir+"/style.css")
+		http.ServeFile(w, r, globalApp.JoinEnv("theme", "style.css"))
 	} else if postRegex.MatchString(r.URL.Path) {
 		handlePost(w, r)
 	} else {
 		handleNotFound(w, r)
 		return
 	}
-	postBody, _ := globalApp.Theme.RenderTemplate("post_full", map[string]string{
+	postBody, _ := globalApp.Theme.RenderTemplate("post_full.html", map[string]string{
 		"post_title": post.Title,
 		"content":    string(post.Content),
 	})
-	body, _ := globalApp.Theme.RenderTemplate("body", map[string]string{
+	body, _ := globalApp.Theme.RenderTemplate("body.html", map[string]string{
 		"title":    "somebodys blog",
 		"posts":    postBody,
 		"rel_link": "../",
 			logError(err)
 			continue
 		}
-		postBody, _ := globalApp.Theme.RenderTemplate("post_small", map[string]string{
+		postBody, _ := globalApp.Theme.RenderTemplate("post_small.html", map[string]string{
 			"post_title": post.Title,
 			"content":    string(post.Content),
 			"location":   "/" + postDir + "/" + p,
 		})
 		posts.WriteString(postBody)
 	}
-	body, _ := globalApp.Theme.RenderTemplate("body", map[string]string{
+	body, _ := globalApp.Theme.RenderTemplate("body.html", map[string]string{
 		"title":    "somebodys blog",
 		"posts":    posts.String(),
 		"rel_link": "",