searchlink 2.3.74 → 2.3.76

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/searchlink/config.rb +23 -23
  3. data/lib/searchlink/curl/html.rb +38 -38
  4. data/lib/searchlink/curl/json.rb +19 -17
  5. data/lib/searchlink/curl.rb +2 -2
  6. data/lib/searchlink/exceptions.rb +2 -2
  7. data/lib/searchlink/help.rb +13 -13
  8. data/lib/searchlink/output.rb +21 -21
  9. data/lib/searchlink/parse.rb +113 -108
  10. data/lib/searchlink/plist.rb +11 -11
  11. data/lib/searchlink/script_plugin.rb +10 -10
  12. data/lib/searchlink/search.rb +6 -6
  13. data/lib/searchlink/searches/amazon.rb +4 -4
  14. data/lib/searchlink/searches/applemusic.rb +28 -28
  15. data/lib/searchlink/searches/bitly.rb +11 -11
  16. data/lib/searchlink/searches/definition.rb +7 -7
  17. data/lib/searchlink/searches/duckduckgo.rb +31 -27
  18. data/lib/searchlink/searches/github.rb +48 -48
  19. data/lib/searchlink/searches/google.rb +16 -16
  20. data/lib/searchlink/searches/helpers/chromium.rb +46 -46
  21. data/lib/searchlink/searches/helpers/firefox.rb +20 -20
  22. data/lib/searchlink/searches/helpers/safari.rb +14 -14
  23. data/lib/searchlink/searches/history.rb +78 -78
  24. data/lib/searchlink/searches/hook.rb +5 -5
  25. data/lib/searchlink/searches/itunes.rb +37 -37
  26. data/lib/searchlink/searches/lastfm.rb +13 -13
  27. data/lib/searchlink/searches/linkding.rb +14 -14
  28. data/lib/searchlink/searches/lyrics.rb +11 -11
  29. data/lib/searchlink/searches/pinboard.rb +35 -35
  30. data/lib/searchlink/searches/social.rb +45 -56
  31. data/lib/searchlink/searches/software.rb +4 -4
  32. data/lib/searchlink/searches/spelling.rb +10 -10
  33. data/lib/searchlink/searches/spotlight.rb +4 -4
  34. data/lib/searchlink/searches/stackoverflow.rb +5 -5
  35. data/lib/searchlink/searches/tmdb.rb +17 -17
  36. data/lib/searchlink/searches/twitter.rb +8 -8
  37. data/lib/searchlink/searches/wikipedia.rb +4 -4
  38. data/lib/searchlink/searches/youtube.rb +7 -7
  39. data/lib/searchlink/searches.rb +16 -16
  40. data/lib/searchlink/semver.rb +4 -4
  41. data/lib/searchlink/string.rb +55 -55
  42. data/lib/searchlink/url.rb +30 -32
  43. data/lib/searchlink/util.rb +3 -3
  44. data/lib/searchlink/version.rb +19 -21
  45. data/lib/searchlink/which.rb +5 -5
  46. data/lib/searchlink.rb +31 -31
  47. metadata +31 -18
  48. data/lib/tokens.rb +0 -3
@@ -9,9 +9,9 @@ module SL
9
9
  #
10
10
  def search_safari_history(term)
11
11
  # Safari
12
- src = File.expand_path('~/Library/Safari/History.db')
12
+ src = File.expand_path("~/Library/Safari/History.db")
13
13
  if File.exist?(src)
14
- SL.notify('Searching Safari History', term)
14
+ SL.notify("Searching Safari History", term)
15
15
 
16
16
  exact_match = false
17
17
  match_phrases = []
@@ -19,10 +19,10 @@ module SL
19
19
  # If search terms start with ''term, only search for exact string matches
20
20
  if term =~ /^ *'/
21
21
  exact_match = true
