compile the blog when it changes

This commit is contained in:
Sami Samhuri 2015-03-29 22:01:42 -07:00
parent aade9641e4
commit 75bd85d66f
2 changed files with 20 additions and 0 deletions

View file

@ -25,6 +25,7 @@ class HarpBlog
@dry_run = dry_run
@title_finder = title_finder || WebTitleFinder.new
@version_finder = version_finder || WebVersionFinder.new
@mutated = false
end
def local_version
@ -153,6 +154,15 @@ class HarpBlog
run("make #{target}")
end
def compile
run('make compile')
@mutated = false
end
def compile_if_mutated
compile if @mutated
end
private
@ -220,6 +230,7 @@ class HarpBlog
write_post(post)
git_commit(action, post.title, post_path(post.dir))
git_push
@mutated = true
post
rescue => e
@ -250,6 +261,7 @@ class HarpBlog
post_dir = post_path(post_dir)
delete_post_body(post_dir, id)
delete_post_index(post_dir, id)
@mutated = true
end
def write_post_body(dir, id, body)

View file

@ -82,6 +82,14 @@ before do
end
end
after do
start = Time.now
if blog.compile_if_mutated
duration = Time.now.to_f - start.to_f
puts "Compiled blog in #{duration.round}ms"
end
end
# status
get '/status' do
status 200