locomotive_google_search 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7dfb734c0125e4af3747ce178eb49e2e2e3797b1
4
- data.tar.gz: 5adabe83589a8a465cd3df1a35b9e8c5874ddfae
3
+ metadata.gz: 3041cccc0ccd76e4b4c2590b00d43755eb2077e9
4
+ data.tar.gz: 4f97d21b8f06232c71ecf6891a337895f6e41daa
5
5
  SHA512:
6
- metadata.gz: a40734cd899868e36a1bc95d9e2ae2770d4a7420d6c093cb413aba1574018d7b0412fd4db728c773c16a51679647c4a343dff1cb305f4ef26bf7024adaaeb133
7
- data.tar.gz: 880b5f4aaab35747e91fa652d21f8634883be5313efc88602ab5c2009518c0271f59c5b573b01e35169cb94f78f8a73fac7407f5c1e0df45db99cdd06fecf381
6
+ metadata.gz: 91fd402a9ab903082109eeba409ffb9ce088ea1615d97a77e79f4162e2baf9da864c4022367bcbfd1ef6b6966c361f8afddd25cd9223ce67718c6d28c7ff2022
7
+ data.tar.gz: 976e8d30366873854ef5117ed2b2bfbcfa3d5b152a00cf4b01cefa528e3a775a6aaed1c78d9200081acf35ffd331ba4a2321eb8746a180b7cb61d24940861ecc
@@ -1,5 +1,5 @@
1
- require 'locomotive_google_search/middlewares/custom_drops'
2
1
  require 'locomotive/steam'
2
+ require 'locomotive_google_search/middlewares/custom_drops'
3
3
 
4
4
  Locomotive::Steam.configure_extension do |config|
5
5
  config.middleware.insert_after Locomotive::Steam::Middlewares::Page, LocomotiveGoogleSearch::Middlewares::CustomDrops
@@ -0,0 +1,8 @@
1
+ module GoogleSearch
2
+
3
+ end
4
+
5
+ require 'locomotive_google_search/google_search/stubbed_json_data'
6
+ require 'locomotive_google_search/google_search/query'
7
+ require 'locomotive_google_search/google_search/result'
8
+ require 'locomotive_google_search/google_search/search'
@@ -1,64 +1,65 @@
1
1
  require 'open-uri'
2
2
 
3
- class GoogleSearch::Query
3
+ module GoogleSearch
4
+ class Query
5
+ attr_reader :term, :start, :data, :results
4
6
 
5
- attr_reader :term, :start, :data, :results
6
-
7
- def initialize(args = {})
8
- @term = args[:term]
9
- @start = args[:start].try(:to_s) || "1"
10
- pull_data
11
- build_results
12
- end
7
+ def initialize(args = {})
8
+ binding.pry
9
+ @term = args[:term]
10
+ @start = args[:start].try(:to_s) || "1"
11
+ pull_data
12
+ build_results
13
+ end
13
14
 
14
- private
15
+ private
15
16
 
16
- def build_results
17
- @results = data["items"].map do |item_hash|
18
- GoogleSearch::Result.new(item_hash)
17
+ def build_results
18
+ @results = data["items"].map do |item_hash|
19
+ GoogleSearch::Result.new(item_hash)
20
+ end
21
+ return @results
19
22
  end
20
- return @results
21
- end
22
23
 
23
- def pull_data
24
- @data = Rails.env.development? ? stubbed_json : JSON.parse(open(generate_url).read)
25
- end
24
+ def pull_data
25
+ @data = Rails.env.development? ? stubbed_json : JSON.parse(open(generate_url).read)
26
+ end
26
27
 
27
- def start_hash
28
- return {} unless start.present?
29
- return { start: start }
30
- end
28
+ def start_hash
29
+ return {} unless start.present?
30
+ return { start: start }
31
+ end
31
32
 
32
- def options
33
- @options ||= { key: ENV["GOOGLE_API_KEY"], cx: ENV["GOOGLE_SEARCH_ENGINE_ID"], q: term }.merge(start_hash)
34
- end
33
+ def options
34
+ @options ||= { key: ENV["GOOGLE_API_KEY"], cx: ENV["GOOGLE_SEARCH_ENGINE_ID"], q: term }.merge(start_hash)
35
+ end
35
36
 
36
- def base_url
37
- "https://www.googleapis.com/customsearch/v1?"
38
- end
37
+ def base_url
38
+ "https://www.googleapis.com/customsearch/v1?"
39
+ end
39
40
 
