Esempio n. 1
0
func main() {
	if tmplSet, err := template.ParseSetFiles("tmpl/header.html", "tmpl/footer.html", "tmpl/index.html"); err != nil {
		log.Fatal("Couldn't parse templates: ", err.String())
	} else {
		tmpls = tmplSet
	}

	http.HandleFunc("/out/", StaticFile)
	http.HandleFunc("/css/", StaticFile)
	http.HandleFunc("/js/", StaticFile)
	http.HandleFunc("/smush", SmushFiles)
	http.HandleFunc("/", SmushIndex)

	if err := http.ListenAndServe(":12345", nil); err != nil {
		log.Fatal("ListenAndServe: ", err.String())
	}
}
Esempio n. 2
0
package handler

import (
	"appengine"
	"http"
	"template"
)

func index(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	model := new(model)
	if err := indexTemplateSet.Execute(w, "Layout", model); err != nil {
		c.Criticalf(`Failed executing template: %v`, err)
		internalServerError(w)
		return
	}
}

var indexTemplateSet = template.SetMust(template.ParseSetFiles(
	"templates/layout.html",
	"templates/index.html"))
Esempio n. 3
0
File: unico.go Progetto: licio/unico
var appConfig struct {
	FacebookAppId         string
	FacebookAppSecret     string
	GoogleClientId        string
	GoogleClientSecret    string
	TwitterConsumerKey    string
	TwitterConsumerSecret string
	AppHost               string
	AppDomain             string
	SessionStoreKey       string
}

var (
	templates = template.SetMust(template.ParseSetFiles(
		"404.html",
		"home.html",
		"header.html",
		"footer.html",
		"error.html"))
)

func init() {
	// Read configuration file
	content, err := ioutil.ReadFile("config.json")
	if err == nil {
		err = json.Unmarshal(content, &appConfig)
	}
	if err != nil {
		panic("Can't load configuration")
	}

	// Make sure every conf option has been completed, except