Skip to content

Commit

Permalink
Merge branch 'master' into safari-datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
benbalter authored Aug 23, 2016
2 parents 829555a + b29c130 commit 03f13b9
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ For simplicity, whenever possible, the API mirrors Jekyll internal data structur

The API is exposed as `http://localhost:4000/_api` (or whatever server/port your Jekyll installation is running on).

**Note: Prior to version 1.0.0, the HTTP API is to be considered a pre-release API, and is subject to breaking changes without notice. You're welcome (and are encouraged) to build external tools or apps against this API, but as the API is refined and finalized, it may not strictly follow [Semantic Versioning](http://semver.org/) standards.**

### API Request and response payloads

#### Pages and Documents
Expand Down
6 changes: 5 additions & 1 deletion lib/jekyll-admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@

module JekyllAdmin
def self.site
@site ||= Jekyll.sites.first
@site ||= begin
site = Jekyll.sites.first
site.future = true
site
end
end
end
1 change: 1 addition & 0 deletions lib/jekyll-admin/server/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Server < Sinatra::Base
end

write_file(document_path, document_body)
ensure_document
json document.to_api(:include_content => true)
end

Expand Down
1 change: 1 addition & 0 deletions lib/jekyll-admin/server/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Server < Sinatra::Base

put "/:data_file_id" do
write_file(data_file.relative_path, data_file_body)
ensure_data_file_exists
json data_file.to_api(:include_content => true)
end

Expand Down
1 change: 1 addition & 0 deletions lib/jekyll-admin/server/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Server < Sinatra::Base
end

write_file(page_path, page_body)
ensure_page
json page.to_api(:include_content => true)
end

Expand Down
1 change: 1 addition & 0 deletions lib/jekyll-admin/server/static_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Server < Sinatra::Base

put "/*" do
write_file(static_file_path, static_file_body)
ensure_static_file_exists
json static_file.to_api(:include_content => true)
end

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"open:src": "babel-node tools/srcServer.js",
"lint": "esw webpack.config.* src tools",
"lint:watch": "npm run lint -- --watch",
"clean-dist": "npm run remove-dist && mkdir ./lib/jekyll-admin/public",
"clean-dist": "npm run remove-dist && npm run add-dist",
"add-dist": "mkdirp ./lib/jekyll-admin/public",
"remove-dist": "rimraf ./lib/jekyll-admin/public",
"build:html": "babel-node tools/buildHtml.js",
"prebuild": "npm run clean-dist && npm run build:html && npm run lint && npm test",
Expand Down Expand Up @@ -70,6 +71,7 @@
"file-loader": "0.8.5",
"isparta": "4.0.0",
"jsdom": "^9.2.1",
"mkdirp": "^0.5.1",
"mocha": "2.4.5",
"nock": "^8.0.0",
"node-sass": "3.7.0",
Expand Down
11 changes: 10 additions & 1 deletion script/cibuild-node
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,13 @@
set -e

echo "Running Node tests..."
npm test

# We want to run `script/build` on CI to ensure things actually build, but
# we don't want to have to run `script/build` locally every time we run tests
#
# Note: `script/build` runs `npm test` as part of the build process
if [ -n "$CI" ]; then
script/build
else
npm test
fi
17 changes: 17 additions & 0 deletions spec/jekyll-admin/server/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,23 @@ def app
delete_file "_posts/2016-01-01-test2.md"
end

it "writes a new file with a future date" do
future_date = Date.today + 7
delete_file "_posts/#{future_date}-test.md"

request = {
:front_matter => { :foo => "bar" },
:raw_content => "test"
}
put "/collections/posts/#{future_date}-test.md", request.to_json

expect(last_response).to be_ok
expect(last_response_parsed["foo"]).to eq("bar")
expect("_posts/#{future_date}-test.md").to be_an_existing_file

delete_file "_posts/#{future_date}-test.md"
end

context "renaming a file" do
%w(with without).each do |type|
it "renames a file #{type} the collection prefix" do
Expand Down

0 comments on commit 03f13b9

Please sign in to comment.