objectiveflickr 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +17 -0
- data/lib/objectiveflickr/flickr_photo.rb +36 -5
- data/lib/objectiveflickr/version.rb +1 -1
- data/test/objectiveflickr_test.rb +10 -6
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
2007-01-04 (0.9.3):
|
2
|
+
* These methods from FlickrPhoto are deprecated:
|
3
|
+
|
4
|
+
* FlickrPhoto.unique_id_from_hash(params, prefix)
|
5
|
+
* FlickrPhoto.url_from_unique_id(uid)
|
6
|
+
* FlickrPhoto.hash_from_unique_id(uid)
|
7
|
+
|
8
|
+
Instead, please call them by these new names:
|
9
|
+
|
10
|
+
* FlickrPhoto.element_id_from_hash(params, prefix)
|
11
|
+
* FlickrPhoto.url_from_element_id(uid)
|
12
|
+
* FlickrPhoto.hash_from_element_id(uid)
|
13
|
+
|
14
|
+
This is for the sake of naming consistency. "Element id" is more
|
15
|
+
web design talk. Henceforth the change.
|
16
|
+
|
17
|
+
|
1
18
|
2006-12-27 (0.9.2):
|
2
19
|
* Added support for Flickr's new "farm" part newly found in its photo URLs
|
3
20
|
|
@@ -14,6 +14,16 @@
|
|
14
14
|
|
15
15
|
module FlickrPhoto
|
16
16
|
@photo_url_base = 'static.flickr.com'
|
17
|
+
@default_buddy_icon = 'http://www.flickr.com/images/buddyicon.jpg'
|
18
|
+
|
19
|
+
# Helper that gets you the URL of the buddy icon of a given user
|
20
|
+
def self.buddy_icon_url(nsid, icon_server=nil, icon_farm=nil)
|
21
|
+
if !icon_server || icon_server.to_i == 0
|
22
|
+
return @default_buddy_icon
|
23
|
+
end
|
24
|
+
|
25
|
+
"#{self.photo_url_base(icon_farm)}/#{icon_server}/buddyicons/#{nsid}.jpg"
|
26
|
+
end
|
17
27
|
|
18
28
|
# Set the default photo base URL, without the http:// part
|
19
29
|
def self.default_photo_url_base(b)
|
@@ -26,17 +36,18 @@ module FlickrPhoto
|
|
26
36
|
self.url_from_normalized_hash(self.normalize_parameter(params))
|
27
37
|
end
|
28
38
|
|
39
|
+
|
29
40
|
# This utility method combines the Flickr photo keys (from which
|
30
41
|
# one gets the real URL of a photo) into a photo id that you can
|
31
42
|
# use in a div
|
32
|
-
def self.
|
43
|
+
def self.element_id_from_hash(params, prefix='photo')
|
33
44
|
p = self.normalize_parameter(params)
|
34
45
|
[prefix, p[:server], p[:id], p[:secret], p[:farm], p[:size], p[:type]].join("-")
|
35
46
|
end
|
36
47
|
|
37
48
|
# This utility method breaks apart the photo id into Flickr photo
|
38
49
|
# keys and returns the photo URL
|
39
|
-
def self.
|
50
|
+
def self.url_from_element_id(uid)
|
40
51
|
self.url_from_normalized_hash(self.hash_from_unique_id(uid))
|
41
52
|
end
|
42
53
|
|
@@ -44,7 +55,7 @@ module FlickrPhoto
|
|
44
55
|
# keys and returns a hash of the photo information
|
45
56
|
#
|
46
57
|
# NOTE: No sanitation check here
|
47
|
-
def self.
|
58
|
+
def self.hash_from_element_id(uid)
|
48
59
|
p = uid.split("-")
|
49
60
|
{
|
50
61
|
:server=>p[1], :id=>p[2], :secret=>p[3],
|
@@ -52,10 +63,24 @@ module FlickrPhoto
|
|
52
63
|
}
|
53
64
|
end
|
54
65
|
|
66
|
+
# DEPRECATED--Call element_id_from_hash instead
|
67
|
+
def self.unique_id_from_hash(params, prefix='photo')
|
68
|
+
self.element_id_from_hash(params, prefix)
|
69
|
+
end
|
70
|
+
|
71
|
+
# DEPRECATED--Call url_from_element_id instead
|
72
|
+
def self.url_from_unique_id(uid)
|
73
|
+
self.url_from_element_id(uid)
|
74
|
+
end
|
75
|
+
|
76
|
+
# DEPRECATED--Call hash_from_element_id instead
|
77
|
+
def self.hash_from_unique_id(uid)
|
78
|
+
self.hash_from_element_id(uid)
|
79
|
+
end
|
80
|
+
|
55
81
|
private
|
56
82
|
def self.url_from_normalized_hash(p)
|
57
|
-
|
58
|
-
url = "#{urlbase}#{@photo_url_base}/#{p[:server]}/#{p[:id]}_#{p[:secret]}"
|
83
|
+
url = "#{photo_url_base(p[:farm])}/#{p[:server]}/#{p[:id]}_#{p[:secret]}"
|
59
84
|
url += "_#{p[:size]}" if p[:size].length > 0
|
60
85
|
url += ".#{p[:type]}"
|
61
86
|
end
|
@@ -71,5 +96,11 @@ module FlickrPhoto
|
|
71
96
|
:type => (params[:type] || params["type"] || "jpg").to_s
|
72
97
|
}
|
73
98
|
end
|
99
|
+
|
100
|
+
private
|
101
|
+
def self.photo_url_base(farm_id=nil)
|
102
|
+
urlbase = (farm_id && farm_id.to_s.length > 0) ? "http://farm#{farm_id}." : "http://"
|
103
|
+
"#{urlbase}#{@photo_url_base}"
|
104
|
+
end
|
74
105
|
end
|
75
106
|
|
@@ -56,22 +56,26 @@ class ObjectiveFlickrTest < Test::Unit::TestCase
|
|
56
56
|
assert_equal(FlickrPhoto.url_from_hash(params), "http://farm321.static.flickr.com/1234/5678_90.jpg", "URL helper failed")
|
57
57
|
params[:farm] = nil
|
58
58
|
|
59
|
-
uid = FlickrPhoto.
|
59
|
+
uid = FlickrPhoto.element_id_from_hash(params, 'blah')
|
60
60
|
assert_equal(uid, "blah-1234-5678-90---jpg", "UID failed")
|
61
61
|
|
62
62
|
params[:farm] = "321"
|
63
63
|
params[:size] = 'b'
|
64
|
-
uid = FlickrPhoto.
|
64
|
+
uid = FlickrPhoto.element_id_from_hash(params, 'blah')
|
65
65
|
assert_equal(uid, "blah-1234-5678-90-321-b-jpg", "UID failed")
|
66
66
|
|
67
67
|
|
68
|
-
assert_equal(FlickrPhoto.
|
68
|
+
assert_equal(FlickrPhoto.url_from_element_id(uid), "http://farm321.static.flickr.com/1234/5678_90_b.jpg", "URL helper failed")
|
69
69
|
|
70
70
|
params[:type] = 'jpg'
|
71
|
-
h = FlickrPhoto.
|
72
|
-
assert_equal(h, params, "
|
71
|
+
h = FlickrPhoto.hash_from_element_id(uid)
|
72
|
+
assert_equal(h, params, "hash_from_element_id failed")
|
73
73
|
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
def test_buddy_icons
|
77
|
+
assert_equal FlickrPhoto.buddy_icon_url("12345678@N1234"), "http://www.flickr.com/images/buddyicon.jpg"
|
78
|
+
assert_equal FlickrPhoto.buddy_icon_url("12345678@N1234", "92"), "http://static.flickr.com/92/buddyicons/12345678@N1234.jpg"
|
79
|
+
assert_equal FlickrPhoto.buddy_icon_url("12345678@N1234", "92", "1"), "http://farm1.static.flickr.com/92/buddyicons/12345678@N1234.jpg"
|
80
|
+
end
|
77
81
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: objectiveflickr
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.9.
|
7
|
-
date:
|
6
|
+
version: 0.9.3
|
7
|
+
date: 2007-01-05 00:00:00 +08:00
|
8
8
|
summary: objectiveflickr is a minimalistic Flickr API library that uses REST-style calls and receives JSON response blocks, resulting in very concise code. Named so in order to echo another Flickr library of mine, under the same name, developed for Objective-C.
|
9
9
|
require_paths:
|
10
10
|
- lib
|