mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-27 14:57:40 +00:00
compile the blog when it changes
This commit is contained in:
parent
aade9641e4
commit
75bd85d66f
2 changed files with 20 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ class HarpBlog
|
||||||
@dry_run = dry_run
|
@dry_run = dry_run
|
||||||
@title_finder = title_finder || WebTitleFinder.new
|
@title_finder = title_finder || WebTitleFinder.new
|
||||||
@version_finder = version_finder || WebVersionFinder.new
|
@version_finder = version_finder || WebVersionFinder.new
|
||||||
|
@mutated = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_version
|
def local_version
|
||||||
|
|
@ -153,6 +154,15 @@ class HarpBlog
|
||||||
run("make #{target}")
|
run("make #{target}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def compile
|
||||||
|
run('make compile')
|
||||||
|
@mutated = false
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile_if_mutated
|
||||||
|
compile if @mutated
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
@ -220,6 +230,7 @@ class HarpBlog
|
||||||
write_post(post)
|
write_post(post)
|
||||||
git_commit(action, post.title, post_path(post.dir))
|
git_commit(action, post.title, post_path(post.dir))
|
||||||
git_push
|
git_push
|
||||||
|
@mutated = true
|
||||||
post
|
post
|
||||||
|
|
||||||
rescue => e
|
rescue => e
|
||||||
|
|
@ -250,6 +261,7 @@ class HarpBlog
|
||||||
post_dir = post_path(post_dir)
|
post_dir = post_path(post_dir)
|
||||||
delete_post_body(post_dir, id)
|
delete_post_body(post_dir, id)
|
||||||
delete_post_index(post_dir, id)
|
delete_post_index(post_dir, id)
|
||||||
|
@mutated = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_post_body(dir, id, body)
|
def write_post_body(dir, id, body)
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,14 @@ before do
|
||||||
end
|
end
|
||||||
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
|
# status
|
||||||
get '/status' do
|
get '/status' do
|
||||||
status 200
|
status 200
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue