bcms_google_mini_search 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/.gitignore +12 -0
  2. data/.rvmrc +1 -0
  3. data/COPYRIGHT.txt +23 -0
  4. data/GPL.txt +674 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE.txt +165 -0
  7. data/README.markdown +3 -7
  8. data/Rakefile +10 -0
  9. data/app/models/search_result.rb +34 -104
  10. data/app/portlets/google_mini_search_engine_portlet.rb +4 -20
  11. data/app/views/layouts/templates/{default.html.erb.html.erb → default.html.erb} +0 -0
  12. data/app/views/portlets/google_mini_search_engine/_form.html.erb +0 -2
  13. data/app/views/portlets/google_mini_search_engine/render.html.erb +17 -39
  14. data/bcms_google_mini_search.gemspec +35 -0
  15. data/doc/README_FOR_APP +2 -0
  16. data/lib/bcms_google_mini_search.rb +1 -2
  17. data/lib/bcms_google_mini_search/engine.rb +7 -0
  18. data/lib/bcms_google_mini_search/routes.rb +3 -3
  19. data/lib/bcms_google_mini_search/version.rb +3 -0
  20. data/lib/generators/bcms_google_mini_search/install/USAGE +10 -0
  21. data/lib/generators/bcms_google_mini_search/install/install_generator.rb +9 -0
  22. data/lib/tasks/.gitkeep +0 -0
  23. data/public/stylesheets/.gitkeep +0 -0
  24. data/test/performance/browsing_test.rb +9 -0
  25. data/test/test_helper.rb +18 -0
  26. data/test/unit/helpers/search_engine_helper_test.rb +4 -0
  27. data/test/unit/portlets/google_mini_search_engine_portlet_test.rb +15 -0
  28. data/test/unit/portlets/search_box_portlet_test.rb +9 -0
  29. data/test/unit/search_result_test.rb +474 -0
  30. data/vendor/plugins/.gitkeep +0 -0
  31. metadata +70 -48
  32. data/app/controllers/application_controller.rb +0 -10
  33. data/app/helpers/application_helper.rb +0 -3
  34. data/lib/bcms_google_mini_search/gsa.rb +0 -144
  35. data/rails/init.rb +0 -3
File without changes
metadata CHANGED
@@ -1,81 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bcms_google_mini_search
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 2
10
- version: 1.2.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - BrowserMedia
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-01 00:00:00 -04:00
19
- default_executable:
20
- dependencies: []
21
-
22
- description: Allows developers to integrate Google Mini or Google Search Appliance into their CMS sites. Can be used to fetch search results and format them.
12
+ date: 2012-01-05 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: browsercms
16
+ requirement: &70196917091400 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.3.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70196917091400
25
+ description: A Google Appliance modules for BrowserCMS. Used to display search results
26
+ from a Google Mini/Search Appliance on a site.
23
27
  email: github@browsermedia.com
24
28
  executables: []
25
-
26
29
  extensions: []
27
-
28
- extra_rdoc_files:
30
+ extra_rdoc_files:
29
31
  - README.markdown
30
- files:
31
- - app/controllers/application_controller.rb
32
- - app/helpers/application_helper.rb
32
+ files:
33
+ - .gitignore
34
+ - .rvmrc
35
+ - COPYRIGHT.txt
36
+ - GPL.txt
37
+ - Gemfile
38
+ - LICENSE.txt
39
+ - README.markdown
40
+ - Rakefile
33
41
  - app/models/search_result.rb
34
42
  - app/portlets/google_mini_search_engine_portlet.rb
35
43
  - app/portlets/search_box_portlet.rb
36
- - app/views/layouts/templates/default.html.erb.html.erb
44
+ - app/views/layouts/templates/default.html.erb
37
45
  - app/views/portlets/google_mini_search_engine/_form.html.erb
38
46
  - app/views/portlets/google_mini_search_engine/render.html.erb
39
47
  - app/views/portlets/search_box/_form.html.erb
40
48
  - app/views/portlets/search_box/render.html.erb
49
+ - bcms_google_mini_search.gemspec
50
+ - doc/README_FOR_APP
41
51
  - lib/bcms_google_mini_search.rb
