18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/jekyll/generators/gather_webmentions.rb', line 18
def generate(site)
@site = site
@site_url = site.config["url"].to_s
if @site.config['serving']
Jekyll::WebmentionIO.log "msg", "Webmentions won’t be gathered when running `jekyll serve`."
@site.config['webmentions'] ||= {}
@site.config['webmentions']['pause_lookups'] = true
return
end
if @site_url.include? "localhost"
Jekyll::WebmentionIO.log "msg", "Webmentions won’t be gathered on localhost."
return
end
if @site.config.dig("webmentions", "pause_lookups") == true
WebmentionIO.log "msg", "Webmention gathering is currently paused."
return
end
WebmentionIO.log "msg", "Beginning to gather webmentions of your posts. This may take a while."
WebmentionIO.api_path = "mentions"
WebmentionIO.api_suffix = "&perPage=9999"
@cached_webmentions = WebmentionIO.read_cached_webmentions "incoming"
@lookups = WebmentionIO.read_lookup_dates
posts = WebmentionIO.gather_documents(@site)
posts.each do |post|
check_for_webmentions(post)
end
WebmentionIO.cache_lookup_dates @lookups
WebmentionIO.cache_webmentions "incoming", @cached_webmentions
end
|