Ejemplo n.º 1
0
func serveTemplateFile(opt map[string]interface{}, w http.ResponseWriter, req *http.Request, absPath, host string, path string) {
	paths := strings.Split(path, "/")
	if paths[1] == "template" {
		p := scut.GetTPath(opt, host)
		http.ServeFile(w, req, filepath.Join(absPath, p, strings.Join(paths[2:], "/")))
	} else { // "tpl"
		http.ServeFile(w, req, filepath.Join(absPath, "modules", paths[2], "tpl", strings.Join(paths[3:], "/")))
	}
}
Ejemplo n.º 2
0
func (f *FileSys) SelectPlace(s string) (iface.Directory, error) {
	var path string
	switch s {
	case "template":
		path = scut.GetTPath(f.opt, f.host)
	case "modules":
		path = "modules"
	case "uploads":
		path = "uploads"
	default:
		return nil, fmt.Errorf("Can't find.")
	}
	path = filepath.Join(f.root, path)
	return directory.New(path), nil
}