-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
79 lines (61 loc) · 1.68 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
# encoding: utf-8
require "rubygems"
require "bundler/setup"
require "fileutils"
SITE = "output"
def notify(msg)
system %Q{terminal-notifier -group 'Nanoc' -title "Nanoc" -message "#{msg}"}
end
desc "remove files in output directory"
task :clean do
puts "Removing output..."
Dir["#{SITE}/*"].each { |f| rm_rf(f) }
end
desc "generate website in output directory"
task :generate do
puts "Generating website..."
system "nanoc co --env=production"
notify("Generating site finished")
end
desc "Deploy to production/live website"
task :deploy => [:generate, :thumb] do
puts "Deploying website to server..."
system "nanoc deploy production"
notify("Deploying site finished")
end
desc "Deploy to staging/preview site"
task :staging => [:thumb] do
puts "Generating website for staging..."
system "nanoc co --env=staging"
notify "Generating stating site finished"
system "nanoc deploy staging"
end
def to_thumb(file, output, width)
system(
'magick',
'-resize',
width.to_s,
file,
output
)
end
desc "Create thumbnails of blog post images"
task :thumb do
puts "Creating missing thumbnails ..."
dest = File.join(__dir__, "output", "img", "blog")
FileUtils.mkpath(dest)
Dir[File.join(__dir__, "blog_img", "*")].each do |path|
file = File.basename(path)
out_large = File.join(dest, file)
out_thumb = File.join(dest, file).pathmap "%X-thumbnail%x"
unless File.exist?(out_large) || File.exist?(out_thumb)
puts "... #{file}"
to_thumb(path, out_large, 1200)
to_thumb(path, out_thumb, 500)
end
end
puts "... done."
end
desc "Generate the whole site."
task :generate_all => [ :thumb, :generate ]
task :default => :generate_all