22
- term.gsub!(/(^ *'+|'+ *$)/, '')
22
+ term.gsub!(/(^ *'+|'+ *$)/, "")
23
23
  elsif term =~ /%22(.*?)%22/
24
24
  match_phrases = term.scan(/%22(\S.*?\S)%22/)
25
- term.gsub!(/%22(\S.*?\S)%22/, '')
25
+ term.gsub!(/%22(\S.*?\S)%22/, "")
26
26
  end
27
27
 
28
28
  terms = []
@@ -41,7 +41,7 @@ module SL
41
41
  end)
42
42
  end
43
43
 
44
- query = terms.join(' AND ')
44
+ query = terms.join(" AND ")
45
45
 
46
46
  cmd = %(sqlite3 -json '#{src}' "select title, url,
47
47
  datetime(visit_time/1000000, 'unixepoch', 'localtime') as datum
@@ -53,8 +53,8 @@ module SL
53
53
  return false if most_recent.strip.empty?
54
54
 
55
55
  bm = JSON.parse(most_recent)[0]
56
- date = Time.parse(bm['datum'])
57
- [bm['url'], bm['title'], date]
56
+ date = Time.parse(bm["datum"])
57
+ [bm["url"], bm["title"], date]
58
58
  else
59
59
  false
60
60
  end
@@ -114,19 +114,19 @@ module SL
114
114
  if parent.is_a?(Array)
115
115
  parent.each do |c|
116
116
  if c.is_a?(Hash)
117
- if c.key?('Children')
118
- results.concat(get_safari_bookmarks(c['Children'], terms))
119
- elsif c.key?('URIDictionary')
120
- title = c['URIDictionary']['title']
121
- url = c['URLString']
117
+ if c.key?("Children")
118
+ results.concat(get_safari_bookmarks(c["Children"], terms))
119
+ elsif c.key?("URIDictionary")
120
+ title = c["URIDictionary"]["title"]
121
+ url = c["URLString"]
122
122
  scored = score_bookmark({ url: url, title: title }, terms)
123
123
 
124
124
  results.push(scored) if scored[:score] > 7
125
125
  end
126
126
  end
127
127
  end
128
- elsif parent&.key?('Children')
129
- results.concat(get_safari_bookmarks(parent['Children'], terms))
128
+ elsif parent&.key?("Children")
129
+ results.concat(get_safari_bookmarks(parent["Children"], terms))
130
130
  end
131
131
 
132
132
  results.sort_by { |h| [h[:score], h[:title].length * -1] }.reverse
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # import
4
- require_relative 'helpers/chromium'
4
+ require_relative "helpers/chromium"
5
5
 
6
6
  # import
7
- require_relative 'helpers/firefox'
7
+ require_relative "helpers/firefox"
8
8
 
9
9
  # import
10
- require_relative 'helpers/safari'
10
+ require_relative "helpers/safari"
11
11
 
12
12
  module SL
13
13
  # Browser history/bookmark search
@@ -15,33 +15,33 @@ module SL
15
15
  class << self
16
16
  def settings
17
17
  {
18
- trigger: 'h(([scfabe])([hb])?)*',
18
+ trigger: "h(([scfabe])([hb])?)*",
19
19
  searches: [
20
- ['h', 'Browser History/Bookmark Search'],
21
- ['hsh', 'Safari History Search'],
22
- ['hsb', 'Safari Bookmark Search'],
23
- ['hshb', nil],
24
- ['hsbh', nil],
25
- ['hch', 'Chrome History Search'],
26
- ['hcb', 'Chrome Bookmark Search'],
27
- ['hchb', nil],
28
- ['hcbh', nil],
29
- ['hfh', 'Firefox History Search'],
30
- ['hfb', 'Firefox Bookmark Search'],
31
- ['hfhb', nil],
32
- ['hfbh', nil],
33
- ['hah', 'Arc History Search'],
34
- ['hab', 'Arc Bookmark Search'],
35
- ['hahb', nil],
36
- ['habh', nil],
37
- ['hbh', 'Brave History Search'],
38
- ['hbb', 'Brave Bookmark Search'],
39
- ['hbhb', nil],
40
- ['hbbh', nil],
41
- ['heh', 'Edge History Search'],
42
- ['heb', 'Edge Bookmark Search'],
43
- ['hehb', nil],
44
- ['hebh', nil]
20
+ ["h", "Browser History/Bookmark Search"],
21
+ ["hsh", "Safari History Search"],
22
+ ["hsb", "Safari Bookmark Search"],
23
+ ["hshb", nil],
24
+ ["hsbh", nil],
25
+ ["hch", "Chrome History Search"],
26
+ ["hcb", "Chrome Bookmark Search"],
27
+ ["hchb", nil],
28
+ ["hcbh", nil],
29
+ ["hfh", "Firefox History Search"],
30
+ ["hfb", "Firefox Bookmark Search"],
31
+ ["hfhb", nil],
32
+ ["hfbh", nil],
33
+ ["hah", "Arc History Search"],
34
+ ["hab", "Arc Bookmark Search"],
35
+ ["hahb", nil],
36
+ ["habh", nil],
37
+ ["hbh", "Brave History Search"],
38
+ ["hbb", "Brave Bookmark Search"],
39
+ ["hbhb", nil],
40
+ ["hbbh", nil],
41
+ ["heh", "Edge History Search"],
42
+ ["heb", "Edge Bookmark Search"],
43
+ ["hehb", nil],
44
+ ["hebh", nil]
45
45
  ]
46
46
  }
47
47
  end
@@ -54,92 +54,92 @@ module SL
54
54
  if str =~ /^s([hb]*)/
55
55
  t = Regexp.last_match(1)
56
56
  if t.length > 1 || t.empty?
57
- types.push('safari_history')
58
- types.push('safari_bookmarks')
59
- elsif t == 'h'
60
- types.push('safari_history')
61
- elsif t == 'b'
62
- types.push('safari_bookmarks')
57
+ types.push("safari_history")
58
+ types.push("safari_bookmarks")
59
+ elsif t == "h"
60
+ types.push("safari_history")
61
+ elsif t == "b"
62
+ types.push("safari_bookmarks")
63
63
  end
64
- str.sub!(/^s([hb]*)/, '')
64
+ str.sub!(/^s([hb]*)/, "")
65
65
  end
66
66
 
67
67
  if str =~ /^c([hb]*)/
68
68
  t = Regexp.last_match(1)
69
69
  if t.length > 1 || t.empty?
70
- types.push('chrome_bookmarks')
71
- types.push('chrome_history')
72
- elsif t == 'h'
73
- types.push('chrome_history')
74
- elsif t == 'b'
75
- types.push('chrome_bookmarks')
70
+ types.push("chrome_bookmarks")
71
+ types.push("chrome_history")
72
+ elsif t == "h"
73
+ types.push("chrome_history")
74
+ elsif t == "b"
75
+ types.push("chrome_bookmarks")
76
76
  end
77
- str.sub!(/^c([hb]*)/, '')
77
+ str.sub!(/^c([hb]*)/, "")
78
78
  end
79
79
 
80
80
  if str =~ /^f([hb]*)$/
81
81
  t = Regexp.last_match(1)
82
82
  if t.length > 1 || t.empty?
83
- types.push('firefox_bookmarks')
84
- types.push('firefox_history')
85
- elsif t == 'h'
86
- types.push('firefox_history')
87
- elsif t == 'b'
88
- types.push('firefox_bookmarks')
83
+ types.push("firefox_bookmarks")
84
+ types.push("firefox_history")
85
+ elsif t == "h"
86
+ types.push("firefox_history")
87
+ elsif t == "b"
88
+ types.push("firefox_bookmarks")
89
89
  end
90
- str.sub!(/^f([hb]*)/, '')
90
+ str.sub!(/^f([hb]*)/, "")
91
91
  end
92
92
 
93
93
  if str =~ /^e([hb]*)$/
94
94
  t = Regexp.last_match(1)
95
95
  if t.length > 1 || t.empty?
96
- types.push('edge_bookmarks')
97
- types.push('edge_history')
98
- elsif t == 'h'
99
- types.push('edge_history')
100
- elsif t == 'b'
101
- types.push('edge_bookmarks')
96
+ types.push("edge_bookmarks")
97
+ types.push("edge_history")
98
+ elsif t == "h"
99
+ types.push("edge_history")
100
+ elsif t == "b"
101
+ types.push("edge_bookmarks")
102
102
  end
103
- str.sub!(/^e([hb]*)/, '')
103
+ str.sub!(/^e([hb]*)/, "")
104
104
  end
105
105
 
106
106
  if str =~ /^b([hb]*)$/
107
107
  t = Regexp.last_match(1)
108
108
  if t.length > 1 || t.empty?
109
- types.push('brave_bookmarks')
110
- types.push('brave_history')
111
- elsif t == 'h'
112
- types.push('brave_history')
113
- elsif t == 'b'
114
- types.push('brave_bookmarks')
109
+ types.push("brave_bookmarks")
110
+ types.push("brave_history")
111
+ elsif t == "h"
112
+ types.push("brave_history")
113
+ elsif t == "b"
114
+ types.push("brave_bookmarks")
115
115
  end
116
- str.sub!(/^b([hb]*)/, '')
116
+ str.sub!(/^b([hb]*)/, "")
117
117
  end
118
118
 
119
119
  next unless str =~ /^a([hb]*)$/
120
120
 
121
121
  t = Regexp.last_match(1)
122
122
  if t.length > 1 || t.empty?
123
- types.push('arc_bookmarks')
124
- types.push('arc_history')
125
- elsif t == 'h'
126
- types.push('arc_history')
127
- elsif t == 'b'
128
- types.push('arc_bookmarks')
123
+ types.push("arc_bookmarks")
124
+ types.push("arc_history")
125
+ elsif t == "h"
126
+ types.push("arc_history")
127
+ elsif t == "b"
128
+ types.push("arc_bookmarks")
129
129
  end
130
- str.sub!(/^a([hb]*)/, '')
130
+ str.sub!(/^a([hb]*)/, "")
131
131
  end
132
132
 
133
133
  url, title = search_history(search_terms, types)
134
- link_text = title if link_text == '' || link_text == search_terms
134
+ link_text = title if link_text == "" || link_text == search_terms
135
135
  [url, title, link_text]
136
136
  end
137
137
 
138
138
  def search_history(term, types = [])
139
139
  if types.empty?
140
- return false unless SL.config['history_types']
140
+ return false unless SL.config["history_types"]
141
141
 
142
- types = SL.config['history_types']
142
+ types = SL.config["history_types"]
143
143
  end
144
144
 
145
145
  results = []
@@ -148,14 +148,14 @@ module SL
148
148
  types.each do |type|
149
149
  url, title, date = send("search_#{type}", term)
150
150
 
151
- results << { 'url' => url, 'title' => title, 'date' => date } if url
151
+ results << { "url" => url, "title" => title, "date" => date } if url
152
152
  end
153
153
 
154
154
  if results.empty?
155
155
  false
156
156
  else
157
- out = results.sort_by! { |r| r['date'] }.last
158
- [out['url'], out['title']]
157
+ out = results.sort_by! { |r| r["date"] }.last
158
+ [out["url"], out["title"]]
159
159
  end
160
160
  else
161
161
  false
@@ -163,6 +163,6 @@ module SL
163
163
  end
164
164
  end
165
165
 
166
- SL::Searches.register 'history', :search, self
166
+ SL::Searches.register "history", :search, self
167
167
  end
168
168
  end
@@ -26,9 +26,9 @@ module SL
26
26
  class << self
27
27
  def settings
28
28
  {
29
- trigger: 'hook',
29
+ trigger: "hook",
30
30
  searches: [
31
- ['hook', 'Hookmark Bookmark Search']
31
+ ["hook", "Hookmark Bookmark Search"]
32
32
  ]
33
33
  }
34
34
  end
@@ -63,8 +63,8 @@ module SL
63
63
  # Search bookmark paths and addresses. Return array of bookmark hashes.
64
64
  def search_hook(search)
65
65
  types = %w[name path address]
66
- query = search.strip.split(' ').map { |s| types.map { |t| %(#{t} contains "#{s}") }.join(' or ') }
67
- query = query.map { |q| "(#{q})" }.join(' and ')
66
+ query = search.strip.split(" ").map { |s| types.map { |t| %(#{t} contains "#{s}") }.join(" or ") }
67
+ query = query.map { |q| "(#{q})" }.join(" and ")
68
68
  path_matches = run_query(query)
69
69
 
70
70
  top_match = path_matches.uniq.first
@@ -74,6 +74,6 @@ module SL
74
74
  end
75
75
  end
76
76
 
77
- SL::Searches.register 'hook', :search, self
77
+ SL::Searches.register "hook", :search, self
78
78
  end
79
79
  end
@@ -7,16 +7,16 @@ module SL
7
7
  class << self
8
8
  def settings
9
9
  {
10
- trigger: '(i(pod|art|alb|song|tud?)|masd?)',
10
+ trigger: "(i(pod|art|alb|song|tud?)|masd?)",
11
11
  searches: [
12
- ['ipod', 'iTunes podcast'],
13
- ['iart', 'iTunes artist'],
14
- ['ialb', 'iTunes album'],
15
- ['isong', 'iTunes song'],
16
- ['itu', 'iOS App Store Search'],
17
- ['itud', 'iOS App Store Developer Link'],
18
- ['mas', 'Mac App Store Search'],
19
- ['masd', 'Mac App Store Developer Link']
12
+ ["ipod", "iTunes podcast"],
13
+ ["iart", "iTunes artist"],
14
+ ["ialb", "iTunes album"],
15
+ ["isong", "iTunes song"],
16
+ ["itu", "iOS App Store Search"],
17
+ ["itud", "iOS App Store Developer Link"],
18
+ ["mas", "Mac App Store Search"],
19
+ ["masd", "Mac App Store Developer Link"]
20
20
  ]
21
21
  }
22
22
  end
@@ -24,67 +24,67 @@ module SL
24
24
  def search(search_type, search_terms, link_text)
25
25
  case search_type
26
26
  when /^ialb$/ # iTunes Album Search
27
- url, title = search_itunes('album', search_terms, false)
27
+ url, title = search_itunes("album", search_terms, false)
28
28
  when /^iart$/ # iTunes Artist Search
29
- url, title = search_itunes('musicArtist', search_terms, false)
29
+ url, title = search_itunes("musicArtist", search_terms, false)
30
30
  when /^imov?$/ # iTunes movie search
31
31
  dev = false
32
- url, title = search_itunes('movie', search_terms, dev, SL.config['itunes_affiliate'])
32
+ url, title = search_itunes("movie", search_terms, dev, SL.config["itunes_affiliate"])
33
33
  when /^ipod$/
34
- url, title = search_itunes('podcast', search_terms, false)
34
+ url, title = search_itunes("podcast", search_terms, false)
35
35
  when /^isong$/ # iTunes Song Search
36
- url, title = search_itunes('song', search_terms, false)
36
+ url, title = search_itunes("song", search_terms, false)
37
37
  when /^itud?$/ # iTunes app search
38
38
  dev = search_type =~ /d$/
39
- url, title = search_itunes('iPadSoftware', search_terms, dev, SL.config['itunes_affiliate'])
39
+ url, title = search_itunes("iPadSoftware", search_terms, dev, SL.config["itunes_affiliate"])
40
40
  when /^masd?$/ # Mac App Store search (mas = itunes link, masd = developer link)
41
41
  dev = search_type =~ /d$/
42
- url, title = search_itunes('macSoftware', search_terms, dev, SL.config['itunes_affiliate'])
42
+ url, title = search_itunes("macSoftware", search_terms, dev, SL.config["itunes_affiliate"])
43
43
  end
44
44
 
45
45
  [url, title, link_text]
46
46
  end
47
47
 
48
48
  def search_itunes(entity, terms, dev, aff = nil)
49
- aff ||= SL.config['itunes_affiliate']
50
-
51
- url = "http://itunes.apple.com/search?term=#{terms.url_encode}&country=#{SL.config['country_code']}&entity=#{entity}&limit=1"
49
+ aff ||= SL.config["itunes_affiliate"]
52
50
 
51
+ url = "https://itunes.apple.com/search?term=#{terms.url_encode}&country=#{SL.config['country_code']}&entity=#{entity}&limit=1"
52
+ puts url
53
53
  begin
54
54
  page = Curl::Json.new(url, compressed: true)
55
55
  json = page.json
56
56
  rescue StandardError => e
57
- SL.add_error('Invalid response', "Search for #{terms}: (#{e})")
57
+ SL.add_error("Invalid response", "Search for #{terms}: (#{e})")
58
58
  return false
59
59
  end
60
60
  return false unless json
61
61
 
62
- return false unless json['resultCount']&.positive?
62
+ return false unless json["resultCount"]&.positive?
63
63
 
64
- result = json['results'][0]
64
+ result = json["results"][0]
65
65
  case entity
66
66
  when /movie/
67
67
  # dev parameter probably not necessary in this case
68
- output_url = result['trackViewUrl']
69
- output_title = result['trackName']
68
+ output_url = result["trackViewUrl"]
69
+ output_title = result["trackName"]
70
70
  when /(mac|iPad)Software/
71
- output_url = dev && result['sellerUrl'] ? result['sellerUrl'] : result['trackViewUrl']
72
- output_title = result['trackName']
71
+ output_url = dev && result["sellerUrl"] ? result["sellerUrl"] : result["trackViewUrl"]
72
+ output_title = result["trackName"]
73
73
  when /(musicArtist|song|album)/
74
- case result['wrapperType']
75
- when 'track'
76
- output_url = result['trackViewUrl']
74
+ case result["wrapperType"]
75
+ when "track"
76
+ output_url = result["trackViewUrl"]
77
77
  output_title = "#{result['trackName']} by #{result['artistName']}"
78
- when 'collection'
79
- output_url = result['collectionViewUrl']
78
+ when "collection"
79
+ output_url = result["collectionViewUrl"]
80
80
  output_title = "#{result['collectionName']} by #{result['artistName']}"
81
- when 'artist'
82
- output_url = result['artistLinkUrl']
83
- output_title = result['artistName']
81
+ when "artist"
82
+ output_url = result["artistLinkUrl"]
83
+ output_title = result["artistName"]
84
84
  end
85
85
  when /podcast/
86
- output_url = result['collectionViewUrl']
87
- output_title = result['collectionName']
86
+ output_url = result["collectionViewUrl"]
87
+ output_title = result["collectionName"]
88
88
  end
89
89
  return false unless output_url && output_title
90
90
 
@@ -94,6 +94,6 @@ module SL
94
94
  end
95
95
  end
96
96
 
97
- SL::Searches.register 'itunes', :search, self
97
+ SL::Searches.register "itunes", :search, self
98
98
  end
99
99
  end
@@ -5,31 +5,31 @@ module SL
5
5
  class << self
6
6
  def settings
7
7
  {
8
- trigger: 'l(art|song)',
8
+ trigger: "l(art|song)",
9
9
  searches: [
10
- ['lart', 'Last.fm Artist Search'],
11
- ['lsong', 'Last.fm Song Search']
10
+ ["lart", "Last.fm Artist Search"],
11
+ ["lsong", "Last.fm Song Search"]
12
12
  ]
13
13
  }
14
14
  end
15
15
 
16
16
  def search(search_type, search_terms, link_text)
17
- type = search_type =~ /art$/ ? 'artist' : 'track'
17
+ type = search_type =~ /art$/ ? "artist" : "track"
18
18
 
19
19
  url = "http://ws.audioscrobbler.com/2.0/?method=#{type}.search&#{type}=#{search_terms.url_encode}&api_key=2f3407ec29601f97ca8a18ff580477de&format=json"
20
20
  json = Curl::Json.new(url).json
21
- return false unless json['results']
21
+ return false unless json["results"]
22
22
 
23
23
  begin
24
24
  case type
25
- when 'track'
26
- result = json['results']['trackmatches']['track'][0]
27
- url = result['url']
25
+ when "track"
26
+ result = json["results"]["trackmatches"]["track"][0]
27
+ url = result["url"]
28
28
  title = "#{result['name']} by #{result['artist']}"
29
- when 'artist'
30
- result = json['results']['artistmatches']['artist'][0]
31
- url = result['url']
32
- title = result['name']
29
+ when "artist"
30
+ result = json["results"]["artistmatches"]["artist"][0]
31
+ url = result["url"]
32
+ title = result["name"]
33
33
  end
34
34
  [url, title, link_text]
35
35
  rescue StandardError
@@ -38,6 +38,6 @@ module SL
38
38
  end
39
39
  end
40
40
 
41
- SL::Searches.register 'lastfm', :search, self
41
+ SL::Searches.register "lastfm", :search, self
42
42
  end
43
43
  end
@@ -9,8 +9,8 @@ module SL
9
9
  {
10
10
  trigger: "(ld|ding)",
11
11
  searches: [
12
- [["ld", "ding"], "Linkding Bookmark Search"],
13
- ],
12
+ [%w[ld ding], "Linkding Bookmark Search"]
13
+ ]
14
14
  }
15
15
  end
16
16
 
@@ -21,9 +21,9 @@ module SL
21
21
  bookmarks = bookmarks.force_encoding("utf-8")
22
22
  bookmarks.gsub!(/[^[:ascii:]]/) do |non_ascii|
23
23
  non_ascii.force_encoding("utf-8")
24
- .encode("utf-16be")
25
- .unpack("H*")[0]
26
- .gsub(/(....)/, '\u\1')
24
+ .encode("utf-16be")
25
+ .unpack1("H*")
26
+ .gsub(/(....)/, '\u\1')
27
27
  end
28
28
 
29
29
  bookmarks.gsub!(/[\u{1F600}-\u{1F6FF}]/, "")
@@ -177,14 +177,14 @@ module SL
177
177
  full_text = [bm["title"], bm["description"], bm["tag_names"].join(" ")].join(" ")
178
178
 
179
179
  score = if title_tags.matches_exact(search_terms)
180
- 14.0
181
- elsif full_text.matches_exact(search_terms)
182
- 13.0
183
- elsif full_text.matches_any(search_terms)
184
- full_text.matches_score(search_terms)
185
- else
186
- 0
187
- end
180
+ 14.0
181
+ elsif full_text.matches_exact(search_terms)
182
+ 13.0
183
+ elsif full_text.matches_any(search_terms)
184
+ full_text.matches_score(search_terms)
185
+ else
186
+ 0
187
+ end
188
188
 
189
189
  return [bm["url"], bm["title"]] if score == 14
190
190
 
@@ -194,7 +194,7 @@ module SL
194
194
  score: score,
195
195
  href: bm["url"],
196
196
  title: bm["title"],
197
- date: bm["date_added"],
197
+ date: bm["date_added"]
198
198
  })
199
199
  end
200
200