app/pages/http_page.rb in under-os-1.0.0 vs app/pages/http_page.rb in under-os-1.1.0

- old
+ new

@@ -11,23 +11,28 @@ def search @search.hide_keyboard @locker.show UnderOs::HTTP.get search_url do |response| - @result.load parse_first_image_url(response.body) do + if image_url = parse_first_image_url(response) + @result.load image_url do + @locker.hide + end + else @locker.hide end end end def search_url query = @search.value query = 'puppy' if query.empty? + query = String.new(query).url_encode - "https://www.google.com.au/search?q=#{query}&source=lnms&tbm=isch" + "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=#{query}" end - def parse_first_image_url(html) - html.scan(/imgurl=(http:\/\/[^&]+)/)[0][0] + def parse_first_image_url(response) + response.json["responseData"]["results"][0]["url"] rescue nil # ftw! end end