Example #1
0
func (h *MangoTemplateProvider) LayoutData(env Env) interface{} {

	header := &Header{
		CurrentUser: services.FetchUserFromEnv(env),
	}

	return header
}
Example #2
0
func LoginPage(env Env) (status Status, headers Headers, body Body) {
	user := services.FetchUserFromEnv(env)
	if user != nil {
		return Redirect(http.StatusFound, "/")
	}
	mangotemplate.ForRender(env, "sessions/login", &SessionData{User: users.NewUser()})
	return
}
Example #3
0
func Edit(env Env) (status Status, headers Headers, body Body) {
	newsId := env.Request().URL.Query().Get(":id")
	currentUser := services.FetchUserFromEnv(env)

	newsInput, err := services.EditNews(currentUser, newsId)
	if err != nil {
		panic(err)
	}

	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	newsViewData := &NewsViewData{
		NewsInput: newsInput,
		ApiBrands: apiBrands,
	}

	mangotemplate.ForRender(env, "news/edit", newsViewData)
	return
}