40
- def generate_url(args = {})
41
- path = args[:path]
42
- url = base_url
43
- return url unless options.present?
44
- options_string = ""
45
- option_to_string = Proc.new {|k, v, index| "#{'&' unless index == 0}#{k.to_s}=#{v.to_s}"}
46
- options.each_with_index do |(key, value), index|
47
- if value.is_a?(String)
48
- options_string << option_to_string.call(key, value, index)
49
- elsif value.is_a?(Array)
50
- value.each do |val|
51
- options_string << option_to_string.call(key, val, index)
41
+ def generate_url(args = {})
42
+ path = args[:path]
43
+ url = base_url
44
+ return url unless options.present?
45
+ options_string = ""
46
+ option_to_string = Proc.new {|k, v, index| "#{'&' unless index == 0}#{k.to_s}=#{v.to_s}"}
47
+ options.each_with_index do |(key, value), index|
48
+ if value.is_a?(String)
49
+ options_string << option_to_string.call(key, value, index)
50
+ elsif value.is_a?(Array)
51
+ value.each do |val|
52
+ options_string << option_to_string.call(key, val, index)
53
+ end
54
+ else
55
+ raise "Currently only string and array values are supported. You tried a #{value.class} value."
52
56
  end
53
- else
54
- raise "Currently only string and array values are supported. You tried a #{value.class} value."
55
57
  end
58
+ URI.encode("#{url}#{options_string}")
56
59
  end
57
- URI.encode("#{url}#{options_string}")
58
- end
59
-
60
- def stubbed_json
61
- JsonData.new(file_name: "google_search").gather
62
- end
63
60
 
61
+ def stubbed_json
62
+ GoogleSearch::StubbedJsonData.parsed_json
63
+ end
64
+ end
64
65
  end
@@ -1,15 +1,19 @@
1
- class GoogleSearch::Result
1
+ require 'locomotive_google_search/liquid/drops/result'
2
2
 
3
- attr_reader :title, :link, :snippet
3
+ module GoogleSearch
4
+ class Result
4
5
 
5
- def initialize(args = {})
6
- @title = args["title"]
7
- @link = args["link"]
8
- @snippet = args["snippet"]
9
- end
6
+ attr_reader :title, :link, :snippet
10
7
 
11
- def to_liquid
12
- Shop::Liquid::Drops::Result.new(self)
13
- end
8
+ def initialize(args = {})
9
+ @title = args["title"]
10
+ @link = args["link"]
11
+ @snippet = args["snippet"]
12
+ end
14
13
 
15
- end
14
+ def to_liquid
15
+ LocomotiveGoogleSearch::Liquid::Drops::Result.new(self)
16
+ end
17
+
18
+ end
19
+ end
@@ -1,43 +1,45 @@
1
- class GoogleSearch::Search
1
+ module GoogleSearch
2
+ class Search
2
3
 
3
- attr_reader :term, :page, :results, :options, :query
4
+ attr_reader :term, :page, :results, :options, :query
4
5
 
5
- def initialize(args = {})
6
- @term = args[:term]
7
- @page = args[:page].try(:to_i) || 1
8
- start = ((@page - 1) * 10) + 1
9
- @options = { term: term, start: start }
10
- search_and_return_one_page
11
- end
6
+ def initialize(args = {})
7
+ @term = args[:term]
8
+ @page = args[:page].try(:to_i) || 1
9
+ start = ((@page - 1) * 10) + 1
10
+ @options = { term: term, start: start }
11
+ search_and_return_one_page
12
+ end
12
13
 
13
- def search_and_return_all_results
14
- @results = []
14
+ def search_and_return_all_results
15
+ @results = []
16
+
17
+ more_pages = true
18
+ while more_pages
19
+ search = GoogleSearch::Query.new(options)
20
+ @results << search.results
21
+ more_pages = search.data["queries"]["nextPage"].present? ? true : false
22
+ options[:start] += 10
23
+ end
24
+ @results.flatten!
25
+ end
15
26
 
16
- more_pages = true
17
- while more_pages
18
- search = GoogleSearch::Query.new(options)
19
- @results << search.results
20
- more_pages = search.data["queries"]["nextPage"].present? ? true : false
21
- options[:start] += 10
27
+ def search_and_return_one_page
28
+ @query = GoogleSearch::Query.new(options)
29
+ @results = @query.results
22
30
  end
23
- @results.flatten!
24
- end
25
31
 
26
- def search_and_return_one_page
27
- @query = GoogleSearch::Query.new(options)
28
- @results = @query.results
29
- end
32
+ def has_next_page?
33
+ query.data["queries"]["nextPage"].present?
34
+ end
30
35
 
31
- def has_next_page?
32
- query.data["queries"]["nextPage"].present?
33
- end
36
+ def next_page
37
+ ((query.data["queries"]["nextPage"].first["startIndex"].to_i - 1) / 10) + 1
38
+ end
34
39
 
