ismasan / mini_flickr

Simple gem to fetch photos from Flickr's REST API

This URL has Read+Write access

ismasan (author)
Thu May 15 05:30:11 -0700 2008
commit  1c13528fa7faf92186ad48a2d5eaec3f7d8db572
tree    a65aa06fef64b8415a6ab4a0b4d3f8872b974164
parent  6924f792ef97826a118ebabddcdcb8e72faf052a
mini_flickr / README.txt
100644 128 lines (76 sloc) 3.252 kb
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
= mini_flickr
 
* http://github.com/ismasan/mini_flickr/tree/master
 
== DESCRIPTION:
 
Simple gem to fetch your Flickr photos through Flickr's REST API
 
Get your Flickr API_KEY at http://www.flickr.com/services/api/keys/
 
Get your Flickr user id at http://idgettr.com/
 
== FEATURES/PROBLEMS:
 
* For now it just fetches the latest 30 photos
 
* This is not meant to upload photos to Flickr
 
== SYNOPSIS:
 
=== Class level configuration
 
  class MyFlickr
    include MiniFlickr::Base
    connect_to_flickr :api_key => 'your-api-key', :user_id => 'your-user-id'
  end
 
  flickr = MyFlickr.new
 
  <% flickr.photos.each do |photo| %>
<a href="<%= photo.medium_url %>">
<img src="<%= photo.small %>" />
</a>
  <% end %>
 
=== Instance level configuration
 
There's also a utility class that takes api_key and user_id as parameters.
This means you can configure Flickr accounts per-instance (for example your site has many users, each with their own Flickr photos).
 
flickr = MiniFlickr::Simple.new('some-key', 'some-user-id')
 
flickr.photos # => collection of MiniFlickr::Photo objects with sizes and url's (see above)
 
You can also use this as a value object for ActiveRecord, for example.
 
class Flickr < MiniFlickr::Simple; end
 
class User < ActiveRecord::Base
composed_of :flickr, :mappings => %w(api_key flickr_user_id)
end
 
user = User.create(:name => 'Ismael', :api_key => 'some-api-key', :flickr_user_id => 'some-flickr-userid')
 
user.flickr.photos # collection of flickr photos
 
== TESTING:
 
This gem uses Rspec for testing. Run the existing specs with rake spec.
 
You'll need to add your own API key in order for the test suite to work.
 
Do so by storing it in a file called/api_key.txt
 
If you contribute, please write specs and make sure they pass.
 
=== Each photo has:
 
==== Source image urls for sizes
 
photo.square
 
photo.thumbnail
 
photo.small
 
photo.medium
 
photo.original
 
==== Page urls for sizes
 
photo.square_url
 
photo.thumbnail_url
 
photo.small_url
 
photo.medium_url
 
photo.original_url
 
== REQUIREMENTS:
 
* Hpricot (sudo gem install hpricot)
 
== INSTALL:
 
* git clone git://github.com/ismasan/mini_flickr.git
 
* cd mini_flickr
 
* rake install_gem
 
== LICENSE:
 
(The MIT License)
 
Copyright (c) 2008 Ismael Celis
 
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
 
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
 
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.