shoeset

Check-in [c532927408]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Progress bar and sleep interval added
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c532927408f96392ad2b2b0c53af5d8744ae6e8c85de7812bd4f32bf08b2890b
User & Date: i5ivem@gmail.com 2010-03-16 15:27:23
Context
2010-03-16
15:27
Changed formatting only check-in: 2e3ea62bd5 user: i5ivem@gmail.com tags: trunk
15:27
Progress bar and sleep interval added check-in: c532927408 user: i5ivem@gmail.com tags: trunk
15:27
use snippet to return tag cloud check-in: 5df11ad2cc user: i5ivem@gmail.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to shoeset.rb.

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
Shoes.setup do
	gem 'flickraw'
end

require 'flickraw'
require 'yaml'
require 'cloud'


Shoes.app do



	FlickRaw.api_key=""
	FlickRaw.shared_secret=""
	
	TOKENFILE = ENV['HOME']+"\\.shoeset.yml"
	#Load token if it exists
	if File.exists?(TOKENFILE)
				$SETTINGS = YAML::load(File.read(TOKENFILE))
				@token = $SETTINGS["Token"]
				auth = flickr.auth.checkToken :auth_token => @token

	else

		frob = flickr.auth.getFrob
		auth_url = FlickRaw.auth_url :frob => frob, :perms => 'read'
	
		para "Click to authorise with Flickr : ", link("Authorise", :click =>auth_url)
		para "Click OK when you are finished."











>
>









>







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
Shoes.setup do
	gem 'flickraw'
end

require 'flickraw'
require 'yaml'
require 'cloud'


Shoes.app do

	
	#Need to improve GUI feedback on opening. Thread??
	FlickRaw.api_key=""
	FlickRaw.shared_secret=""
	
	TOKENFILE = ENV['HOME']+"\\.shoeset.yml"
	#Load token if it exists
	if File.exists?(TOKENFILE)
				$SETTINGS = YAML::load(File.read(TOKENFILE))
				@token = $SETTINGS["Token"]
				auth = flickr.auth.checkToken :auth_token => @token
				
	else

		frob = flickr.auth.getFrob
		auth_url = FlickRaw.auth_url :frob => frob, :perms => 'read'
	
		para "Click to authorise with Flickr : ", link("Authorise", :click =>auth_url)
		para "Click OK when you are finished."
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
	@setlist = []
	@photosetlist = flickr.photosets.getList.each do |set|
		@setlist << set["title"]
	end

	list_box :items => @setlist, 
		:chose => @setlist[0] do |set|

			para set.text

			photosetinfo = @photosetlist.select {|s| s["title"] == set.text}

			debug(photosetinfo)


			debug photosetinfo[0]["id"].to_s #it's an array of a hash. Even though just one
			photosetphotos = flickr.photosets.getPhotos(:photoset_id => photosetinfo[0]["id"] )
			debug(photosetphotos["photo"])
			array = []

			photosetphotos["photo"].each do |photo|
				debug flickr.tags.getListPhoto(:photo_id => photo["id"])
				temp = flickr.tags.getListPhoto(:photo_id => photo["id"])
				temp["tags"].each do |tags| #should be an array
					array << tags["_content"]
				end
				debug array




				# Caching - anyway? Could cache list of photos from set, but then what about if updated?
				# Sleep interval between calls.
			end

		cloud = TagCloud.new(array.join(" "))

		eval cloud.build
		debug cloud.build
		end
	
end










>

>

>

>
>



|
>
|
|
|
|
|
|
|
|
>
>
>
|
<
|
<
|
>
|
|
|
|




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
	@setlist = []
	@photosetlist = flickr.photosets.getList.each do |set|
		@setlist << set["title"]
	end

	list_box :items => @setlist, 
		:chose => @setlist[0] do |set|
			#Need to implement redraw on next select, etc....
			para set.text
			$p = progress :width => 1.0
			photosetinfo = @photosetlist.select {|s| s["title"] == set.text}
		
			debug(photosetinfo)
			count = photosetinfo[0]["photos"].to_f
			counter = 0.0
			debug photosetinfo[0]["id"].to_s #it's an array of a hash. Even though just one
			photosetphotos = flickr.photosets.getPhotos(:photoset_id => photosetinfo[0]["id"] )
			debug(photosetphotos["photo"])
			$array = []
			Thread.new do
				photosetphotos["photo"].each do |photo|
					debug flickr.tags.getListPhoto(:photo_id => photo["id"])
					temp = flickr.tags.getListPhoto(:photo_id => photo["id"])
					temp["tags"].each do |tags| #should be an array
						$array << tags["_content"]
					end
					debug $array
					sleep(1) # Sleep interval between calls.
					counter += 1.0
					$p.fraction = counter/count
					debug (counter/count)
					# Caching - anyway? Could cache list of photos from set, but then what about if updated?

				end

			cloud = TagCloud.new($array.join(" "))
			$p.hide
			debug cloud.build
			eval cloud.build
			end
		end
end