42
- - lib/bcms_google_mini_search/gsa.rb
52
+ - lib/bcms_google_mini_search/engine.rb
43
53
  - lib/bcms_google_mini_search/routes.rb
44
- - rails/init.rb
45
- - README.markdown
46
- has_rdoc: true
54
+ - lib/bcms_google_mini_search/version.rb
55
+ - lib/generators/bcms_google_mini_search/install/USAGE
56
+ - lib/generators/bcms_google_mini_search/install/install_generator.rb
57
+ - lib/tasks/.gitkeep
58
+ - public/stylesheets/.gitkeep
59
+ - test/performance/browsing_test.rb
60
+ - test/test_helper.rb
61
+ - test/unit/helpers/search_engine_helper_test.rb
62
+ - test/unit/portlets/google_mini_search_engine_portlet_test.rb
63
+ - test/unit/portlets/search_box_portlet_test.rb
64
+ - test/unit/search_result_test.rb
65
+ - vendor/plugins/.gitkeep
47
66
  homepage: http://github.com/browsermedia/bcms_google_mini_search
48
67
  licenses: []
49
-
50
68
  post_install_message:
51
- rdoc_options: []
52
-
53
- require_paths:
69
+ rdoc_options:
70
+ - --charset=UTF-8
71
+ require_paths:
54
72
  - lib
55
- required_ruby_version: !ruby/object:Gem::Requirement
73
+ required_ruby_version: !ruby/object:Gem::Requirement
56
74
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ segments:
62
80
  - 0
63
- version: "0"
64
- required_rubygems_version: !ruby/object:Gem::Requirement
81
+ hash: 1363344703138389246
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
83
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- hash: 3
70
- segments:
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ segments:
71
89
  - 0
72
- version: "0"
90
+ hash: 1363344703138389246
73
91
  requirements: []
74
-
75
92
  rubyforge_project: bcms_google_mini_search
76
- rubygems_version: 1.6.2
93
+ rubygems_version: 1.8.10
77
94
  signing_key:
78
95
  specification_version: 3
79
96
  summary: A Google Mini Search Module for BrowserCMS