35
- def next_page
36
- ((query.data["queries"]["nextPage"].first["startIndex"].to_i - 1) / 10) + 1
37
- end
40
+ def previous_page
41
+ page - 1
42
+ end
38
43
 
39
- def previous_page
40
- page - 1
41
44
  end
42
-
43
- end
45
+ end
@@ -0,0 +1,419 @@
1
+ module GoogleSearch
2
+ class StubbedJsonData
3
+ def self.parsed_json
4
+ JSON.parse(json)
5
+ end
6
+
7
+ def self.json
8
+ string = <<-eos.squish
9
+ {
10
+ "kind": "customsearch#search",
11
+ "url": {
12
+ "type": "application/json",
13
+ "template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"
14
+ },
15
+ "queries": {
16
+ "nextPage": [
17
+ {
18
+ "title": "Google Custom Search - bunk bed",
19
+ "totalResults": "61",
20
+ "searchTerms": "bunk bed",
21
+ "count": 10,
22
+ "startIndex": 11,
23
+ "inputEncoding": "utf8",
24
+ "outputEncoding": "utf8",
25
+ "safe": "off",
26
+ "cx": "016635208486203313961:unyqgqxiyrw"
27
+ }
28
+ ],
29
+ "request": [
30
+ {
31
+ "title": "Google Custom Search - bunk bed",
32
+ "totalResults": "61",
33
+ "searchTerms": "bunk bed",
34
+ "count": 10,
35
+ "startIndex": 1,
36
+ "inputEncoding": "utf8",
37
+ "outputEncoding": "utf8",
38
+ "safe": "off",
39
+ "cx": "016635208486203313961:unyqgqxiyrw"
40
+ }
41
+ ]
42
+ },
43
+ "context": {
44
+ "title": "Adultbunkbeds"
45
+ },
46
+ "searchInformation": {
47
+ "searchTime": 0.151713,
48
+ "formattedSearchTime": "0.15",
49
+ "totalResults": "61",
50
+ "formattedTotalResults": "61"
51
+ },
52
+ "items": [
53
+ {
54
+ "kind": "customsearch#result",
55
+ "title": "Adult Bunk Beds",
56
+ "htmlTitle": "Adult \u003cb\u003eBunk Beds\u003c/b\u003e",
57
+ "link": "http://adultbunkbeds.com/collections/adult-bunk-beds",
58
+ "displayLink": "adultbunkbeds.com",
59
+ "snippet": "Here at Francis Lofts & Bunks, we are proud to offer bunk beds that you will be \nexcited to have in your home. Featuring beautiful, durable aluminum, our bun.",
60
+ "htmlSnippet": "Here at Francis Lofts &amp; Bunks, we are proud to offer \u003cb\u003ebunk beds\u003c/b\u003e that you will be \u003cbr\u003e\nexcited to have in your home. Featuring beautiful, durable aluminum, our bun.",
61
+ "cacheId": "xOBqR0MVDr4J",
62
+ "formattedUrl": "adultbunkbeds.com/collections/adult-bunk-beds",
63
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/collections/adult-\u003cb\u003ebunk\u003c/b\u003e-\u003cb\u003ebeds\u003c/b\u003e",
64
+ "pagemap": {
65
+ "metatags": [
66
+ {
67
+ "viewport": "width=device-width, initial-scale=1",
68
+ "og:title": "Queen Bunk Beds, Full Bunk Beds, Twin Bunk Beds",
69
+ "og:type": "website",
70
+ "og:description": "Here at Francis Lofts &amp; Bunks, we are proud to offer bunk beds that you will be excited to have in your home. Featuring beautiful, durable aluminum, our bun",
71
+ "og:url": "http://adultbunkbeds.com/collections/adult-bunk-beds",
72
+ "og:site_name": "Francis Lofts & Bunks"
73
+ }
74
+ ]
75
+ }
76
+ },
77
+ {
78
+ "kind": "customsearch#result",
79
+ "title": "Francis Lofts & Bunks: Bunk Beds and Loft Beds for Adults",
80
+ "htmlTitle": "Francis Lofts &amp; Bunks: \u003cb\u003eBunk Beds\u003c/b\u003e and Loft Beds for Adults",
81
+ "link": "http://adultbunkbeds.com/",
82
+ "displayLink": "adultbunkbeds.com",
83
+ "snippet": "Increase the space in your home with a bunk bed or loft bed designed for adults, \nfeaturing 10 available colors and a huge weight capacity.",
84
+ "htmlSnippet": "Increase the space in your home with a \u003cb\u003ebunk bed\u003c/b\u003e or loft bed designed for adults, \u003cbr\u003e\nfeaturing 10 available colors and a huge weight capacity.",
85
+ "cacheId": "Z_yMNMsYLY8J",
86
+ "formattedUrl": "adultbunkbeds.com/",
87
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/",
88
+ "pagemap": {
89
+ "cse_image": [
90
+ {
91
+ "src": "http://cdn.shopify.com/s/files/1/0154/0359/t/20/assets/flab-logo-final.svg?2371661885111191792"
92
+ }
93
+ ],
94
+ "cse_thumbnail": [
95
+ {
96
+ "width": "196",
97
+ "height": "80",
98
+ "src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQBEzIwROOQCy1FhfmDpNuPrSi0yEgVKc5qQmGPIkYBB8GJdpzpUMskhQ"
99
+ }
100
+ ],
101
+ "metatags": [
102
+ {
103
+ "viewport": "width=device-width, initial-scale=1",
104
+ "og:title": "Bunk Beds and Loft Beds for Adults",
105
+ "og:type": "website",
106
+ "og:description": "Increase the space in your home with a bunk bed or loft bed designed for adults, featuring 10 available colors and a huge weight capacity.",
107
+ "og:url": "http://adultbunkbeds.com/",
108
+ "og:site_name": "Francis Lofts & Bunks"
109
+ }
110
+ ]
111
+ }
112
+ },
113
+ {
114
+ "kind": "customsearch#result",
115
+ "title": "Bunk Bed for Adults – Francis Lofts & Bunks",
116
+ "htmlTitle": "\u003cb\u003eBunk Bed\u003c/b\u003e for Adults – Francis Lofts &amp; Bunks",
117
+ "link": "http://adultbunkbeds.com/products/bunk-bed",
118
+ "displayLink": "adultbunkbeds.com",
119
+ "snippet": "Our bunk beds are built for adults, featuring a 2000 pound weight capacity, 6 \navailable colors, and a contemporary aluminum design.",
120
+ "htmlSnippet": "Our \u003cb\u003ebunk beds\u003c/b\u003e are built for adults, featuring a 2000 pound weight capacity, 6 \u003cbr\u003e\navailable colors, and a contemporary aluminum design.",
121
+ "cacheId": "9RQMUoQwu1YJ",
122
+ "formattedUrl": "adultbunkbeds.com/products/bunk-bed",
123
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/products/\u003cb\u003ebunk\u003c/b\u003e-\u003cb\u003ebed\u003c/b\u003e",
124
+ "pagemap": {
125
+ "product": [
126
+ {
127
+ "url": "http://adultbunkbeds.com/products/bunk-bed",
128
+ "image": "//cdn.shopify.com/s/files/1/0154/0359/products/bunk-bed-builder_grande.png?v=1430329850",
129
+ "price": "$2,525.00"
130
+ }
131
+ ],
132
+ "cse_image": [
133
+ {
134
+ "src": "http://cdn.shopify.com/s/files/1/0154/0359/products/bunk-bed-builder_grande.png?v=1430329850"
135
+ }
136
+ ],
137
+ "Review-aggregate": [
138
+ {
139
+ "itemreviewed": "Bunk Bed",
140
+ "votes": "42"
141
+ }
142
+ ],
143
+ "cse_thumbnail": [
144
+ {
145
+ "width": "239",
146
+ "height": "211",
147
+ "src": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcRQyBkG6svgP6Hpi6Vvv4RZKElwfX48t7Cn13i_SkY8Mun0x17yro8nu40"
148
+ }
149
+ ],
150
+ "metatags": [
151
+ {
152
+ "viewport": "width=device-width, initial-scale=1",
153
+ "og:type": "product",
154
+ "og:title": "Bunk Bed",
155
+ "og:image": "http://cdn.shopify.com/s/files/1/0154/0359/products/bunk-bed-builder_grande.png?v=1430329850",
156
+ "og:image:secure_url": "https://cdn.shopify.com/s/files/1/0154/0359/products/bunk-bed-builder_grande.png?v=1430329850",
157
+ "og:price:amount": "2,525.00",
158
+ "og:price:currency": "USD",
159
+ "og:description": "Our bunk beds are built for adults, featuring a 2,000 pound weight capacity, 6 available colors, and a contemporary aluminum design.",
160
+ "og:url": "http://adultbunkbeds.com/products/bunk-bed",
161
+ "og:site_name": "Francis Lofts & Bunks"
162
+ }
163
+ ]
164
+ }
165
+ },
166
+ {
167
+ "kind": "customsearch#result",
168
+ "title": "Loft Bed for Adults – Francis Lofts & Bunks",
169
+ "htmlTitle": "Loft \u003cb\u003eBed\u003c/b\u003e for Adults – Francis Lofts &amp; \u003cb\u003eBunks\u003c/b\u003e",
170
+ "link": "http://adultbunkbeds.com/products/loft-bed",
171
+ "displayLink": "adultbunkbeds.com",
172
+ "snippet": "Our loft bed is designed specifically for adults, featuring a contemporary \naluminum design, 6 finishes, and a huge weight capacity.",
173
+ "htmlSnippet": "Our loft \u003cb\u003ebed\u003c/b\u003e is designed specifically for adults, featuring a contemporary \u003cbr\u003e\naluminum design, 6 finishes, and a huge weight capacity.",
174
+ "cacheId": "fd_LWS8rgUIJ",
175
+ "formattedUrl": "adultbunkbeds.com/products/loft-bed",
176
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/products/loft-\u003cb\u003ebed\u003c/b\u003e",
177
+ "pagemap": {
178
+ "product": [
179
+ {
180
+ "url": "http://adultbunkbeds.com/products/loft-bed",
181
+ "image": "//cdn.shopify.com/s/files/1/0154/0359/products/loft-bed-builder_grande.png?v=1430329775",
182
+ "price": "$2,065.00"
183
+ }
184
+ ],
185
+ "cse_image": [
186
+ {
187
+ "src": "http://cdn.shopify.com/s/files/1/0154/0359/products/loft-bed-builder_grande.png?v=1430329775"
188
+ }
189
+ ],
190
+ "Review-aggregate": [
191
+ {
192
+ "itemreviewed": "Loft Bed",
193
+ "votes": "36"
194
+ }
195
+ ],
196
+ "cse_thumbnail": [
197
+ {
198
+ "width": "239",
199
+ "height": "211",
200
+ "src": "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSFTIgmPJgnHqCiwj6M77yuSfNnXrZlLZ1mG2oRckqzmsJAE73fHrJrOas"
201
+ }
202
+ ],
203
+ "metatags": [
204
+ {
205
+ "viewport": "width=device-width, initial-scale=1",
206
+ "og:type": "product",
207
+ "og:title": "Loft Bed",
208
+ "og:image": "http://cdn.shopify.com/s/files/1/0154/0359/products/loft-bed-builder_grande.png?v=1430329775",
209
+ "og:image:secure_url": "https://cdn.shopify.com/s/files/1/0154/0359/products/loft-bed-builder_grande.png?v=1430329775",
210
+ "og:price:amount": "2,065.00",
211
+ "og:price:currency": "USD",
212
+ "og:description": "Our loft bed is designed specifically for adults, featuring a contemporary aluminum design, 6 finishes, and a huge weight capacity.",
213
+ "og:url": "http://adultbunkbeds.com/products/loft-bed",
214
+ "og:site_name": "Francis Lofts & Bunks"
215
+ }
216
+ ]
217
+ }
218
+ },
219
+ {
220
+ "kind": "customsearch#result",
221
+ "title": "About Us | Francis Lofts & Bunks – Francis Lofts & Bunks",
222
+ "htmlTitle": "About Us | Francis Lofts &amp; \u003cb\u003eBunks\u003c/b\u003e – Francis Lofts &amp; \u003cb\u003eBunks\u003c/b\u003e",
223
+ "link": "http://adultbunkbeds.com/pages/about-us",
224
+ "displayLink": "adultbunkbeds.com",
225
+ "snippet": "Form and function combined make these beds ones that you will be proud to ... \nOne month after that, the queen bunk bed would be designed and prototyped.",
226
+ "htmlSnippet": "Form and function combined make these beds ones that you will be proud to ... \u003cbr\u003e\nOne month after that, the queen \u003cb\u003ebunk bed\u003c/b\u003e would be designed and prototyped.",
227
+ "cacheId": "7MoO6ajnlNsJ",
228
+ "formattedUrl": "adultbunkbeds.com/pages/about-us",
229
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/pages/about-us",
230
+ "pagemap": {
231
+ "cse_image": [
232
+ {
233
+ "src": "http://cdn.shopify.com/s/files/1/0154/0359/t/20/assets/flab-logo-final.svg?2371661885111191792"
234
+ }
235
+ ],
236
+ "cse_thumbnail": [
237
+ {
238
+ "width": "196",
239
+ "height": "80",
240
+ "src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQBEzIwROOQCy1FhfmDpNuPrSi0yEgVKc5qQmGPIkYBB8GJdpzpUMskhQ"
241
+ }
242
+ ],
243
+ "metatags": [
244
+ {
245
+ "viewport": "width=device-width, initial-scale=1",
246
+ "og:title": "About Us | Francis Lofts & Bunks",
247
+ "og:type": "website",
248
+ "og:description": "Welcome to Francis Lofts &amp; Bunks! We are available by phone from 9 AM EST - 6 PM EST Monday through Friday at 855-873-4972 or you can leave a message anytim",
249
+ "og:url": "http://adultbunkbeds.com/pages/about-us",
250
+ "og:site_name": "Francis Lofts & Bunks"
251
+ }
252
+ ]
253
+ }
254
+ },
255
+ {
256
+ "kind": "customsearch#result",
257
+ "title": "Gallery – Francis Lofts & Bunks",
258
+ "htmlTitle": "Gallery – Francis Lofts &amp; \u003cb\u003eBunks\u003c/b\u003e",
259
+ "link": "http://adultbunkbeds.com/pages/gallery",
260
+ "displayLink": "adultbunkbeds.com",
261
+ "snippet": "Adult Bunk Beds Adult Loft Beds. ... Menu. 100 off your order for July 4th! Use \ndiscount code “America” at checkout. About; Beds. Menu ...",
262
+ "htmlSnippet": "Adult \u003cb\u003eBunk Beds\u003c/b\u003e Adult Loft Beds. ... Menu. 100 off your order for July 4th! Use \u003cbr\u003e\ndiscount code “America” at checkout. About; Beds. Menu&nbsp;...",
263
+ "cacheId": "1u-FIFIzDKsJ",
264
+ "formattedUrl": "adultbunkbeds.com/pages/gallery",
265
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/pages/gallery",
266
+ "pagemap": {
267
+ "cse_image": [
268
+ {
269
+ "src": "http://cdn.shopify.com/s/files/1/0154/0359/t/20/assets/flab-logo-final.svg?2371661885111191792"
270
+ }
271
+ ],
272
+ "cse_thumbnail": [
273
+ {
274
+ "width": "196",
275
+ "height": "80",
276
+ "src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQBEzIwROOQCy1FhfmDpNuPrSi0yEgVKc5qQmGPIkYBB8GJdpzpUMskhQ"
277
+ }
278
+ ],
279
+ "metatags": [
280
+ {
281
+ "viewport": "width=device-width, initial-scale=1",
282
+ "og:title": "Gallery",
283
+ "og:type": "website",
284
+ "og:description": "Adult Bunk Beds Adult Loft Beds",
285
+ "og:url": "http://adultbunkbeds.com/pages/gallery",
286
+ "og:site_name": "Francis Lofts & Bunks"
287
+ }
288
+ ]
289
+ }
290
+ },
291
+ {
292
+ "kind": "customsearch#result",
293
+ "title": "Contact Us – Francis Lofts & Bunks",
294
+ "htmlTitle": "Contact Us – Francis Lofts &amp; \u003cb\u003eBunks\u003c/b\u003e",
295
+ "link": "http://adultbunkbeds.com/pages/contact-us",
296
+ "displayLink": "adultbunkbeds.com",
297
+ "snippet": "We Are Bed Builders. Francis Lofts & Bunks builds beds that meet your specific \nneeds and most important saves you space in your home. Learn More ...",
298
+ "htmlSnippet": "We Are \u003cb\u003eBed\u003c/b\u003e Builders. Francis Lofts &amp; \u003cb\u003eBunks\u003c/b\u003e builds \u003cb\u003ebeds\u003c/b\u003e that meet your specific \u003cbr\u003e\nneeds and most important saves you space in your home. Learn More&nbsp;...",
299
+ "cacheId": "NXOw590FYrUJ",
300
+ "formattedUrl": "adultbunkbeds.com/pages/contact-us",
301
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/pages/contact-us",
302
+ "pagemap": {
303
+ "cse_image": [
304
+ {
305
+ "src": "http://cdn.shopify.com/s/files/1/0154/0359/t/20/assets/flab-logo-final.svg?10420158721134471868"
306
+ }
307
+ ],
308
+ "cse_thumbnail": [
309
+ {
310
+ "width": "196",
311
+ "height": "80",
312
+ "src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSiMX0shED_3SosUvDdP3Q1qK5YQTmc3xjP9OGpdWOJYchrAb9aySMs-zU"
313
+ }
314
+ ],
315
+ "metatags": [
316
+ {
317
+ "viewport": "width=device-width, initial-scale=1",
318
+ "og:title": "Contact Us",
319
+ "og:type": "website",
320
+ "og:description": "Our physical operation is open Monday - Friday 9:00 AM EST - 6:00 PM EST. We would still love to hear from you on the weekends or off hours, so don't hesitate t",
321
+ "og:url": "http://adultbunkbeds.com/pages/contact-us",
322
+ "og:site_name": "Francis Lofts & Bunks"
323
+ }
324
+ ]
325
+ }
326
+ },
327
+ {
328
+ "kind": "customsearch#result",
329
+ "title": "Aluminum Lofted Bed",
330
+ "htmlTitle": "Aluminum Lofted \u003cb\u003eBed\u003c/b\u003e",
331
+ "link": "http://adultbunkbeds.com/collections/loft-beds/aluminum-lofted-bed",
332
+ "displayLink": "adultbunkbeds.com",
333
+ "snippet": "Francis Lofts & Bunks is in the business of making high quality, stunning loft beds \nthat adults can be proud to show off. A loft bed for adults provides relief for ...",
334
+ "htmlSnippet": "Francis Lofts &amp; \u003cb\u003eBunks\u003c/b\u003e is in the business of making high quality, stunning loft \u003cb\u003ebeds\u003c/b\u003e \u003cbr\u003e\nthat adults can be proud to show off. A loft \u003cb\u003ebed\u003c/b\u003e for adults provides relief for&nbsp;...",
335
+ "cacheId": "yWf6ftP14lcJ",
336
+ "formattedUrl": "adultbunkbeds.com/collections/loft-beds/aluminum-lofted-bed",
337
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/collections/loft-\u003cb\u003ebeds\u003c/b\u003e/aluminum-lofted-\u003cb\u003ebed\u003c/b\u003e",
338
+ "pagemap": {
339
+ "cse_image": [
340
+ {
341
+ "src": "http://cdn.shopify.com/s/files/1/0154/0359/products/10_grande.jpeg?v=1346189936"
342
+ }
343
+ ],
344
+ "cse_thumbnail": [
345
+ {
346
+ "width": "273",
347
+ "height": "185",
348
+ "src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSFz_r2Ekgp5rlZXffcicCc7FsCou08en284nTHFR-btj2VyY746qkINCo"
349
+ }
350
+ ],
351
+ "metatags": [
352
+ {
353
+ "viewport": "width=device-width, initial-scale=1",
354
+ "og:title": "Queen Loft Beds, Full Loft Beds, Twin Loft Beds",
355
+ "og:type": "website",
356
+ "og:description": "Adults all over Urban America are choosing to live in smaller spaces to save themselves from pervasively high rent. Our founder, Ryan, paid $1,000 / month to li",
357
+ "og:url": "http://adultbunkbeds.com/collections/loft-beds/aluminum-lofted-bed",
358
+ "og:site_name": "Francis Lofts & Bunks"
359
+ }
360
+ ]
361
+ }
362
+ },
363
+ {
364
+ "kind": "customsearch#result",
365
+ "title": "Standard Beds – Francis Lofts & Bunks",
366
+ "htmlTitle": "Standard \u003cb\u003eBeds\u003c/b\u003e – Francis Lofts &amp; \u003cb\u003eBunks\u003c/b\u003e",
367
+ "link": "http://adultbunkbeds.com/collections/standard-beds",
368
+ "displayLink": "adultbunkbeds.com",
369
+ "snippet": "After requests from our customers wanting a standalone bed, or a bed to put \nunderneath their loft, we are now proud to offer modern standard beds that you \nwill ...",
370
+ "htmlSnippet": "\ufeffAfter requests from our customers wanting a standalone \u003cb\u003ebed\u003c/b\u003e, or a \u003cb\u003ebed\u003c/b\u003e to put \u003cbr\u003e\nunderneath their loft, we are now proud to offer modern standard \u003cb\u003ebeds\u003c/b\u003e that you \u003cbr\u003e\nwill&nbsp;...",
371
+ "cacheId": "Ig2j599RV3kJ",
372
+ "formattedUrl": "adultbunkbeds.com/collections/standard-beds",
373
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/collections/standard-\u003cb\u003ebeds\u003c/b\u003e",
374
+ "pagemap": {
375
+ "cse_image": [
376
+ {
377
+ "src": "http://cdn.shopify.com/s/files/1/0154/0359/products/standard_bed_8e4877f9-7403-4ece-b94e-a9dc966c7b2d_grande.jpg?v=1381192329"
378
+ }
379
+ ],
380
+ "cse_thumbnail": [
381
+ {
382
+ "width": "259",
383
+ "height": "194",
384
+ "src": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQEEGTZqoa6C5UCHZvZfphHAacZt-FFjgnnTowPlQDkJdjc1mAi4H_Rr-TJ"
385
+ }
386
+ ],
387
+ "metatags": [
388
+ {
389
+ "viewport": "width=device-width, initial-scale=1",
390
+ "og:title": "Standard Beds",
391
+ "og:type": "website",
392
+ "og:description": "Our handcrafted aluminum beds are made with the love and care of skilled artisans right here in the USA. They boast unprecedented quality and beauty.",
393
+ "og:url": "http://adultbunkbeds.com/collections/standard-beds",
394
+ "og:site_name": "Francis Lofts & Bunks"
395
+ }
396
+ ]
397
+ }
398
+ },
399
+ {
400
+ "kind": "customsearch#result",
401
+ "title": "http://adultbunkbeds.com/ daily http://adultbunkbeds.com/products ...",
402
+ "htmlTitle": "http://adultbunkbeds.com/ daily http://adultbunkbeds.com/products \u003cb\u003e...\u003c/b\u003e",
403
+ "link": "http://adultbunkbeds.com/sitemap_products_1.xml?from=101807419&to=547066820",
404
+ "displayLink": "adultbunkbeds.com",
405
+ "snippet": "... https://cdn.shopify.com/s/files/1/0154/0359/products/standard-bed-builder.png?\nv=1430329818 Standard Bed http://adultbunkbeds.com/products/bunk-bed ...",
406
+ "htmlSnippet": "... https://cdn.shopify.com/s/files/1/0154/0359/products/standard-bed-builder.png?\u003cbr\u003e\nv=1430329818 Standard Bed http://adultbunkbeds.com/products/\u003cb\u003ebunk\u003c/b\u003e-\u003cb\u003ebed\u003c/b\u003e&nbsp;...",
407
+ "cacheId": "DFZX3aFpQ9AJ",
408
+ "mime": "text/xml",
409
+ "formattedUrl": "adultbunkbeds.com/sitemap_products_1.xml?from=101807419...",
410
+ "htmlFormattedUrl": "adult\u003cb\u003ebunkbeds\u003c/b\u003e.com/sitemap_products_1.xml?from=101807419..."
411
+ }
412
+ ]
413
+ }
414
+ eos
415
+ string
416
+ end
417
+
418
+ end
419
+ end
@@ -1,7 +1,7 @@
1
1
  module LocomotiveGoogleSearch
