-
-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable watch to prevent race condition between threads calling site.process #320
Changes from 6 commits
fd83a67
1203e14
9e7b78d
efd6ede
4ce5082
c43c34e
0c170bd
82aba50
a573bb5
87f8e2b
9514901
2bf85ae
3652c41
f4d94ab
1d5a49b
5a87555
e26934f
7d086f2
c8fab6c
e1af381
28c4f9c
1f8c8c2
bce59f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,21 +13,15 @@ class Server < Sinatra::Base | |
|
||
put "/*?/?:path.:ext" do | ||
ensure_html_content | ||
write_path = relative_page_path | ||
if request_payload["path"] && request_payload["path"] != relative_page_path | ||
delete_file page_path | ||
write_path = request_payload["path"] | ||
end | ||
|
||
write_file(write_path, page_body) | ||
updated_page = pages.find { |p| p.path == write_path } | ||
render_404 if updated_page.nil? | ||
json updated_page.to_api(:include_content => true) | ||
delete_file path if renamed? | ||
write_file write_path, page_body | ||
ensure_page | ||
json page.to_api(:include_content => true) | ||
end | ||
|
||
delete "/*?/?:path.:ext" do | ||
ensure_page | ||
delete_file page_path | ||
delete_file path | ||
content_type :json | ||
status 200 | ||
halt | ||
|
@@ -52,14 +46,6 @@ def html_content? | |
page.html? | ||
end | ||
|
||
def request_path | ||
sanitized_path request_payload["path"] | ||
end | ||
|
||
def filename | ||
"#{params["path"]}.#{params["ext"]}" | ||
end | ||
|
||
def pages | ||
site.pages.select(&:html?) | ||
end | ||
|
@@ -75,25 +61,13 @@ def directory_paths | |
pages.map { |p| File.dirname(p.path).split("/")[0] }.uniq | ||
end | ||
|
||
def page_path | ||
File.join(directory_path, filename) | ||
end | ||
|
||
def relative_page_path | ||
return filename if params["splat"].first.empty? | ||
File.join(params["splat"].first, filename) | ||
end | ||
|
||
def page | ||
site.pages.find { |p| sanitized_path(p.path) == page_path } | ||
end | ||
|
||
def directory_path | ||
sanitized_path params["splat"].first | ||
end | ||
|
||
def ensure_directory | ||
render_404 unless Dir.exist?(directory_path) | ||
found = site.pages.find { |p| sanitized_path(p.path) == path } | ||
return found if found | ||
return unless File.file?(write_path) | ||
Jekyll::Page.new( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could do either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think he's asking if we want to look to the existing page first then fall back to creating a new one like we do for other content types? |
||
site, site.source, File.dirname(write_path), File.basename(write_path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want the full path for |
||
) | ||
end | ||
|
||
def ensure_page | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
foo: bar2 | ||
--- | ||
|
||
test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really 🆒 You da boss 😎