80
- test_files: []
81
-
97
+ test_files:
98
+ - test/performance/browsing_test.rb
99
+ - test/test_helper.rb
100
+ - test/unit/helpers/search_engine_helper_test.rb
101
+ - test/unit/portlets/google_mini_search_engine_portlet_test.rb
102
+ - test/unit/portlets/search_box_portlet_test.rb
103
+ - test/unit/search_result_test.rb
@@ -1,10 +0,0 @@
1
- # Filters added to this controller apply to all controllers in the application.
2
- # Likewise, all the methods added will be available for all controllers.
3
-
4
- class ApplicationController < ActionController::Base
5
- helper :all # include all helpers, all the time
6
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
-
8
- # Scrub sensitive parameters from your log
9
- # filter_parameter_logging :password
10
- end
@@ -1,3 +0,0 @@
1
- # Methods added to this helper will be available to all templates in the application.
2
- module ApplicationHelper
3
- end
@@ -1,144 +0,0 @@
1
- # A general purpose API for querying a Google Search Appliance for results.
2
- module GSA
3
-
4
- # Represents a single instance of a Google Mini
5
- class Engine
6
- attr_accessor :host, :port, :path, :default_collection, :default_front_end
7
-
8
- def initialize(options = {})
9
- self.port = 8080
10
- self.path = "/search"
11
- self.host = options[:host]
12
- self.default_front_end = options[:front_end]
13
- self.default_collection = options[:collection]
14
- end
15
-
16
- # Return a Hash suitable to be passed to SearchResult.find()
17
- def options_for_query
18
- {:host=>host, :front_end=>default_front_end, :collection=>default_collection}
19
- end
20
- end
21
-
22
- # GSA support slightly different features than Google Mini.
23
- class Appliance < Engine
24
-
25
-
26
-
27
- # Fetch a set of Suggested queries, based on a given query.
28
- #
29
- # See http://code.google.com/apis/searchappliance/documentation/50/admin_searchexp/ce_understanding.html#h3drc for the spec.
30
- # See http://groups.google.com/group/Google-Search-Appliance-Help/browse_thread/thread/8a821fc8475a5e24/34a5c3c8ab74ed35?hl=en&lnk=gst#34a5c3c8ab74ed35
31
- # for details about how this is implemented.
32
- #
33
- # Clustering (aka Narrow your search) is only supported by GSA.
34
- # @param [String] query A term to fetch 'suggested' queries for/
35
- # @return [GSA::SuggestedQueries] A set of suggested queries
36
- def find_narrow_search_results(query)
37
- return [] unless query
38
-
39
- url = narrow_search_results_url(query)
40
- document = SearchResult.fetch_document(url)
41
- SuggestedQueries.new(document)
42
- end
43
-
44
- private
45
-
46
- # Returns the URL to GET a set of Dynamic Search Clusters for a particular query.
47
- def narrow_search_results_url(query)
48
- "#{host}/cluster?coutput=xml&q=#{CGI::escape(query)}&site=#{default_collection}&client=#{default_front_end}&output=xml_no_dtd&oe=UTF-8&ie=UTF-8"
49
- end
50
- end
51
-
52
- # Represents a set of suggested search terms, based on results from a GSA.
53
- # AKA DynamicResultClusters
54
- class SuggestedQueries
55
- def initialize(xml_as_string)
56
- @clusters = []
57
- doc = REXML::Document.new(xml_as_string)
58
- doc.elements.each('toplevel/Response/cluster/gcluster') do |ele|
59
- @clusters << Suggestion.new(ele.elements["label"].attributes["data"])
60
- end
61
-
62
- end
63
-
64
- delegate :each, :each_with_index, :size, '[]', :to=>:clusters
65
-
66
- private
67
-
68
- def clusters
69
- @clusters
70
- end
71
-
72
-
73
- # Since generating are handled in the view, this might no longer be necessary a separate class, and could probably be converted into a String.
74
- class Suggestion
75
- attr_accessor :query
76
-
77
- def initialize(query)
78
- self.query = query
79
- end
80
-
81
- end
82
- end
83
-
84
-
85
-
86
-
87
- class Query
88
- attr_reader :engine, :query, :front_end, :collection
89
-
90
- def initialize(options={})
91
- @engine = options[:engine]
92
- @query = options[:query]
93
- @front_end = options[:front_end]
94
- @collection = options[:collection]
95
- end
96
- end
97
-
98
- # Represent a collection of results from a GSA search.
99
- class Results
100
-
101
- attr_accessor :query
102
-
103
-
104
- end
105
-
106
- # Represents a single result (aka Hit) from a GSA query.
107
- # Defined by http://code.google.com/apis/searchappliance/documentation/46/xml_reference.html#results_xml_tag_r
108
- class Result
109
- attr_accessor :number, :title, :url, :description, :size, :cache_id, :results
110
-
111
- # @param [RXEML::Element] xml_element The <R> result from GSA a search.
112
- def initialize(xml_element = nil)
113
- return if xml_element == nil
114
- self.number = xml_element.attributes["N"]
115
- self.title = xml_element.elements["T"].try(:text)
116
- self.url = xml_element.elements["U"].try(:text)
117
- self.description = xml_element.elements["S"].try(:text)
118
-
119
- cache_element = xml_element.elements["HAS/C"]
120
-
121
- if cache_element
122
- self.size = cache_element.attributes["SZ"]
123
- self.cache_id = cache_element.attributes["CID"]
124
- else
125
- self.size = ""
126
- self.cache_id=""
127
- end
128
-
129
- end
130
-
131
- # Returns the value for q if a user wants to request the cached version of this document.
132
- def cached_document_param
133
- param = "cache:#{cache_id}:#{url}"
134
- if results
135
- param += "+#{results.query}"
136
- end
137
- param
138
- end
139
-
140
- def cached_document_url(gsa_query)
141
- SearchResult.query_url(cached_document_param, {:host=>gsa_query.engine.host, :collection=>gsa_query.collection, :front_end=>gsa_query.front_end, :as_xml=>false})
142
- end
143
- end
144
- end
@@ -1,3 +0,0 @@
1
- gem_root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
2
- Cms.add_to_rails_paths gem_root
3
- Cms.add_generator_paths gem_root, "db/migrate/[0-9]*_*.rb"