added basic support for most recent and most interesting photos, needs formatting and caching for a production system

This commit is contained in:
Andrew Davidson 2009-10-30 02:08:05 -07:00
parent b90c251333
commit 285ad1893b
5 changed files with 41 additions and 2 deletions

View file

@ -27,9 +27,36 @@ class FlickrController < ApplicationController
respond_to do |format|
format.html
format.xml
end
end
def interesting
@parray = Array.new
sresult = flickr.photos.search(:user_id => @@flickr_id, :per_page => 20, :sort => "interestingness-desc")
for r in sresult do
@parray += [:id => r.id, :source => flickr.photos.getSizes(:photo_id => r.id).find{|m| m.label == "Thumbnail"}.source]
end
respond_to do |format|
format.html
end
end
def recent
@parray = Array.new
sresult = flickr.photos.search(:user_id => @@flickr_id, :per_page => 20)
for r in sresult do
@parray += [:id => r.id, :source => flickr.photos.getSizes(:photo_id => r.id).find{|m| m.label == "Thumbnail"}.source]
end
respond_to do |format|
format.html
end
end
end

View file

@ -0,0 +1,7 @@
<div class="box">
<div class="border" style="width:400px;">
<% for p in @parray do %>
<%= link_to image_tag(p[:source], :alt => p[:id]), :action => 'photo', :id => p[:id] %>
<% end %>
</div>
</div>

View file

@ -0,0 +1 @@
<%= render :partial => "grid" %>

View file

@ -0,0 +1 @@
<%= render :partial => 'grid' %>

View file

@ -39,12 +39,15 @@ ActionController::Routing::Routes.draw do |map|
# Note: These default routes make all actions in every controller accessible via GET requests. You should
# consider removing or commenting them out if you're using named routes and resources.
map.connect 'f', :controller => "flickr", :action => "index"
map.connect 'f/i', :controller => "flickr", :action => "interesting"
map.connect 'p/:id', :controller => "flickr", :action => "photo"
map.connect 'f/:action/:id', :controller => "flickr", :action => "recent"
map.connect 's/i', :controller => "screenshot", :action => "index"
map.connect 's/:filename', :controller => "screenshot", :action => "single", :requirements => { :filename => /.*/ }
map.connect 'i/:action', :controller => "info"
map.connect ':controller/:action/:id'