jekyll-webmention_io 3.3.2 → 3.3.6

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
- SHA1:
3
- metadata.gz: 33b8089dd07065db73ad59fbf4da05f5e6a6a65d
4
- data.tar.gz: 4dcd8591cc9ff96aff981440d1042538c595e7f1
2
+ SHA256:
3
+ metadata.gz: 020334fc76fba2718d1567fc7938e4b09d3f9612023f32be752f41b88ded0fd9
4
+ data.tar.gz: bf9f07dd3cb7bc2fe266e92fab05f5122125fdf4012272e576d1095cf8a9cfde
5
5
  SHA512:
6
- metadata.gz: d04a8b7e3f54e1d13235f5d68d3a781f8c2185e1662fdabc4a202f54750683ef215f00dd0b02bf3b0a8af2cb99d019128cf49ab78f3da54dddcecc6f4d7ec411
7
- data.tar.gz: 7692c870f2e8cc5068a132de7176906c3280bdfe96ff6d6db6dbeb351bb03a98f2a4ee3a075cfc245e24cec528818ca061a96859b11ec6ace2235858838e655c
6
+ metadata.gz: 1876c839ad26beae83a09d2a41d066fcd2187d3914c2c5b3086a3582a878f0b90dd2f46a2929efb0cf51d71ef106cf3459a7016668d5b163a03d4e8e7c8be97e
7
+ data.tar.gz: e33a2f9291ea21f7c83b8e558b8f0c3e7b2a179442b4675b7d46c00b3df8300e553b039451e5731455f2662f1875a85b34cd62ac63f8441f0c97072d497fd984
@@ -3,65 +3,70 @@
3
3
  require "json"
4
4
 
5
5
  module Jekyll
6
- module Commands
7
- class WebmentionCommand < Command
8
- def self.init_with_program(prog)
9
- prog.command(:webmention) do |c|
10
- c.syntax "webmention"
11
- c.description "Sends queued webmentions"
6
+ module WebmentionIO
7
+ module Commands
8
+ class WebmentionCommand < Command
9
+ def self.init_with_program(prog)
10
+ prog.command(:webmention) do |c|
11
+ c.syntax "webmention"
12
+ c.description "Sends queued webmentions"
12
13
 
13
- c.action { |args, options| process args, options }
14
+ c.action { |args, options| process args, options }
15
+ end
14
16
  end
15
- end
16
17
 
17
- def self.process(_args = [], options = {})
18
- options = configuration_from_options(options)
19
- WebmentionIO.bootstrap(Jekyll::Site.new(options))
18
+ def self.process(_args = [], options = {})
19
+ options = configuration_from_options(options)
20
+ WebmentionIO.bootstrap(Jekyll::Site.new(options))
20
21
 
21
- if File.exist? WebmentionIO.cache_file("sent.yml")
22
- WebmentionIO.log "error", "Your outgoing webmentions queue needs to be upgraded. Please re-build your project."
23
- end
24
- count = 0
25
- cached_outgoing = WebmentionIO.get_cache_file_path "outgoing"
26
- if File.exist?(cached_outgoing)
27
- outgoing = WebmentionIO.load_yaml(cached_outgoing)
28
- outgoing.each do |source, targets|
29
- targets.each do |target, response|
30
- # skip ones we’ve handled
31
- next unless response == false
22
+ if File.exist? WebmentionIO.cache_file("sent.yml")
23
+ WebmentionIO.log "error", "Your outgoing webmentions queue needs to be upgraded. Please re-build your project."
24
+ end
32
25
 
33
- # convert protocol-less links
34
- if target.index("//").zero?
35
- target = "http:#{target}"
36
- end
26
+ WebmentionIO.log "msg", "Getting ready to send webmentions (this may take a while)."
27
+
28
+ count = 0
29
+ cached_outgoing = WebmentionIO.get_cache_file_path "outgoing"
30
+ if File.exist?(cached_outgoing)
31
+ outgoing = WebmentionIO.load_yaml(cached_outgoing)
32
+ outgoing.each do |source, targets|
33
+ targets.each do |target, response|
34
+ # skip ones we’ve handled
35
+ next unless response == false
37
36
 
38
- # skip bad URLs
39
- next unless WebmentionIO.uri_ok?(target)
37
+ # convert protocol-less links
38
+ if target.index("//").zero?
39
+ target = "http:#{target}"
40
+ end
40
41
 
41
- # get the endpoint
42
- endpoint = WebmentionIO.get_webmention_endpoint(target)
43
- next unless endpoint
42
+ # skip bad URLs
43
+ next unless WebmentionIO.uri_ok?(target)
44
44
 
45
- # get the response
46
- response = WebmentionIO.webmention(source, target, endpoint)
47
- next unless response
45
+ # get the endpoint
46
+ endpoint = WebmentionIO.get_webmention_endpoint(target)
47
+ next unless endpoint
48
48
 
