forked from mmistakes/made-mistakes-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile.rb
87 lines (76 loc) · 2.64 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
##############
# Jekyll tasks
##############
# Usage: rake serve
desc "Serve Jekyll site locally"
task :serve do
system "bundle exec jekyll serve --no-watch --config _config.dev.yml"
end # task :serve
# Usage: rake build
desc "Build production Jekyll site"
task :build do
system "bundle exec jekyll build"
end # task :build
# Usage: rake drafts
desc "Build local Jekyll site with _drafts posts"
task :drafts do
system "bundle exec jekyll build --drafts --config _config.dev.yml"
end # task :drafts
##################
# Production tasks
##################
# Usage: rake minify
desc "Minify files"
task :minify do
puts '* Minifying files'
system "java -jar _build/htmlcompressor.jar -r --type html --compress-js -o _site _site"
end # task :minify
# Ping Pingomatic
desc 'Ping pingomatic'
task :pingomatic do
begin
require 'xmlrpc/client'
puts '* Pinging ping-o-matic'
XMLRPC::Client.new('rpc.pingomatic.com', '/').call('weblogUpdates.extendedPing', 'mademistakes.com' , 'https://mademistakes.com', 'https://mademistakes.com/atom.xml')
rescue LoadError
puts '! Could not ping ping-o-matic, because XMLRPC::Client could not be found.'
end
end # task :pingomatic
# Ping Google
desc 'Notify Google of the new sitemap'
task :sitemapgoogle do
begin
require 'net/http'
require 'uri'
puts '* Pinging Google about our sitemap'
Net::HTTP.get('www.google.com', '/webmasters/tools/ping?sitemap=' + URI.escape('https://mademistakes.com/sitemap.xml'))
rescue LoadError
puts '! Could not ping Google about our sitemap, because Net::HTTP or URI could not be found.'
end
end # task :sitemapgoogle
# Ping Bing
desc 'Notify Bing of the new sitemap'
task :sitemapbing do
begin
require 'net/http'
require 'uri'
puts '* Pinging Bing about our sitemap'
Net::HTTP.get('www.bing.com', '/webmaster/ping.aspx?siteMap=' + URI.escape('https://mademistakes.com/sitemap.xml'))
rescue LoadError
puts '! Could not ping Bing about our sitemap, because Net::HTTP or URI could not be found.'
end
end # task :sitemapbing
# Usage: rake notify
desc 'Notify various services about new content'
task :notify => [:pingomatic, :sitemapgoogle, :sitemapbing] do
end # task :notify
# Usage: rake rsync
desc 'rsync the contents of ./_site to the server'
task :rsync do
puts '* rsyncing the contents of ./_site to the server'
system 'rsync -prvz --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r _site/ [email protected]:domains/mademistakes.com/html/'
end # task :rsync
# Usage: rake deploy
desc 'Build _site, minify files, rsync the files, and notify services about new content'
task :deploy => [:build, :minify, :rsync, :notify] do
end # task :deploy