searchlink 2.3.85 → 2.3.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02b111da9ce13f8646d7357ae5560a1c6b84bb45fd506dca8fafe96e1c844bea
4
- data.tar.gz: 02fd69545df789fdf1105dea4971b53f02bfc33ac0da20a3f25454c11f9a9ae7
3
+ metadata.gz: 9ec0f6dcca720a1630213bc1addbad3dc28cc949756b5d43ca74394b9a3a1023
4
+ data.tar.gz: 979260379965c9d0c69de75990fea6639f8cd628f4cf1c9fd7b9f9b226170761
5
5
  SHA512:
6
- metadata.gz: 7af24cad60ca01ead8ab4a76f82c6d6fa9be6aa30752f088c23cfe387d9a3adf8f076e5e4d1f1dc25d9eeda8879d1ae7e83bbee3bcea250de6914dc67d35cf0c
7
- data.tar.gz: '089fb329c4c7be4cf30bf929b8c4309374a0b8055f42eb2adeb2c62d29f7a9ef84d9e45527a5c0a13c7e0061345ee814cfd431bc6f33614ad034f8d8c970250a'
6
+ metadata.gz: '0934cdf6a1c087e2fe2dee24bb962ca699fcfafc9848260fd0c75500c2d1531e75cb5f6a33ce4a32ab586c7594ef630a325ccca644bbf0a3a68ca659997d9ab4'
7
+ data.tar.gz: e4767b29327c7f7147efb584ea3e1dee68eafd982802b5b3375b6dddd8f3eb8e1aeb4ed444f9f8486422999eeb6f6b7f4bf94e8b051124d48c3d265867a05827
data/bin/searchlink CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- SILENT = ENV['SL_SILENT'] =~ /false/i ? false : true
5
- $LOAD_PATH.unshift File.join(__dir__, '..')
4
+ SILENT = ENV.fetch("SL_SILENT", nil) =~ /false/i ? false : true
5
+ NO_CONFIRM = ENV.fetch("SL_NO_CONFIRM", nil) =~ /true/i ? true : false
6
+ $LOAD_PATH.unshift File.join(__dir__, "..")
6
7
 
7
8
  # import
8
- require 'lib/searchlink'
9
+ require "lib/searchlink"
9
10
 
10
11
  if RUBY_VERSION.to_f > 1.9
11
12
  Encoding.default_external = Encoding::UTF_8
@@ -20,9 +21,19 @@ SL::Searches.load_custom
20
21
  # SL::Searches.load_searches
21
22
 
22
23
  overwrite = true
23
- backup = SL.config['backup']
24
+ backup = SL.config["backup"]
24
25
 
25
- if !ARGV.empty?
26
+ if ARGV.empty?
27
+ input = $stdin.read.scrubup
28
+ sl.parse(input)
29
+ output = SL.output&.join
30
+
31
+ if SL.clipboard
32
+ print input
33
+ else
34
+ print output
35
+ end
36
+ else
26
37
  files = []
27
38
  ARGV.each do |arg|
28
39
  case arg
@@ -30,7 +41,7 @@ if !ARGV.empty?
30
41
  print SL.version_check
31
42
  puts
32
43
  sl.help_cli
33
- $stdout.puts 'See https://github.com/ttscoff/searchlink/wiki for help'
44
+ $stdout.puts "See https://github.com/ttscoff/searchlink/wiki for help"
34
45
  Process.exit 0
35
46
  when /^(--?)?v(er(s(ion)?)?)?$/
36
47
  print SL.version_check
@@ -46,7 +57,7 @@ if !ARGV.empty?
46
57
 
47
58
  files.each do |file|
48
59
  if File.exist?(file) && `file -b "#{file}"|grep -c text`.to_i.positive?
49
- input = IO.read(file).scrubup
60
+ input = File.read(file).scrubup
50
61
 
51
62
  backup_file = "#{file}.bak"
52
63
  backup_file = "#{file}.bak 1" if File.exist?(backup_file)
@@ -55,12 +66,12 @@ if !ARGV.empty?
55
66
  FileUtils.cp(file, backup_file) if backup && overwrite
56
67
 
57
68
  sl.parse(input)
58
- output = SL.output&.join('')
69
+ output = SL.output&.join
59
70
 
