Skip to content

Commit

Permalink
Merge pull request #415 from jekyll/race
Browse files Browse the repository at this point in the history
Bring watch back
  • Loading branch information
mertkahyaoglu authored Sep 24, 2017
2 parents 1485512 + b54a9a4 commit c16185f
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 22 deletions.
1 change: 0 additions & 1 deletion lib/jekyll-admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def self.site

# Monkey Patches
require_relative "./jekyll/commands/serve"
require_relative "./jekyll/commands/build"

[Jekyll::Page, Jekyll::Document, Jekyll::StaticFile, Jekyll::Collection].each do |klass|
klass.include JekyllAdmin::APIable
Expand Down
12 changes: 11 additions & 1 deletion lib/jekyll-admin/file_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ def write_file(path, content)
File.open(path, "wb") do |file|
file.write(content)
end
site.process
# we should fully process in dev mode for tests to pass
if ENV["RACK_ENV"] == "production"
site.read
else
site.process
end
end

# Delete the file at the given path
Expand All @@ -31,6 +36,11 @@ def delete_file(path)
site.process
end

def delete_file_without_process(path)
Jekyll.logger.debug "DELETING:", path
FileUtils.rm_f sanitized_path(path)
end

private

def ensure_requested_file
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll-admin/server/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Server < Sinatra::Base

if renamed?
ensure_requested_file
delete_file path
delete_file_without_process path
end

write_file write_path, document_body
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll-admin/server/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Server < Sinatra::Base
put "/*?/?:path.:ext" do
if renamed?
ensure_requested_file
delete_file path
delete_file_without_process path
end

write_file write_path, data_file_body
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll-admin/server/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Server < Sinatra::Base

if renamed?
ensure_requested_file
delete_file path
delete_file_without_process path
end

write_file write_path, page_body
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll-admin/server/static_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Server < Sinatra::Base
put "/*" do
if renamed?
ensure_requested_file
delete_file path
delete_file_without_process path
end

write_file(write_path, static_file_body)
Expand Down
14 changes: 0 additions & 14 deletions lib/jekyll/commands/build.rb

This file was deleted.

2 changes: 0 additions & 2 deletions lib/jekyll/commands/serve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def start_up_webrick(opts, destination)
def jekyll_admin_monkey_patch(server)
server.mount "/admin", Rack::Handler::WEBrick, JekyllAdmin::StaticServer
server.mount "/_api", Rack::Handler::WEBrick, JekyllAdmin::Server
Jekyll.logger.warn "Auto-regeneration:", "disabled by JekyllAdmin."
Jekyll.logger.warn "", "The site will regenerate only via the Admin interface."
Jekyll.logger.info "JekyllAdmin mode:", ENV["RACK_ENV"] || "production"
end
end
Expand Down

0 comments on commit c16185f

Please sign in to comment.