-
Notifications
You must be signed in to change notification settings - Fork 14
/
Rakefile.rb
117 lines (100 loc) · 3.36 KB
/
Rakefile.rb
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
##############
# Jekyll tasks
##############
# Usage: rake serve, rake serve:prod
task :serve => ["serve:dev"]
namespace :serve do
desc "Serve development Jekyll site locally"
task :dev do
puts "Starting up development Jekyll site server..."
system "JEKYLL_ENV=development bundle exec jekyll serve --incremental --config _config.yml,_config.dev.yml"
end
desc "Serve production Jekyll site locally"
task :prod do
puts "Starting up production Jekyll site server..."
system "JEKYLL_ENV=production bundle exec jekyll serve --no-watch"
end
end
# Usage: rake build, rake build:dev, rake build:drafts
task :build => ["build:prod"]
namespace :build do
desc "Regenerate files for production"
task :prod do
puts "* Regenerating files for production..."
system "JEKYLL_ENV=production bundle exec jekyll build"
end
desc "Regenerate files for development"
task :dev do
puts "* Regenerating files for development..."
system "bundle exec jekyll build --config _config.yml,_config.dev.yml --profile"
end
desc "Regenerate files and drafts for development"
task :drafts do
puts "* Regenerating files and drafts for development..."
system "bundle exec jekyll build --config _config.yml,_config.dev.yml --profile --drafts"
end
end
####################
# Notification tasks
####################
# Usage: rake notify
task :notify => ["notify:pingomatic", "notify:google", "notify:bing"]
desc "Notify various services that the site has been updated"
namespace :notify do
desc "Notify Ping-O-Matic"
task :pingomatic do
begin
require 'xmlrpc/client'
puts "* Notifying Ping-O-Matic that the site has updated"
XMLRPC::Client.new('rpc.pingomatic.com', '/').call('weblogUpdates.extendedPing', 'habd.as' , 'https://habd.as', 'https://habd.as/feed.xml')
rescue LoadError
puts "! Could not ping ping-o-matic, because XMLRPC::Client could not be found."
end
end
desc "Notify Google of updated sitemap"
task :google do
begin
require 'net/http'
require 'uri'
puts "* Notifying Google that the site has updated"
Net::HTTP.get('www.google.com', '/webmasters/tools/ping?sitemap=' + URI.escape('https://habd.as/sitemap.xml'))
rescue LoadError
puts "! Could not ping Google about our sitemap, because Net::HTTP or URI could not be found."
end
end
desc "Notify Bing of updated sitemap"
task :bing do
begin
require 'net/http'
require 'uri'
puts '* Notifying Bing that the site has updated'
Net::HTTP.get('www.bing.com', '/webmaster/ping.aspx?siteMap=' + URI.escape('https://habd.as/sitemap.xml'))
rescue LoadError
puts "! Could not ping Bing about our sitemap, because Net::HTTP or URI could not be found."
end
end
end
###############
# Testing tasks
###############
task :test do
require 'html-proofer'
sh "bundle exec jekyll build"
HTMLProofer.check_directory("./_site").run
end
##################
# Deployment tasks
##################
# Usage: rake gh_pages
desc "push the contents of ./_site to gh-pages"
task :gh_pages do
puts "* now we are ready to syn the contents of ./_site to the gh-pages"
system "ls -lah _site"
end
# Usage: rake deploy
task :deploy => ["deploy:prod"]
namespace :deploy do
desc "Regenerate and sync production files, and notify services of the update"
task :prod => ["build", "gh_pages", "notify"] do
end
end