searchlink 2.3.76 → 2.3.78

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
  SHA256:
3
- metadata.gz: be4b0bed0468171691989a3253680ad36237420963132e4ee7696b4ca529be78
4
- data.tar.gz: d83e1b707146106f42557b551368831a6d09bb953ab94c9f52008f01f113978c
3
+ metadata.gz: 529bd69f890aa6ee030706db4f66a1be5935513048aff397b8d2eb602f870f62
4
+ data.tar.gz: d5900f17c460e90554575e93e787c5c7c7781f3dd5cc3be5db6ebe25b6b2f098
5
5
  SHA512:
6
- metadata.gz: 538c8a40d2faf7deb9a228a4f05804a80dd84ee59fb1aadfc43d2e903bb7529e03358d07dc7f559508a57be5fab13ede66b342931f17e640039123f8feefe4c2
7
- data.tar.gz: 39c52a0f44a142fa5e165bb5b2f05cc4e81446ef4ff04ae369e9cf6f181c401d8602f6bbf4958f49db4d49714beae51d77bead32ed16cff9b5ccd1ef183d048d
6
+ metadata.gz: 55f45d757d279b85f884b92d8d4a89d34ea74bbe095c20781b628e188a15ab349064f1558bd8819b4a16345c4a69cfbcee10fb7b2dfd6739634d4c852224ee4b
7
+ data.tar.gz: e1d30f640035634907b17bacb2ce9796d6ee833947194abf7bd5412380f2b6c8889c5e61fc6ababf8721f16aabf32e4e87bcb788724e31e4e6d6b96f2d9b2811
@@ -325,7 +325,7 @@ module SL
325
325
  link_info.sub!(/\s*:\s*$/, "")
326
326
  end
327
327
 
328
- unless !@link_text.empty? || !link_info.sub(/^[!\^]\S+/, "").strip.empty?
328
+ if @link_text.empty? && link_info.sub(/^[!\^]\S+/, "").strip.empty?
329
329
  SL.add_error("No input", match)
330
330
  counter_errors += 1
331
331
  invalid_search = true
@@ -399,7 +399,6 @@ module SL
399
399
  search_terms = @link_text
400
400
  elsif search_word && search_word[1] =~ /^(\S+\.)+\S+$/
401
401
  search_type = SL::GoogleSearch.api_key? ? "gg" : "g"
402
- puts SL::GoogleSearch.api_key?
403
402
  search_terms = "site:#{search_word[1]} #{@link_text}"
404
403
  else
405
404
  SL.add_error("Invalid search#{SL::Searches.did_you_mean(search_word[1])}", match)
@@ -424,10 +423,9 @@ module SL
424
423
 
425
424
  if (search_type && search_terms) || @url
426
425
  # warn "Searching #{search_type} for #{search_terms}"
427
- unless @url
428
- @search_count += 1
429
- @url, title, @link_text = do_search(search_type, search_terms, @link_text, @search_count)
430
- end
426
+
427
+ @search_count += 1
428
+ @url, title, @link_text = do_search(search_type, search_terms, @link_text, @search_count)
431
429
 
432
430
  if (@link_text == "" || @link_text == "%") && @url
433
431
  if title
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SL
4
+ # is.gd link shortening
5
+ class IsgdSearch
6
+ class << self
7
+ def settings
8
+ {
9
+ trigger: "isgd",
10
+ searches: [
11
+ ["isgd", "is.gd Shorten"]
12
+ ]
13
+ }
14
+ end
15
+
16
+ def search(_, search_terms, link_text)
17
+ if SL::URL.url?(search_terms)
18
+ link = search_terms
19
+ else
20
+ link, rtitle = SL.ddg(search_terms, link_text)
21
+ end
22
+
23
+ url, title = isgd_shorten(link, rtitle)
24
+ link_text = title || url
25
+ [url, title, link_text]
26
+ end
27
+
28
+ def isgd_shorten(url, title = nil)
29
+ long_url = url.dup
30
+
31
+ data = Curl::Json.new("https://is.gd/create.php?format=json&url=#{CGI.escape(long_url)}", symbolize_names: true)
32
+
33
+ if data.json.key?('errorcode')
34
+ SL.add_error('Error creating is.gd url', data.json[:errorcode])
35
+ return [false, title, link_text]
36
+ end
37
+
38
+ link = data.json[:shorturl]
39
+ rtitle = SL::URL.title(long_url)
40
+ title = rtitle
41
+ link_text = rtitle if link_text == '' && !SL.titleize
42
+ [link, title, link_text]
43
+ end
44
+ end
45
+
46
+ SL::Searches.register "isgd", :search, self
47
+ end
48
+ end
@@ -208,6 +208,9 @@ require_relative "searches/history"
208
208
  # import
209
209
  require_relative "searches/hook"
210
210
 
211
+ # import
212
+ require_relative "searches/isgd"
213
+
211
214
  # import
212
215
  require_relative "searches/lastfm"
213
216
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SL
4
- VERSION = "2.3.76"
4
+ VERSION = '2.3.78'
5
5
  end
6
6
 
7
7
  # Main module
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchlink
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.76
4
+ version: 2.3.78
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-06 00:00:00.000000000 Z
11
+ date: 2024-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -284,6 +284,7 @@ files:
284
284
  - lib/searchlink/searches/helpers/safari.rb
285
285
  - lib/searchlink/searches/history.rb
286
286
  - lib/searchlink/searches/hook.rb
287
+ - lib/searchlink/searches/isgd.rb
287
288
  - lib/searchlink/searches/itunes.rb
288
289
  - lib/searchlink/searches/lastfm.rb
289
290
  - lib/searchlink/searches/linkding.rb