49
- # capture JSON responses in case site wants to do anything with them
50
- begin
51
- response = JSON.parse response
52
- rescue JSON::ParserError
53
- response = ""
49
+ # get the response
50
+ response = WebmentionIO.webmention(source, target, endpoint)
51
+ next unless response
52
+
53
+ # capture JSON responses in case site wants to do anything with them
54
+ begin
55
+ response = JSON.parse response
56
+ rescue JSON::ParserError
57
+ response = ""
58
+ end
59
+ outgoing[source][target] = response
60
+ count += 1
54
61
  end
55
- outgoing[source][target] = response
56
- count += 1
57
62
  end
58
- end
59
- if count.positive?
60
- WebmentionIO.dump_yaml(cached_outgoing, outgoing)
61
- end
62
- WebmentionIO.log "msg", "#{count} webmentions sent."
63
- end # file exists (outgoing)
64
- end # def process
65
- end # WebmentionCommand
66
- end # Commands
63
+ if count.positive?
64
+ WebmentionIO.dump_yaml(cached_outgoing, outgoing)
65
+ end
66
+ WebmentionIO.log "msg", "#{count} webmentions sent."
67
+ end # file exists (outgoing)
68
+ end # def process
69
+ end # WebmentionCommand
70
+ end # Commands
71
+ end # WebmentionIO
67
72
  end # Jekyll
@@ -8,6 +8,7 @@
8
8
  #
9
9
 
10
10
  require "uglifier"
11
+ require "fileutils"
11
12
 
12
13
  module Jekyll
13
14
  module WebmentionIO
@@ -32,11 +33,18 @@ module Jekyll
32
33
  return
33
34
  end
34
35
 
35
- @source_file_destination = if handler.source?
36
- @site.in_source_dir(handler.destination)
37
- else
38
- Dir.mktmpdir
39
- end
36
+ if @site.config['serving']
37
+ Jekyll::WebmentionIO.log "msg", "A WebmentionIO.js source file will not be generated during `jekyll serve`."
38
+ end
39
+
40
+ @source_file_base_dir = if handler.source? && !@site.config['serving']
41
+ @site.in_source_dir()
42
+ else
43
+ Dir.mktmpdir
44
+ end
45
+
46
+ @destination = handler.destination
47
+ @source_file_destination = File.join(@source_file_base_dir, @destination)
40
48
 
41
49
  @javascript = +"" # unfrozen String
42
50
 
@@ -77,12 +85,12 @@ module Jekyll
77
85
  end
78
86
 
79
87
  def create_js_file
80
- Dir.mkdir(@source_file_destination) unless File.exist?(@source_file_destination)
88
+ FileUtils.mkdir_p(@source_file_destination) unless File.exist?(@source_file_destination)
81
89
  File.open(File.join(@source_file_destination, @file_name), "wb") { |f| f.write(@javascript) }
82
90
  end
83
91
 
84
92
  def deploy_js_file
85
- js_file = WebmentionIO::JavaScriptFile.new(@site, @source_file_destination, "", @file_name)
93
+ js_file = WebmentionIO::JavaScriptFile.new(@site, @source_file_base_dir, @destination, @file_name)
86
94
  @site.static_files << js_file
87
95
  end
88
96
  end
@@ -19,6 +19,14 @@ module Jekyll
19
19
  @site = site
20
20
  @site_url = site.config["url"].to_s
21
21
 
22
+ if @site.config['serving']
23
+ Jekyll::WebmentionIO.log "msg", "Webmentions won’t be gathered when running `jekyll serve`."
24
+
25
+ @site.config['webmentions'] ||= {}
26
+ @site.config['webmentions']['pause_lookups'] = true
27
+ return
28
+ end
29
+
22
30
  if @site_url.include? "localhost"
23
31
  Jekyll::WebmentionIO.log "msg", "Webmentions won’t be gathered on localhost."
24
32
  return
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  # frozen_string_literal: true
2
3
 
3
4
  # (c) Aaron Gustafson
@@ -17,6 +18,14 @@ module Jekyll
17
18
  @site = site
18
19
  @site_url = site.config["url"].to_s
19
20
 
21
+ if @site.config['serving']
22
+ Jekyll::WebmentionIO.log "msg", "Webmentions lookups are not run when running `jekyll serve`."
23
+
24
+ @site.config['webmentions'] ||= {}
25
+ @site.config['webmentions']['pause_lookups'] = true
26
+ return
27
+ end
28
+
20
29
  if @site_url.include? "localhost"
21
30
  WebmentionIO.log "msg", "Webmentions lookups are not run on localhost."
22
31
  return
