示例#1
0
func Tagged(args martini.Params, r render.Render, su models.User, dbh *db.Dbh, p *models.Page) {

	tag := args["tag"]

	images := dbh.GetImagesWithTag(tag)

	var imageLinks []imageLink
	for _, f := range images {
		if f.Trashed {
			log.Println("Trashed: ", f)
			continue
		}
		imageLinks = append(imageLinks, imageLink{Title: f.Name, FileName: f.Name})
	}

	p.SetUser(su)
	p.SetTitle("Tagged", tag)
	description := fmt.Sprintf("Images tagged as %s", tag)
	p.Data = TaggedVars{Title: tag, Description: description, ImageLinks: imageLinks}
	p.Encoding = "json"

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