2
2
  module Liquid
3
3
  module Drops
4
- class Result < ::Locomotive::Liquid::Drops::Base
4
+ class Result < ::Locomotive::Steam::Liquid::Drops::Base
5
5
 
6
6
  delegate :title, :link, :snippet, :to => :@_source
7
7
 
@@ -24,11 +24,11 @@ module LocomotiveGoogleSearch
24
24
  end
25
25
 
26
26
  def page
27
- @context.registers[:controller].params[:page] || 1
27
+ @context.registers[:request].params['page'].try(:to_i) || 1
28
28
  end
29
29
 
30
30
  def options
31
- text = @context.registers[:controller].params[:query]
31
+ text = @context.registers[:request].params['query']
32
32
  { term: text, page: page }
33
33
  end
34
34
 
@@ -1,7 +1,5 @@
1
- require 'locomotive_google_search/google_search/query'
2
- require 'locomotive_google_search/google_search/result'
3
- require 'locomotive_google_search/google_search/search'
4
- require 'locomotive_google_search/liquid/drops/results'
1
+ require 'locomotive_google_search/google_search'
2
+ require 'locomotive_google_search/liquid/drops/result'
5
3
  require 'locomotive_google_search/liquid/drops/search'
6
4
 
7
5
  module LocomotiveGoogleSearch
