jekyll-webmention_io 2.9.3 → 2.9.5

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: df2d1e232da80abf4e83e052708a43d24b8f1a3d
4
- data.tar.gz: d15ceae3bf7c5877f8051d9b7a451e96505b8ba6
3
+ metadata.gz: cd122620cc5cf4d2195470575097895be9183d57
4
+ data.tar.gz: 26ff0f36663bc3134fedd02931c423de07d40072
5
5
  SHA512:
6
- metadata.gz: 4f0940b1a66eefda4f6b2152d02595004197581ebebadf327ca9b16e06ed6634d834cdddf4e14b06142c3b0b1598057f5969f976eed548b2f7419aaa6c4508a2
7
- data.tar.gz: 4e20719a96f174cc00ea0e6529726bce2dbedb322136c1ceca958f7c231c59d427a66b4cfdb6452e37ee568512d8c4fb65d8e328ae6b76ecac0d343fe96b3d24
6
+ metadata.gz: 6f159198178ae48701cd58269466e807293a5c4db23164ffa958815efbd56f113373eddd58e240d9ced395b5b48e864cd59155e2053aec290931b155b88ba9ff
7
+ data.tar.gz: 475202c106eeaff3c98c565bfcabd754f1703e9b5f2174a25b783304c98a4d7a0348c4c963f944c0a18e897d6381f958278b6ed99c05eb0a3dab25e8ecbdeb5c
@@ -35,11 +35,15 @@ module Jekyll
35
35
 
36
36
  @cached_webmentions = Jekyll::WebmentionIO.read_cached_webmentions "incoming"
37
37
 
38
+ @lookups = Jekyll::WebmentionIO.read_lookup_dates
39
+
38
40
  posts = Jekyll::WebmentionIO.gather_documents(@site)
39
41
  posts.each do |post|
40
42
  check_for_webmentions(post)
41
43
  end
42
44
 
45
+ Jekyll::WebmentionIO.cache_lookup_dates @lookups
46
+
43
47
  Jekyll::WebmentionIO.cache_webmentions "incoming", @cached_webmentions
44
48
  end # generate
45
49
 
@@ -48,12 +52,18 @@ module Jekyll
48
52
  def check_for_webmentions(post)
49
53
  Jekyll::WebmentionIO.log "info", "Checking for webmentions of #{post.url}."
50
54
 
51
- # get the last webmention
52
55
  last_webmention = @cached_webmentions.dig(post.url, @cached_webmentions.dig(post.url)&.keys&.last)
53
56
 
57
+ # get the last webmention
58
+ last_lookup = if @lookups[post.url]
59
+ @lookups[post.url]
60
+ else
61
+ Date.parse last_webmention.dig("raw", "verified_date")
62
+ end
63
+
54
64
  # should we throttle?
55
65
  if post.respond_to? "date" # Some docs have no date
56
- if last_webmention && Jekyll::WebmentionIO.post_should_be_throttled?(post, post.date, last_webmention.dig("raw", "verified_date"))
66
+ if last_lookup && Jekyll::WebmentionIO.post_should_be_throttled?(post, post.date, last_lookup)
57
67
  Jekyll::WebmentionIO.log "info", "Throttling this post."
58
68
  return
59
69
  end
@@ -74,6 +84,7 @@ module Jekyll
74
84
  Jekyll::WebmentionIO.log "info", "No webmentions found."
75
85
  end
76
86
 
87
+ @lookups[post.url] = Date.today
77
88
  cache_new_webmentions(post.url, response)
78
89
  end
79
90
 
@@ -49,6 +49,7 @@ module Jekyll
49
49
  "incoming" => "#{@cache_folder}/#{@file_prefix}received.yml",
50
50
  "outgoing" => "#{@cache_folder}/#{@file_prefix}outgoing.yml",
51
51
  "bad_uris" => "#{@cache_folder}/#{@file_prefix}bad_uris.yml",
52
+ "lookups" => "#{@cache_folder}/#{@file_prefix}lookups.yml"
52
53
  }
53
54
  @cache_files.each do |_key, file|
54
55
  unless File.exist?(file)
@@ -160,14 +161,27 @@ module Jekyll
160
161
  end
161
162
  end
162
163
 
164
+ def self.read_lookup_dates()
165
+ cache_file = get_cache_file_path "lookups"
166
+ lookups = open(cache_file) { |f| YAML.load(f) }
167
+ lookups
168
+ end
169
+
170
+ def self.cache_lookup_dates(lookups)
171
+ cache_file = get_cache_file_path "lookups"
172
+ File.open(cache_file, "w") { |f| YAML.dump(lookups, f) }
173
+
174
+ Jekyll::WebmentionIO.log "msg", "Lookups have been cached."
175
+ end
176
+
163
177
  # allowed throttles: last_week, last_month, last_year, older
164
178
  # allowed values: daily, weekly, monthly, yearly, every X days|weeks|months|years
165
- def self.post_should_be_throttled?(post, item_date, last_webmention_date)
179
+ def self.post_should_be_throttled?(post, item_date, last_lookup)
166
180
  throttles = @config.dig("throttle_lookups")
167
- if throttles && item_date && last_webmention_date
181
+ if throttles && item_date && last_lookup
168
182
  age = get_timeframe_from_date(item_date)
169
183
  throttle = throttles.dig(age)
170
- if throttle && Date.parse(last_webmention_date) >= get_date_from_string(throttle)
184
+ if throttle && last_lookup >= get_date_from_string(throttle)
171
185
  log "info", "Throttling #{post.data["title"]} (Only checking it #{throttle})"
172
186
  return true
173
187
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module WebmentionIO
5
- VERSION = "2.9.3".freeze
5
+ VERSION = "2.9.5".freeze
6
6
  end
7
7
  end
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.9.3
4
+ version: 2.9.5
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-06-29 00:00:00.000000000 Z
11
+ date: 2018-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll