Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1This sets a default value for the tpl directory that works for Nixpkgs. 2 3diff --git a/server/web.go b/server/web.go 4index d024a42..0522d02 100644 5--- a/server/web.go 6+++ b/server/web.go 7@@ -10,6 +10,7 @@ import "path/filepath" 8 import "time" 9 import "strings" 10 import "fmt" 11+import "os" 12 13 var layoutTpl *template.Template 14 var mainPageTpl *template.Template 15@@ -44,7 +45,11 @@ func deriveTemplate(filename string) (*template.Template, error) { 16 } 17 18 func (s *Server) tplFilename(filename string) string { 19- td := filepath.Join(s.cfg.ConfigDir, "..", "tpl") 20+ ex, err := os.Executable() 21+ if err != nil { 22+ panic(err) 23+ } 24+ td := filepath.Join(filepath.Dir(ex), "..", "share", "tpl") 25 if s.cfg.TplPath != "" { 26 td = s.cfg.TplPath 27 }