updated to lazy load flickraw and error messages are handled cleaner with flash[:error]

This commit is contained in:
Andrew Davidson 2009-10-30 00:33:29 -07:00
parent ca8077dec8
commit c159583d31

View file

@ -1,4 +1,5 @@
class FlickrController < ApplicationController
FlickrawOptions = { :lazyload => true }
require 'flickraw'
@@flickr_id = "13827925@N00"
@ -7,7 +8,7 @@ class FlickrController < ApplicationController
begin
@pinfo = flickr.photos.getInfo :photo_id => @pid
rescue => e
@error = true;
flash[:error] = "Photo " + params[:id].to_s + " could not be found. Random photo displayed."
@pid = flickr.photos.search(:user_id => @@flickr_id).rand.id
@pinfo = flickr.photos.getInfo :photo_id => @pid
end
@ -20,10 +21,11 @@ class FlickrController < ApplicationController
end
def home
@pid = flickr.photos.search(:user_id => @@flickr_id).rand.id
@pinfo = flickr.photos.getInfo(:photo_id => @pid)
@pinfo = flickr.photos.getInfo(:photo_id => @pid)
@psize = flickr.photos.getSizes(:photo_id => @pid).find{|m| m.label == "Medium"}
flash[:error] = "Could not connect to Flickr."
@pid = @pinfo = @psize = nil
respond_to do |format|
format.html