jekyll-webmention_io 2.9.7 → 3.0.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 +4 -4
- data/lib/jekyll-webmention_io.rb +3 -1
- data/lib/jekyll/commands/webmention.rb +2 -2
- data/lib/jekyll/generators/compile_js.rb +8 -6
- data/lib/jekyll/generators/queue_webmentions.rb +4 -4
- data/lib/jekyll/tags/bookmarks.rb +1 -6
- data/lib/jekyll/tags/likes.rb +1 -6
- data/lib/jekyll/tags/links.rb +1 -6
- data/lib/jekyll/tags/posts.rb +1 -6
- data/lib/jekyll/tags/replies.rb +1 -6
- data/lib/jekyll/tags/reposts.rb +1 -6
- data/lib/jekyll/tags/rsvps.rb +1 -6
- data/lib/jekyll/tags/{_.rb → webmention.rb} +1 -1
- data/lib/jekyll/tags/webmention_type.rb +21 -0
- data/lib/jekyll/tags/webmentions_head.rb +1 -1
- data/lib/jekyll/tags/webmentions_js.rb +4 -3
- data/lib/jekyll/webmention_io.rb +27 -17
- data/lib/jekyll/webmention_io/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6830a7a6abb84d8ba34c51b817ad817147561818
|
4
|
+
data.tar.gz: 37956daf8a417c5a9fcbae7e1337c6993a82e746
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db99babf8e9e508f875517cb5890d300362018384e56fa9ac3ca30763cca55d500ad836e4153b66516b2f1ad2f7b5549cab682e83c6da833cd7fa9e20e1da5a
|
7
|
+
data.tar.gz: 788ede8be0748a6baf69e23354996f51155cbd628dec2af8619ea8bcfb855071d5ed6fd57f66a0577884ebd03fc1e10c66991778cafb502fdc261d5f6069c135
|
data/lib/jekyll-webmention_io.rb
CHANGED
@@ -15,13 +15,13 @@ module Jekyll
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.process(_args = [], _options = {})
|
18
|
-
if File.exist?
|
18
|
+
if File.exist? Jekyll::WebmentionIO.cache_file("sent.yml")
|
19
19
|
Jekyll::WebmentionIO.log "error", "Your outgoing webmentions queue needs to be upgraded. Please re-build your project."
|
20
20
|
end
|
21
21
|
count = 0
|
22
22
|
cached_outgoing = Jekyll::WebmentionIO.get_cache_file_path "outgoing"
|
23
23
|
if File.exist?(cached_outgoing)
|
24
|
-
outgoing =
|
24
|
+
outgoing = Jekyll::WebmentionIO.load_yaml(cached_outgoing)
|
25
25
|
outgoing.each do |source, targets|
|
26
26
|
targets.each do |target, response|
|
27
27
|
next unless response == false
|
@@ -45,7 +45,7 @@ module Jekyll
|
|
45
45
|
|
46
46
|
@source_file_destination = (config["source"] == false ? Dir.mktmpdir : "#{@site.config["source"]}/#{config["destination"]}")
|
47
47
|
|
48
|
-
@javascript =
|
48
|
+
@javascript = +"" # unfrozen String
|
49
49
|
|
50
50
|
concatenate_asset_files
|
51
51
|
|
@@ -62,7 +62,9 @@ module Jekyll
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
private
|
65
|
+
private
|
66
|
+
|
67
|
+
def add_webmention_types
|
66
68
|
js_types = []
|
67
69
|
Jekyll::WebmentionIO.types.each do |type|
|
68
70
|
js_types.push "'#{type}': '#{type.to_singular}'"
|
@@ -76,7 +78,7 @@ module Jekyll
|
|
76
78
|
@javascript << types_js.sub(/TYPES/, js_types.join(","))
|
77
79
|
end
|
78
80
|
|
79
|
-
|
81
|
+
def concatenate_asset_files
|
80
82
|
source = File.expand_path("../assets/", __dir__)
|
81
83
|
Dir["#{source}/*.js"].each do |file|
|
82
84
|
handler = File.open(file, "rb")
|
@@ -84,19 +86,19 @@ module Jekyll
|
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
87
|
-
|
89
|
+
def uglify
|
88
90
|
uglify_config = {
|
89
91
|
:harmony => true,
|
90
92
|
}
|
91
93
|
@javascript = Uglifier.new(uglify_config).compile(@javascript)
|
92
94
|
end
|
93
95
|
|
94
|
-
|
96
|
+
def create_js_file
|
95
97
|
Dir.mkdir(@source_file_destination) unless File.exist?(@source_file_destination)
|
96
98
|
File.open("#{@source_file_destination}/#{@file_name}", "w") { |f| f.write(@javascript) }
|
97
99
|
end
|
98
100
|
|
99
|
-
|
101
|
+
def deploy_js_file
|
100
102
|
js_file = Jekyll::WebmentionIO::JavaScriptFile.new(@site, @source_file_destination, "", @file_name)
|
101
103
|
@site.static_files << js_file
|
102
104
|
end
|
@@ -72,13 +72,13 @@ module Jekyll
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def upgrade_outgoing_webmention_cache
|
75
|
-
old_sent_file =
|
76
|
-
old_outgoing_file =
|
75
|
+
old_sent_file = Jekyll::WebmentionIO.cache_file("sent.yml")
|
76
|
+
old_outgoing_file = Jekyll::WebmentionIO.cache_file("queued.yml")
|
77
77
|
unless File.exist? old_sent_file
|
78
78
|
return
|
79
79
|
end
|
80
|
-
sent_webmentions =
|
81
|
-
outgoing_webmentions =
|
80
|
+
sent_webmentions = Jekyll::WebmentionIO.load_yaml(old_sent_file)
|
81
|
+
outgoing_webmentions = Jekyll::WebmentionIO.load_yaml(old_outgoing_file)
|
82
82
|
merged = {}
|
83
83
|
outgoing_webmentions.each do |source_url, webmentions|
|
84
84
|
collection = {}
|
@@ -11,17 +11,12 @@
|
|
11
11
|
#
|
12
12
|
module Jekyll
|
13
13
|
module WebmentionIO
|
14
|
-
class WebmentionBookmarksTag <
|
14
|
+
class WebmentionBookmarksTag < WebmentionTypeTag
|
15
15
|
def initialize(tag_name, text, tokens)
|
16
16
|
super
|
17
17
|
@text = text
|
18
18
|
self.template = "bookmarks"
|
19
19
|
end
|
20
|
-
|
21
|
-
def set_data(data, _types)
|
22
|
-
webmentions = extract_type @template_name, data
|
23
|
-
@data = { "webmentions" => webmentions.values }
|
24
|
-
end
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
data/lib/jekyll/tags/likes.rb
CHANGED
@@ -11,17 +11,12 @@
|
|
11
11
|
#
|
12
12
|
module Jekyll
|
13
13
|
module WebmentionIO
|
14
|
-
class WebmentionLikesTag <
|
14
|
+
class WebmentionLikesTag < WebmentionTypeTag
|
15
15
|
def initialize(tag_name, text, tokens)
|
16
16
|
super
|
17
17
|
@text = text
|
18
18
|
self.template = "likes"
|
19
19
|
end
|
20
|
-
|
21
|
-
def set_data(data, _types)
|
22
|
-
webmentions = extract_type @template_name, data
|
23
|
-
@data = { "webmentions" => webmentions.values }
|
24
|
-
end
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
data/lib/jekyll/tags/links.rb
CHANGED
@@ -11,17 +11,12 @@
|
|
11
11
|
#
|
12
12
|
module Jekyll
|
13
13
|
module WebmentionIO
|
14
|
-
class WebmentionLinksTag <
|
14
|
+
class WebmentionLinksTag < WebmentionTypeTag
|
15
15
|
def initialize(tag_name, text, tokens)
|
16
16
|
super
|
17
17
|
@text = text
|
18
18
|
self.template = "links"
|
19
19
|
end
|
20
|
-
|
21
|
-
def set_data(data, _types)
|
22
|
-
webmentions = extract_type @template_name, data
|
23
|
-
@data = { "webmentions" => webmentions.values }
|
24
|
-
end
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
data/lib/jekyll/tags/posts.rb
CHANGED
@@ -11,17 +11,12 @@
|
|
11
11
|
#
|
12
12
|
module Jekyll
|
13
13
|
module WebmentionIO
|
14
|
-
class WebmentionPostsTag <
|
14
|
+
class WebmentionPostsTag < WebmentionTypeTag
|
15
15
|
def initialize(tag_name, text, tokens)
|
16
16
|
super
|
17
17
|
@text = text
|
18
18
|
self.template = "posts"
|
19
19
|
end
|
20
|
-
|
21
|
-
def set_data(data, _types)
|
22
|
-
webmentions = extract_type @template_name, data
|
23
|
-
@data = { "webmentions" => webmentions.values }
|
24
|
-
end
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
data/lib/jekyll/tags/replies.rb
CHANGED
@@ -11,17 +11,12 @@
|
|
11
11
|
#
|
12
12
|
module Jekyll
|
13
13
|
module WebmentionIO
|
14
|
-
class WebmentionRepliesTag <
|
14
|
+
class WebmentionRepliesTag < WebmentionTypeTag
|
15
15
|
def initialize(tag_name, text, tokens)
|
16
16
|
super
|
17
17
|
@text = text
|
18
18
|
self.template = "replies"
|
19
19
|
end
|
20
|
-
|
21
|
-
def set_data(data, _types)
|
22
|
-
webmentions = extract_type @template_name, data
|
23
|
-
@data = { "webmentions" => webmentions.values }
|
24
|
-
end
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
data/lib/jekyll/tags/reposts.rb
CHANGED
@@ -11,17 +11,12 @@
|
|
11
11
|
#
|
12
12
|
module Jekyll
|
13
13
|
module WebmentionIO
|
14
|
-
class WebmentionRepostsTag <
|
14
|
+
class WebmentionRepostsTag < WebmentionTypeTag
|
15
15
|
def initialize(tag_name, text, tokens)
|
16
16
|
super
|
17
17
|
@text = text
|
18
18
|
self.template = "reposts"
|
19
19
|
end
|
20
|
-
|
21
|
-
def set_data(data, _types)
|
22
|
-
webmentions = extract_type @template_name, data
|
23
|
-
@data = { "webmentions" => webmentions.values }
|
24
|
-
end
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
data/lib/jekyll/tags/rsvps.rb
CHANGED
@@ -11,17 +11,12 @@
|
|
11
11
|
#
|
12
12
|
module Jekyll
|
13
13
|
module WebmentionIO
|
14
|
-
class WebmentionRsvpsTag <
|
14
|
+
class WebmentionRsvpsTag < WebmentionTypeTag
|
15
15
|
def initialize(tag_name, text, tokens)
|
16
16
|
super
|
17
17
|
@text = text
|
18
18
|
self.template = "rsvps"
|
19
19
|
end
|
20
|
-
|
21
|
-
def set_data(data, _types)
|
22
|
-
webmentions = extract_type @template_name, data
|
23
|
-
@data = { "webmentions" => webmentions.values }
|
24
|
-
end
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# (c) Aaron Gustafson
|
4
|
+
# https://github.com/aarongustafson/jekyll-webmention_io
|
5
|
+
# Licence : MIT
|
6
|
+
#
|
7
|
+
# this liquid plugin insert a webmentions into your Octopress or Jekyll blog
|
8
|
+
# using http://webmention.io/
|
9
|
+
#
|
10
|
+
module Jekyll
|
11
|
+
module WebmentionIO
|
12
|
+
# Superclass for Webmention types:
|
13
|
+
# [ bookmarks | likes | links | posts | replies | reposts | rsvps ]
|
14
|
+
class WebmentionTypeTag < WebmentionTag
|
15
|
+
def set_data(data, _types)
|
16
|
+
webmentions = extract_type @template_name, data
|
17
|
+
@data = { "webmentions" => webmentions.values }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -11,7 +11,7 @@ module Jekyll
|
|
11
11
|
module WebmentionIO
|
12
12
|
class WebmentionHeadTag < Liquid::Tag
|
13
13
|
def render(context)
|
14
|
-
head =
|
14
|
+
head = +"" # unfrozen String
|
15
15
|
head << '<link rel="dns-prefetch" href="https://webmention.io">'
|
16
16
|
head << '<link rel="preconnect" href="https://webmention.io">'
|
17
17
|
head << '<link rel="preconnect" href="ws://webmention.io:8080">'
|
@@ -27,14 +27,15 @@ module Jekyll
|
|
27
27
|
config = config.merge(site_config)
|
28
28
|
|
29
29
|
# JS file
|
30
|
-
js =
|
30
|
+
js = +"" # unfrozen String
|
31
31
|
unless config["deploy"] == false
|
32
|
-
|
32
|
+
destination = config["destination"].chomp("/").reverse.chomp("/").reverse # removes prefix & suffix "/"
|
33
|
+
js_file_path = "#{site.config["baseurl"]}/#{destination}/JekyllWebmentionIO.js"
|
33
34
|
js << "<script src=\"#{js_file_path}\" async></script>"
|
34
35
|
end
|
35
36
|
|
36
37
|
Jekyll::WebmentionIO.log "info", "Gathering templates for JavaScript."
|
37
|
-
templates =
|
38
|
+
templates = +"" # unfrozen String
|
38
39
|
template_files = Jekyll::WebmentionIO.types + %w(count webmentions)
|
39
40
|
template_files.each do |template|
|
40
41
|
templates << "<template style=\"display:none\" id=\"webmention-#{template}\">"
|
data/lib/jekyll/webmention_io.rb
CHANGED
@@ -41,21 +41,21 @@ module Jekyll
|
|
41
41
|
OpenSSL::SSL::SSLError,
|
42
42
|
].freeze
|
43
43
|
|
44
|
-
def self.bootstrap
|
45
|
-
|
46
|
-
@jekyll_config =
|
44
|
+
def self.bootstrap(site)
|
45
|
+
@site = site
|
46
|
+
@jekyll_config = site.config
|
47
47
|
@config = @jekyll_config["webmentions"] || {}
|
48
48
|
|
49
49
|
# Set up the cache folder & files
|
50
|
-
@cache_folder = @config["cache_folder"] || ".jekyll-cache"
|
50
|
+
@cache_folder = site.in_source_dir(@config["cache_folder"] || ".jekyll-cache")
|
51
51
|
Dir.mkdir(@cache_folder) unless File.exist?(@cache_folder)
|
52
52
|
@file_prefix = ""
|
53
53
|
@file_prefix = "webmention_io_" unless @cache_folder.include? "webmention"
|
54
54
|
@cache_files = {
|
55
|
-
"incoming" => "
|
56
|
-
"outgoing" => "
|
57
|
-
"bad_uris" => "
|
58
|
-
"lookups" => "
|
55
|
+
"incoming" => cache_file("received.yml"),
|
56
|
+
"outgoing" => cache_file("outgoing.yml"),
|
57
|
+
"bad_uris" => cache_file("bad_uris.yml"),
|
58
|
+
"lookups" => cache_file("lookups.yml")
|
59
59
|
}
|
60
60
|
@cache_files.each_value do |file|
|
61
61
|
unless File.exist?(file)
|
@@ -69,7 +69,11 @@ module Jekyll
|
|
69
69
|
@api_endpoint = "#{@api_url}/#{path}"
|
70
70
|
end
|
71
71
|
|
72
|
-
#
|
72
|
+
# Helpers
|
73
|
+
def self.cache_file(filename)
|
74
|
+
Jekyll.sanitized_path(@cache_folder, "#{@file_prefix}#{filename}")
|
75
|
+
end
|
76
|
+
|
73
77
|
def self.get_cache_file_path(key)
|
74
78
|
path = false
|
75
79
|
if @cache_files.key? key
|
@@ -84,9 +88,7 @@ module Jekyll
|
|
84
88
|
end
|
85
89
|
|
86
90
|
cache_file = get_cache_file_path which
|
87
|
-
|
88
|
-
|
89
|
-
cached_webmentions
|
91
|
+
load_yaml(cache_file)
|
90
92
|
end
|
91
93
|
|
92
94
|
def self.cache_webmentions(which, webmentions)
|
@@ -140,8 +142,7 @@ module Jekyll
|
|
140
142
|
|
141
143
|
def self.read_lookup_dates()
|
142
144
|
cache_file = get_cache_file_path "lookups"
|
143
|
-
|
144
|
-
lookups
|
145
|
+
load_yaml(cache_file)
|
145
146
|
end
|
146
147
|
|
147
148
|
def self.cache_lookup_dates(lookups)
|
@@ -286,6 +287,14 @@ module Jekyll
|
|
286
287
|
File.open(file, "wb") { |f| f.puts YAML.dump(data) }
|
287
288
|
end
|
288
289
|
|
290
|
+
# Utility Method
|
291
|
+
# Safely parse given YAML +file+ path and return data.
|
292
|
+
#
|
293
|
+
# Returns empty hash if parsing fails to return data
|
294
|
+
def self.load_yaml(file)
|
295
|
+
SafeYAML.load_file(file) || {}
|
296
|
+
end
|
297
|
+
|
289
298
|
private
|
290
299
|
|
291
300
|
def self.get_http_response(uri)
|
@@ -315,7 +324,7 @@ module Jekyll
|
|
315
324
|
# Never cache webmention.io in here
|
316
325
|
return if uri.host == "webmention.io"
|
317
326
|
cache_file = @cache_files["bad_uris"]
|
318
|
-
bad_uris =
|
327
|
+
bad_uris = load_yaml(cache_file)
|
319
328
|
bad_uris[uri.host] = Time.now.to_s
|
320
329
|
dump_yaml(cache_file, bad_uris)
|
321
330
|
end
|
@@ -323,7 +332,7 @@ module Jekyll
|
|
323
332
|
def self.uri_ok?(uri)
|
324
333
|
uri = URI.parse(URI.encode(uri))
|
325
334
|
now = Time.now.to_s
|
326
|
-
bad_uris =
|
335
|
+
bad_uris = load_yaml(@cache_files["bad_uris"])
|
327
336
|
if bad_uris.key? uri.host
|
328
337
|
last_checked = DateTime.parse(bad_uris[uri.host])
|
329
338
|
cache_bad_uris_for = @config["cache_bad_uris_for"] || 1 # in days
|
@@ -345,5 +354,6 @@ end
|
|
345
354
|
require_all "commands"
|
346
355
|
require_all "generators"
|
347
356
|
|
348
|
-
require_relative "tags/
|
357
|
+
require_relative "tags/webmention"
|
358
|
+
require_relative "tags/webmention_type"
|
349
359
|
require_all "tags"
|
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:
|
4
|
+
version: 3.0.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-
|
11
|
+
date: 2018-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -232,7 +232,6 @@ files:
|
|
232
232
|
- lib/jekyll/generators/compile_js.rb
|
233
233
|
- lib/jekyll/generators/gather_webmentions.rb
|
234
234
|
- lib/jekyll/generators/queue_webmentions.rb
|
235
|
-
- lib/jekyll/tags/_.rb
|
236
235
|
- lib/jekyll/tags/bookmarks.rb
|
237
236
|
- lib/jekyll/tags/count.rb
|
238
237
|
- lib/jekyll/tags/likes.rb
|
@@ -241,6 +240,8 @@ files:
|
|
241
240
|
- lib/jekyll/tags/replies.rb
|
242
241
|
- lib/jekyll/tags/reposts.rb
|
243
242
|
- lib/jekyll/tags/rsvps.rb
|
243
|
+
- lib/jekyll/tags/webmention.rb
|
244
|
+
- lib/jekyll/tags/webmention_type.rb
|
244
245
|
- lib/jekyll/tags/webmentions.rb
|
245
246
|
- lib/jekyll/tags/webmentions_head.rb
|
246
247
|
- lib/jekyll/tags/webmentions_js.rb
|