Rough attempt at showing photos from flickr.

You can see a list of your recently uploaded Flickr photos at
/photos/new, which is nice!  However the tests are broken and there's a
lot of mess that should be in the model instead of the controller.
Committing as-is because I'm tired.
This commit is contained in:
Skud
2013-05-08 22:01:09 +10:00
parent acf164990d
commit cc6d6633cc
6 changed files with 39 additions and 29 deletions

View File

@@ -36,6 +36,7 @@ group :assets do
end
gem 'jquery-rails'
gem 'flickraw'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

View File

@@ -85,6 +85,7 @@ GEM
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
fastthread (1.0.7)
flickraw (0.9.6)
friendly_id (4.0.9)
fssm (0.2.10)
geocoder (1.1.6)
@@ -247,6 +248,7 @@ DEPENDENCIES
devise
diff-lcs
factory_girl_rails (~> 4.0)
flickraw
friendly_id
geocoder
gravatar-ultimate

View File

@@ -26,8 +26,22 @@ class PhotosController < ApplicationController
# GET /photos/new.json
def new
@photo = Photo.new
# NOTE: we should move a bunch of this into the Member model
@flickr_login = nil
@flickr_auth = current_member.authentications.find_by_provider('flickr')
if @flickr_auth
FlickRaw.api_key = ENV['FLICKR_KEY']
FlickRaw.shared_secret = ENV['FLICKR_SECRET']
flickr = FlickRaw::Flickr.new
flickr.access_token = @flickr_auth.token
flickr.access_secret = @flickr_auth.secret
@flickr_login = flickr.test.login
@photos = flickr.people.getPhotos(:user_id => 'me', :per_page => 30)
end
respond_to do |format|
format.html # new.html.erb
format.json { render json: @photo }

View File

@@ -1,22 +0,0 @@
= form_for @photo do |f|
- if @photo.errors.any?
#error_explanation
%h2= "#{pluralize(@photo.errors.count, "error")} prohibited this photo from being saved:"
%ul
- @photo.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :owner_id
= f.number_field :owner_id
.field
= f.label :flickr_photo_id
= f.number_field :flickr_photo_id
.field
= f.label :thumbnail_url
= f.text_field :thumbnail_url
.field
= f.label :fullsize_url
= f.text_field :fullsize_url
.actions
= f.submit 'Save'

View File

@@ -1,7 +1,2 @@
%h1 Editing photo
- content_for :title, "Edit Photo"
= render 'form'
= link_to 'Show', @photo
\|
= link_to 'Back', photos_path

View File

@@ -1,7 +1,27 @@
- content_for :title, "New Photo"
- if @flickr_auth
= render 'form'
%p
Connected to Flickr as
= succeed "." do
= link_to @flickr_login.username, "http://flickr.com/photos/#{@flickr_login.id}"
%p Select a photo from your recent uploads:
- c = 0
%ul.thumbnails
.row
- @photos.each do |p|
- c += 1
%li.span2
.thumbnail(style='height: 220px')
= image_tag(FlickRaw.url_q(p), :alt => '', :class => 'img-rounded')
%p
=p.title
- if (c % 6) == 0
.row
- else
.alert
You must