flickraw 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/auth.rb +25 -0
- data/examples/flickr_KDE.rb +23 -0
- data/examples/interestingness.rb +6 -0
- data/flickraw_rdoc.rb +2 -3
- data/lib/flickraw.rb +1 -1
- data/rakefile +1 -1
- metadata +5 -2
data/examples/auth.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'flickraw'
|
2
|
+
|
3
|
+
# This is how to authenticate on flickr website.
|
4
|
+
# You need an API key for that, see http://www.flickr.com/services/api/keys/
|
5
|
+
API_KEY=''
|
6
|
+
SHARED_SECRET=''
|
7
|
+
|
8
|
+
FlickRaw.api_key=API_KEY
|
9
|
+
FlickRaw.shared_secret=SHARED_SECRET
|
10
|
+
|
11
|
+
frob = flickr.auth.getFrob
|
12
|
+
auth_url = FlickRaw.auth_url :frob => frob, :perms => 'read'
|
13
|
+
|
14
|
+
puts "Open this url in your process to complete the authication process : #{auth_url}"
|
15
|
+
puts "Press Enter when you are finished."
|
16
|
+
STDIN.getc
|
17
|
+
|
18
|
+
begin
|
19
|
+
flickr.auth.getToken :frob => frob
|
20
|
+
login = flickr.test.login
|
21
|
+
puts "You are now authenticated as #{login.username}"
|
22
|
+
rescue FlickRaw::FailedResponse => e
|
23
|
+
puts "Authentication failed : #{e.msg}"
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# Chooses a photo from the current interesting
|
3
|
+
# photo and set it as the background image on
|
4
|
+
# your first KDE desktop.
|
5
|
+
|
6
|
+
require 'flickraw'
|
7
|
+
require 'open-uri'
|
8
|
+
DESKTOP=1
|
9
|
+
|
10
|
+
list = flickr.interestingness.getList
|
11
|
+
photo = list[rand( 100)]
|
12
|
+
sizes = flickr.photos.getSizes( :photo_id => photo.id)
|
13
|
+
original = sizes.find {|s| s.label == 'Original' }
|
14
|
+
|
15
|
+
url = original.source
|
16
|
+
file = File.basename url
|
17
|
+
full_path = File.join(Dir.pwd, file)
|
18
|
+
|
19
|
+
open url do |remote|
|
20
|
+
open(file, 'wb') { |local| local << remote.read }
|
21
|
+
end
|
22
|
+
|
23
|
+
`dcop kdesktop KBackgroundIface setWallpaper #{DESKTOP} #{full_path} 7`
|
data/flickraw_rdoc.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "rdoc/parsers/parserfactory"
|
2
2
|
require "rdoc/parsers/parse_rb"
|
3
|
-
#require "flickraw"
|
4
3
|
require "cgi"
|
5
4
|
|
6
5
|
FLICKR_API_URL='http://www.flickr.com/services/api'
|
@@ -95,13 +94,13 @@ END
|
|
95
94
|
if info.respond_to? :errors
|
96
95
|
errors = "<b>Error codes</b>\n"
|
97
96
|
info.errors.each {|e|
|
98
|
-
errors << "* #{e.code}: <em
|
97
|
+
errors << "* #{e.code}: <em>#{e.message}</em>\n\n"
|
99
98
|
errors << " #{e.to_s}\n"
|
100
99
|
}
|
101
100
|
end
|
102
101
|
|
103
102
|
if info.method.respond_to? :response
|
104
|
-
response = "<b>
|
103
|
+
response = "<b>Returns</b>\n"
|
105
104
|
raw = CGI.unescapeHTML(info.method.response.to_s)
|
106
105
|
response << raw.collect { |line| line.insert(0, ' ') }.join
|
107
106
|
else
|
data/lib/flickraw.rb
CHANGED
data/rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
|
|
5
5
|
require 'lib/flickraw'
|
6
6
|
require 'flickraw_rdoc'
|
7
7
|
|
8
|
-
PKG_FILES = FileList["lib/flickraw.rb", "flickraw_rdoc.rb", "rakefile"].to_a
|
8
|
+
PKG_FILES = FileList["lib/flickraw.rb", "flickraw_rdoc.rb", "rakefile", "examples/*.rb"].to_a
|
9
9
|
|
10
10
|
spec = Gem::Specification.new do |s|
|
11
11
|
s.summary = "Flickr library with a syntax close to the syntax described on http://www.flickr.com/services/api"
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: flickraw
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2006-07-
|
6
|
+
version: "0.2"
|
7
|
+
date: 2006-07-14 00:00:00 +02:00
|
8
8
|
summary: Flickr library with a syntax close to the syntax described on http://www.flickr.com/services/api
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -32,6 +32,9 @@ files:
|
|
32
32
|
- lib/flickraw.rb
|
33
33
|
- flickraw_rdoc.rb
|
34
34
|
- rakefile
|
35
|
+
- examples/auth.rb
|
36
|
+
- examples/interestingness.rb
|
37
|
+
- examples/flickr_KDE.rb
|
35
38
|
test_files: []
|
36
39
|
|
37
40
|
rdoc_options: []
|