This repository has been archived by the owner on Jan 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Rakefile
92 lines (75 loc) · 2.14 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
88
89
90
91
92
require "html_compressor"
##############
# Build #
##############
# Generate the site
# Minify, optimize, and compress
desc "build the site"
task :build do
system "bundle exec jekyll build --incremental"
system "bundle exec rake minify_html" #Minify our HTML
end
##############
# Develop #
##############
# Useful for development
# It watches for chagnes and updates when it finds them
desc "Watch the site and regenerate when it changes"
task :watch do
system "bundle exec jekyll serve --baseurl '' --watch"
end
##############
# Deploy #
##############
# Deploy the site
# Ping / Notify after site is deployed
desc "deploy the site"
task :deploy do
system "bundle exec s3_website push"
system "bundle exec rake notify" #ping google/bing about our sitemap updates
end
##############
# Minify #
##############
desc "Minify HTML"
task :minify_html do
puts "## Minifying HTML"
compressor = HtmlCompressor::HtmlCompressor.new
Dir.glob("_site/**/*.html").each do |name|
puts "Minifying #{name}"
input = File.read(name)
output = File.open("#{name}", "w")
output << compressor.compress(input)
output.close
end
end
##############
# Notify #
##############
# Ping Google and Yahoo to let them know you updated your site
site = "www.YOUR-URL.com"
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('#{site}/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 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('#{site}/sitemap.xml'))
rescue LoadError
puts '! Could not ping Bing about our sitemap, because Net::HTTP or URI could not be found.'
end
end
desc "Notify various services about new content"
task :notify => [:sitemapgoogle, :sitemapbing] do
end