Exemple #1
0
func Album(args martini.Params, su models.User, session sessions.Session, r render.Render, dbh *db.Dbh, p *models.Page) {
	name := args["name"]
	auser := args["user"]
	key := args["key"]

	if auser != "" {
		log.Println("album user: "******"flash", "Login Required")
		r.Redirect(strings.Join([]string{utils.AppCfg.Url(), "login"}, "/"), http.StatusFound)
		return
	}

	images := dbh.GetAllImagesByAlbumId(album.Id)

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

	p.SetTitle("Album", name)
	p.SetUser(su)
	p.Data = AlbumVars{Title: name, Description: album.Description, ImageLinks: imageLinks}

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