← Back to team overview

cairo-dock-team team mailing list archive

[Merge] lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/WebSearch into lp:cairo-dock-plug-ins-extras

 

Eduardo Mucelli R. Oliveira has proposed merging lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/WebSearch into lp:cairo-dock-plug-ins-extras.

Requested reviews:
  Cairo-Dock Team (cairo-dock-team)


Fixing the Google search since the engine changed the result stats HTML. Fixing the Bing result stats. Fixing the stats showing.
-- 
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/WebSearch/+merge/24982
Your team Cairo-Dock Team is requested to review the proposed merge of lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/WebSearch into lp:cairo-dock-plug-ins-extras.
=== modified file 'WebSearch/Changelog.txt'
--- WebSearch/Changelog.txt	2010-05-03 16:50:31 +0000
+++ WebSearch/Changelog.txt	2010-05-10 11:38:24 +0000
@@ -1,4 +1,5 @@
-0.7.0: (May/3/2010): WebSearch now fetch results from Wikipedia. Some code improvements. A new icon has been drawn, and a new preview also, both using Gimp. 
+0.7.3: (May/10/2010): Fixing the Google search since the engine changed the result stats HTML. Fixing the Bing result stats. Fixing the stats showing.
+0.7.0: (May/3/2010): WebSearch now fetch results from Wikipedia. Some code improvements. A new icon has been drawn, and a new preview also, both using Gimp.
 0.5.5: (May/1/2010): WebSearch now fetch results from Flickr and optionally it shows the image thumbnail as sub-icon. Thumbnail download is faster, it was parallelized with multi-threading. Fixed the removal of Google Images injected results within Google search. Adding Youtube, and Webshots result stats. Removed the log when downloading thumbnails. Any console output was removed.
 0.4.1 (April/25/2010): WebSearch now fetch results from Webshots and optionally it shows the image thumbnail as sub-icon. Now thumbnails are downloaded only by each sub-icons pagination increasing the response time. Changing a show_youtube_video_preview parameter for a general one show_thumbnail_preview able for any search engine which gives thumbnail possibility.
 0.3.0 (April/21/2010): WebSearch now fetch results from Youtube and optionally it shows the video thumbnail as sub-icon. New applet preview image that shows the results of a Youtube search.

=== modified file 'WebSearch/WebSearch'
--- WebSearch/WebSearch	2010-05-03 16:50:31 +0000
+++ WebSearch/WebSearch	2010-05-10 11:38:24 +0000
@@ -33,14 +33,13 @@
 %w{rubygems open-uri nokogiri dbus parseconfig launchy}.each { |x| require x }			# requirements
 
 class Array
-	def third
-		self[2]																			# defining the method "third" just for code readability
-	end
+	def third;self[2];end																# defining the method "third" just for code readability
+	def fifth;self[4];end
 end
 
 class String
 	def to_b
-		["true"].include?(self.downcase)												# string to boolean
+		"true" == downcase																# string to boolean
 	end
 end
 
@@ -48,6 +47,7 @@
 applet_service = bus.service("org.cairodock.CairoDock")
 applet_name = File.basename(Dir.getwd)													# nome do applet, neste caso é demo_ruby
 applet_path = "/org/cairodock/CairoDock/#{applet_name}"									# caminho onde o objeto está guardado no bus
+
 applet_object = applet_service.object(applet_path)
 applet_object.introspect
 applet_object.default_iface = 'org.cairodock.CairoDock.applet'							# list of icons contained in our sub-dock, or in our desklet
@@ -96,7 +96,7 @@
 
 	def download_thumbnail
 		# download thumb quietly (q), name it (O) '#{image_id}.jpg' and take it to the directory named as engine
-		system("wget -q #{self.thumb_url} -O #{self.thumb_path}") 
+		IO.popen("wget -q #{self.thumb_url} -O #{self.thumb_path}") 
 		self.downloaded_thumb = true
 		self.icon = File.expand_path(self.thumb_path)
 	end
@@ -245,7 +245,7 @@
 	end
 
 	def action_on_click
-		if self.query.empty?
+		if self.stats.empty?
 			ask_for_search_query
 		else
 			@icon.ShowDialog(self.stats, DialogActiveTime) 
@@ -332,9 +332,10 @@
 		self.links[inicio, self.number_of_displayed_links].each do |link|				# first let's download the thumbs if necessary
 			if link.instance_of?(ThumbnailedLink) and not link.downloaded_thumb?		# class that provides thumbs and a not yet downloaded thumb
 				if self.show_thumbnail_preview 											# user want to see thumbs, so let's get it
-					threads << Thread.new(link) do |l|									# parallelizing thumb download with multi-threading
-						l.download_thumbnail
-					end
+#					threads << Thread.new(link) do |l|									# parallelizing thumb download with multi-threading
+#						l.download_thumbnail
+#					end
+					p link.download_thumbnail
 				end
 			end
 		end
@@ -375,9 +376,9 @@
 	# Retrieve informations from Google search stats
 	# The stats array positions "Resultados first - second de aproximadamente third para fourth (fifth segundos)"
 	def retrieve_google_result_stats google
-		stats = (google/"p[@id='resultStats']/b").to_a
-		total = stats.third.inner_text
-		time = stats.last.inner_text
+		stats = (google/"div[@id='resultStats']")
+		/^About ([\S]+) results \s\(([\S]+) seconds\)/.match(stats.inner_text)
+		total, time = $1, $2
 		"Search for #{self.query} returned #{total} results in #{time} seconds"
 	end
 
@@ -397,7 +398,7 @@
 	# The stats array postions "first-second 'of' third 'results'"
 	def retrieve_bing_result_stats bing
 		stats = (bing/"span[@id='count']").inner_text
-		total = stats.split.third
+		total = stats.split.fifth
 		"Search for #{self.query} returned #{total} results"
 	end
 

=== modified file 'WebSearch/WebSearch.conf'
--- WebSearch/WebSearch.conf	2010-05-03 16:50:31 +0000
+++ WebSearch/WebSearch.conf	2010-05-10 11:38:24 +0000
@@ -1,4 +1,4 @@
-#!en;0.7.0
+#!en;0.7.3
 
 #[gtk-about]
 [Icon]

=== modified file 'WebSearch/auto-load.conf'
--- WebSearch/auto-load.conf	2010-05-03 16:50:31 +0000
+++ WebSearch/auto-load.conf	2010-05-10 11:38:24 +0000
@@ -10,4 +10,4 @@
 category = 2
 
 # Version of the applet; change it everytime you change something in the config file. Don't forget to update the version both in this file and in the config file.
-version = 0.7.0
+version = 0.7.3


Follow ups