-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
48 lines (39 loc) · 894 Bytes
/
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
namespace :site do
desc "Removes generated content"
task :clean do
rm_rf "_site/"
end
desc "Generates site"
task :generate do
system "jekyll"
end
desc "Opens generated site in new browser tab"
task :preview do
t = Thread.new {
Rake::Task["server:start"].execute
}
system("open http://localhost:4000/")
trap("INT") { t.kill }
t.join
end
end
namespace :server do
desc "Starts server with generated site"
task :start do
require 'webrick'
include WEBrick
mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
mime_types.store 'js', 'application/javascript'
s = HTTPServer.new(
:Port => 4000,
:MimeTypes => mime_types
)
s.mount("/", HTTPServlet::FileHandler, "_site/")
t = Thread.new {
s.start
}
trap("INT") { s.shutdown }
t.join()
end
end
task :default => :"site:generate"