60
71
  next unless output
61
72
 
62
73
  if overwrite
63
- File.open(file, 'w') do |f|
74
+ File.open(file, "w") do |f|
64
75
  f.puts output
65
76
  end
66
77
  else
@@ -70,14 +81,4 @@ if !ARGV.empty?
70
81
  warn "Error reading #{file}"
71
82
  end
72
83
  end
73
- else
74
- input = $stdin.read.scrubup
75
- sl.parse(input)
76
- output = SL.output&.join('')
77
-
78
- if SL.clipboard
79
- print input
80
- else
81
- print output
82
- end
83
84
  end
@@ -82,6 +82,11 @@ module SL
82
82
  # E.g. [](!g Search Text)
83
83
  empty_uses_page_title: false
84
84
 
85
+ # If confirm is true, then a popup dialog will be displayed
86
+ # showing the destination of each found link. Hitting cancel
87
+ # will leave the link unchanged.
88
+ confirm: false
89
+
85
90
  # To create custom abbreviations for Google Site Searches,
86
91
  # add to (or replace) the hash below.
87
92
  # "abbreviation" => "site.url",
@@ -168,6 +173,9 @@ module SL
168
173
  # amazon_partner: "bretttercom-20"
169
174
  config["amazon_partner"] ||= ""
170
175
 
176
+ # display a popup dialog confirmation
177
+ config["confirm"] ||= false
178
+
171
179
  # To create custom abbreviations for Google Site Searches,
172
180
  # add to (or replace) the hash below.
173
181
  # "abbreviation" => "site.url",
@@ -202,11 +202,13 @@ module Curl
202
202
  ##
203
203
  def h(level = '\d')
204
204
  res = []