@@ -63,7 +72,7 @@ module Jekyll
63
72
  if post.data["in_reply_to"]
64
73
  uris[post.data["in_reply_to"]] = false
65
74
  end
66
- post.content.scan(/(?:https?:)?\/\/[^\s)#"]+/) do |match|
75
+ post.content.scan(/(?:https?:)?\/\/[^\s)#\[\]{}<>%|\^"]+/) do |match|
67
76
  unless uris.key? match
68
77
  uris[match] = false
69
78
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module WebmentionIO
5
- VERSION = "3.3.2"
5
+ VERSION = "3.3.6"
6
6
  end
7
7
  end
@@ -126,7 +126,7 @@ module Jekyll
126
126
 
127
127
  def self.get_response(api_params)
128
128
  api_params << @api_suffix
129
- url = "#{@api_endpoint}?#{api_params}"
129
+ url = URI::Parser.new.escape("#{@api_endpoint}?#{api_params}")
130
130
  log "info", "Sending request to #{url}."
131
131
  source = get_uri_source(url)
132
132
  if source
@@ -171,6 +171,7 @@ module Jekyll
171
171
 
172
172
  def self.get_timeframe_from_date(time)
173
173
  date = time.to_date
174
+ timeframe = nil
174
175
  TIMEFRAMES.each do |key, value|
175
176
  if date.to_date > get_date_from_string(value)
176
177
  timeframe = key
@@ -284,8 +285,8 @@ module Jekyll
284
285
  when Net::HTTPSuccess then
285
286
  return response.body.force_encoding("UTF-8")
286
287
  when Net::HTTPRedirection then
287
- redirect_to = URI.parse(URI.encode(response["location"]))
288
- redirect_to = redirect_to.relative? ? "#{uri.scheme}://#{uri.host}" + redirect_to.to_s : redirect_to.to_s
288
+ redirect_to = URI::Parser.new.parse(response["location"])
289
+ redirect_to = redirect_to.relative? ? "#{original_uri.scheme}://#{original_uri.host}" + redirect_to.to_s : redirect_to.to_s
289
290
  return get_uri_source(redirect_to, redirect_limit - 1, original_uri)
290
291
  else
291
292
  uri_is_not_ok(uri)
@@ -328,7 +329,7 @@ module Jekyll
328
329
  # Private Methods
329
330
 
330
331
  def self.get_http_response(uri)
331
- uri = URI.parse(URI.encode(uri))
332
+ uri = URI::Parser.new.parse(uri)
332
333
  http = Net::HTTP.new(uri.host, uri.port)
333
334
  http.read_timeout = 10
334
335
 
@@ -351,7 +352,7 @@ module Jekyll
351
352
 
352
353
  # Cache bad URLs for a bit
353
354
  def self.uri_is_not_ok(uri)
354
- uri = URI.parse(URI.encode(uri))
355
+ uri = URI::Parser.new.parse(uri.to_s)
355
356
  # Never cache webmention.io in here
356
357
  return if uri.host == "webmention.io"
357
358
 
@@ -362,7 +363,7 @@ module Jekyll
362
363
  end
363
364
 
364
365
  def self.uri_ok?(uri)
365
- uri = URI.parse(URI.encode(uri))
366
+ uri = URI::Parser.new.parse(uri.to_s)
366
367
  now = Time.now.to_s
367
368
  bad_uris = load_yaml(@cache_files["bad_uris"])
368
369
  if bad_uris.key? uri.host
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-webmention_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Gustafson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-29 00:00:00.000000000 Z
11
+ date: 2021-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 3.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4.0'
22
+ version: '5.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 3.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4.0'
32
+ version: '5.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: json
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '1.14'
123
+ version: '2.2'
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '1.14'
130
+ version: '2.2'
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: cucumber
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -198,6 +198,20 @@ dependencies:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0.48'
201
+ - !ruby/object:Gem::Dependency
202
+ name: kramdown-parser-gfm
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: '1.1'
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: '1.1'
201
215
  description: |
202
216
  This Gem includes a suite of tools for managing webmentions in Jekyll:
203
217
 
@@ -270,15 +284,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
270
284
  requirements:
271
285
  - - ">="
272
286
  - !ruby/object:Gem::Version
273
- version: 2.3.0
287
+ version: 2.7.0
274
288
  required_rubygems_version: !ruby/object:Gem::Requirement
275
289
  requirements:
276
290
  - - ">="
277
291
  - !ruby/object:Gem::Version
278
292
  version: '0'
279
293
  requirements: []
280
- rubyforge_project:
281
- rubygems_version: 2.6.13
294
+ rubygems_version: 3.0.3.1
282
295
  signing_key:
283
296
  specification_version: 4
284
297
  summary: A Jekyll plugin for sending & receiving webmentions via Webmention.io.