jekyll-webmention_io 3.2.0 → 3.3.0

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
2
  SHA1:
3
- metadata.gz: b9d0274bb949c53137ce51261e4c2ff534b85806
4
- data.tar.gz: 94dc7afb53715fb5e6661b9fa7fad76cc225e2ca
3
+ metadata.gz: 03fd32c2683f0ffc0d9494ffa0be93ae40835b97
4
+ data.tar.gz: 30f080cb695df8870b9919b0783f91a744d382fb
5
5
  SHA512:
6
- metadata.gz: ed77eae6a0645a492b91a3e7d75aedf006e684290735cee508ec6fd5385cadad0530e47f59b29450c1398bec096c202aa13c30ee4542a6cfd2c425c6b6fba640
7
- data.tar.gz: 8b60976284215965fc4295c444a6059ab5f5409dfa4a6ffa650c03900322f8614d00ec53271d58e1bc5c7a7b98387809f9a7d850a3bd9a41433398cfad8c4871
6
+ metadata.gz: f7f1ba64a3b949dd3fa9a5e724ba788f5513d5914f9256b5ec1ce88069fd5d74ed38213c7c1c3f55f438a6722dc0c6ac065e979aa8b8786e403d65bfe25d3077
7
+ data.tar.gz: b92a21d5542a6cb586bbf47bb0abdbf50c961e3d766c43880d59367fa51a8a15252bca5bcbc4b9c1a2a9656271d047cbd479c370e6534af5778e31779fe8a38b
@@ -14,7 +14,10 @@ module Jekyll
14
14
  end
15
15
  end
16
16
 
17
- def self.process(_args = [], _options = {})
17
+ def self.process(_args = [], options = {})
18
+ options = configuration_from_options(options)
19
+ WebmentionIO.bootstrap(Jekyll::Site.new(options))
20
+
18
21
  if File.exist? WebmentionIO.cache_file("sent.yml")
19
22
  WebmentionIO.log "error", "Your outgoing webmentions queue needs to be upgraded. Please re-build your project."
20
23
  end
@@ -24,17 +27,26 @@ module Jekyll
24
27
  outgoing = WebmentionIO.load_yaml(cached_outgoing)
25
28
  outgoing.each do |source, targets|
26
29
  targets.each do |target, response|
30
+ # skip ones we’ve handled
27
31
  next unless response == false
28
32
 
33
+ # convert protocol-less links
29
34
  if target.index("//").zero?
30
35
  target = "http:#{target}"
31
36
  end
37
+
38
+ # skip bad URLs
39
+ next unless WebmentionIO.uri_ok?(target)
40
+
41
+ # get the endpoint
32
42
  endpoint = WebmentionIO.get_webmention_endpoint(target)
33
43
  next unless endpoint
34
44
 
45
+ # get the response
35
46
  response = WebmentionIO.webmention(source, target, endpoint)
36
47
  next unless response
37
48
 
49
+ # capture JSON responses in case site wants to do anything with them
38
50
  begin
39
51
  response = JSON.parse response
40
52
  rescue JSON::ParserError
@@ -147,7 +147,7 @@ module Jekyll
147
147
 
148
148
  if response && response["links"]
149
149
  response["links"].reverse_each do |link|
150
- webmention = WebmentionIO::Webmention.new(link, @site)
150
+ webmention = WebmentionIO::WebmentionItem.new(link, @site)
151
151
 
152
152
  # Do we already have it?
153
153
  if webmentions.key? webmention.id
@@ -8,7 +8,7 @@
8
8
  # using http://webmention.io/ and the following syntax:
9
9
  #
10
10
  require_relative "webmention_io/version"
11
- require_relative "webmention_io/webmention"
11
+ require_relative "webmention_io/webmention_item"
12
12
  require_relative "webmention_io/js_handler"
13
13
 
14
14
  require "json"
@@ -209,9 +209,13 @@ module Jekyll
209
209
  # log "info", "Looking for webmention endpoint at #{uri}"
210
210
  begin
211
211
  endpoint = Webmention::Client.supports_webmention?(uri)
