searchlink 2.3.84 → 2.3.86
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/config.rb +9 -1
- data/lib/searchlink/curl/html.rb +17 -9
- data/lib/searchlink/output.rb +32 -10
- data/lib/searchlink/parse.rb +252 -261
- data/lib/searchlink/searches/helpers/safari.rb +6 -1
- data/lib/searchlink/searches/history.rb +5 -6
- data/lib/searchlink/searches/popup.rb +68 -0
- data/lib/searchlink/searches/shortener.rb +81 -0
- data/lib/searchlink/searches/{bitly.rb → shorteners/bitly.rb} +0 -1
- data/lib/searchlink/searches/shorteners/tinyurl.rb +72 -0
- data/lib/searchlink/searches.rb +27 -25
- data/lib/searchlink/string.rb +105 -36
- data/lib/searchlink/url.rb +2 -0
- data/lib/searchlink/util.rb +4 -3
- data/lib/searchlink/version.rb +1 -1
- metadata +9 -6
- /data/lib/searchlink/searches/{isgd.rb → shorteners/isgd.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c00e022d8b8155db4e6fd3acd6ccaa69be955a316774be41747cce0e476f0df6
|
4
|
+
data.tar.gz: 8487fcec9ab7d7830c467e5bfa2ed4008104a2363cb776b18864848891a7d98b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66ee6b30d332f4047f4f1528a8f39b6eb51cbb0b6ef0f3abd5b546ea3dd4433ec212c4b72c9d46a680c65e69078afc617caf8d5d7da757181281bb5c16518ad8
|
7
|
+
data.tar.gz: 7b29d19cdddbc9c6ecbe07ecaf7cc23e685da82fd03fe16645a4775ee0aa15ca96bc859da6bc38725fdd074642fa986a396bd745e4af87379bfbfd17f60e83b2
|
data/lib/searchlink/config.rb
CHANGED
@@ -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",
|
@@ -176,7 +184,7 @@ module SL
|
|
176
184
|
# hash can override existing search triggers.
|
177
185
|
config["custom_site_searches"] ||= {
|
178
186
|
"bt" => "brettterpstra.com",
|
179
|
-
"imdb" => "imdb.com"
|
187
|
+
"imdb" => "imdb.com",
|
180
188
|
}
|
181
189
|
|
182
190
|
# confirm existence of links generated from custom search replacements
|
data/lib/searchlink/curl/html.rb
CHANGED
@@ -90,7 +90,7 @@ module Curl
|
|
90
90
|
tag: tag,
|
91
91
|
source: tag_source,
|
92
92
|
attrs: attrs,
|
93
|
-
content: contents
|
93
|
+
content: contents,
|
94
94
|
}
|
95
95
|
end
|
96
96
|
|
@@ -147,7 +147,7 @@ module Curl
|
|
147
147
|
output << {
|
148
148
|
type: "opengraph",
|
149
149
|
attrs: nil,
|
150
|
-
src: @meta[src]
|
150
|
+
src: @meta[src],
|
151
151
|
}
|
152
152
|
end
|
153
153
|
images = tags(%w[img source])
|
@@ -162,21 +162,21 @@ module Curl
|
|
162
162
|
image, media = s.split(/ /)
|
163
163
|
srcset << {
|
164
164
|
src: image,
|
165
|
-
media: media
|
165
|
+
media: media,
|
166
166
|
}
|
167
167
|
end
|
168
168
|
end
|
169
169
|
output << {
|
170
170
|
type: "srcset",
|
171
171
|
attrs: img[:attrs],
|
172
|
-
images: srcset
|
172
|
+
images: srcset,
|
173
173
|
}
|
174
174
|
end
|
175
175
|
when /img/
|
176
176
|
output << {
|
177
177
|
type: "img",
|
178
178
|
src: img[:attrs].filter { |a| a[:key] =~ /src/i }.first[:value],
|
179
|
-
attrs: img[:attrs]
|
179
|
+
attrs: img[:attrs],
|
180
180
|
}
|
181
181
|
end
|
182
182
|
end
|
@@ -189,7 +189,7 @@ module Curl
|
|
189
189
|
links = @links.nil? ? 0 : @links.count
|
190
190
|
[
|
191
191
|
%(<HTMLCurl: @code="#{@code}" @url="#{@url}" @title="#{@title}"),
|
192
|
-
%(@description=#{@description} @headers:#{headers} @meta:#{meta} @links:#{links}>)
|
192
|
+
%(@description=#{@description} @headers:#{headers} @meta:#{meta} @links:#{links}>),
|
193
193
|
].join(" ")
|
194
194
|
end
|
195
195
|
|
@@ -253,14 +253,22 @@ module Curl
|
|
253
253
|
attrs = tag["attrs"].strip.to_enum(:scan, /(?ix)
|
254
254
|
(?<key>[@a-z0-9-]+)(?:=(?<quot>["'])
|
255
255
|
(?<value>[^"']+)\k<quot>|[ >])?/i).map { Regexp.last_match }
|
256
|
-
|
256
|
+
|
257
|
+
attrs.map! do |a|
|
258
|
+
val = if a["key"] =~ /^(class|rel)$/
|
259
|
+
a["value"].nil? ? "" : a["value"].split(/ /)
|
260
|
+
else
|
261
|
+
a["value"]
|
262
|
+
end
|
263
|
+
{ key: a["key"], value: val }
|
264
|
+
end
|
257
265
|
end
|
258
266
|
{
|
259
267
|
tag: tag["tag"],
|
260
268
|
source: tag.to_s,
|
261
269
|
attrs: attrs,
|
262
270
|
content: tag["content"],
|
263
|
-
tags: content_tags(tag["content"])
|
271
|
+
tags: content_tags(tag["content"]),
|
264
272
|
}
|
265
273
|
end
|
266
274
|
end
|
@@ -351,7 +359,7 @@ module Curl
|
|
351
359
|
title: title,
|
352
360
|
rel: rel,
|
353
361
|
text: text,
|
354
|
-
class: link_class
|
362
|
+
class: link_class,
|
355
363
|
}
|
356
364
|
links << link
|
357
365
|
end
|
data/lib/searchlink/output.rb
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
module SL
|
4
4
|
class << self
|
5
5
|
attr_writer :titleize, :clipboard, :output, :footer, :line_num,
|
6
|
-
:match_column, :match_length, :originput, :errors, :report, :printout
|
6
|
+
:match_column, :match_length, :originput, :errors, :report, :printout,
|
7
|
+
:shortener
|
7
8
|
|
8
9
|
# Whether or not to add a title to the output
|
9
10
|
def titleize
|
@@ -60,6 +61,16 @@ module SL
|
|
60
61
|
@errors ||= {}
|
61
62
|
end
|
62
63
|
|
64
|
+
# Stores query parameters
|
65
|
+
def query
|
66
|
+
@query ||= {}
|
67
|
+
end
|
68
|
+
|
69
|
+
# The shortener to use
|
70
|
+
def shortener
|
71
|
+
@shortener ||= :none
|
72
|
+
end
|
73
|
+
|
63
74
|
# Posts macOS notifications
|
64
75
|
#
|
65
76
|
# @param title [String] The title of the notification
|
@@ -102,6 +113,10 @@ module SL
|
|
102
113
|
|
103
114
|
title = title.gsub(/[ \t]+/, " ")
|
104
115
|
|
116
|
+
url.add_query_string!
|
117
|
+
|
118
|
+
url = SL::Shortener.shorten(url, SL.shortener)
|
119
|
+
|
105
120
|
case type.to_sym
|
106
121
|
when :ref_title
|
107
122
|
%(\n[#{text}]: #{url}#{title})
|
@@ -141,7 +156,6 @@ module SL
|
|
141
156
|
#
|
142
157
|
def print_footer
|
143
158
|
unless SL.footer.empty?
|
144
|
-
|
145
159
|
footnotes = []
|
146
160
|
SL.footer.delete_if do |note|
|
147
161
|
note.strip!
|
@@ -202,6 +216,14 @@ module SL
|
|
202
216
|
SL.errors[type].push("(#{position}): #{str}")
|
203
217
|
end
|
204
218
|
|
219
|
+
# Add to query string
|
220
|
+
# @param hsh [Hash] The queries to add
|
221
|
+
# @return [nil]
|
222
|
+
def add_query(hsh)
|
223
|
+
SL.query ||= {}
|
224
|
+
SL.query.merge!(hsh)
|
225
|
+
end
|
226
|
+
|
205
227
|
# Prints the report.
|
206
228
|
#
|
207
229
|
# @return [String] The report.
|
@@ -226,10 +248,10 @@ module SL
|
|
226
248
|
|
227
249
|
out = ""
|
228
250
|
inline = if SL.originput.split(/\n/).length > 1
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
251
|
+
false
|
252
|
+
else
|
253
|
+
SL.config["inline"] || SL.originput.split(/\n/).length == 1
|
254
|
+
end
|
233
255
|
|
234
256
|
SL.errors.each do |k, v|
|
235
257
|
next if v.empty?
|
@@ -237,10 +259,10 @@ module SL
|
|
237
259
|
v.each_with_index do |err, i|
|
238
260
|
out += "(#{k}) #{err}"
|
239
261
|
out += if inline
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
262
|
+
i == v.length - 1 ? " | " : ", "
|
263
|
+
else
|
264
|
+
"\n"
|
265
|
+
end
|
244
266
|
end
|
245
267
|
end
|
246
268
|
|