jekyll-webmention_io 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/assets/{webmention_websocket.js → webmention_websocket.js.disabled} +1 -1
- data/lib/jekyll/commands/webmention.rb +23 -25
- data/lib/jekyll/generators/compile_js.rb +31 -32
- data/lib/jekyll/generators/queue_webmentions.rb +41 -43
- data/lib/jekyll/tags/count.rb +8 -10
- data/lib/jekyll/tags/likes.rb +8 -10
- data/lib/jekyll/tags/links.rb +8 -10
- data/lib/jekyll/tags/posts.rb +9 -11
- data/lib/jekyll/tags/replies.rb +8 -10
- data/lib/jekyll/tags/reposts.rb +9 -11
- data/lib/jekyll/tags/webmentions.rb +5 -7
- data/lib/jekyll/tags/webmentions_head.rb +12 -12
- data/lib/jekyll/tags/webmentions_js.rb +18 -18
- data/lib/jekyll/webmention_io/version.rb +1 -1
- data/lib/jekyll/webmention_io.rb +122 -115
- data/lib/jekyll-webmention_io.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a5fc8540b37c11c6a5c8cabc941a0a8abfb6d28
|
4
|
+
data.tar.gz: b2c35dd389644a77a84b198efc998dcdc6dc3773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ee6dd28ea2cab6e24e6b13c49f32e626188b223824b04da05978ada666ee778673a3d7e299afaa74ae37bddc0b95198914fbb08b066832816198a831e05b837
|
7
|
+
data.tar.gz: 9ad5fd09b1bbc9d5961647359c10e69bd1654619dc4d42abbf10b7195c71c253a8078fddfc2f9cf73e85948f4ae93e897d9f90d6303d6d119d8ef31dd453bd66
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
if ( ! ( 'JekyllWebmentionIO' in window ) ){ window.JekyllWebmentionIO = {}; }
|
8
8
|
|
9
|
-
var ws = new WebSocket('
|
9
|
+
var ws = new WebSocket('wss://webmention.io:8080');
|
10
10
|
|
11
11
|
ws.onopen = function(){
|
12
12
|
// Send the current window URL to the server to register to receive notifications about this URL
|
@@ -1,46 +1,44 @@
|
|
1
|
-
require
|
1
|
+
require "json"
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
module Commands
|
5
5
|
class WebmentionCommand < Command
|
6
|
-
def self.init_with_program(
|
6
|
+
def self.init_with_program(prog)
|
7
7
|
prog.command(:webmention) do |c|
|
8
|
-
c.syntax
|
9
|
-
c.description
|
10
|
-
|
8
|
+
c.syntax "webmention"
|
9
|
+
c.description "Sends queued webmentions"
|
10
|
+
|
11
11
|
c.action { |args, options| process args, options }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.process(
|
16
|
-
if File.
|
17
|
-
Jekyll::WebmentionIO
|
15
|
+
def self.process(_args = [], _options = {})
|
16
|
+
if File.exist? "#{Jekyll::WebmentionIO.cache_folder}/#{Jekyll::WebmentionIO.file_prefix}sent.yml"
|
17
|
+
Jekyll::WebmentionIO.log "error", "Your outgoing webmentions queue needs to be upgraded. Please re-build your project."
|
18
18
|
end
|
19
19
|
count = 0
|
20
|
-
cached_outgoing = Jekyll::WebmentionIO
|
21
|
-
if File.
|
22
|
-
outgoing = open(cached_outgoing) { |f| YAML.
|
20
|
+
cached_outgoing = Jekyll::WebmentionIO.get_cache_file_path "outgoing"
|
21
|
+
if File.exist?(cached_outgoing)
|
22
|
+
outgoing = open(cached_outgoing) { |f| YAML.safe_load(f) }
|
23
23
|
outgoing.each do |source, targets|
|
24
24
|
targets.each do |target, response|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
25
|
+
next unless response === false
|
26
|
+
if target.index("//") == 0
|
27
|
+
target = "http:#{target}"
|
28
|
+
end
|
29
|
+
endpoint = Jekyll::WebmentionIO.get_webmention_endpoint(target)
|
30
|
+
next unless endpoint
|
31
|
+
response = Jekyll::WebmentionIO.webmention(source, target, endpoint)
|
32
|
+
if response
|
33
|
+
outgoing[source][target] = JSON.parse response.body
|
34
|
+
count += 1
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
40
38
|
if count > 0
|
41
|
-
File.open(cached_outgoing,
|
39
|
+
File.open(cached_outgoing, "w") { |f| YAML.dump(outgoing, f) }
|
42
40
|
end
|
43
|
-
Jekyll::WebmentionIO
|
41
|
+
Jekyll::WebmentionIO.log "info", "#{count} webmentions sent."
|
44
42
|
end # file exists (outgoing)
|
45
43
|
end # def process
|
46
44
|
end # WebmentionCommand
|
@@ -1,56 +1,55 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# This generator gathers webmentions of your pages
|
6
6
|
#
|
7
7
|
|
8
|
-
require
|
8
|
+
require "uglifier"
|
9
9
|
|
10
10
|
module Jekyll
|
11
11
|
module WebmentionIO
|
12
12
|
class JavaScriptFile < StaticFile
|
13
13
|
def destination_rel_dir
|
14
14
|
config = {
|
15
|
-
|
15
|
+
"destination" => "js",
|
16
16
|
}
|
17
|
-
js_config = Jekyll::WebmentionIO
|
17
|
+
js_config = Jekyll::WebmentionIO.config["js"] || {}
|
18
18
|
config = config.merge(js_config)
|
19
|
-
config[
|
19
|
+
config["destination"]
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
using StringInflection
|
24
24
|
class CompileJS < Generator
|
25
|
-
|
26
25
|
safe true
|
27
26
|
priority :low
|
28
|
-
|
27
|
+
|
29
28
|
def generate(site)
|
30
|
-
if site.config.dig(
|
31
|
-
Jekyll::WebmentionIO
|
29
|
+
if site.config.dig("webmentions", "js") == false
|
30
|
+
Jekyll::WebmentionIO.log "info", "Skipping JavaScript inclusion."
|
32
31
|
return
|
33
32
|
end
|
34
33
|
|
35
34
|
config = {
|
36
|
-
|
37
|
-
|
35
|
+
"destination" => "js",
|
36
|
+
"uglify" => true,
|
38
37
|
}
|
39
|
-
site_config = site.config.dig(
|
40
|
-
|
38
|
+
site_config = site.config.dig("webmentions", "js") || {}
|
39
|
+
|
41
40
|
config = config.merge(site_config)
|
42
|
-
|
43
|
-
source = File.join(File.dirname(File.expand_path(__FILE__)),
|
44
|
-
|
45
|
-
javascript =
|
41
|
+
|
42
|
+
source = File.join(File.dirname(File.expand_path(__FILE__)), "../assets/")
|
43
|
+
|
44
|
+
javascript = ""
|
46
45
|
Dir["#{source}/*.js"].each do |file|
|
47
|
-
handler = File.open(file,
|
46
|
+
handler = File.open(file, "rb")
|
48
47
|
javascript << File.read(handler)
|
49
48
|
end
|
50
|
-
|
49
|
+
|
51
50
|
# Dump in types
|
52
51
|
js_types = []
|
53
|
-
Jekyll::WebmentionIO
|
52
|
+
Jekyll::WebmentionIO.types.each do |type|
|
54
53
|
js_types.push "'#{type}': '#{type.to_singular}'"
|
55
54
|
end
|
56
55
|
types_js = <<-EOF
|
@@ -59,25 +58,25 @@ module Jekyll
|
|
59
58
|
JekyllWebmentionIO.types = { TYPES };
|
60
59
|
}(this, this.JekyllWebmentionIO));
|
61
60
|
EOF
|
62
|
-
javascript << types_js.sub(
|
63
|
-
|
64
|
-
unless config[
|
61
|
+
javascript << types_js.sub(%r!TYPES!, js_types.join(","))
|
62
|
+
|
63
|
+
unless config["uglify"] == false
|
65
64
|
uglify_config = {
|
66
|
-
:harmony => true
|
65
|
+
:harmony => true,
|
67
66
|
}
|
68
67
|
javascript = Uglifier.new(uglify_config).compile(javascript)
|
69
68
|
end
|
70
69
|
|
71
70
|
# Generate the file
|
72
|
-
file_name =
|
73
|
-
source_file_destination = (
|
74
|
-
Dir.mkdir(
|
75
|
-
File.open("#{source_file_destination}/#{file_name}",
|
76
|
-
unless config[
|
77
|
-
js_file = Jekyll::WebmentionIO::JavaScriptFile.new(site, source_file_destination,
|
71
|
+
file_name = "JekyllWebmentionIO.js"
|
72
|
+
source_file_destination = (config["source"] == false ? Dir.mktmpdir : "#{site.config["source"]}/#{config["destination"]}")
|
73
|
+
Dir.mkdir(source_file_destination) unless File.exist?(source_file_destination)
|
74
|
+
File.open("#{source_file_destination}/#{file_name}", "w") { |f| f.write(javascript) }
|
75
|
+
unless config["deploy"] == false
|
76
|
+
js_file = Jekyll::WebmentionIO::JavaScriptFile.new(site, source_file_destination, "", file_name)
|
78
77
|
site.static_files << js_file
|
79
78
|
end
|
80
79
|
end
|
81
80
|
end
|
82
81
|
end
|
83
|
-
end
|
82
|
+
end
|
@@ -1,41 +1,40 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# This generator caches sites you mention so they can be mentioned
|
6
6
|
#
|
7
7
|
|
8
8
|
module Jekyll
|
9
9
|
class QueueWebmentions < Generator
|
10
|
-
|
11
10
|
safe true
|
12
11
|
priority :low
|
13
|
-
|
12
|
+
|
14
13
|
def generate(site)
|
15
|
-
if site.config.dig(
|
16
|
-
Jekyll::WebmentionIO
|
14
|
+
if site.config.dig("webmentions", "pause_lookups") == true
|
15
|
+
Jekyll::WebmentionIO.log "info", "Webmention lookups are currently paused."
|
17
16
|
return
|
18
17
|
end
|
19
18
|
|
20
|
-
Jekyll::WebmentionIO
|
19
|
+
Jekyll::WebmentionIO.log "info", "Beginning to gather webmentions you’ve made. This may take a while."
|
20
|
+
|
21
|
+
upgrade_outgoing_webmention_cache
|
22
|
+
|
23
|
+
cache_file = Jekyll::WebmentionIO.get_cache_file_path "outgoing"
|
24
|
+
webmentions = open(cache_file) { |f| YAML.safe_load(f) }
|
25
|
+
|
26
|
+
posts = if Jekyll::VERSION >= "3.0.0"
|
27
|
+
site.posts.docs
|
28
|
+
else
|
29
|
+
site.posts
|
30
|
+
end
|
21
31
|
|
22
|
-
upgrade_outgoing_webmention_cache()
|
23
|
-
|
24
|
-
cache_file = Jekyll::WebmentionIO::get_cache_file_path 'outgoing'
|
25
|
-
webmentions = open(cache_file) { |f| YAML.load(f) }
|
26
|
-
|
27
|
-
if Jekyll::VERSION >= "3.0.0"
|
28
|
-
posts = site.posts.docs
|
29
|
-
else
|
30
|
-
posts = site.posts
|
31
|
-
end
|
32
|
-
|
33
32
|
posts.each do |post|
|
34
|
-
uri = "#{site.config[
|
33
|
+
uri = "#{site.config["url"]}#{post.url}"
|
35
34
|
mentions = get_mentioned_uris(post)
|
36
|
-
if webmentions.
|
35
|
+
if webmentions.key? uri
|
37
36
|
mentions.each do |mentioned_uri, response|
|
38
|
-
unless webmentions[uri].
|
37
|
+
unless webmentions[uri].key? mentioned_uri
|
39
38
|
webmentions[uri][mentioned_uri] = response
|
40
39
|
end
|
41
40
|
end
|
@@ -44,50 +43,49 @@ module Jekyll
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
cache_file = Jekyll::WebmentionIO
|
48
|
-
File.open(cache_file,
|
46
|
+
cache_file = Jekyll::WebmentionIO.get_cache_file_path "outgoing"
|
47
|
+
File.open(cache_file, "w") { |f| YAML.dump(webmentions, f) }
|
49
48
|
|
50
|
-
Jekyll::WebmentionIO
|
49
|
+
Jekyll::WebmentionIO.log "info", "Webmentions have been gathered and cached."
|
51
50
|
end
|
52
51
|
|
53
52
|
def upgrade_outgoing_webmention_cache
|
54
|
-
old_sent_file = "#{Jekyll::WebmentionIO
|
55
|
-
old_outgoing_file = "#{Jekyll::WebmentionIO
|
56
|
-
unless File.
|
53
|
+
old_sent_file = "#{Jekyll::WebmentionIO.cache_folder}/#{Jekyll::WebmentionIO.file_prefix}sent.yml"
|
54
|
+
old_outgoing_file = "#{Jekyll::WebmentionIO.cache_folder}/#{Jekyll::WebmentionIO.file_prefix}queued.yml"
|
55
|
+
unless File.exist? old_sent_file
|
57
56
|
return
|
58
57
|
end
|
59
|
-
sent_webmentions = open(old_sent_file) { |f| YAML.
|
60
|
-
outgoing_webmentions = open(old_outgoing_file) { |f| YAML.
|
58
|
+
sent_webmentions = open(old_sent_file) { |f| YAML.safe_load(f) }
|
59
|
+
outgoing_webmentions = open(old_outgoing_file) { |f| YAML.safe_load(f) }
|
61
60
|
merged = {}
|
62
61
|
outgoing_webmentions.each do |source_url, webmentions|
|
63
62
|
collection = {}
|
64
63
|
webmentions.each do |target_url|
|
65
|
-
if sent_webmentions.dig(
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
collection[target_url] = if sent_webmentions.dig(source_url, target_url)
|
65
|
+
""
|
66
|
+
else
|
67
|
+
false
|
68
|
+
end
|
70
69
|
end
|
71
70
|
merged[source_url] = collection
|
72
71
|
end
|
73
|
-
cached_outgoing = Jekyll::WebmentionIO
|
74
|
-
File.open(cached_outgoing,
|
72
|
+
cached_outgoing = Jekyll::WebmentionIO.get_cache_file_path "outgoing"
|
73
|
+
File.open(cached_outgoing, "w") { |f| YAML.dump(merged, f) }
|
75
74
|
File.delete old_sent_file, old_outgoing_file
|
76
|
-
Jekyll::WebmentionIO
|
77
|
-
end
|
75
|
+
Jekyll::WebmentionIO.log "info", "Upgraded your sent webmentions cache."
|
76
|
+
end
|
78
77
|
|
79
78
|
def get_mentioned_uris(post)
|
80
79
|
uris = {}
|
81
|
-
if post.data[
|
82
|
-
uris[post.data[
|
80
|
+
if post.data["in_reply_to"]
|
81
|
+
uris[post.data["in_reply_to"]] = false
|
83
82
|
end
|
84
83
|
post.content.scan(/(?:https?:)?\/\/[^\s)#"]+/) do |match|
|
85
|
-
unless uris.
|
84
|
+
unless uris.key? match
|
86
85
|
uris[match] = false
|
87
86
|
end
|
88
87
|
end
|
89
88
|
return uris
|
90
89
|
end
|
91
|
-
|
92
90
|
end
|
93
|
-
end
|
91
|
+
end
|
data/lib/jekyll/tags/count.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# this liquid plugin insert a webmentions into your Octopress or Jekill blog
|
6
6
|
# using http://webmention.io/ and the following syntax:
|
7
7
|
#
|
8
8
|
# {% webmention_count post.url [ likes | links | posts | replies | reposts ]* %}
|
9
|
-
#
|
9
|
+
#
|
10
10
|
module Jekyll
|
11
11
|
module WebmentionIO
|
12
12
|
class WebmentionCountTag < Jekyll::WebmentionIO::WebmentionTag
|
13
|
-
|
14
13
|
def initialize(tagName, text, tokens)
|
15
14
|
super
|
16
15
|
@text = text
|
17
|
-
set_template
|
16
|
+
set_template "count"
|
18
17
|
end
|
19
18
|
|
20
|
-
def set_data(
|
21
|
-
@data = {
|
19
|
+
def set_data(data, types)
|
20
|
+
@data = { "count" => data.length, "types" => types }
|
22
21
|
end
|
23
|
-
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
|
-
Liquid::Template.register_tag(
|
29
|
-
Liquid::Template.register_tag(
|
26
|
+
Liquid::Template.register_tag("webmention_count", Jekyll::WebmentionIO::WebmentionCountTag)
|
27
|
+
Liquid::Template.register_tag("webmentions_count", Jekyll::WebmentionIO::WebmentionCountTag)
|
data/lib/jekyll/tags/likes.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# this liquid plugin insert a webmentions into your Octopress or Jekill blog
|
6
6
|
# using http://webmention.io/ and the following syntax:
|
7
7
|
#
|
8
8
|
# {% webmention_likes post.url %}
|
9
|
-
#
|
9
|
+
#
|
10
10
|
module Jekyll
|
11
11
|
module WebmentionIO
|
12
12
|
class WebmentionLikesTag < Jekyll::WebmentionIO::WebmentionTag
|
13
|
-
|
14
13
|
def initialize(tagName, text, tokens)
|
15
14
|
super
|
16
15
|
@text = text
|
17
|
-
set_template
|
16
|
+
set_template "likes"
|
18
17
|
end
|
19
18
|
|
20
|
-
def set_data(
|
21
|
-
webmentions = extract_type
|
22
|
-
@data = {
|
19
|
+
def set_data(data, _types)
|
20
|
+
webmentions = extract_type "likes", data
|
21
|
+
@data = { "webmentions" => webmentions.values }
|
23
22
|
end
|
24
|
-
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
Liquid::Template.register_tag(
|
27
|
+
Liquid::Template.register_tag("webmention_likes", Jekyll::WebmentionIO::WebmentionLikesTag)
|
data/lib/jekyll/tags/links.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# this liquid plugin insert a webmentions into your Octopress or Jekill blog
|
6
6
|
# using http://webmention.io/ and the following syntax:
|
7
7
|
#
|
8
8
|
# {% webmention_links post.url %}
|
9
|
-
#
|
9
|
+
#
|
10
10
|
module Jekyll
|
11
11
|
module WebmentionIO
|
12
12
|
class WebmentionLinksTag < Jekyll::WebmentionIO::WebmentionTag
|
13
|
-
|
14
13
|
def initialize(tagName, text, tokens)
|
15
14
|
super
|
16
15
|
@text = text
|
17
|
-
set_template
|
16
|
+
set_template "links"
|
18
17
|
end
|
19
18
|
|
20
|
-
def set_data(
|
21
|
-
webmentions = extract_type
|
22
|
-
@data = {
|
19
|
+
def set_data(data, _types)
|
20
|
+
webmentions = extract_type "links", data
|
21
|
+
@data = { "webmentions" => webmentions.values }
|
23
22
|
end
|
24
|
-
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
Liquid::Template.register_tag(
|
27
|
+
Liquid::Template.register_tag("webmention_links", Jekyll::WebmentionIO::WebmentionLinksTag)
|
data/lib/jekyll/tags/posts.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# this liquid plugin insert a webmentions into your Octopress or Jekill blog
|
6
6
|
# using http://webmention.io/ and the following syntax:
|
7
7
|
#
|
8
8
|
# {% webmention_posts post.url %}
|
9
|
-
#
|
9
|
+
#
|
10
10
|
module Jekyll
|
11
11
|
module WebmentionIO
|
12
12
|
class WebmentionRepostsTag < Jekyll::WebmentionIO::WebmentionTag
|
13
|
-
|
14
13
|
def initialize(tagName, text, tokens)
|
15
|
-
super
|
14
|
+
super
|
16
15
|
@text = text
|
17
|
-
set_template
|
16
|
+
set_template "posts"
|
18
17
|
end
|
19
18
|
|
20
|
-
def set_data(
|
21
|
-
webmentions = extract_type
|
22
|
-
@data = {
|
19
|
+
def set_data(data, _types)
|
20
|
+
webmentions = extract_type "posts", data
|
21
|
+
@data = { "webmentions" => webmentions.values }
|
23
22
|
end
|
24
|
-
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
Liquid::Template.register_tag(
|
27
|
+
Liquid::Template.register_tag("webmention_posts", Jekyll::WebmentionIO::WebmentionRepostsTag)
|
data/lib/jekyll/tags/replies.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# this liquid plugin insert a webmentions into your Octopress or Jekill blog
|
6
6
|
# using http://webmention.io/ and the following syntax:
|
7
7
|
#
|
8
8
|
# {% webmention_replies post.url %}
|
9
|
-
#
|
9
|
+
#
|
10
10
|
module Jekyll
|
11
11
|
module WebmentionIO
|
12
12
|
class WebmentionRepliesTag < Jekyll::WebmentionIO::WebmentionTag
|
13
|
-
|
14
13
|
def initialize(tagName, text, tokens)
|
15
14
|
super
|
16
15
|
@text = text
|
17
|
-
set_template
|
16
|
+
set_template "replies"
|
18
17
|
end
|
19
18
|
|
20
|
-
def set_data(
|
21
|
-
webmentions = extract_type
|
22
|
-
@data = {
|
19
|
+
def set_data(data, _types)
|
20
|
+
webmentions = extract_type "replies", data
|
21
|
+
@data = { "webmentions" => webmentions.values }
|
23
22
|
end
|
24
|
-
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
Liquid::Template.register_tag(
|
27
|
+
Liquid::Template.register_tag("webmention_replies", Jekyll::WebmentionIO::WebmentionRepliesTag)
|
data/lib/jekyll/tags/reposts.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# this liquid plugin insert a webmentions into your Octopress or Jekill blog
|
6
6
|
# using http://webmention.io/ and the following syntax:
|
7
7
|
#
|
8
8
|
# {% webmention_reposts post.url %}
|
9
|
-
#
|
9
|
+
#
|
10
10
|
module Jekyll
|
11
11
|
module WebmentionIO
|
12
12
|
class WebmentionRepostsTag < Jekyll::WebmentionIO::WebmentionTag
|
13
|
-
|
14
13
|
def initialize(tagName, text, tokens)
|
15
|
-
super
|
14
|
+
super
|
16
15
|
@text = text
|
17
|
-
set_template
|
16
|
+
set_template "reposts"
|
18
17
|
end
|
19
18
|
|
20
|
-
def set_data(
|
21
|
-
webmentions = extract_type
|
22
|
-
@data = {
|
19
|
+
def set_data(data, _types)
|
20
|
+
webmentions = extract_type "reposts", data
|
21
|
+
@data = { "webmentions" => webmentions.values }
|
23
22
|
end
|
24
|
-
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
Liquid::Template.register_tag(
|
27
|
+
Liquid::Template.register_tag("webmention_reposts", Jekyll::WebmentionIO::WebmentionRepostsTag)
|
@@ -1,24 +1,22 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# this liquid plugin insert a webmentions into your Octopress or Jekill blog
|
6
6
|
# using http://webmention.io/ and the following syntax:
|
7
7
|
#
|
8
8
|
# {% webmentions post.url [ likes | links | posts | replies | reposts ]* %}
|
9
|
-
#
|
9
|
+
#
|
10
10
|
module Jekyll
|
11
11
|
module WebmentionIO
|
12
12
|
class WebmentionsTag < Jekyll::WebmentionIO::WebmentionTag
|
13
|
-
|
14
13
|
def initialize(tagName, text, tokens)
|
15
14
|
super
|
16
15
|
@text = text
|
17
|
-
set_template
|
16
|
+
set_template "webmentions"
|
18
17
|
end
|
19
|
-
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
|
-
Liquid::Template.register_tag(
|
22
|
+
Liquid::Template.register_tag("webmentions", Jekyll::WebmentionIO::WebmentionsTag)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Stuff for the `head`
|
6
6
|
#
|
7
7
|
|
@@ -9,23 +9,23 @@ module Jekyll
|
|
9
9
|
module WebmentionIO
|
10
10
|
class WebmentionHeadTag < Liquid::Tag
|
11
11
|
def render(context)
|
12
|
-
head =
|
12
|
+
head = ""
|
13
13
|
head << '<link rel="dns-prefetch" href="https://webmention.io">'
|
14
14
|
head << '<link rel="preconnect" href="https://webmention.io">'
|
15
15
|
head << '<link rel="preconnect" href="ws://webmention.io:8080">'
|
16
|
-
|
17
|
-
page = context[
|
16
|
+
|
17
|
+
page = context["page"]
|
18
18
|
site = context.registers[:site]
|
19
|
-
if page[
|
20
|
-
if page[
|
21
|
-
redirect = site.config[
|
22
|
-
elsif page[
|
23
|
-
redirect = site.config[
|
19
|
+
if page["redirect_from"]
|
20
|
+
if page["redirect_from"].is_a? String
|
21
|
+
redirect = site.config["url"] + page["redirect_from"]
|
22
|
+
elsif page["redirect_from"].is_a? Array
|
23
|
+
redirect = site.config["url"] + page["redirect_from"].join(",#{site.config["url"]}")
|
24
24
|
end
|
25
25
|
head << "<meta property=\"webmention:redirected_from\" content=\"#{redirect}\">"
|
26
26
|
end
|
27
27
|
|
28
|
-
username = site.config.dig(
|
28
|
+
username = site.config.dig("webmentions", "username")
|
29
29
|
if username
|
30
30
|
head << "<link rel=\"pingback\" href=\"https://webmention.io/#{username}/xmlrpc\">"
|
31
31
|
head << "<link rel=\"webmention\" href=\"https://webmention.io/#{username}/webmention\">"
|
@@ -37,4 +37,4 @@ module Jekyll
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
Liquid::Template.register_tag(
|
40
|
+
Liquid::Template.register_tag("webmentions_head", Jekyll::WebmentionIO::WebmentionHeadTag)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# JS stuff
|
6
6
|
#
|
7
7
|
|
@@ -12,37 +12,37 @@ module Jekyll
|
|
12
12
|
site = context.registers[:site]
|
13
13
|
|
14
14
|
# JS can be turned off too
|
15
|
-
if site.config.dig(
|
16
|
-
Jekyll::WebmentionIO
|
17
|
-
return
|
15
|
+
if site.config.dig("webmentions", "js") == false
|
16
|
+
Jekyll::WebmentionIO.log "info", "JavaScript output is disabled, so the {% webmentions_js %} tag is being skipped"
|
17
|
+
return ""
|
18
18
|
end
|
19
19
|
|
20
20
|
config = {
|
21
|
-
|
22
|
-
|
21
|
+
"destination" => "js",
|
22
|
+
"uglify" => true,
|
23
23
|
}
|
24
|
-
site_config = site.config.dig(
|
24
|
+
site_config = site.config.dig("webmentions", "js") || {}
|
25
25
|
config = config.merge(site_config)
|
26
26
|
|
27
27
|
# JS file
|
28
|
-
js =
|
29
|
-
unless config[
|
30
|
-
js_file_path = "#{site.config[
|
28
|
+
js = ""
|
29
|
+
unless config["deploy"] == false
|
30
|
+
js_file_path = "#{site.config["baseurl"]}/#{config["destination"]}/JekyllWebmentionIO.js"
|
31
31
|
js << "<script src=\"#{js_file_path}\" async></script>"
|
32
32
|
end
|
33
|
-
|
34
|
-
templates =
|
35
|
-
template_files = Jekyll::WebmentionIO
|
33
|
+
|
34
|
+
templates = ""
|
35
|
+
template_files = Jekyll::WebmentionIO.types + %w(count webmentions)
|
36
36
|
template_files.each do |template|
|
37
37
|
templates << "<template style=\"display:none\" id=\"webmention-#{template}\">"
|
38
|
-
templates << Jekyll::WebmentionIO
|
39
|
-
templates <<
|
38
|
+
templates << Jekyll::WebmentionIO.get_template_contents(template)
|
39
|
+
templates << "</template>"
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
"#{js}\n#{templates}"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
Liquid::Template.register_tag(
|
48
|
+
Liquid::Template.register_tag("webmentions_js", Jekyll::WebmentionIO::WebmentionJSTag)
|
data/lib/jekyll/webmention_io.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
1
|
# (c) Aaron Gustafson
|
2
|
-
# https://github.com/aarongustafson/jekyll-webmention_io
|
2
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
3
3
|
# Licence : MIT
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# this liquid plugin insert a webmentions into your Octopress or Jekill blog
|
6
6
|
# using http://webmention.io/ and the following syntax:
|
7
|
-
#
|
8
|
-
require_relative
|
7
|
+
#
|
8
|
+
require_relative "webmention_io/version"
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
10
|
+
require "json"
|
11
|
+
require "net/http"
|
12
|
+
require "uri"
|
13
|
+
require "openssl"
|
14
|
+
require "string_inflection"
|
15
|
+
require "webmention"
|
16
16
|
|
17
17
|
module Jekyll
|
18
18
|
module WebmentionIO
|
19
|
-
|
20
|
-
@logger_prefix = '[jekyll-webmention_io]'
|
21
19
|
|
22
|
-
@
|
20
|
+
@logger_prefix = "[jekyll-webmention_io]"
|
21
|
+
|
22
|
+
@api_url = "https://webmention.io/api"
|
23
23
|
@api_endpoint = @api_url
|
24
|
-
@api_suffix =
|
25
|
-
|
26
|
-
@types =
|
24
|
+
@api_suffix = ""
|
25
|
+
|
26
|
+
@types = %w(likes links posts replies reposts)
|
27
27
|
|
28
|
-
def self.bootstrap
|
28
|
+
def self.bootstrap
|
29
29
|
# @jekyll_config = Jekyll.configuration({ 'quiet' => true })
|
30
|
-
@jekyll_config = Jekyll
|
31
|
-
@config = @jekyll_config[
|
32
|
-
|
30
|
+
@jekyll_config = Jekyll.configuration({})
|
31
|
+
@config = @jekyll_config["webmentions"] || {}
|
32
|
+
|
33
33
|
# Set up the cache folder & files
|
34
|
-
@cache_folder = @config[
|
35
|
-
Dir.mkdir(@cache_folder) unless File.
|
36
|
-
@file_prefix =
|
37
|
-
|
38
|
-
@file_prefix =
|
34
|
+
@cache_folder = @config["cache_folder"] || ".jekyll-cache"
|
35
|
+
Dir.mkdir(@cache_folder) unless File.exist?(@cache_folder)
|
36
|
+
@file_prefix = ""
|
37
|
+
unless @cache_folder.include? "webmention"
|
38
|
+
@file_prefix = "webmention_io_"
|
39
39
|
end
|
40
40
|
@cache_files = {
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
"incoming" => "#{@cache_folder}/#{@file_prefix}received.yml",
|
42
|
+
"outgoing" => "#{@cache_folder}/#{@file_prefix}outgoing.yml",
|
43
|
+
"bad_uris" => "#{@cache_folder}/#{@file_prefix}bad_uris.yml",
|
44
44
|
}
|
45
|
-
@cache_files.each do |
|
46
|
-
|
47
|
-
File.open(file,
|
45
|
+
@cache_files.each do |_key, file|
|
46
|
+
unless File.exist?(file)
|
47
|
+
File.open(file, "w") { |f| YAML.dump({}, f) }
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -53,41 +53,46 @@ module Jekyll
|
|
53
53
|
def self.config
|
54
54
|
@config
|
55
55
|
end
|
56
|
+
|
56
57
|
def self.jekyll_config
|
57
58
|
@jekyll_config
|
58
59
|
end
|
60
|
+
|
59
61
|
def self.cache_files
|
60
62
|
@cache_files
|
61
63
|
end
|
64
|
+
|
62
65
|
def self.cache_folder
|
63
66
|
@cache_folder
|
64
67
|
end
|
68
|
+
|
65
69
|
def self.file_prefix
|
66
70
|
@file_prefix
|
67
71
|
end
|
72
|
+
|
68
73
|
def self.types
|
69
74
|
@types
|
70
75
|
end
|
71
|
-
|
72
|
-
def self.get_cache_file_path(
|
76
|
+
|
77
|
+
def self.get_cache_file_path(key)
|
73
78
|
path = false
|
74
|
-
if @cache_files.
|
79
|
+
if @cache_files.key? key
|
75
80
|
path = @cache_files[key]
|
76
81
|
end
|
77
82
|
return path
|
78
83
|
end
|
79
84
|
|
80
85
|
# API helpers
|
81
|
-
#def uri_params_for(api_params)
|
86
|
+
# def uri_params_for(api_params)
|
82
87
|
# api_params.keys.sort.map do |k|
|
83
88
|
# "#{CGI::escape(k)}=#{CGI::escape(api_params[k])}"
|
84
89
|
# end.join('&')
|
85
|
-
#end
|
90
|
+
# end
|
86
91
|
|
87
92
|
def self.set_api_endpoint(path)
|
88
93
|
@api_endpoint = "#{@api_url}/#{path}"
|
89
94
|
end
|
90
|
-
|
95
|
+
|
91
96
|
def self.set_api_suffix(suffix)
|
92
97
|
@api_suffix = suffix
|
93
98
|
end
|
@@ -104,108 +109,110 @@ module Jekyll
|
|
104
109
|
|
105
110
|
# allowed throttles: last_week, last_month, last_year, older
|
106
111
|
# allowed values: daily, weekly, monthly, yearly, every X days|weeks|months|years
|
107
|
-
def self.post_should_be_throttled?(
|
108
|
-
throttles = @config.dig(
|
112
|
+
def self.post_should_be_throttled?(post, item_date, last_webmention_date)
|
113
|
+
throttles = @config.dig("throttle_lookups")
|
109
114
|
if throttles && item_date && last_webmention_date
|
110
|
-
age = get_timeframe_from_date(
|
111
|
-
throttle = throttles.dig(
|
112
|
-
if throttle && get_date_from_string(
|
113
|
-
log
|
115
|
+
age = get_timeframe_from_date(item_date)
|
116
|
+
throttle = throttles.dig(age)
|
117
|
+
if throttle && get_date_from_string(throttle) >= Date.parse(last_webmention_date)
|
118
|
+
log "info", "Throttling #{post.data["title"]} (Only checking it #{throttle})"
|
114
119
|
return true
|
115
120
|
end
|
116
121
|
end
|
117
|
-
return false
|
122
|
+
return false
|
118
123
|
end
|
119
|
-
|
124
|
+
|
125
|
+
def self.get_timeframe_from_date(time)
|
120
126
|
date = time.to_date
|
121
127
|
timeframes = {
|
122
|
-
|
123
|
-
|
124
|
-
|
128
|
+
"last_week" => "weekly",
|
129
|
+
"last_month" => "monthly",
|
130
|
+
"last_year" => "yearly",
|
125
131
|
}
|
126
132
|
timeframe = nil
|
127
133
|
timeframes.each do |key, value|
|
128
|
-
if date.to_date > get_date_from_string(
|
134
|
+
if date.to_date > get_date_from_string(value)
|
129
135
|
timeframe = key
|
130
136
|
break
|
131
137
|
end
|
132
138
|
end
|
133
|
-
|
134
|
-
timeframe =
|
139
|
+
unless timeframe
|
140
|
+
timeframe = "older"
|
135
141
|
end
|
136
142
|
return timeframe
|
137
143
|
end
|
144
|
+
|
138
145
|
# supported: daily, weekly, monthly, yearly, every X days|weeks|months|years
|
139
|
-
def self.get_date_from_string(
|
146
|
+
def self.get_date_from_string(text)
|
140
147
|
today = Date.today
|
141
|
-
pattern =
|
142
|
-
matches = text.match(
|
143
|
-
|
144
|
-
if text ==
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
matches = text.match(
|
148
|
+
pattern = %r!every\s(?:(\d+)\s)?(day|week|month|year)s?!
|
149
|
+
matches = text.match(pattern)
|
150
|
+
unless matches
|
151
|
+
text = if text == "daily"
|
152
|
+
"every 1 day"
|
153
|
+
else
|
154
|
+
"every 1 " + text.sub("ly", "")
|
155
|
+
end
|
156
|
+
matches = text.match(pattern)
|
150
157
|
end
|
151
158
|
n = matches[1] ? matches[1].to_i : 1
|
152
159
|
unit = matches[2]
|
153
160
|
# weeks aren't natively supported in Ruby
|
154
|
-
if unit ==
|
155
|
-
n
|
156
|
-
unit =
|
161
|
+
if unit == "week"
|
162
|
+
n *= 7
|
163
|
+
unit = "day"
|
157
164
|
end
|
158
165
|
# dynamic method call
|
159
166
|
return today.send "prev_#{unit}", n
|
160
167
|
end
|
161
168
|
|
162
|
-
def self.get_webmention_endpoint(
|
169
|
+
def self.get_webmention_endpoint(uri)
|
163
170
|
# log 'info', "Looking for webmention endpoint at #{uri}"
|
164
171
|
begin
|
165
|
-
endpoint = Webmention::Client.supports_webmention?(
|
166
|
-
|
167
|
-
log
|
172
|
+
endpoint = Webmention::Client.supports_webmention?(uri)
|
173
|
+
unless endpoint
|
174
|
+
log "info", "Could not find a webmention endpoint at #{uri}"
|
168
175
|
end
|
169
176
|
rescue => e
|
170
|
-
log
|
177
|
+
log "info", "Endpoint lookup failed for #{uri}: #{e.message}"
|
171
178
|
endpoint = false
|
172
179
|
end
|
173
180
|
endpoint
|
174
181
|
end
|
175
182
|
|
176
|
-
def self.webmention(
|
177
|
-
log
|
178
|
-
#return `curl -s -i -d \"source=#{source}&target=#{target}\" -o /dev/null #{endpoint}`
|
179
|
-
response = Webmention::Client.send_mention(
|
183
|
+
def self.webmention(source, target, endpoint)
|
184
|
+
log "info", "Sending webmention of #{target} in #{source}"
|
185
|
+
# return `curl -s -i -d \"source=#{source}&target=#{target}\" -o /dev/null #{endpoint}`
|
186
|
+
response = Webmention::Client.send_mention(endpoint, source, target, true)
|
180
187
|
if response
|
181
|
-
log
|
188
|
+
log "info", "Webmention successful!"
|
182
189
|
else
|
183
|
-
log
|
190
|
+
log "info", "Webmention failed, but will remain queued for next time"
|
184
191
|
end
|
185
192
|
response
|
186
193
|
end
|
187
194
|
|
188
|
-
def self.get_template_contents(
|
189
|
-
if Jekyll::WebmentionIO
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
+
def self.get_template_contents(template)
|
196
|
+
if Jekyll::WebmentionIO.config.dig("templates", template)
|
197
|
+
# Jekyll::WebmentionIO::log 'info', "Using custom #{template} template"
|
198
|
+
template_file = Jekyll::WebmentionIO.config["templates"][template]
|
199
|
+
else
|
200
|
+
# Jekyll::WebmentionIO::log 'info', "Using default #{template} template"
|
201
|
+
template_file = File.join(File.dirname(File.expand_path(__FILE__)), "templates/#{template}.html")
|
195
202
|
end
|
196
|
-
|
197
|
-
|
198
|
-
|
203
|
+
# Jekyll::WebmentionIO::log 'info', "Template file: #{template_file}"
|
204
|
+
handler = File.open(template_file, "rb")
|
205
|
+
handler.read
|
199
206
|
end
|
200
|
-
|
207
|
+
|
201
208
|
# Connections
|
202
|
-
def self.is_uri_ok(
|
209
|
+
def self.is_uri_ok(uri)
|
203
210
|
uri = URI.parse(URI.encode(uri))
|
204
211
|
now = Time.now.to_s
|
205
|
-
bad_uris = open(@cache_files[
|
212
|
+
bad_uris = open(@cache_files["bad_uris"]) { |f| YAML.safe_load(f) }
|
206
213
|
if bad_uris.key? uri.host
|
207
|
-
last_checked = DateTime.parse(
|
208
|
-
cache_bad_uris_for = @config[
|
214
|
+
last_checked = DateTime.parse(bad_uris[uri.host])
|
215
|
+
cache_bad_uris_for = @config["cache_bad_uris_for"] || 1 # in days
|
209
216
|
recheck_at = last_checked.next_day(cache_bad_uris_for).to_s
|
210
217
|
if recheck_at > now
|
211
218
|
return false
|
@@ -215,23 +222,23 @@ module Jekyll
|
|
215
222
|
end
|
216
223
|
|
217
224
|
# Cache bad URLs for a bit
|
218
|
-
def self.uri_is_not_ok(
|
219
|
-
cache_file = @cache_files[
|
220
|
-
bad_uris = open(cache_file) { |f| YAML.
|
225
|
+
def self.uri_is_not_ok(uri)
|
226
|
+
cache_file = @cache_files["bad_uris"]
|
227
|
+
bad_uris = open(cache_file) { |f| YAML.safe_load(f) }
|
221
228
|
bad_uris[uri.host] = Time.now.to_s
|
222
|
-
File.open(cache_file,
|
229
|
+
File.open(cache_file, "w") { |f| YAML.dump(bad_uris, f) }
|
223
230
|
end
|
224
|
-
|
231
|
+
|
225
232
|
def self.get_uri_source(uri, redirect_limit = 10, original_uri = false)
|
226
|
-
original_uri
|
227
|
-
|
233
|
+
original_uri ||= uri
|
234
|
+
unless is_uri_ok(uri)
|
228
235
|
return false
|
229
236
|
end
|
230
237
|
if redirect_limit > 0
|
231
238
|
uri = URI.parse(URI.encode(uri))
|
232
239
|
http = Net::HTTP.new(uri.host, uri.port)
|
233
240
|
http.read_timeout = 10
|
234
|
-
if uri.scheme ==
|
241
|
+
if uri.scheme == "https"
|
235
242
|
http.use_ssl = true
|
236
243
|
http.ssl_version = :TLSv1
|
237
244
|
http.ciphers = "ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:-LOW"
|
@@ -241,45 +248,45 @@ module Jekyll
|
|
241
248
|
request = Net::HTTP::Get.new(uri.request_uri)
|
242
249
|
response = http.request(request)
|
243
250
|
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, OpenSSL::SSL::SSLError => e
|
244
|
-
log
|
251
|
+
log "warn", "Got an error checking #{original_uri}: #{e}"
|
245
252
|
uri_is_not_ok(uri)
|
246
253
|
return false
|
247
254
|
end
|
248
255
|
case response
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
256
|
+
when Net::HTTPSuccess then
|
257
|
+
return response.body.force_encoding("UTF-8")
|
258
|
+
when Net::HTTPRedirection then
|
259
|
+
redirect_to = URI.parse(URI.encode(response["location"]))
|
260
|
+
redirect_to = redirect_to.relative? ? "#{uri.scheme}://#{uri.host}" + redirect_to.to_s : redirect_to.to_s
|
261
|
+
return get_uri_source(redirect_to, redirect_limit - 1, original_uri)
|
262
|
+
else
|
263
|
+
uri_is_not_ok(uri)
|
264
|
+
return false
|
258
265
|
end
|
259
266
|
else
|
260
267
|
if original_uri
|
261
|
-
log
|
268
|
+
log "warn", "too many redirects for #{original_uri}"
|
262
269
|
end
|
263
270
|
uri_is_not_ok(uri)
|
264
271
|
return false
|
265
272
|
end
|
266
273
|
end
|
267
274
|
|
268
|
-
def self.log(
|
269
|
-
Jekyll.logger.method(type).call(
|
275
|
+
def self.log(type, message)
|
276
|
+
Jekyll.logger.method(type).call("#{@logger_prefix} #{message}")
|
270
277
|
end
|
271
278
|
|
272
279
|
end
|
273
280
|
end
|
274
281
|
|
275
282
|
# Load all the bits
|
276
|
-
Dir[File.dirname(__FILE__) +
|
283
|
+
Dir[File.dirname(__FILE__) + "/commands/*.rb"].each do |file|
|
277
284
|
require file
|
278
285
|
end
|
279
|
-
Dir[File.dirname(__FILE__) +
|
286
|
+
Dir[File.dirname(__FILE__) + "/generators/*.rb"].each do |file|
|
280
287
|
require file
|
281
288
|
end
|
282
289
|
require "#{File.dirname(__FILE__)}/tags/_.rb"
|
283
|
-
Dir[File.dirname(__FILE__) +
|
284
|
-
require file unless file.include?
|
290
|
+
Dir[File.dirname(__FILE__) + "/tags/*.rb"].each do |file|
|
291
|
+
require file unless file.include? "_.rb"
|
285
292
|
end
|
data/lib/jekyll-webmention_io.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "jekyll"
|
2
|
+
require "jekyll/webmention_io"
|
3
3
|
|
4
|
-
Jekyll::WebmentionIO
|
4
|
+
Jekyll::WebmentionIO.bootstrap
|
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.
|
4
|
+
version: 2.8.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-08-
|
11
|
+
date: 2017-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -225,7 +225,7 @@ files:
|
|
225
225
|
- lib/jekyll/assets/liquid.js
|
226
226
|
- lib/jekyll/assets/webmention_counters.js
|
227
227
|
- lib/jekyll/assets/webmention_loader.js
|
228
|
-
- lib/jekyll/assets/webmention_websocket.js
|
228
|
+
- lib/jekyll/assets/webmention_websocket.js.disabled
|
229
229
|
- lib/jekyll/commands/webmention.rb
|
230
230
|
- lib/jekyll/generators/compile_js.rb
|
231
231
|
- lib/jekyll/generators/gather_webmentions.rb
|