212
- log("info", "Could not find a webmention endpoint at #{uri}") unless endpoint
212
+ unless endpoint
213
+ log("info", "Could not find a webmention endpoint at #{uri}")
214
+ uri_is_not_ok(uri)
215
+ end
213
216
  rescue StandardError => e
214
217
  log "info", "Endpoint lookup failed for #{uri}: #{e.message}"
218
+ uri_is_not_ok(uri)
215
219
  endpoint = false
216
220
  end
217
221
  endpoint
@@ -220,12 +224,12 @@ module Jekyll
220
224
  def self.webmention(source, target, endpoint)
221
225
  log "info", "Sending webmention of #{target} in #{source}"
222
226
  # return `curl -s -i -d \"source=#{source}&target=#{target}\" -o /dev/null #{endpoint}`
223
- response = Webmention::Client.send_mention(endpoint, source, target, true)
224
- status = response.dig("parsed_response", "data", "status").to_s
225
- if status == "200"
227
+ mention = Webmention::Client.send_mention(endpoint, source, target, true)
228
+ if (mention.response.is_a? Net::HTTPOK) || (mention.response.is_a? Net::HTTPCreated) || (mention.response.is_a? Net::HTTPAccepted)
226
229
  log "info", "Webmention successful!"
227
- return response.response.body
230
+ return mention.response.body
228
231
  else
232
+ log "info", mention.inspect
229
233
  log "info", "Webmention failed, but will remain queued for next time"
230
234
  false
231
235
  end
@@ -235,8 +239,8 @@ module Jekyll
235
239
  @template_file_cache[template] ||= begin
236
240
  configured_template = @config.dig("templates", template)
237
241
  if configured_template
238
- log "info", "Using custom #{template} template"
239
- configured_template
242
+ log "info", "Using custom #{template} template from site source"
243
+ @site.in_source_dir configured_template
240
244
  else
241
245
  File.expand_path("templates/#{template}.html", __dir__)
242
246
  end
@@ -252,10 +256,15 @@ module Jekyll
252
256
  end
253
257
 
254
258
  def self.html_templates
259
+ proofer = if @config['html_proofer'] == true
260
+ ' data-proofer-ignore'
261
+ else
262
+ ''
263
+ end
255
264
  @html_templates ||= begin
256
265
  templates = +"" # unfrozen String
257
266
  supported_templates.each do |template|
258
- templates << "<template style=\"display:none\" id=\"webmention-#{template}\">"
267
+ templates << "<template style=\"display:none\" id=\"webmention-#{template}\"#{proofer}>"
259
268
  templates << get_template_contents(template)
260
269
  templates << "</template>"
261
270
  end
@@ -364,7 +373,7 @@ module Jekyll
364
373
  return true
365
374
  end
366
375
 
367
- private_class_method :get_http_response, :uri_is_not_ok, :uri_ok?
376
+ private_class_method :get_http_response, :uri_is_not_ok
368
377
  end
369
378
  end
370
379
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module WebmentionIO
5
- VERSION = "3.2.0"
5
+ VERSION = "3.3.0"
6
6
  end
7
7
  end
@@ -4,12 +4,12 @@
4
4
  # https://github.com/aarongustafson/jekyll-webmention_io
5
5
  # Licence : MIT
6
6
  #
7
- # this liquid plugin insert a webmentions into your Octopress or Jekyll blog
7
+ # this liquid plugin insert a webmention into your Octopress or Jekyll blog
8
8
  # using http://webmention.io/ and the following syntax:
9
9
  #
10
10
  module Jekyll
11
11
  module WebmentionIO
12
- class Webmention
12
+ class WebmentionItem
13
13
  attr_reader :id, :hash
14
14
 
15
15
  def initialize(mention, site)
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.2.0
4
+ version: 3.3.0
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-09-15 00:00:00.000000000 Z
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -257,7 +257,7 @@ files:
257
257
  - lib/jekyll/webmention_io.rb
258
258
  - lib/jekyll/webmention_io/js_handler.rb
259
259
  - lib/jekyll/webmention_io/version.rb
260
- - lib/jekyll/webmention_io/webmention.rb
260
+ - lib/jekyll/webmention_io/webmention_item.rb
261
261
  homepage: https://github.com/aarongustafson/jekyll-webmention_io
262
262
  licenses:
263
263
  - MIT