-
Notifications
You must be signed in to change notification settings - Fork 0
/
jekyll-rakefile.rb
114 lines (94 loc) · 3.13 KB
/
jekyll-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
require "html_compressor"
require 'html-proofer'
##############
# 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 --watch"
end
################
# Validate #
################
# Validate HTML , and missing image alt tags
task :htmlproofer do
Rake::Task['build'].invoke
puts 'Running html proofer...'.yellow.bold
HTMLProofer.check_directory('./_site', allow_hash_href: true,
# ignore missing image alt tags
alt_ignore: [/.*/],
# ignore _site/custom_404.html, _site/custom_50x.html, _site/search.html
file_ignore: [/custom|search/],
# only check links for 404s
only_4xx: true,
# ignore _site/reference b/c API links aren't generated during build; they're generated dynamically by tocify.js when opening page in browser
url_ignore: [/reference/]
).run
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