jekyll-webmention_io 2.2.1 → 2.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: bc2baf7e1ce8ecdb8928406d0194e562eea7e486
4
- data.tar.gz: a2fe21b63d34830511960e890edccb645aab2b1d
3
+ metadata.gz: c117bdfd999aabbbaf34a7baa34510806ec30250
4
+ data.tar.gz: df0874f2a17993d0fc40fc8d826b1fe7f64c3cb6
5
5
  SHA512:
6
- metadata.gz: aa7a34a559d02bb541ff95ac9e36c7832ff3b5f9f50a92d0623506958a3f27068bafded7e8d293ab94aa4c881fb4a3ca6a396cff3806e811f013ae5687c308b8
7
- data.tar.gz: 8ba3e8e580f1d9674e6b89cc7a01dad1bb2871ff5754425120205de6cda1413ff5ca99fcb7f2fa60bf8763452121102e80b9be91b0c5be9e1a6708c7a9ba8d88
6
+ metadata.gz: 90bac1c91f4c780eb9ad39ee4eec4dad12272797bd8d00ec3e7924c670449450281b0e6b2970877202ca8d9b9fc490ae4426f207aee29b552fb291817434d069
7
+ data.tar.gz: 89524277af525e270403ed3f9e57cfa966e72348fbb61971d44f435ba362d4fedd8c711ce4b529f1636762d46f8c89d17d699e94b512a58f8f4972c49261dec6
@@ -5,44 +5,43 @@ module Jekyll
5
5
  prog.command(:webmention) do |c|
6
6
  c.syntax 'webmention'
7
7
  c.description 'Sends queued webmentions'
8
-
9
- c.action { |args, options| process args, options }
8
+
9
+ c.action { |args, options| process args, options }
10
10
  end
11
11
  end
12
12
 
13
13
  def self.process( args=[], options={} )
14
- cached_outgoing = Jekyll::WebmentionIO::get_cache_file_path 'outgoing'
15
- cached_sent = Jekyll::WebmentionIO::get_cache_file_path 'sent'
16
- if File.exists?(cached_outgoing)
17
- if File.exists?(cached_sent)
18
- sent = open(cached_sent) { |f| YAML.load(f) }
19
- else
20
- sent = {}
21
- end # file exists (sent)
22
- outgoing = open(cached_outgoing) { |f| YAML.load(f) }
23
- outgoing.each_pair do |source, targets|
24
- if ! sent[source] or ! sent[source].kind_of? Array
25
- sent[source] = Array.new
26
- end
27
- targets.each do |target|
28
- if target and ! sent[source].find_index( target )
29
- if target.index( "//" ) == 0
30
- target = "http:#{target}"
31
- end
32
- endpoint = Jekyll::WebmentionIO::get_webmention_endpoint( target )
33
- if endpoint
34
- endpoint.scan(/href="([^"]+)"/) do |endpoint_url|
35
- endpoint_url = endpoint_url[0]
36
- Jekyll::WebmentionIO::webmention( source, target, endpoint )
37
- end
38
- sent[source].push( target )
39
- end
40
- end
41
- end
42
- end
43
- File.open(cached_sent, 'w') { |f| YAML.dump(sent, f) }
44
- end # file exists (outgoing)
45
- end # def process
14
+ cached_outgoing = Jekyll::WebmentionIO::get_cache_file_path 'outgoing'
15
+ cached_sent = Jekyll::WebmentionIO::get_cache_file_path 'sent'
16
+ if File.exists?(cached_outgoing)
17
+ if File.exists?(cached_sent)
18
+ sent = open(cached_sent) { |f| YAML.load(f) }
19
+ else
20
+ sent = {}
21
+ end # file exists (sent)
22
+ outgoing = open(cached_outgoing) { |f| YAML.load(f) }
23
+ outgoing.each_pair do |source, targets|
24
+ if ! sent[source] or ! sent[source].kind_of? Array
25
+ sent[source] = Array.new
26
+ end
27
+ targets.each do |target|
28
+ if target and ! sent[source].find_index( target )
29
+ if target.index( "//" ) == 0
30
+ target = "http:#{target}"
31
+ end
32
+ endpoint = Jekyll::WebmentionIO::get_webmention_endpoint( target )
33
+ if endpoint
34
+ response = Jekyll::WebmentionIO::webmention( source, target, endpoint )
35
+ if response
36
+ sent[source].push( target )
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ File.open(cached_sent, 'w') { |f| YAML.dump(sent, f) }
43
+ end # file exists (outgoing)
44
+ end # def process
46
45
  end # WebmentionCommand
47
46
  end # Commands
48
47
  end # Jekyll
@@ -25,6 +25,12 @@ module Jekyll
25
25
  head << "<meta property=\"webmention:redirected_from\" content=\"#{redirect}\">"
26
26
  end
27
27
 
28
+ config = site.config['webmentions']
29
+ if config.has_key? 'username'
30
+ head << "<link rel=\"pingback\" href=\"https://webmention.io/#{config['username']}/xmlrpc\">"
31
+ head << "<link rel=\"webmention\" href=\"https://webmention.io/#{config['username']}/webmention\">"
32
+ end
33
+
28
34
  head
29
35
  end
30
36
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module WebmentionIO
3
- VERSION = "2.2.1"
3
+ VERSION = "2.3.0"
4
4
  end
5
5
  end
@@ -12,6 +12,7 @@ require 'net/http'
12
12
  require 'uri'
13
13
  require 'openssl'
14
14
  require 'string_inflection'
15
+ require 'webmention'
15
16
 
16
17
  module Jekyll
17
18
  module WebmentionIO
@@ -98,12 +99,17 @@ module Jekyll
98
99
 
99
100
  def self.get_webmention_endpoint( uri )
100
101
  log 'info', "Looking for webmention endpoint at #{uri}"
101
- return `curl -s --location "#{uri}" | grep 'rel="webmention"'`
102
+ endpoint = Webmention::Client.supports_webmention?( uri )
103
+ if ! endpoint
104
+ log 'info', "No webmention endpoint at #{uri}"
105
+ end
106
+ endpoint
102
107
  end
103
108
 
104
109
  def self.webmention( source, target, endpoint )
105
- log 'info', "Sending webmention of #{source} to #{endpoint}"
106
- return `curl -s -i -d \"source=#{source}&target=#{target}\" -o /dev/null #{endpoint}`
110
+ log 'info', "Sending webmention of #{target} in #{source} to #{endpoint}"
111
+ #return `curl -s -i -d \"source=#{source}&target=#{target}\" -o /dev/null #{endpoint}`
112
+ return Webmention::Client.send_mention( endpoint, source, target, true )
107
113
  end
108
114
 
109
115
  # Utilities
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: 2.2.1
4
+ version: 2.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: 2017-06-29 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -114,6 +114,20 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '3.2'
117
+ - !ruby/object:Gem::Dependency
118
+ name: webmention
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 0.1.6
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 0.1.6
117
131
  - !ruby/object:Gem::Dependency
118
132
  name: bundler
119
133
  requirement: !ruby/object:Gem::Requirement