searchlink 2.3.80 → 2.3.81
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 +4 -4
- data/lib/searchlink/curl/html.rb +1 -1
- data/lib/searchlink/curl/json.rb +1 -1
- data/lib/searchlink/parse.rb +22 -4
- data/lib/searchlink/plist.rb +91 -88
- data/lib/searchlink/searches/github.rb +1 -1
- data/lib/searchlink/searches/isgd.rb +3 -3
- data/lib/searchlink/searches/itunes.rb +0 -1
- data/lib/searchlink/searches/pinboard.rb +13 -14
- data/lib/searchlink/searches/youtube.rb +2 -2
- data/lib/searchlink/searches.rb +5 -5
- data/lib/searchlink/string.rb +3 -3
- data/lib/searchlink/tokens.rb +5 -0
- data/lib/searchlink/url.rb +27 -1
- data/lib/searchlink/version.rb +6 -2
- metadata +18 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ce66d54f12c512c8e3e4508cf86d9dfde5e0be920a7bfe30bdc6071caceba54d
|
|
4
|
+
data.tar.gz: 744eb155302ed0901f3eba23ed8c50b73e8834040389662cfd4ae715843041e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9210886c698b4e82e7bb6d5b56732febef66c612ebe90351e66e0a4fcd9b6494ecac4b2bac5422b288bde4b25ba2d40b7bcb8737af467e757fafc19c8827a69
|
|
7
|
+
data.tar.gz: a36ba8e0be0f29f3f4cc31558ecdc0ba76b35e48cd2ecdd1a0ff35b9ce014dbfcc5063084111b1b26694e335b82ba86e391d63a855623cb6297c00e6560c3324
|
data/lib/searchlink/curl/html.rb
CHANGED
data/lib/searchlink/curl/json.rb
CHANGED
data/lib/searchlink/parse.rb
CHANGED
|
@@ -151,7 +151,7 @@ module SL
|
|
|
151
151
|
end
|
|
152
152
|
terms_p = search_terms.split(/ +/)
|
|
153
153
|
if terms_p.length > highest_token
|
|
154
|
-
remainder = terms_p[highest_token - 1
|
|
154
|
+
remainder = terms_p[highest_token - 1..].join(" ")
|
|
155
155
|
terms_p = terms_p[0..highest_token - 2]
|
|
156
156
|
terms_p.push(remainder)
|
|
157
157
|
end
|
|
@@ -252,6 +252,24 @@ module SL
|
|
|
252
252
|
end
|
|
253
253
|
end
|
|
254
254
|
|
|
255
|
+
if input =~ /\[\n(.*?\n)+\]\((.*?)?\)/
|
|
256
|
+
input.gsub!(/\[\n(((\s*(?:[-+*]|\d+\.)?\s+)*(!\S+ +)?(.*?))\n)+\]\((!\S+.*?)?\)/) do
|
|
257
|
+
m = Regexp.last_match
|
|
258
|
+
lines = m[0].split(/\n/)
|
|
259
|
+
lines = lines[1..-2]
|
|
260
|
+
lines.map do |l|
|
|
261
|
+
el_rx = /(\s*(?:[-+*]|\d+\.)?\s+)?(!\S+ )?(\w.*?)$/
|
|
262
|
+
if l =~ el_rx
|
|
263
|
+
els = l.match(el_rx)
|
|
264
|
+
search = els[2] ? els[2].strip : (m[6] ? m[6] : "!g")
|
|
265
|
+
"#{els[1]}[#{els[3].strip}](#{search})"
|
|
266
|
+
else
|
|
267
|
+
l
|
|
268
|
+
end
|
|
269
|
+
end.join("\n")
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
255
273
|
if input =~ /\[(.*?)\]\((.*?)\)/
|
|
256
274
|
lines = input.split(/\n/)
|
|
257
275
|
out = []
|
|
@@ -263,11 +281,11 @@ module SL
|
|
|
263
281
|
SL.line_num = num - line_difference
|
|
264
282
|
@cursor_difference = 0
|
|
265
283
|
# ignore links in code blocks
|
|
266
|
-
if line =~ /^( {4,}|\t+)[
|
|
284
|
+
if line =~ /^(( {4,}|\t+)[^*+-])/
|
|
267
285
|
out.push(line)
|
|
268
286
|
next
|
|
269
287
|
end
|
|
270
|
-
if line =~
|
|
288
|
+
if line =~ /^\s*[~`]{3,}/
|
|
271
289
|
if in_code_block
|
|
272
290
|
in_code_block = false
|
|
273
291
|
out.push(line)
|
|
@@ -605,7 +623,7 @@ module SL
|
|
|
605
623
|
end
|
|
606
624
|
terms_p = terms.split(/ +/)
|
|
607
625
|
if terms_p.length > highest_token
|
|
608
|
-
remainder = terms_p[highest_token - 1
|
|
626
|
+
remainder = terms_p[highest_token - 1..].join(" ")
|
|
609
627
|
terms_p = terms_p[0..highest_token - 2]
|
|
610
628
|
terms_p.push(remainder)
|
|
611
629
|
end
|
data/lib/searchlink/plist.rb
CHANGED
|
@@ -65,18 +65,17 @@ module Plist
|
|
|
65
65
|
|
|
66
66
|
def parse
|
|
67
67
|
plist_tags = PTag.mappings.keys.join("|")
|
|
68
|
-
start_tag
|
|
69
|
-
end_tag
|
|
68
|
+
start_tag = /<(#{plist_tags})([^>]*)>/i
|
|
69
|
+
end_tag = %r{</(#{plist_tags})[^>]*>}i
|
|
70
70
|
|
|
71
71
|
require "strscan"
|
|
72
72
|
|
|
73
73
|
@scanner = StringScanner.new(@xml)
|
|
74
74
|
until @scanner.eos?
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
elsif @scanner.scan(start_tag)
|
|
75
|
+
next unless @scanner.scan(COMMENT_START)
|
|
76
|
+
|
|
77
|
+
@scanner.scan(COMMENT_END)
|
|
78
|
+
if @scanner.scan(start_tag)
|
|
80
79
|
@listener.tag_start(@scanner[1], nil)
|
|
81
80
|
@listener.tag_end(@scanner[1]) if @scanner[2] =~ %r{/$}
|
|
82
81
|
elsif @scanner.scan(TEXT)
|
|
@@ -88,117 +87,121 @@ module Plist
|
|
|
88
87
|
end
|
|
89
88
|
end
|
|
90
89
|
end
|
|
91
|
-
end
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
class PTag
|
|
92
|
+
@@mappings = {}
|
|
93
|
+
def self.mappings
|
|
94
|
+
@@mappings
|
|
95
|
+
end
|
|
98
96
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
def self.inherited(sub_class)
|
|
98
|
+
key = sub_class.to_s.downcase
|
|
99
|
+
key.gsub!(/^plist::/, "")
|
|
100
|
+
key.gsub!(/^p/, "") unless key == "plist"
|
|
103
101
|
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
@@mappings[key] = sub_class
|
|
103
|
+
super
|
|
104
|
+
end
|
|
106
105
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
attr_accessor :text, :children
|
|
107
|
+
|
|
108
|
+
def initialize
|
|
109
|
+
@children = []
|
|
110
|
+
end
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
def to_ruby
|
|
113
|
+
raise "Unimplemented: #{self.class}#to_ruby on #{inspect}"
|
|
114
|
+
end
|
|
114
115
|
end
|
|
115
|
-
end
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
class PList < PTag
|
|
118
|
+
def to_ruby
|
|
119
|
+
children.first&.to_ruby
|
|
120
|
+
end
|
|
120
121
|
end
|
|
121
|
-
end
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
class PDict < PTag
|
|
124
|
+
def to_ruby
|
|
125
|
+
dict = {}
|
|
126
|
+
key = nil
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
128
|
+
children.each do |c|
|
|
129
|
+
if key.nil?
|
|
130
|
+
key = c.to_ruby
|
|
131
|
+
else
|
|
132
|
+
dict[key] = c.to_ruby
|
|
133
|
+
key = nil
|
|
134
|
+
end
|
|
134
135
|
end
|
|
135
|
-
end
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
dict
|
|
138
|
+
end
|
|
138
139
|
end
|
|
139
|
-
end
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
class PKey < PTag
|
|
142
|
+
def to_ruby
|
|
143
|
+
CGI.unescapeHTML(text || "")
|
|
144
|
+
end
|
|
144
145
|
end
|
|
145
|
-
end
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
class PString < PTag
|
|
148
|
+
def to_ruby
|
|
149
|
+
CGI.unescapeHTML(text || "")
|
|
150
|
+
end
|
|
150
151
|
end
|
|
151
|
-
end
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
class PArray < PTag
|
|
154
|
+
def to_ruby
|
|
155
|
+
children.collect(&:to_ruby)
|
|
156
|
+
end
|
|
156
157
|
end
|
|
157
|
-
end
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
class PInteger < PTag
|
|
160
|
+
def to_ruby
|
|
161
|
+
text.to_i
|
|
162
|
+
end
|
|
162
163
|
end
|
|
163
|
-
end
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
class PTrue < PTag
|
|
166
|
+
def to_ruby
|
|
167
|
+
true
|
|
168
|
+
end
|
|
168
169
|
end
|
|
169
|
-
end
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
class PFalse < PTag
|
|
172
|
+
def to_ruby
|
|
173
|
+
false
|
|
174
|
+
end
|
|
174
175
|
end
|
|
175
|
-
end
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
class PReal < PTag
|
|
178
|
+
def to_ruby
|
|
179
|
+
text.to_f
|
|
180
|
+
end
|
|
180
181
|
end
|
|
181
|
-
end
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
require "date"
|
|
184
|
+
|
|
185
|
+
class PDate < PTag
|
|
186
|
+
def to_ruby
|
|
187
|
+
DateTime.parse(text)
|
|
188
|
+
end
|
|
187
189
|
end
|
|
188
|
-
end
|
|
189
190
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
191
|
+
require "base64"
|
|
192
|
+
|
|
193
|
+
class PData < PTag
|
|
194
|
+
def to_ruby
|
|
195
|
+
data = Base64.decode64(text.gsub(/\s+/, ""))
|
|
196
|
+
|
|
197
|
+
begin
|
|
198
|
+
Marshal.load(data)
|
|
199
|
+
rescue Exception
|
|
200
|
+
io = StringIO.new
|
|
201
|
+
io.write data
|
|
202
|
+
io.rewind
|
|
203
|
+
io
|
|
204
|
+
end
|
|
202
205
|
end
|
|
203
206
|
end
|
|
204
207
|
end
|
|
@@ -30,15 +30,15 @@ module SL
|
|
|
30
30
|
|
|
31
31
|
data = Curl::Json.new("https://is.gd/create.php?format=json&url=#{CGI.escape(long_url)}", symbolize_names: true)
|
|
32
32
|
|
|
33
|
-
if data.json.key?(
|
|
34
|
-
SL.add_error(
|
|
33
|
+
if data.json.key?("errorcode")
|
|
34
|
+
SL.add_error("Error creating is.gd url", data.json[:errorcode])
|
|
35
35
|
return [false, title, link_text]
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
link = data.json[:shorturl]
|
|
39
39
|
rtitle = SL::URL.title(long_url)
|
|
40
40
|
title = rtitle
|
|
41
|
-
link_text = rtitle if link_text ==
|
|
41
|
+
link_text = rtitle if link_text == "" && !SL.titleize
|
|
42
42
|
[link, title, link_text]
|
|
43
43
|
end
|
|
44
44
|
end
|
|
@@ -49,7 +49,6 @@ module SL
|
|
|
49
49
|
aff ||= SL.config["itunes_affiliate"]
|
|
50
50
|
|
|
51
51
|
url = "https://itunes.apple.com/search?term=#{terms.url_encode}&country=#{SL.config['country_code']}&entity=#{entity}&limit=1"
|
|
52
|
-
puts url
|
|
53
52
|
begin
|
|
54
53
|
page = Curl::Json.new(url, compressed: true)
|
|
55
54
|
json = page.json
|
|
@@ -9,8 +9,8 @@ module SL
|
|
|
9
9
|
{
|
|
10
10
|
trigger: "pb",
|
|
11
11
|
searches: [
|
|
12
|
-
["pb", "Pinboard Bookmark Search"]
|
|
13
|
-
]
|
|
12
|
+
["pb", "Pinboard Bookmark Search"],
|
|
13
|
+
],
|
|
14
14
|
}
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -26,7 +26,6 @@ module SL
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
bookmarks.gsub!(/[\u{1F600}-\u{1F6FF}]/, "")
|
|
29
|
-
|
|
30
29
|
bookmarks = JSON.parse(bookmarks)
|
|
31
30
|
updated = Time.now
|
|
32
31
|
{ "update_time" => updated, "bookmarks" => bookmarks }
|
|
@@ -100,8 +99,8 @@ module SL
|
|
|
100
99
|
def search(_, search_terms, link_text)
|
|
101
100
|
unless SL.config["pinboard_api_key"]
|
|
102
101
|
SL.add_error("Missing Pinboard API token",
|
|
103
|
-
|
|
104
|
-
to your configuration (pinboard_api_key: YOURKEY)
|
|
102
|
+
"Find your api key at https://pinboard.in/settings/password and add it
|
|
103
|
+
to your configuration (pinboard_api_key: YOURKEY)")
|
|
105
104
|
return false
|
|
106
105
|
end
|
|
107
106
|
|
|
@@ -149,14 +148,14 @@ module SL
|
|
|
149
148
|
full_text = [bm["description"], bm["extended"], bm["tags"]].join(" ")
|
|
150
149
|
|
|
151
150
|
score = if title_tags.matches_exact(search_terms)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
14.0
|
|
152
|
+
elsif full_text.matches_exact(search_terms)
|
|
153
|
+
13.0
|
|
154
|
+
elsif full_text.matches_any(search_terms)
|
|
155
|
+
full_text.matches_score(search_terms)
|
|
156
|
+
else
|
|
157
|
+
0
|
|
158
|
+
end
|
|
160
159
|
|
|
161
160
|
return [bm["href"], bm["description"]] if score == 14
|
|
162
161
|
|
|
@@ -166,7 +165,7 @@ module SL
|
|
|
166
165
|
score: score,
|
|
167
166
|
href: bm["href"],
|
|
168
167
|
title: bm["description"],
|
|
169
|
-
date: bm["time"]
|
|
168
|
+
date: bm["time"],
|
|
170
169
|
})
|
|
171
170
|
end
|
|
172
171
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module SL
|
|
4
4
|
# YouTube Search/Linking
|
|
5
5
|
class YouTubeSearch
|
|
6
|
-
YOUTUBE_RX = %r{(?:youtu\.be/|youtube\.com/watch\?v=)?(?<id>[a-z0-9_
|
|
6
|
+
YOUTUBE_RX = %r{(?:youtu\.be/|youtube\.com/watch\?v=)?(?<id>[a-z0-9_-]+)$}i.freeze
|
|
7
7
|
|
|
8
8
|
class << self
|
|
9
9
|
def settings
|
|
@@ -19,7 +19,7 @@ module SL
|
|
|
19
19
|
def search(search_type, search_terms, link_text)
|
|
20
20
|
if SL::URL.url?(search_terms) && search_terms =~ YOUTUBE_RX
|
|
21
21
|
url = search_terms
|
|
22
|
-
elsif search_terms =~ /^[a-z0-9_
|
|
22
|
+
elsif search_terms =~ /^[a-z0-9_-]+$/i
|
|
23
23
|
url = "https://youtube.com/watch?v=#{search_terms}"
|
|
24
24
|
else
|
|
25
25
|
url, title = SL.ddg("site:youtube.com #{search_terms}", link_text)
|
data/lib/searchlink/searches.rb
CHANGED
|
@@ -53,7 +53,7 @@ module SL
|
|
|
53
53
|
searches.each do |s|
|
|
54
54
|
out << "<tr>
|
|
55
55
|
<td>
|
|
56
|
-
<code>!#{s[0].is_a?(Array) ? "#{s[0][0]} (#{s[0][1
|
|
56
|
+
<code>!#{s[0].is_a?(Array) ? "#{s[0][0]} (#{s[0][1..].join(',')})" : s[0]}
|
|
57
57
|
</code>
|
|
58
58
|
</td><td>#{s[1]}</td></tr>"
|
|
59
59
|
end
|
|
@@ -72,7 +72,7 @@ module SL
|
|
|
72
72
|
|
|
73
73
|
searches.each do |s|
|
|
74
74
|
shortcut = if s[0].is_a?(Array)
|
|
75
|
-
"#{s[0][0]} (#{s[0][1
|
|
75
|
+
"#{s[0][0]} (#{s[0][1..].join(',')})"
|
|
76
76
|
else
|
|
77
77
|
s[0]
|
|
78
78
|
end
|
|
@@ -100,13 +100,13 @@ module SL
|
|
|
100
100
|
|
|
101
101
|
def valid_searches
|
|
102
102
|
searches = []
|
|
103
|
-
plugins[:search].
|
|
103
|
+
plugins[:search].each_value { |plugin| searches.push(plugin[:trigger]) }
|
|
104
104
|
searches
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
def valid_search?(term)
|
|
108
108
|
valid = false
|
|
109
|
-
valid = true if term =~ /^(#{valid_searches.join(
|
|
109
|
+
valid = true if term =~ /^(#{valid_searches.join('|')})$/
|
|
110
110
|
valid = true if SL.config["custom_site_searches"].keys.include? term
|
|
111
111
|
# SL.notify("Invalid search#{did_you_mean(term)}", term) unless valid
|
|
112
112
|
valid
|
|
@@ -166,7 +166,7 @@ module SL
|
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
def do_search(search_type, search_terms, link_text, timeout: SL.config["timeout"])
|
|
169
|
-
plugins[:search].
|
|
169
|
+
plugins[:search].each_value do |plugin|
|
|
170
170
|
trigger = plugin[:trigger].gsub(/(^\^|\$$)/, "")
|
|
171
171
|
if search_type =~ /^#{trigger}$/
|
|
172
172
|
search = proc { plugin[:class].search(search_type, search_terms, link_text) }
|
data/lib/searchlink/string.rb
CHANGED
|
@@ -91,7 +91,7 @@ module SL
|
|
|
91
91
|
## @return { description_of_the_return_value }
|
|
92
92
|
##
|
|
93
93
|
def fix_gist_file
|
|
94
|
-
sub(/^file-/, "").sub(/-([
|
|
94
|
+
sub(/^file-/, "").sub(/-([^-]+)$/, '.\1')
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
# Turn a string into a slug, removing spaces and
|
|
@@ -160,7 +160,7 @@ module SL
|
|
|
160
160
|
# force trailing slash
|
|
161
161
|
path.sub!(%r{/?$}, "/")
|
|
162
162
|
# remove last path element
|
|
163
|
-
path.sub!(%r{/[^/]+[
|
|
163
|
+
path.sub!(%r{/[^/]+[.-][^/]+/$}, "")
|
|
164
164
|
# remove starting/ending slashes
|
|
165
165
|
path.gsub!(%r{(^/|/$)}, "")
|
|
166
166
|
# split at slashes, delete sections that are shorter
|
|
@@ -277,7 +277,7 @@ module SL
|
|
|
277
277
|
|
|
278
278
|
next if parts.length == 1
|
|
279
279
|
|
|
280
|
-
remaining_separators = seo_title_separators[i
|
|
280
|
+
remaining_separators = seo_title_separators[i..].map { |s| Regexp.escape(s) }.join("")
|
|
281
281
|
seps = Regexp.new("^[^#{remaining_separators}]+$")
|
|
282
282
|
|
|
283
283
|
longest = parts.longest_element.strip
|
data/lib/searchlink/url.rb
CHANGED
|
@@ -5,6 +5,22 @@ module SL
|
|
|
5
5
|
# URL module
|
|
6
6
|
module URL
|
|
7
7
|
class << self
|
|
8
|
+
def follow_redirects(url, limit = 5)
|
|
9
|
+
return url if limit.zero?
|
|
10
|
+
|
|
11
|
+
uri = URI.parse(url)
|
|
12
|
+
response = Net::HTTP.get_response(uri)
|
|
13
|
+
|
|
14
|
+
case response
|
|
15
|
+
when Net::HTTPSuccess
|
|
16
|
+
response.uri.to_s
|
|
17
|
+
when Net::HTTPRedirection
|
|
18
|
+
follow_redirects(response["location"], limit - 1)
|
|
19
|
+
else
|
|
20
|
+
url
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
8
24
|
# Validates that a link exists and returns 200
|
|
9
25
|
def valid_link?(uri_str, limit = 5)
|
|
10
26
|
return false unless uri_str
|
|
@@ -130,6 +146,17 @@ module SL
|
|
|
130
146
|
# end
|
|
131
147
|
|
|
132
148
|
begin
|
|
149
|
+
if url =~ %r{https://(amzn.to|(www\.)?amazon\.com)/}
|
|
150
|
+
final_url = follow_redirects(url)
|
|
151
|
+
m = final_url.match(%r{https://www.amazon.com/(.*?)/dp/})
|
|
152
|
+
title = if m
|
|
153
|
+
m[1].gsub(/-/, " ")
|
|
154
|
+
else
|
|
155
|
+
url.remove_protocol
|
|
156
|
+
end
|
|
157
|
+
return title
|
|
158
|
+
end
|
|
159
|
+
|
|
133
160
|
page = Curl::Html.new(url)
|
|
134
161
|
|
|
135
162
|
title = page.title || nil
|
|
@@ -146,7 +173,6 @@ module SL
|
|
|
146
173
|
title.remove_protocol
|
|
147
174
|
rescue StandardError
|
|
148
175
|
SL.add_error("Error retrieving title", "Error determining title for #{url.strip}")
|
|
149
|
-
warn "Error retrieving title for #{url.strip}"
|
|
150
176
|
url.remove_protocol
|
|
151
177
|
end
|
|
152
178
|
end
|
data/lib/searchlink/version.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module SL
|
|
4
|
-
VERSION =
|
|
4
|
+
VERSION = "2.3.81"
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
# Main module
|
|
@@ -44,7 +44,11 @@ module SL
|
|
|
44
44
|
"Accept" => "application/vnd.github+json",
|
|
45
45
|
"X-GitHub-Api-Version" => "2022-11-28",
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
if defined? Secrets::GH_AUTH_TOKEN
|
|
48
|
+
headers["Authorization"] = "Bearer #{Secrets::GH_AUTH_TOKEN}"
|
|
49
|
+
elsif SL.config['github_token']
|
|
50
|
+
headers["Authorization"] = "Bearer #{SL.settings["github_token"]}"
|
|
51
|
+
end
|
|
48
52
|
|
|
49
53
|
url = "https://api.github.com/repos/ttscoff/searchlink/releases/latest"
|
|
50
54
|
page = Curl::Json.new(url, headers: headers)
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: searchlink
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.81
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brett Terpstra
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2025-01-05 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: base64
|
|
@@ -248,6 +247,20 @@ dependencies:
|
|
|
248
247
|
- - "~>"
|
|
249
248
|
- !ruby/object:Gem::Version
|
|
250
249
|
version: 0.9.5
|
|
250
|
+
- !ruby/object:Gem::Dependency
|
|
251
|
+
name: pastel
|
|
252
|
+
requirement: !ruby/object:Gem::Requirement
|
|
253
|
+
requirements:
|
|
254
|
+
- - "~>"
|
|
255
|
+
- !ruby/object:Gem::Version
|
|
256
|
+
version: '0.8'
|
|
257
|
+
type: :development
|
|
258
|
+
prerelease: false
|
|
259
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
260
|
+
requirements:
|
|
261
|
+
- - "~>"
|
|
262
|
+
- !ruby/object:Gem::Version
|
|
263
|
+
version: '0.8'
|
|
251
264
|
description: macOS System Service for inline web searches
|
|
252
265
|
email:
|
|
253
266
|
- me@brettterpstra.com
|
|
@@ -301,6 +314,7 @@ files:
|
|
|
301
314
|
- lib/searchlink/searches/youtube.rb
|
|
302
315
|
- lib/searchlink/semver.rb
|
|
303
316
|
- lib/searchlink/string.rb
|
|
317
|
+
- lib/searchlink/tokens.rb
|
|
304
318
|
- lib/searchlink/url.rb
|
|
305
319
|
- lib/searchlink/util.rb
|
|
306
320
|
- lib/searchlink/version.rb
|
|
@@ -309,7 +323,6 @@ homepage: https://github.com/ttscoff/searchlink
|
|
|
309
323
|
licenses:
|
|
310
324
|
- MIT
|
|
311
325
|
metadata: {}
|
|
312
|
-
post_install_message:
|
|
313
326
|
rdoc_options: []
|
|
314
327
|
require_paths:
|
|
315
328
|
- lib
|
|
@@ -324,8 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
324
337
|
- !ruby/object:Gem::Version
|
|
325
338
|
version: '0'
|
|
326
339
|
requirements: []
|
|
327
|
-
rubygems_version: 3.
|
|
328
|
-
signing_key:
|
|
340
|
+
rubygems_version: 3.6.2
|
|
329
341
|
specification_version: 4
|
|
330
342
|
summary: Create Markdown links from web searches without leaving your editor.
|
|
331
343
|
test_files: []
|