Skip to content

Commit 03f13b9

Browse files
authored
Merge branch 'master' into safari-datetime
2 parents 829555a + b29c130 commit 03f13b9

File tree

9 files changed

+41
-3
lines changed

9 files changed

+41
-3
lines changed

docs/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ For simplicity, whenever possible, the API mirrors Jekyll internal data structur
99

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

12+
**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.**
13+
1214
### API Request and response payloads
1315

1416
#### Pages and Documents

lib/jekyll-admin.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838

3939
module JekyllAdmin
4040
def self.site
41-
@site ||= Jekyll.sites.first
41+
@site ||= begin
42+
site = Jekyll.sites.first
43+
site.future = true
44+
site
45+
end
4246
end
4347
end

lib/jekyll-admin/server/collection.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Server < Sinatra::Base
3333
end
3434

3535
write_file(document_path, document_body)
36+
ensure_document
3637
json document.to_api(:include_content => true)
3738
end
3839

lib/jekyll-admin/server/data.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Server < Sinatra::Base
1515

1616
put "/:data_file_id" do
1717
write_file(data_file.relative_path, data_file_body)
18+
ensure_data_file_exists
1819
json data_file.to_api(:include_content => true)
1920
end
2021

lib/jekyll-admin/server/page.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Server < Sinatra::Base
1818
end
1919

2020
write_file(page_path, page_body)
21+
ensure_page
2122
json page.to_api(:include_content => true)
2223
end
2324

lib/jekyll-admin/server/static_file.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Server < Sinatra::Base
1717

1818
put "/*" do
1919
write_file(static_file_path, static_file_body)
20+
ensure_static_file_exists
2021
json static_file.to_api(:include_content => true)
2122
end
2223

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"open:src": "babel-node tools/srcServer.js",
1111
"lint": "esw webpack.config.* src tools",
1212
"lint:watch": "npm run lint -- --watch",
13-
"clean-dist": "npm run remove-dist && mkdir ./lib/jekyll-admin/public",
13+
"clean-dist": "npm run remove-dist && npm run add-dist",
14+
"add-dist": "mkdirp ./lib/jekyll-admin/public",
1415
"remove-dist": "rimraf ./lib/jekyll-admin/public",
1516
"build:html": "babel-node tools/buildHtml.js",
1617
"prebuild": "npm run clean-dist && npm run build:html && npm run lint && npm test",
@@ -70,6 +71,7 @@
7071
"file-loader": "0.8.5",
7172
"isparta": "4.0.0",
7273
"jsdom": "^9.2.1",
74+
"mkdirp": "^0.5.1",
7375
"mocha": "2.4.5",
7476
"nock": "^8.0.0",
7577
"node-sass": "3.7.0",

script/cibuild-node

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,13 @@
33
set -e
44

55
echo "Running Node tests..."
6-
npm test
6+
7+
# We want to run `script/build` on CI to ensure things actually build, but
8+
# we don't want to have to run `script/build` locally every time we run tests
9+
#
10+
# Note: `script/build` runs `npm test` as part of the build process
11+
if [ -n "$CI" ]; then
12+
script/build
13+
else
14+
npm test
15+
fi

spec/jekyll-admin/server/collection_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,23 @@ def app
195195
delete_file "_posts/2016-01-01-test2.md"
196196
end
197197

198+
it "writes a new file with a future date" do
199+
future_date = Date.today + 7
200+
delete_file "_posts/#{future_date}-test.md"
201+
202+
request = {
203+
:front_matter => { :foo => "bar" },
204+
:raw_content => "test"
205+
}
206+
put "/collections/posts/#{future_date}-test.md", request.to_json
207+
208+
expect(last_response).to be_ok
209+
expect(last_response_parsed["foo"]).to eq("bar")
210+
expect("_posts/#{future_date}-test.md").to be_an_existing_file
211+
212+
delete_file "_posts/#{future_date}-test.md"
213+
end
214+
198215
context "renaming a file" do
199216
%w(with without).each do |type|
200217
it "renames a file #{type} the collection prefix" do

0 commit comments

Comments
 (0)