func renderRealUser(w http.ResponseWriter, request *http.Request) {
	context := appengine.NewContext(request)
	user := user.Current(context)
	render(user.Email, "", w, request)
}
renderRealUser executes the graph page template for a real user
package main
import (
	"fmt"
	"github.com/alexandre-normand/glukit/app/apimodel"
	"github.com/alexandre-normand/glukit/app/config"
	"github.com/alexandre-normand/glukit/app/engine"
	"github.com/alexandre-normand/glukit/app/model"
	"github.com/alexandre-normand/glukit/app/store"
	"github.com/alexandre-normand/glukit/app/util"
	"github.com/gorilla/mux"
	"google.golang.org/appengine"
	"google.golang.org/appengine/datastore"
	"google.golang.org/appengine/delay"
	"google.golang.org/appengine/log"
	"google.golang.org/appengine/taskqueue"
	"google.golang.org/appengine/user"
	"html/template"
	"net/http"
	"sync"
	"time"
)
var dataBrowserTemplate = template.Must(template.ParseFiles("view/templates/databrowser.html"))
var reportTemplate = template.Must(template.ParseFiles("view/templates/report.html"))
var landingTemplate = template.Must(template.ParseFiles("view/templates/landing.html"))
var muxRouter = mux.NewRouter()
var initOnce sync.Once
const (
	DEMO_PATH_PREFIX        = "demo."
	DEMO_PICTURE_URL        = "https://farm8.staticflickr.com/7389/10813078553_ab4e1397f4_b_d.jpg"
	GLUCOSE_UNIT_PARAMETER  = "unit"
	CONTENT_SECURITY_POLICY = "default-src 'self'; img-src *; style-src 'unsafe-inline' 'self'; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://api.stripe.com; frame-src 'self' https://js.stripe.com; script-src 'self' 'unsafe-inline' js.stripe.com *.googleapis.com *.google-analytics.com"
)
type RenderVariables struct {
	PathPrefix           string
	StripePublishableKey string
	SSLHost              string
	GlucoseUnit          apimodel.GlucoseUnit
}
func main() {
	appConfig = config.NewAppConfig()
	http.Handle("/", muxRouter)
	muxRouter.HandleFunc("/_ah/warmup", warmUp)
	muxRouter.HandleFunc("/initpower", warmUp)
	muxRouter.HandleFunc("/"+DEMO_PATH_PREFIX+"data", demoContent)
	muxRouter.HandleFunc("/data", personalData)
	muxRouter.HandleFunc("/"+DEMO_PATH_PREFIX+"steadySailor", demoSteadySailorData)
	muxRouter.HandleFunc("/steadySailor", steadySailorData)
	muxRouter.HandleFunc("/"+DEMO_PATH_PREFIX+"dashboard", demoDashboard)
	muxRouter.HandleFunc("/dashboard", dashboard)
	muxRouter.HandleFunc("/"+DEMO_PATH_PREFIX+"glukitScores", glukitScoresForDemo)
	muxRouter.HandleFunc("/glukitScores", glukitScores)
	muxRouter.HandleFunc("/"+DEMO_PATH_PREFIX+"a1cs", a1cEstimatesForDemo)
	muxRouter.HandleFunc("/a1cs", a1cEstimates)
	muxRouter.HandleFunc("/donation", handleDonation)
	muxRouter.HandleFunc("/demo", renderDemo)
	muxRouter.HandleFunc("/browse", renderRealUser)
	muxRouter.HandleFunc("/"+DEMO_PATH_PREFIX+"report", demoReport)
	muxRouter.HandleFunc("/report", report)
	muxRouter.HandleFunc("/", landing)
	muxRouter.HandleFunc("/googleauth", googleauth)
	muxRouter.HandleFunc("/userlogin", loginUser)
	muxRouter.HandleFunc("/oauth2callback", oauthCallback)
	muxRouter.HandleFunc("/v1/calibrations", initializeAndHandleRequest).Methods("POST").Name(CALIBRATIONS_V1_ROUTE)
	muxRouter.HandleFunc("/v1/injections", initializeAndHandleRequest).Methods("POST").Name(INJECTIONS_V1_ROUTE)
	muxRouter.HandleFunc("/v1/meals", initializeAndHandleRequest).Methods("POST").Name(MEALS_V1_ROUTE)
	muxRouter.HandleFunc("/v1/glucosereads", initializeAndHandleRequest).Methods("POST").Name(GLUCOSEREADS_V1_ROUTE)
	muxRouter.HandleFunc("/v1/exercises", initializeAndHandleRequest).Methods("POST").Name(EXERCISES_V1_ROUTE)
	muxRouter.HandleFunc("/token", initializeAndHandleRequest).Methods("POST").Name(TOKEN_ROUTE)
	muxRouter.HandleFunc("/authorize", initializeAndHandleRequest).Methods("GET").Name(AUTHORIZE_ROUTE)
	engine.RunGlukitScoreCalculationChunk = delay.Func(engine.GLUKIT_SCORE_BATCH_CALCULATION_FUNCTION_NAME, engine.RunGlukitScoreBatchCalculation)
	engine.RunA1CCalculationChunk = delay.Func(engine.A1C_BATCH_CALCULATION_FUNCTION_NAME, engine.RunA1CBatchCalculation)
	appengine.Main()
}
func landing(w http.ResponseWriter, request *http.Request) {
	if err := landingTemplate.Execute(w, nil); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}
func oauthCallback(writer http.ResponseWriter, request *http.Request) {
	handleLoggedInUser(writer, request)
}
func renderDemo(w http.ResponseWriter, request *http.Request) {
	context := appengine.NewContext(request)
	_, key, _, err := store.GetUserData(context, DEMO_EMAIL)
	if err == datastore.ErrNoSuchEntity {
		log.Infof(context, "No data found for demo user [%s], creating it", DEMO_EMAIL)
		key, err = store.StoreUserProfile(context, time.Now(),
			model.GlukitUser{DEMO_EMAIL, "Demo", "OfMe", time.Now(), model.DIABETES_TYPE_1, "", time.Now(),
				apimodel.UNDEFINED_GLUCOSE_READ, model.UNDEFINED_SCORE, model.UNDEFINED_SCORE, true, DEMO_PICTURE_URL, time.Now(),
				model.UNDEFINED_A1C_ESTIMATE})
		if err != nil {
			util.Propagate(err)
		}
		task, err := processDemoFile.Task(key)
		if err != nil {
			util.Propagate(err)
		}
		taskqueue.Add(context, task, DATASTORE_WRITES_QUEUE_NAME)
	} else if err != nil {
		util.Propagate(err)
	} else {
		log.Infof(context, "Data already stored for demo user [%s], continuing...", DEMO_EMAIL)
	}
	render(DEMO_EMAIL, DEMO_PATH_PREFIX, w, request)
}