205
- headlines = @body.to_enum(:scan, %r{<h(?<level>#{level})(?<tag> .*?)?>(?<text>.*?)</h#{level}>}i).map { Regexp.last_match }
205
+ headlines = @body.to_enum(:scan, %r{<h(?<level>#{level})(?<tag> .*?)?>(?<text>.*?)</h#{level}>}i).map do
206
+ Regexp.last_match
207
+ end
206
208
  headlines.each do |m|
207
209
  headline = { level: m["level"] }
208
210
  if m["tag"].nil?
209
- attrs = nil
211
+ nil
210
212
  else
211
213
  attrs = m["tag"].to_enum(:scan, /(?<attr>\w+)=(?<quot>["'])(?<content>.*?)\k<quot>/).map { Regexp.last_match }
212
214
  attrs.each { |a| headline[a["attr"].to_sym] = a["content"] }
@@ -253,7 +255,15 @@ module Curl
253
255
  attrs = tag["attrs"].strip.to_enum(:scan, /(?ix)
254
256
  (?<key>[@a-z0-9-]+)(?:=(?<quot>["'])
255
257
  (?<value>[^"']+)\k<quot>|[ >])?/i).map { Regexp.last_match }
256
- attrs.map! { |a| { key: a["key"], value: a["key"] =~ /^(class|rel)$/ ? a["value"].split(/ /) : a["value"] } }
258
+
259
+ attrs.map! do |a|
260
+ val = if a["key"] =~ /^(class|rel)$/
261
+ a["value"].nil? ? "" : a["value"].split(/ /)
262
+ else
263
+ a["value"]
264
+ end
265
+ { key: a["key"], value: val }
266
+ end
257
267
  end
258
268
  {
259
269
  tag: tag["tag"],
@@ -394,9 +404,7 @@ module Curl
394
404
  headers = headers.nil? ? "" : headers.map { |h, v| %(-H "#{h}: #{v}") }.join(" ")
395
405
  compress = compressed ? "--compressed" : ""
396
406
  source = `#{@curl} -#{flags} #{compress} #{headers} '#{url}' 2>/dev/null`
397
- if source.nil? || source.empty?
398
- source = `#{@curl} -#{flags} #{compress} -A "#{agent}" #{headers} '#{url}' 2>/dev/null`
399
- end
407
+ source = `#{@curl} -#{flags} #{compress} -A "#{agent}" #{headers} '#{url}' 2>/dev/null` if source.nil? || source.empty?
400
408
 
401
409
  return false if source.nil? || source.empty?
402
410
 
@@ -417,18 +425,21 @@ module Curl
417
425
  end
418
426
 
419
427
  if headers["content-type"] =~ /json/
420
- return { url: url, code: code, headers: headers, meta: nil, links: nil, head: nil, body: source.strip, source: source.strip, body_links: nil, body_images: nil }
428
+ return { url: url, code: code, headers: headers, meta: nil, links: nil, head: nil, body: source.strip,
429
+ source: source.strip, body_links: nil, body_images: nil }
421
430
  end
422
431
 
423
432
  head = source.match(%r{(?<=<head>)(.*?)(?=</head>)}mi)
424
433
 
425
434
  if head.nil?
426
- { url: url, code: code, headers: headers, meta: nil, links: nil, head: nil, body: source.strip, source: source.strip, body_links: nil, body_images: nil }
435
+ { url: url, code: code, headers: headers, meta: nil, links: nil, head: nil, body: source.strip,
436
+ source: source.strip, body_links: nil, body_images: nil }
427
437
  else
428
438
  meta = meta_tags(head[1])
429
439
  links = link_tags(head[1])
430
440
  body = source.match(%r{<body.*?>(.*?)</body>}mi)[1]
431
- { url: url, code: code, headers: headers, meta: meta, links: links, head: head[1], body: body, source: source.strip, body_links: body_links, body_images: body_images }
441
+ { url: url, code: code, headers: headers, meta: meta, links: links, head: head[1], body: body,
442
+ source: source.strip, body_links: body_links, body_images: body_images }
432
443
  end
433
444
  end
434
445
 
@@ -28,10 +28,10 @@ module Curl
28
28
  target = json
29
29
  parts.each do |part|
30
30
  target = if part =~ /(?<key>[^\[]+)\[(?<int>\d+)\]/
31
- target[key][int.to_i]
32
- else
33
- target[part]
34
- end
31
+ target[key][int.to_i]
32
+ else
33
+ target[part]
34
+ end
35
35
  end
36
36
 
37
37
  target
@@ -58,9 +58,7 @@ module Curl
58
58
  compress = compressed ? "--compressed" : ""
59
59
 
60
60
  source = `#{@curl} -#{flags} #{compress} #{headers} #{data} "#{url}" 2>/dev/null`
61
- if source.nil? || source.empty?
62
- source = `#{@curl} -#{flags} #{compress} -A "#{agent}" #{headers} '#{url}' 2>/dev/null`
63
- end
61
+ source = `#{@curl} -#{flags} #{compress} -A "#{agent}" #{headers} '#{url}' 2>/dev/null` if source.nil? || source.empty?
64
62
 
65
63
  return false if source.nil? || source.empty?
66
64
 
@@ -67,7 +67,9 @@ module SL
67
67
 
68
68
  if SL.config["custom_site_searches"]
69
69
  text += "\n-- [Custom Searches] ----------------------\n"
70
- SL.config["custom_site_searches"].sort_by { |l, _s| l }.each { |label, site| text += "!#{label}#{label.spacer} #{site}\n" }
70
+ SL.config["custom_site_searches"].sort_by do |l, _s|
71
+ l
72
+ end.each { |label, site| text += "!#{label}#{label.spacer} #{site}\n" }
71
73
  end
72
74
  text
73
75
  end
@@ -80,7 +82,9 @@ module SL
80
82
  out << '<table id="custom">'
81
83
  out << "<thead><td>Shortcut</td><td>Search Type</td></thead>"
82
84
  out << "<tbody>"
83
- SL.config["custom_site_searches"].each { |label, site| out << "<tr><td><code>!#{label}</code></td><td>#{site}</td></tr>" }
85
+ SL.config["custom_site_searches"].each do |label, site|
86
+ out << "<tr><td><code>!#{label}</code></td><td>#{site}</td></tr>"
87
+ end
84
88
  out << "</tbody>"
85
89
  out << "</table>"
86
90
  out.join("\n")
@@ -115,16 +115,7 @@ module SL
115
115
 
116
116
  url.add_query_string!
117
117
 
118
- url = case SL.shortener
119
- when :isgd
120
- SL::IsgdSearch.shorten(url)
121
- when :tinyurl
122
- SL::TinyurlSearch.shorten(url)
123
- when :bitly
124
- SL::BitlySearch.shorten(url)
125
- else
126
- url
127
- end
118
+ url = SL::Shortener.shorten(url, SL.shortener)
128
119
 
129
120
  case type.to_sym
130
121
  when :ref_title
@@ -2,6 +2,14 @@
2
2
 
3
3
  module SL
4
4
  class SearchLink
5
+ # Confirm a URL with a popup if requested
6
+ def confirmed?(url)
7
+ return true if !SL.config["confirm"] || NO_CONFIRM
8
+
9
+ SL::Shortener.confirm?(url)
10
+ end
11
+
12
+ # Parse the input string and perform searches
5
13
  def parse(input)
6
14
  SL.output = []
7
15
  return false if input.empty?
@@ -11,16 +19,14 @@ module SL
11
19
 
12
20
  parse_commands(input)
13
21
 
14
- SL.config["inline"] = true if input.scan(/\]\(/).length == 1 && input.split(/\n/).length == 1
22
+ SL.config["inline"] = true if input.scan("](").length == 1 && input.split("\n").length == 1
15
23
  SL.errors = {}
16
24
  SL.report = []
17
25
  SL.shortener = :none
18
26
 
19
27
  # Check for new version
20
28
  latest_version = SL.new_version?
21
- if latest_version
22
- SL.add_output("<!-- v#{latest_version} available, run SearchLink on the word 'update' to install. -->")
23
- end
29
+ SL.add_output("<!-- v#{latest_version} available, run SearchLink on the word 'update' to install. -->") if latest_version
24
30
 
25
31
  @links = {}
26
32
  SL.footer = []
@@ -33,14 +39,14 @@ module SL
33
39
  input.scan(/\[(.*?)\]:\s+(.*?)\n/).each { |match| @links[match[1].strip] = match[0] }
34
40
 
35
41
  @prefix = if SL.config["prefix_random"]
36
- if input =~ /\[(\d{4}-)\d+\]: \S+/
37
- Regexp.last_match(1)
38
- else
39
- format("%04d-", rand(9999))
40
- end
41
- else
42
- ""
43
- end
42
+ if input =~ /\[(\d{4}-)\d+\]: \S+/
43
+ Regexp.last_match(1)
44
+ else
45
+ format("%04d-", rand(9999))
46
+ end
47
+ else
48
+ ""
49
+ end
44
50
 
45
51
  @highest_marker = 0
46
52
  input.scan(/^\s{,3}\[(?:#{@prefix})?(\d+)\]: /).each do
@@ -57,7 +63,7 @@ module SL
57
63
  if SL.config["complete_bare"]
58
64
  rx = %r{(?ix-m)(?<!\(|:\s|<)(?:
59
65
  (?:https?://)(?:[\da-z.-]+)\.(?:[a-z.]{2,6})
60
- (?:[/\w\d.\-()_/+=?&%]*?(?=[\s\n]|$))
66
+ (?:[/\w\d.\-()_+=?&%]*?(?=[\s\n]|$))
61
67
  )}
62
68
  input.gsub!(rx) do
63
69
  url_match = Regexp.last_match
@@ -68,17 +74,17 @@ module SL
68
74
  if input =~ /\[\n(.*?\n)+\]\((.*?)?\)/
69
75
  input.gsub!(/\[\n(((\s*(?:[-+*]|\d+\.)?\s+)*(!\S+ +)?(.*?))\n)+\]\((!\S+.*?)?\)/) do
70
76
  m = Regexp.last_match
71
- lines = m[0].split(/\n/)
77
+ lines = m[0].split("\n")
72
78
  lines = lines[1..-2]
73
79
  lines.map do |l|
74
80
  el_rx = /(\s*(?:[-+*]|\d+\.)?\s+)?(!\S+ )?(\w.*?)$/
75
81
  if l =~ el_rx
76
82
  els = l.match(el_rx)
77
83
  search = if els[2]
78
- els[2].strip
79
- else
80
- m[6] || "!g"
81
- end
84
+ els[2].strip
85
+ else
86
+ m[6] || "!g"
87
+ end
82
88
  "#{els[1]}[#{els[3].strip}](#{search})"
83
89
  else
84
90
  l
@@ -89,7 +95,7 @@ module SL
89
95
 
90
96
  # Handle links in the form of [text](url) or [text](url "title")
91
97
  if input =~ /\[(.*?)\]\((.*?)\)/
92
- lines = input.split(/\n/)
98
+ lines = input.split("\n")
93
99
  out = []
94
100
 
95
101
  total_links = input.scan(/\[(.*?)\]\((.*?)\)/).length
@@ -138,9 +144,7 @@ module SL
138
144
  end
139
145
 
140
146
  counter_links += 1
141
- unless SILENT
142
- $stderr.print("\033[0K\rProcessed: #{counter_links} of #{total_links}, #{counter_errors} errors. ")
143
- end
147
+ $stderr.print("\033[0K\rProcessed: #{counter_links} of #{total_links}, #{counter_errors} errors. ") unless SILENT
144
148
 
145
149
  @link_text = this_match[1] || ""
146
150
  link_info = parse_arguments(this_match[2].strip).strip || ""
@@ -201,10 +205,10 @@ module SL
201
205
  m = Regexp.last_match
202
206
 
203
207
  search_type = if m[1].nil?
204
- SL::GoogleSearch.api_key? ? "gg" : "g"
205
- else
206
- m[1]
207
- end
208
+ SL::GoogleSearch.api_key? ? "gg" : "g"
209
+ else
210
+ m[1]
211
+ end
208
212
 
209
213
  search_type.extract_shortener!
210
214
 
@@ -220,9 +224,7 @@ module SL
220
224
  search_terms = @link_text if search_terms == ""
221
225
 
222
226
  # if the input starts with a +, append it to the link text as the search terms
223
- if search_terms.strip =~ /^\+[^+]/
224
- search_terms = "#{@link_text} #{search_terms.strip.sub(/^\+\s*/, "")}"
225
- end
227
+ search_terms = "#{@link_text} #{search_terms.strip.sub(/^\+\s*/, '')}" if search_terms.strip =~ /^\+[^+]/
226
228
 
227
229
  # if the end of input contain "^", copy to clipboard instead of STDOUT
228
230
  SL.clipboard = true if search_terms =~ /(!!)?\^(!!)?$/
@@ -262,9 +264,7 @@ module SL
262
264
  search_terms = false
263
265
  end
264
266
 
265
- if search_type && !search_terms.empty?
266
- search_type, search_terms = custom_search(search_type, search_terms)
267
- end
267
+ search_type, search_terms = custom_search(search_type, search_terms) if search_type && !search_terms.empty?
268
268
 
269
269
  SL.add_query(query) if query
270
270
 
@@ -283,7 +283,12 @@ module SL
283
283
  end
284
284
 
285
285
  if @url
286
- title = SL::URL.title(@url) if SL.titleize && title == ""
286
+ res = confirmed?(@url)
287
+ return match unless res
288
+
289
+ @url = res if res.is_a?(String) && SL::URL.url?(res)
290
+
291
+ title = SL::URL.title(@url) if SL.titleize && (title.nil? || title.empty?)
287
292
 
288
293
  @link_text = title if @link_text == "" && title
289
294
  force_title = search_type =~ /def/ ? true : false
@@ -346,7 +351,7 @@ module SL
346
351
  elsif SL.footer.empty?
347
352
  SL.add_output input
348
353
  else
349
- last_line = input.strip.split(/\n/)[-1]
354
+ last_line = input.strip.split("\n")[-1]
350
355
  case last_line
351
356
  when /^\[.*?\]: http/
352
357
  SL.add_output "#{input.rstrip}\n"
@@ -458,10 +463,10 @@ module SL
458
463
  when /^([tfilm])?@(\S+)\s*$/
459
464
  type = Regexp.last_match(1)
460
465
  type ||= if Regexp.last_match(2) =~ /[a-z0-9_]@[a-z0-9_.]+/i
461
- "m"
462
- else
463
- "t"
464
- end
466
+ "m"
467
+ else
468
+ "t"
469
+ end
465
470
  @link_text = input.sub(/^[tfilm]/, "")
466
471
  SL.add_query(query) if query
467
472
  @url, title = SL::SocialSearch.social_handle(type, @link_text)
@@ -473,16 +478,28 @@ module SL
473
478
  end
474
479
 
475
480
  if @url
476
- if type =~ /sp(ell)?/
477
- SL.add_output(@url)
478
- elsif link_only
479
- SL.add_output(@url)
480
- elsif @url == "embed"
481
- SL.add_output(title)
482
- else
483
- type = reference_link ? :ref_title : :inline
481
+ res = confirmed?(@url)
482
+ if res
483
+ if res.is_a?(String) && SL::URL.url?(res)
484
+ @url = res
485
+ title = SL::URL.title(@url) if SL.titleize && title == ""
486
+ end
487
+
488
+ if type =~ /sp(ell)?/
489
+ SL.add_output(@url)
490
+ elsif link_only
491
+ SL.add_output(@url)
492
+ elsif @url == "embed"
493
+ SL.add_output(title)
494
+ else
495
+ type = reference_link ? :ref_title : :inline
484
496
 
485
- SL.add_output SL.make_link(type, @link_text, @url, title: title, force_title: false)
497
+ SL.add_output SL.make_link(type, @link_text, @url, title: title, force_title: false)
498
+ SL.print_errors
499
+ end
500
+ else
501
+ SL.add_error("Canceled", "User canceled result #{@url}")
502
+ SL.add_output SL.originput.chomp
486
503
  SL.print_errors
487
504
  end
488
505
  else
@@ -555,7 +572,8 @@ module SL
555
572
 
556
573
  input.parse_flags! unless skip_flags
557
574
 
558
- options = %w[debug country_code inline prefix_random include_titles remove_seo validate_links complete_bare]
575
+ options = %w[debug country_code inline prefix_random include_titles remove_seo validate_links complete_bare
576
+ confirm]
559
577
  options.each do |o|
560
578
  if input =~ /^ *#{o}:\s+(\S+)$/
561
579
  val = Regexp.last_match(1).strip
@@ -621,10 +639,10 @@ module SL
621
639
  note = mtch[1].strip
622
640
  @footnote_counter += 1
623
641
  ref = if !@link_text.empty? && @link_text.scan(/\s/).empty?
624
- @link_text
625
- else
626
- format("%<p>sfn%<c>04d", p: @prefix, c: @footnote_counter)
627
- end
642
+ @link_text
643
+ else
644
+ format("%<p>sfn%<c>04d", p: @prefix, c: @footnote_counter)
645
+ end
628
646
  SL.add_footer "[^#{ref}]: #{note}"
629
647
  res = "[^#{ref}]"
630
648
  @cursor_difference += (SL.match_length - res.length)
@@ -648,12 +666,16 @@ module SL
648
666
  search_type = "r"
649
667
  tokens = v.scan(/\$term\d+[ds]?/).sort.uniq
650
668
 
651
- if !tokens.empty?
669
+ if tokens.empty?
670
+ search_terms = v.gsub(/\$term[ds]?/i) do |mtch|
671
+ search_terms.downcase! if mtch =~ /d$/i
672
+ search_terms.slugify! if mtch =~ /s$/i
673
+ search_terms.url_encode
674
+ end
675
+ else
652
676
  highest_token = 0
653
677
  tokens.each do |token|
654
- if token =~ /(\d+)[ds]?$/ && Regexp.last_match(1).to_i > highest_token
655
- highest_token = Regexp.last_match(1).to_i
656
- end
678
+ highest_token = Regexp.last_match(1).to_i if token =~ /(\d+)[ds]?$/ && Regexp.last_match(1).to_i > highest_token
657
679
  end
658
680
  terms_p = search_terms.split(/ +/)
659
681
  if terms_p.length > highest_token
@@ -679,12 +701,6 @@ module SL
679
701
  v.gsub!(/#{Regexp.escape(t) + re_down}/, replacement.url_encode)
680
702
  end
681
703
  search_terms = v
682
- else
683
- search_terms = v.gsub(/\$term[ds]?/i) do |mtch|
684
- search_terms.downcase! if mtch =~ /d$/i
685
- search_terms.slugify! if mtch =~ /s$/i
686
- search_terms.url_encode
687
- end
688
704
  end
689
705
  else
690
706
  search_type = SL::GoogleSearch.api_key? ? "gg" : "g"