-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
87 lines (77 loc) · 2.17 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# frozen_string_literal: true
require 'cgi'
DOMAIN = File.read('CNAME').strip.freeze
URL = "https://#{DOMAIN}"
SITEMAP = "#{URL}/sitemap.xml"
desc 'Ping Pingomatic'
task :pingomatic do
require 'xmlrpc/client'
puts '* Pinging ping-o-matic'
XMLRPC::Client.new('rpc.pingomatic.com', '/')
.call(
'weblogUpdates.extendedPing',
DOMAIN,
URL,
SITEMAP
)
rescue LoadError
puts '! Could not ping ping-o-matic. XMLRPC::Client not found.'
end
desc 'Ping Google'
task :sitemapgoogle do
require 'net/http'
require 'uri'
puts '* Pinging Google about our sitemap'
Net::HTTP.get(
'www.google.com',
'/webmasters/tools/ping?sitemap=' + CGI.escape(SITEMAP)
)
rescue LoadError
puts '! Could not ping Google about sitemap. Net::HTTP not found.'
end
desc 'Ping Bing of the new sitemap'
task :sitemapbing do
require 'net/http'
require 'uri'
puts '* Pinging Bing about our sitemap'
Net::HTTP.get(
'www.bing.com',
'/webmaster/ping.aspx?siteMap=' + CGI.escape(SITEMAP)
)
rescue LoadError
puts '! Could not ping Bing about sitemap. Net::HTTP not found.'
end
desc 'Ping pubsubhubbub server.'
task :pingpubsubhubbub do
require 'net/http'
puts '* Pinging pubsubhubbub server'
data = 'hub.mode=publish&hub.url=' + CGI.escape(SITEMAP)
http = Net::HTTP.new('pubsubhubbub.appspot.com', 80)
resp, data = http.post(
'http://pubsubhubbub.appspot.com/publish',
data,
{ 'Content-Type' => 'application/x-www-form-urlencoded' }
)
puts "Ping error: #{resp}, #{data}" unless resp.code == '204'
end
# rake notify
desc 'Notify various services about new content'
task notify: %i[pingomatic sitemapgoogle sitemapbing pingpubsubhubbub] do
end
desc 'Run htmlproofer'
task :htmlproofer do
require 'html-proofer'
sh 'htmlproofer --assume-extension --empty-alt-ignore ./_site'
# options = { assume_extension: true }
# HTMLProofer.check_directory('./_site', options).run
rescue
puts 'OK'
end
desc 'Run htmlproofer and check external links'
task :external_links do
require 'html-proofer'
sh 'htmlproofer --external_only ./_site'
rescue
puts 'OK'
end
task default: [:notify]