diff --git a/app/controllers/flickr_controller.rb b/app/controllers/flickr_controller.rb index 7890aef..6671b64 100644 --- a/app/controllers/flickr_controller.rb +++ b/app/controllers/flickr_controller.rb @@ -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 diff --git a/app/views/flickr/_grid.html.erb b/app/views/flickr/_grid.html.erb new file mode 100644 index 0000000..0f854d0 --- /dev/null +++ b/app/views/flickr/_grid.html.erb @@ -0,0 +1,7 @@ +
+
+ <% for p in @parray do %> + <%= link_to image_tag(p[:source], :alt => p[:id]), :action => 'photo', :id => p[:id] %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/flickr/interesting.html.erb b/app/views/flickr/interesting.html.erb new file mode 100644 index 0000000..d0ca19c --- /dev/null +++ b/app/views/flickr/interesting.html.erb @@ -0,0 +1 @@ +<%= render :partial => "grid" %> \ No newline at end of file diff --git a/app/views/flickr/recent.html.erb b/app/views/flickr/recent.html.erb new file mode 100644 index 0000000..0d57587 --- /dev/null +++ b/app/views/flickr/recent.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'grid' %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index cbef93c..191b1dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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'