Example #1
0
File: ihkh.go Project: hawx/ihkh
func getIndex(client flickr.Client, userInfo views.UserInfo, _ string, page, pageSize int) (views.PhotosCtx, error) {
	resp, err := client.PublicPhotos(userInfo.Id, pageSize, page)
	if err != nil {
		return views.PhotosCtx{}, err
	}

	ctx := views.PhotosCtx{
		Title:    fmt.Sprintf("ihkh : %s", userInfo.UserName),
		Photos:   []views.Photo{},
		UserInfo: userInfo,
	}

	if resp.Photos.Page > 1 {
		ctx.PrevPage = fmt.Sprintf("/%d", resp.Photos.Page-1)
	}
	if resp.Photos.Page != resp.Photos.Pages {
		ctx.NextPage = fmt.Sprintf("/%d", resp.Photos.Page+1)
	}

	for _, photo := range resp.Photos.Photo {
		ctx.Photos = append(ctx.Photos, views.Photo{
			Id:     photo.Id,
			Src:    photo.Url,
			Width:  photo.Width,
			Height: photo.Height,
		})
	}

	return ctx, nil
}
Example #2
0
File: ihkh.go Project: hawx/ihkh
func getAllTags(client flickr.Client, userInfo views.UserInfo) (interface{}, error) {
	resp, err := client.Tags(userInfo.Id)
	if err != nil {
		return nil, err
	}

	ctx := views.TagsCtx{
		Title:    fmt.Sprintf("ihkh : %s", userInfo.UserName),
		Tags:     []string{},
		UserInfo: userInfo,
	}

	for _, tag := range resp.Tags.Tag {
		ctx.Tags = append(ctx.Tags, tag)
	}

	return ctx, nil
}
Example #3
0
File: ihkh.go Project: hawx/ihkh
func getAllSets(client flickr.Client, userInfo views.UserInfo) (interface{}, error) {
	resp, err := client.Photosets(userInfo.Id)
	if err != nil {
		return nil, err
	}

	ctx := views.SetsCtx{
		Title:    fmt.Sprintf("ihkh : %s", userInfo.UserName),
		Sets:     []views.Set{},
		UserInfo: userInfo,
	}

	for _, set := range resp.Photosets.Photoset {
		ctx.Sets = append(ctx.Sets, views.Set{
			Id:    set.Id,
			Title: set.Title,
		})
	}

	return ctx, nil
}