jekyll-webmention_io 3.3.2 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/commands/webmention.rb +55 -50
- data/lib/jekyll/webmention_io/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88a46606dd33c75831806c6e23393e895c789b41
|
4
|
+
data.tar.gz: b5898399c88d1dcfa2f935d3a2dfe4add6ed8de2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1b0e90e457913a9fe52ebdc17f436b2235478d5e5ee4854bb949596320b7f7a1ed9290aac305c40c6265ea0672584bdb8e62bafacb3591cf591782f2ec1b295
|
7
|
+
data.tar.gz: 3aad19c81497b2215127d0a9ef9fd78563864dedf036e6b4eef43016b0bd0a7d11139e92a877c389983e195587d5fd5d2093e9883e5a5943895c62422d4fa49e
|
@@ -3,65 +3,70 @@
|
|
3
3
|
require "json"
|
4
4
|
|
5
5
|
module Jekyll
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
14
|
+
c.action { |args, options| process args, options }
|
15
|
+
end
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def self.process(_args = [], options = {})
|
19
|
+
options = configuration_from_options(options)
|
20
|
+
WebmentionIO.bootstrap(Jekyll::Site.new(options))
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
39
|
-
|
37
|
+
# convert protocol-less links
|
38
|
+
if target.index("//").zero?
|
39
|
+
target = "http:#{target}"
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
next unless endpoint
|
42
|
+
# skip bad URLs
|
43
|
+
next unless WebmentionIO.uri_ok?(target)
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
# get the endpoint
|
46
|
+
endpoint = WebmentionIO.get_webmention_endpoint(target)
|
47
|
+
next unless endpoint
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end #
|
64
|
-
end #
|
65
|
-
end #
|
66
|
-
end #
|
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
|
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.
|
4
|
+
version: 3.3.3
|
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-
|
11
|
+
date: 2018-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|