github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

jzting / flickr_original_sinatra

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: efbf3e1

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

a simple sinatra app to retrieve original size images using the flickr api — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

flickr api now returns 'b' instead of 'l' for large images 
Jason Ting (author)
Tue May 05 17:28:07 -0700 2009
commit  efbf3e195a242dba04c22491569e51caa12eed77
tree    4b2477fc6ea988d48f358043c4fa0a6033fa024d
parent  efafe9b7b079b9e4b087d44e80b5e5da8a4422ce
flickr_original_sinatra / flickr_sinatra.rb flickr_sinatra.rb
100644 68 lines (59 sloc) 1.316 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'rubygems'
require 'sinatra'
require 'flickr'
 
# Setup the Flickr stuff
@@flickr = Flickr.new("flickr.cache", "f2949bc8f2e7d566279784478033e72a", "74b4e685176f27be")
 
not_found do
  erb :index
end
 
get "/" do
  erb :index
end
 
get "/view/:id" do |id|
  begin
    photos = @@flickr.photos.getSizes(params[:id])
    if photos.sizes[:Original]
      original = photos.sizes[:Original].source
      redirect original
    elsif photos.sizes[:Large]
      photos.sizes[:Large]
      large = photos.sizes[:Large].source
      redirect large
    else
      erb :error
    end
  rescue XMLRPC::FaultException
    erb :error
  end
end
 
get "/download/:id" do |id|
  begin
    photos = @@flickr.photos.getSizes(params[:id])
    if photos.sizes[:Original]
      original = photos.sizes[:Original].source.gsub(/_o/, '_o_d')
      redirect original
    elsif photos.sizes[:Large]
      photos.sizes[:Large]
      large = photos.sizes[:Large].source.gsub(/_b/, '_b_d')
      redirect large
    else
      erb :error
    end
  rescue XMLRPC::FaultException
    erb :error
  end
end
 
use_in_file_templates!
 
__END__
 
@@ index
<html>
<body>
<h1>nothing to see here!</h1>
</body>
</html>
 
@@ error
<html>
<body>
<h1>sorry, this image is unavailable.</h1>
</body>
</html>
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server