@@ -1,3 +1,3 @@
1
1
  module LocomotiveGoogleSearch
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.12"
21
- spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency 'rake', '~> 10.0'
22
22
  spec.add_development_dependency "rspec", "~> 3.0"
23
+ spec.add_development_dependency 'locomotivecms_steam', '~> 1.1'
23
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotive_google_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Francis
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: locomotivecms_steam
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
55
69
  description:
56
70
  email:
57
71
  - ryan.p.francis@gmail.com
@@ -68,14 +82,15 @@ files:
68
82
  - bin/console
69
83
  - bin/setup
70
84
  - lib/locomotive_google_search.rb
85
+ - lib/locomotive_google_search/google_search.rb
71
86
  - lib/locomotive_google_search/google_search/query.rb
72
87
  - lib/locomotive_google_search/google_search/result.rb
73
88
  - lib/locomotive_google_search/google_search/search.rb
89
+ - lib/locomotive_google_search/google_search/stubbed_json_data.rb
74
90
  - lib/locomotive_google_search/liquid/drops/result.rb
75
91
  - lib/locomotive_google_search/liquid/drops/search.rb
76
92
  - lib/locomotive_google_search/middlewares/custom_drops.rb
77
93
  - lib/locomotive_google_search/version.rb
78
- - locomotive_google_search-0.1.0.gem
79
94
  - locomotive_google_search.gemspec
80
95
  homepage: https://github.com/LaunchPadLab/locomotive_google_search
81
96
  licenses: []