示例#1
0
func ImagePage(args martini.Params, su models.User, res http.ResponseWriter, req *http.Request, r render.Render, dbh *db.Dbh, p *models.Page) {
	name := args["name"]

	image := dbh.FirstImageByName(name)
	tags := dbh.GetAllTagsByImageId(image.Id)

	errs := make(map[string]string)
	form := utils.GenerateForm(&forms.Tag{Image: name}, "/tag", "POST", errs)

	p.SetUser(su)
	p.SetTitle("Image")

	src := fmt.Sprintf("%s/i/%s", utils.AppCfg.Url(), name)
	fullsrc := fmt.Sprintf("%s/o/%s", utils.AppCfg.Url(), name)
	p.Data = ImagePageVars{Name: src, Full: fullsrc, Tags: tags, Form: form}

	encoder.Render(p.Encoding, 200, "image", p, r)
}