From 5f30a45819770d1417a64e1d05e54952a594c6a6 Mon Sep 17 00:00:00 2001 From: Andrew Davidson Date: Thu, 29 Oct 2009 00:32:41 -0700 Subject: [PATCH] flickr stuff basically operational, no error handling. --- app/controllers/flickr_controller.rb | 37 ++++++++++++++++++++++++ app/controllers/screenshot_controller.rb | 20 +++++++++++++ app/views/flickr/_single.html.erb | 6 ++++ app/views/flickr/home.html.erb | 3 ++ app/views/flickr/index.html.erb | 0 app/views/flickr/photo.html.erb | 1 + app/views/layouts/application.html.erb | 11 +++++++ app/views/screenshot/index.html.erb | 0 app/views/screenshot/single.html.erb | 0 config/environment.rb | 4 ++- config/routes.rb | 9 ++++++ db/development.sqlite3 | 1 + public/stylesheets/global.css | 37 ++++++++++++++++++++++++ tmp/restart.txt | 0 14 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 app/views/flickr/_single.html.erb create mode 100644 app/views/flickr/home.html.erb create mode 100644 app/views/flickr/index.html.erb create mode 100644 app/views/flickr/photo.html.erb create mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/screenshot/index.html.erb create mode 100644 app/views/screenshot/single.html.erb create mode 100644 db/development.sqlite3 create mode 100644 public/stylesheets/global.css create mode 100644 tmp/restart.txt diff --git a/app/controllers/flickr_controller.rb b/app/controllers/flickr_controller.rb index abc4cf8..8fe2b21 100644 --- a/app/controllers/flickr_controller.rb +++ b/app/controllers/flickr_controller.rb @@ -1,2 +1,39 @@ class FlickrController < ApplicationController + require 'flickraw' + + def index + + respond_to do |format| + format.html + format.xml + end + end + + def photo + @pid = params[:id] + @pinfo = flickr.photos.getInfo :photo_id => @pid + getSizes = flickr.photos.getSizes :photo_id => @pid + @psizes = getSizes.find{|m| m.label == "Medium"} + + respond_to do |format| + format.html + format.xml + end + end + + def home + photos = flickr.photos.search(:user_id => "13827925@N00") + random = photos[rand(photos.size)] + @pid = random.id + @pinfo = flickr.photos.getInfo :secret => random.secret, :photo_id => @pid + getSizes = flickr.photos.getSizes :photo_id => @pid + @psizes = getSizes.find{|m| m.label == "Medium"} + + respond_to do |format| + format.html + format.xml + end + end + + end diff --git a/app/controllers/screenshot_controller.rb b/app/controllers/screenshot_controller.rb index 19fe469..d4655c4 100644 --- a/app/controllers/screenshot_controller.rb +++ b/app/controllers/screenshot_controller.rb @@ -1,2 +1,22 @@ class ScreenshotController < ApplicationController + + def index + @screenshots = "x" + + respond_to do |format| + format.html + format.xml + end + end + + def single + @screenshot = "x" + + respond_to do |format| + format.html + format.xml + end + end + + end diff --git a/app/views/flickr/_single.html.erb b/app/views/flickr/_single.html.erb new file mode 100644 index 0000000..1637ed6 --- /dev/null +++ b/app/views/flickr/_single.html.erb @@ -0,0 +1,6 @@ +
+
+ <%= link_to image_tag(@psizes.source, :alt => @pinfo.title), :controller => "flickr", :action => "photo", :id => @pid %> +

<%= @pinfo.title %>

+
+
\ No newline at end of file diff --git a/app/views/flickr/home.html.erb b/app/views/flickr/home.html.erb new file mode 100644 index 0000000..c2ead3e --- /dev/null +++ b/app/views/flickr/home.html.erb @@ -0,0 +1,3 @@ +<%= render :partial => 'single' %> + + \ No newline at end of file diff --git a/app/views/flickr/index.html.erb b/app/views/flickr/index.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/flickr/photo.html.erb b/app/views/flickr/photo.html.erb new file mode 100644 index 0000000..921f58f --- /dev/null +++ b/app/views/flickr/photo.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'single' %> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000..a644d3f --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,11 @@ + + + Photogriffy.net + <%= stylesheet_link_tag 'global' %> + + +
+ <%= yield %> +
+ + \ No newline at end of file diff --git a/app/views/screenshot/index.html.erb b/app/views/screenshot/index.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/screenshot/single.html.erb b/app/views/screenshot/single.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/config/environment.rb b/config/environment.rb index 1de8437..0d518c9 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -19,7 +19,9 @@ Rails::Initializer.run do |config| # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" # config.gem "sqlite3-ruby", :lib => "sqlite3" # config.gem "aws-s3", :lib => "aws/s3" - + config.gem "flickraw" + + # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named # config.plugins = [ :exception_notification, :ssl_requirement, :all ] diff --git a/config/routes.rb b/config/routes.rb index ea14ce1..e58068c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,6 +38,15 @@ ActionController::Routing::Routes.draw do |map| # Install the default routes as the lowest priority. # 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/i', :controller => "flickr", :action => "index" + map.connect 'f/:id', :controller => "flickr", :action => "photo" + + map.connect 's/i', :controller => "screenshot", :action => "index" + map.connect 's/:id', :controller => "screenshot", :action => "single" + map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' + + map.root :controller => "flickr", :action => "home" end diff --git a/db/development.sqlite3 b/db/development.sqlite3 new file mode 100644 index 0000000..1db515f --- /dev/null +++ b/db/development.sqlite3 @@ -0,0 +1 @@ +S \ No newline at end of file diff --git a/public/stylesheets/global.css b/public/stylesheets/global.css new file mode 100644 index 0000000..4d152c2 --- /dev/null +++ b/public/stylesheets/global.css @@ -0,0 +1,37 @@ +body { + color: #858C94; + background-color: #332920; + font-family: Helvetica, Verdana, sans-serif; + font-size: .8em; +} +#wrapper { + width:100%; + overflow:none; +} + +#header { + color:#BBB3A6; + font-size:1.5em; + padding:40px; + margin:0 auto; + text-align:center; +} + +#footer { + color:#BBB3A6; + font-size:.6em; + margin:0 auto; + text-align:center; +} + +div.flickr { + padding-top:100px; + margin:0em auto; + text-align:center; +} +div.border { + background-color:#BBB3A6; + padding:5px; + margin:0 auto; + color:#48362A; +} \ No newline at end of file diff --git a/tmp/restart.txt b/tmp/restart.txt new file mode 100644 index 0000000..e69de29