diff --git a/server/harp_blog.rb b/server/harp_blog.rb index 4e8d3c0..61067d2 100644 --- a/server/harp_blog.rb +++ b/server/harp_blog.rb @@ -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) diff --git a/server/server.rb b/server/server.rb index 1af77b7..ebd8fc5 100755 --- a/server/server.rb +++ b/server/server.rb @@ -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