removing log dir from .gitignore
[monkeycharger.git] / vendor / rails / actionwebservice / examples / googlesearch / direct / search_controller.rb
blob7c69f0225e1462cc04f0281e4ca737f343611a6b
1 class SearchController < ApplicationController
2   web_service_api :google_search
3   wsdl_service_name 'GoogleSearch'
5   def doGetCachedPage
6     "<html><body>i am a cached page. my key was %s, url was %s</body></html>" % [@params['key'], @params['url']]
7   end
9   def doSpellingSuggestion
10     "%s: Did you mean '%s'?" % [@params['key'], @params['phrase']]
11   end
13   def doGoogleSearch
14     resultElement = ResultElement.new
15     resultElement.summary = "ONlamp.com: Rolling with Ruby on Rails"
16     resultElement.URL = "http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html"
17     resultElement.snippet = "Curt Hibbs shows off Ruby on Rails by building a simple application that requires " +
18                             "almost no Ruby experience. ... Rolling with Ruby on Rails. ..."
19     resultElement.title = "Teh Railz0r"
20     resultElement.cachedSize = "Almost no lines of code!"
21     resultElement.relatedInformationPresent = true
22     resultElement.hostName = "rubyonrails.com"
23     resultElement.directoryCategory = category("Web Development", "UTF-8")
25     result = GoogleSearchResult.new
26     result.documentFiltering = @params['filter']
27     result.searchComments = ""
28     result.estimatedTotalResultsCount = 322000
29     result.estimateIsExact = false
30     result.resultElements = [resultElement]
31     result.searchQuery = "http://www.google.com/search?q=ruby+on+rails"
32     result.startIndex = @params['start']
33     result.endIndex = @params['start'] + @params['maxResults']
34     result.searchTips = "\"on\" is a very common word and was not included in your search [details]"
35     result.searchTime = 0.000001
37     # For Mono, we have to clone objects if they're referenced by more than one place, otherwise
38     # the Ruby SOAP collapses them into one instance and uses references all over the
39     # place, confusing Mono. 
40     #
41     # This has recently been fixed:
42     #   http://bugzilla.ximian.com/show_bug.cgi?id=72265
43     result.directoryCategories = [
44       category("Web Development", "UTF-8"),
45       category("Programming", "US-ASCII"),
46     ]
48     result
49   end
51   private
52     def category(name, encoding)
53       cat = DirectoryCategory.new
54       cat.fullViewableName = name.dup
55       cat.specialEncoding = encoding.dup
56       cat
57     end
58 end