jekyll-s3 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +49 -2
- data/changelog.md +4 -0
- data/example-configurations.md +43 -0
- data/features/cassettes/cucumber_tags/create-redirect.yml +384 -0
- data/features/jekyll-s3-as-library.feature +6 -0
- data/features/jekyll-s3-redirects.feature +16 -0
- data/features/step_definitions/steps.rb +5 -0
- data/features/support/test_site_dirs/create-redirects/_jekyll_s3.yml +6 -0
- data/features/support/test_site_dirs/create-redirects/_site/.gitkeep +0 -0
- data/features/support/vcr.rb +1 -0
- data/jekyll-s3.gemspec +1 -1
- data/lib/jekyll-s3/cli.rb +4 -3
- data/lib/jekyll-s3/uploader.rb +44 -3
- metadata +13 -4
data/README.md
CHANGED
@@ -10,6 +10,7 @@ Deploy your jekyll site to S3.
|
|
10
10
|
* Upload your site to AWS S3
|
11
11
|
* Help you use AWS Cloudfront to distribute your Jekyll blog
|
12
12
|
* Create an S3 website for you
|
13
|
+
* Improve page speed with HTTP cache control and gzipping
|
13
14
|
|
14
15
|
## Install
|
15
16
|
|
@@ -31,6 +32,10 @@ s3_bucket: your.blog.bucket.com
|
|
31
32
|
|
32
33
|
* Run `jekyll-s3` to push your Jekyll blog to S3. Congratulations! You are live.
|
33
34
|
|
35
|
+
(If you are using `jekyll-s3` on an [EC2 instance with IAM
|
36
|
+
roles](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UsingIAM.html#UsingIAMrolesWithAmazonEC2Instances),
|
37
|
+
you can omit the `s3_id` and `s3_secret` keys in the config file.)
|
38
|
+
|
34
39
|
### Using environment variables
|
35
40
|
|
36
41
|
You can use ERB in your `_jekyll_s3.yml` file which incorporates environment variables:
|
@@ -150,7 +155,21 @@ thus force the CDN system to reload the changes from your Jekyll S3 bucket.
|
|
150
155
|
#### Specifying custom settings for your CloudFront distribution
|
151
156
|
|
152
157
|
The gem `configure-s3-website`, which is a dependency of `jekyll-s3`, lets you
|
153
|
-
define custom settings for your CloudFront distribution.
|
158
|
+
define custom settings for your CloudFront distribution.
|
159
|
+
|
160
|
+
For example, like this you can define a your own TTL and CNAME:
|
161
|
+
|
162
|
+
```yaml
|
163
|
+
cloudfront_distribution_config:
|
164
|
+
default_cache_behavior:
|
165
|
+
min_TTL: <%= 60 * 60 * 24 %>
|
166
|
+
aliases:
|
167
|
+
quantity: 1
|
168
|
+
items:
|
169
|
+
CNAME: your.website.com
|
170
|
+
```
|
171
|
+
|
172
|
+
See the [gem's
|
154
173
|
documentation](https://github.com/laurilehmijoki/configure-s3-website) for more
|
155
174
|
info.
|
156
175
|
|
@@ -166,7 +185,30 @@ Enable the headless mode by adding the `--headless` or `-h` argument after
|
|
166
185
|
|
167
186
|
### Configuring redirects on your Jekyll S3 website
|
168
187
|
|
169
|
-
You can set HTTP redirects on your Jekyll S3 website
|
188
|
+
You can set HTTP redirects on your Jekyll S3 website in two ways. If you only
|
189
|
+
need simple "301 Moved Premanently" redirects for certain keys, use the
|
190
|
+
Simple Redirects method. Otherwise, use the Routing Rules method.
|
191
|
+
|
192
|
+
#### Simple Redirects
|
193
|
+
|
194
|
+
For simple redirects Jekyll S3 uses Amazon S3's
|
195
|
+
[`x-amz-website-redirect-location`](http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html)
|
196
|
+
metadata. It will create zero-byte objects for each path you want
|
197
|
+
redirected with the appropriate `x-amz-website-redirect-location` value.
|
198
|
+
|
199
|
+
For setting up simple redirect rules, simply list each path and target
|
200
|
+
as key-value pairs under the `redirects` configuration option:
|
201
|
+
|
202
|
+
```yaml
|
203
|
+
redirects:
|
204
|
+
index.php: /
|
205
|
+
about.php: about.html
|
206
|
+
music-files/promo.mp4: http://www.youtube.com/watch?v=dQw4w9WgXcQ
|
207
|
+
```
|
208
|
+
|
209
|
+
#### Routing Rules
|
210
|
+
|
211
|
+
You can configure more complex redirect rules by adding the following
|
170
212
|
configuration into the `_jekyll_s3.yml` file:
|
171
213
|
|
172
214
|
```yaml
|
@@ -213,6 +255,11 @@ Jekyll::S3::Uploader.run('/path/to/your/jekyll-site/_site/', config, in_headless
|
|
213
255
|
The code above will assume that you have the `_jekyll_s3.yml` in the directory
|
214
256
|
`/path/to/your/jekyll-site`.
|
215
257
|
|
258
|
+
## Example configurations
|
259
|
+
|
260
|
+
See
|
261
|
+
<https://github.com/laurilehmijoki/jekyll-s3/blob/master/example-configurations.md>.
|
262
|
+
|
216
263
|
## Known issues
|
217
264
|
|
218
265
|
None. Please send a pull request if you spot any.
|
data/changelog.md
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Example `jekyll-s3` configurations
|
2
|
+
|
3
|
+
This document shows examples of complete `_jekyll_s3.yml` configurations.
|
4
|
+
|
5
|
+
## Minimal
|
6
|
+
|
7
|
+
````yaml
|
8
|
+
s3_id: abcd
|
9
|
+
s3_secret: 2s+x92
|
10
|
+
s3_bucket: your.domain.net
|
11
|
+
````
|
12
|
+
|
13
|
+
## Minimal with EC2 AIM roles
|
14
|
+
|
15
|
+
````yaml
|
16
|
+
s3_bucket: your.domain.net
|
17
|
+
````
|
18
|
+
|
19
|
+
If you run `jekyll-s3` on an EC2 instance with IAM roles, it is possible to omit
|
20
|
+
the `s3_id` and `s3_secret`.
|
21
|
+
|
22
|
+
## Optimised for speed: using CloudFront, gzip and cache headers
|
23
|
+
|
24
|
+
````yaml
|
25
|
+
s3_id: <%= ENV['your_domain_net_aws_key'] %>
|
26
|
+
s3_secret: <%= ENV['your_domain_net_aws_secret'] %>
|
27
|
+
s3_bucket: your.domain.net
|
28
|
+
cloudfront_distribution_id: <%= ENV['your_domain_net_cloudfront_distribution_id'] %>
|
29
|
+
cloudfront_distribution_config:
|
30
|
+
default_cache_behavior:
|
31
|
+
min_TTL: <%= 60 * 60 * 24 %>
|
32
|
+
aliases:
|
33
|
+
quantity: 1
|
34
|
+
items:
|
35
|
+
CNAME: your.domain.net
|
36
|
+
max_age: 120
|
37
|
+
gzip: true
|
38
|
+
````
|
39
|
+
|
40
|
+
Above, we store the AWS credentials and the id of the CloudFront distribution as
|
41
|
+
environment variables. It's convenient, since you can keep the `_jekyll_s3.yml`
|
42
|
+
in a public Git repo, and thus have your deployment configurations
|
43
|
+
version-controlled.
|
@@ -0,0 +1,384 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://s3.amazonaws.com/jekyll-s3-test.net?max-keys=1000
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- ''
|
12
|
+
User-Agent:
|
13
|
+
- aws-sdk-ruby/1.8.5 ruby/1.9.3 x86_64-darwin11.4.2
|
14
|
+
Date:
|
15
|
+
- Tue, 28 May 2013 16:44:09 GMT
|
16
|
+
Authorization:
|
17
|
+
- AWS foo:foo
|
18
|
+
Accept:
|
19
|
+
- ! '*/*'
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
X-Amz-Id-2:
|
26
|
+
- kGCga6NIm0ybqHxPbkdrzL4YTE2Ik7Az88+JBSXk1uPWgj0a0ozR9z5BdOUOZSKy
|
27
|
+
X-Amz-Request-Id:
|
28
|
+
- 87A0319E10B35221
|
29
|
+
Date:
|
30
|
+
- Tue, 28 May 2013 16:43:53 GMT
|
31
|
+
Content-Type:
|
32
|
+
- application/xml
|
33
|
+
Transfer-Encoding:
|
34
|
+
- chunked
|
35
|
+
Server:
|
36
|
+
- AmazonS3
|
37
|
+
body:
|
38
|
+
encoding: US-ASCII
|
39
|
+
string: ! '<?xml version="1.0" encoding="UTF-8"?>
|
40
|
+
|
41
|
+
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>jekyll-s3-test.net</Name><Prefix></Prefix><Marker></Marker><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated><Contents><Key>.gitkeep</Key><LastModified>2013-05-28T16:27:36.000Z</LastModified><ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag><Size>0</Size><Owner><ID>3855ebae0f370c3dd0c8d8031863792112bd2a2cb18fa310d3f463ae0dea62f1</ID><DisplayName>fluid83</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents></ListBucketResult>'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Tue, 28 May 2013 16:44:09 GMT
|
44
|
+
- request:
|
45
|
+
method: head
|
46
|
+
uri: https://s3.amazonaws.com/jekyll-s3-test.net/.gitkeep
|
47
|
+
body:
|
48
|
+
encoding: US-ASCII
|
49
|
+
string: ''
|
50
|
+
headers:
|
51
|
+
Content-Type:
|
52
|
+
- ''
|
53
|
+
User-Agent:
|
54
|
+
- aws-sdk-ruby/1.8.5 ruby/1.9.3 x86_64-darwin11.4.2
|
55
|
+
Date:
|
56
|
+
- Tue, 28 May 2013 16:44:09 GMT
|
57
|
+
Authorization:
|
58
|
+
- AWS foo:foo
|
59
|
+
Accept:
|
60
|
+
- ! '*/*'
|
61
|
+
response:
|
62
|
+
status:
|
63
|
+
code: 200
|
64
|
+
message: OK
|
65
|
+
headers:
|
66
|
+
X-Amz-Id-2:
|
67
|
+
- bAn0wcE+zU2espZy2XzUQAoKBVY42UbUZ6ELx6Vm4MFsCynvMspnh9xHuPpbw4BR
|
68
|
+
X-Amz-Request-Id:
|
69
|
+
- 16821C1979EFD9FB
|
70
|
+
Date:
|
71
|
+
- Tue, 28 May 2013 16:43:54 GMT
|
72
|
+
Last-Modified:
|
73
|
+
- Tue, 28 May 2013 16:27:36 GMT
|
74
|
+
Etag:
|
75
|
+
- ! '"d41d8cd98f00b204e9800998ecf8427e"'
|
76
|
+
Accept-Ranges:
|
77
|
+
- bytes
|
78
|
+
Content-Type:
|
79
|
+
- ''
|
80
|
+
Content-Length:
|
81
|
+
- '0'
|
82
|
+
Server:
|
83
|
+
- AmazonS3
|
84
|
+
body:
|
85
|
+
encoding: US-ASCII
|
86
|
+
string: ''
|
87
|
+
http_version:
|
88
|
+
recorded_at: Tue, 28 May 2013 16:44:10 GMT
|
89
|
+
- request:
|
90
|
+
method: head
|
91
|
+
uri: https://s3.amazonaws.com/jekyll-s3-test.net/.gitkeep
|
92
|
+
body:
|
93
|
+
encoding: US-ASCII
|
94
|
+
string: ''
|
95
|
+
headers:
|
96
|
+
Content-Type:
|
97
|
+
- ''
|
98
|
+
User-Agent:
|
99
|
+
- aws-sdk-ruby/1.8.5 ruby/1.9.3 x86_64-darwin11.4.2
|
100
|
+
Date:
|
101
|
+
- Tue, 28 May 2013 16:44:10 GMT
|
102
|
+
Authorization:
|
103
|
+
- AWS foo:foo
|
104
|
+
Accept:
|
105
|
+
- ! '*/*'
|
106
|
+
response:
|
107
|
+
status:
|
108
|
+
code: 200
|
109
|
+
message: OK
|
110
|
+
headers:
|
111
|
+
X-Amz-Id-2:
|
112
|
+
- S4qbXk9empwOUKpUl3teDUGS60qYOg0CxRm7v8ccxa1Z5Y9K60DWvq8v7YHWAPWc
|
113
|
+
X-Amz-Request-Id:
|
114
|
+
- 62DB5F01C0BEF2BA
|
115
|
+
Date:
|
116
|
+
- Tue, 28 May 2013 16:43:54 GMT
|
117
|
+
Last-Modified:
|
118
|
+
- Tue, 28 May 2013 16:27:36 GMT
|
119
|
+
Etag:
|
120
|
+
- ! '"d41d8cd98f00b204e9800998ecf8427e"'
|
121
|
+
Accept-Ranges:
|
122
|
+
- bytes
|
123
|
+
Content-Type:
|
124
|
+
- ''
|
125
|
+
Content-Length:
|
126
|
+
- '0'
|
127
|
+
Server:
|
128
|
+
- AmazonS3
|
129
|
+
body:
|
130
|
+
encoding: US-ASCII
|
131
|
+
string: ''
|
132
|
+
http_version:
|
133
|
+
recorded_at: Tue, 28 May 2013 16:44:10 GMT
|
134
|
+
- request:
|
135
|
+
method: head
|
136
|
+
uri: https://s3.amazonaws.com/jekyll-s3-test.net/.gitkeep
|
137
|
+
body:
|
138
|
+
encoding: US-ASCII
|
139
|
+
string: ''
|
140
|
+
headers:
|
141
|
+
Content-Type:
|
142
|
+
- ''
|
143
|
+
User-Agent:
|
144
|
+
- aws-sdk-ruby/1.8.5 ruby/1.9.3 x86_64-darwin11.4.2
|
145
|
+
Date:
|
146
|
+
- Tue, 28 May 2013 16:44:10 GMT
|
147
|
+
Authorization:
|
148
|
+
- AWS foo:foo
|
149
|
+
Accept:
|
150
|
+
- ! '*/*'
|
151
|
+
response:
|
152
|
+
status:
|
153
|
+
code: 200
|
154
|
+
message: OK
|
155
|
+
headers:
|
156
|
+
X-Amz-Id-2:
|
157
|
+
- KIW+hvipZEv+PgPc03LeddPDEcI7EzDH/CuoxrksuGUIHeA3ecmbIA+jlOgpMCi7
|
158
|
+
X-Amz-Request-Id:
|
159
|
+
- CFFC7DE02A902B74
|
160
|
+
Date:
|
161
|
+
- Tue, 28 May 2013 16:43:55 GMT
|
162
|
+
Last-Modified:
|
163
|
+
- Tue, 28 May 2013 16:27:36 GMT
|
164
|
+
Etag:
|
165
|
+
- ! '"d41d8cd98f00b204e9800998ecf8427e"'
|
166
|
+
Accept-Ranges:
|
167
|
+
- bytes
|
168
|
+
Content-Type:
|
169
|
+
- ''
|
170
|
+
Content-Length:
|
171
|
+
- '0'
|
172
|
+
Server:
|
173
|
+
- AmazonS3
|
174
|
+
body:
|
175
|
+
encoding: US-ASCII
|
176
|
+
string: ''
|
177
|
+
http_version:
|
178
|
+
recorded_at: Tue, 28 May 2013 16:44:11 GMT
|
179
|
+
- request:
|
180
|
+
method: head
|
181
|
+
uri: https://s3.amazonaws.com/jekyll-s3-test.net/welcome.php
|
182
|
+
body:
|
183
|
+
encoding: US-ASCII
|
184
|
+
string: ''
|
185
|
+
headers:
|
186
|
+
Content-Type:
|
187
|
+
- ''
|
188
|
+
User-Agent:
|
189
|
+
- aws-sdk-ruby/1.8.5 ruby/1.9.3 x86_64-darwin11.4.2
|
190
|
+
Date:
|
191
|
+
- Tue, 28 May 2013 16:44:11 GMT
|
192
|
+
Authorization:
|
193
|
+
- AWS foo:foo
|
194
|
+
Accept:
|
195
|
+
- ! '*/*'
|
196
|
+
response:
|
197
|
+
status:
|
198
|
+
code: 404
|
199
|
+
message: Not Found
|
200
|
+
headers:
|
201
|
+
X-Amz-Request-Id:
|
202
|
+
- C3D38989428864B4
|
203
|
+
X-Amz-Id-2:
|
204
|
+
- iEtbd2+jBo4YB/bWQF7S0nIPD04ctKzv8FpUL3vTPUQzwpVE70mCORaHuXASL/6V
|
205
|
+
Content-Type:
|
206
|
+
- application/xml
|
207
|
+
Transfer-Encoding:
|
208
|
+
- chunked
|
209
|
+
Date:
|
210
|
+
- Tue, 28 May 2013 16:43:54 GMT
|
211
|
+
Server:
|
212
|
+
- AmazonS3
|
213
|
+
body:
|
214
|
+
encoding: US-ASCII
|
215
|
+
string: ''
|
216
|
+
http_version:
|
217
|
+
recorded_at: Tue, 28 May 2013 16:44:12 GMT
|
218
|
+
- request:
|
219
|
+
method: put
|
220
|
+
uri: https://s3.amazonaws.com/jekyll-s3-test.net/welcome.php
|
221
|
+
body:
|
222
|
+
encoding: ASCII-8BIT
|
223
|
+
string: !binary ""
|
224
|
+
headers:
|
225
|
+
Content-Type:
|
226
|
+
- ''
|
227
|
+
Content-Length:
|
228
|
+
- '0'
|
229
|
+
X-Amz-Website-Redirect-Location:
|
230
|
+
- /welcome
|
231
|
+
User-Agent:
|
232
|
+
- aws-sdk-ruby/1.8.5 ruby/1.9.3 x86_64-darwin11.4.2
|
233
|
+
Date:
|
234
|
+
- Tue, 28 May 2013 16:44:12 GMT
|
235
|
+
Authorization:
|
236
|
+
- AWS foo:foo
|
237
|
+
Accept:
|
238
|
+
- ! '*/*'
|
239
|
+
response:
|
240
|
+
status:
|
241
|
+
code: 200
|
242
|
+
message: OK
|
243
|
+
headers:
|
244
|
+
X-Amz-Id-2:
|
245
|
+
- shxpzCHDkXgP6Ru7MjzBbiiONhv8O72UHLa12njGg/Ml16sNy9kGzzCEUp4T450a
|
246
|
+
X-Amz-Request-Id:
|
247
|
+
- 73AD74BF97A9FE39
|
248
|
+
Date:
|
249
|
+
- Tue, 28 May 2013 16:43:56 GMT
|
250
|
+
Etag:
|
251
|
+
- ! '"d41d8cd98f00b204e9800998ecf8427e"'
|
252
|
+
Content-Length:
|
253
|
+
- '0'
|
254
|
+
Server:
|
255
|
+
- AmazonS3
|
256
|
+
body:
|
257
|
+
encoding: US-ASCII
|
258
|
+
string: ''
|
259
|
+
http_version:
|
260
|
+
recorded_at: Tue, 28 May 2013 16:44:12 GMT
|
261
|
+
- request:
|
262
|
+
method: head
|
263
|
+
uri: https://s3.amazonaws.com/jekyll-s3-test.net/pets/dogs
|
264
|
+
body:
|
265
|
+
encoding: US-ASCII
|
266
|
+
string: ''
|
267
|
+
headers:
|
268
|
+
Content-Type:
|
269
|
+
- ''
|
270
|
+
User-Agent:
|
271
|
+
- aws-sdk-ruby/1.8.5 ruby/1.9.3 x86_64-darwin11.4.2
|
272
|
+
Date:
|
273
|
+
- Tue, 28 May 2013 16:44:12 GMT
|
274
|
+
Authorization:
|
275
|
+
- AWS foo:foo
|
276
|
+
Accept:
|
277
|
+
- ! '*/*'
|
278
|
+
response:
|
279
|
+
status:
|
280
|
+
code: 404
|
281
|
+
message: Not Found
|
282
|
+
headers:
|
283
|
+
X-Amz-Request-Id:
|
284
|
+
- 720BC22A793D95A4
|
285
|
+
X-Amz-Id-2:
|
286
|
+
- pc2CHQG08/lLFwc/Cq3upvG3Sm+wDzsmf1FsA+YuUjkfojvJB45NbkL5LCX35bpi
|
287
|
+
Content-Type:
|
288
|
+
- application/xml
|
289
|
+
Transfer-Encoding:
|
290
|
+
- chunked
|
291
|
+
Date:
|
292
|
+
- Tue, 28 May 2013 16:43:55 GMT
|
293
|
+
Server:
|
294
|
+
- AmazonS3
|
295
|
+
body:
|
296
|
+
encoding: US-ASCII
|
297
|
+
string: ''
|
298
|
+
http_version:
|
299
|
+
recorded_at: Tue, 28 May 2013 16:44:13 GMT
|
300
|
+
- request:
|
301
|
+
method: put
|
302
|
+
uri: https://s3.amazonaws.com/jekyll-s3-test.net/pets/dogs
|
303
|
+
body:
|
304
|
+
encoding: ASCII-8BIT
|
305
|
+
string: !binary ""
|
306
|
+
headers:
|
307
|
+
Content-Type:
|
308
|
+
- ''
|
309
|
+
Content-Length:
|
310
|
+
- '0'
|
311
|
+
X-Amz-Website-Redirect-Location:
|
312
|
+
- /cats-and-dogs/wuf
|
313
|
+
User-Agent:
|
314
|
+
- aws-sdk-ruby/1.8.5 ruby/1.9.3 x86_64-darwin11.4.2
|
315
|
+
Date:
|
316
|
+
- Tue, 28 May 2013 16:44:13 GMT
|
317
|
+
Authorization:
|
318
|
+
- AWS foo:foo
|
319
|
+
Accept:
|
320
|
+
- ! '*/*'
|
321
|
+
response:
|
322
|
+
status:
|
323
|
+
code: 200
|
324
|
+
message: OK
|
325
|
+
headers:
|
326
|
+
X-Amz-Id-2:
|
327
|
+
- qnGdeAUFkp76ErkCyx64T/eUilvlp2Y/b7QSCg5u+ghYyTtlR20szfiw0+tO/p7+
|
328
|
+
X-Amz-Request-Id:
|
329
|
+
- A38BEDA58C01CC5A
|
330
|
+
Date:
|
331
|
+
- Tue, 28 May 2013 16:43:57 GMT
|
332
|
+
Etag:
|
333
|
+
- ! '"d41d8cd98f00b204e9800998ecf8427e"'
|
334
|
+
Content-Length:
|
335
|
+
- '0'
|
336
|
+
Server:
|
337
|
+
- AmazonS3
|
338
|
+
body:
|
339
|
+
encoding: US-ASCII
|
340
|
+
string: ''
|
341
|
+
http_version:
|
342
|
+
recorded_at: Tue, 28 May 2013 16:44:14 GMT
|
343
|
+
- request:
|
344
|
+
method: get
|
345
|
+
uri: https://s3.amazonaws.com/jekyll-s3-test.net?max-keys=1000
|
346
|
+
body:
|
347
|
+
encoding: US-ASCII
|
348
|
+
string: ''
|
349
|
+
headers:
|
350
|
+
Content-Type:
|
351
|
+
- ''
|
352
|
+
User-Agent:
|
353
|
+
- aws-sdk-ruby/1.8.5 ruby/1.9.3 x86_64-darwin11.4.2
|
354
|
+
Date:
|
355
|
+
- Tue, 28 May 2013 16:44:14 GMT
|
356
|
+
Authorization:
|
357
|
+
- AWS foo:foo
|
358
|
+
Accept:
|
359
|
+
- ! '*/*'
|
360
|
+
response:
|
361
|
+
status:
|
362
|
+
code: 200
|
363
|
+
message: OK
|
364
|
+
headers:
|
365
|
+
X-Amz-Id-2:
|
366
|
+
- SEAH/XjpATFm0o1XovAZAXLIsYIktpmxg986HNG//aMuvy+sDLmbee5d+fPpO+x0
|
367
|
+
X-Amz-Request-Id:
|
368
|
+
- 2C139CA22908CC7A
|
369
|
+
Date:
|
370
|
+
- Tue, 28 May 2013 16:43:58 GMT
|
371
|
+
Content-Type:
|
372
|
+
- application/xml
|
373
|
+
Transfer-Encoding:
|
374
|
+
- chunked
|
375
|
+
Server:
|
376
|
+
- AmazonS3
|
377
|
+
body:
|
378
|
+
encoding: US-ASCII
|
379
|
+
string: ! '<?xml version="1.0" encoding="UTF-8"?>
|
380
|
+
|
381
|
+
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>jekyll-s3-test.net</Name><Prefix></Prefix><Marker></Marker><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated><Contents><Key>.gitkeep</Key><LastModified>2013-05-28T16:27:36.000Z</LastModified><ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag><Size>0</Size><Owner><ID>3855ebae0f370c3dd0c8d8031863792112bd2a2cb18fa310d3f463ae0dea62f1</ID><DisplayName>fluid83</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>pets/dogs</Key><LastModified>2013-05-28T16:43:57.000Z</LastModified><ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag><Size>0</Size><Owner><ID>3855ebae0f370c3dd0c8d8031863792112bd2a2cb18fa310d3f463ae0dea62f1</ID><DisplayName>fluid83</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>welcome.php</Key><LastModified>2013-05-28T16:43:56.000Z</LastModified><ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag><Size>0</Size><Owner><ID>3855ebae0f370c3dd0c8d8031863792112bd2a2cb18fa310d3f463ae0dea62f1</ID><DisplayName>fluid83</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents></ListBucketResult>'
|
382
|
+
http_version:
|
383
|
+
recorded_at: Tue, 28 May 2013 16:44:14 GMT
|
384
|
+
recorded_with: VCR 2.3.0
|
@@ -21,3 +21,9 @@ Feature: Using Jekyll-s3 as a library
|
|
21
21
|
When my Jekyll site is in "features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi"
|
22
22
|
Then jekyll-s3 will push my blog to S3 and invalidate the Cloudfront distribution
|
23
23
|
And report that it invalidated 2 Cloudfront item
|
24
|
+
|
25
|
+
@create-redirect
|
26
|
+
Scenario: Developer wants feedback on how many redirects Jekyll-s3 created
|
27
|
+
When my Jekyll site is in "features/support/test_site_dirs/create-redirects"
|
28
|
+
Then jekyll-s3 will push my blog to S3
|
29
|
+
And report that it created 2 new redirects
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Feature: configure redirects
|
2
|
+
|
3
|
+
@create-redirect
|
4
|
+
Scenario: The user wants to configure new redirects for HTTP resources
|
5
|
+
When my Jekyll site is in "features/support/test_site_dirs/create-redirects"
|
6
|
+
Then jekyll-s3 will push my blog to S3
|
7
|
+
And the output should equal
|
8
|
+
"""
|
9
|
+
Deploying _site/* to jekyll-s3-test.net
|
10
|
+
No new or changed files to upload
|
11
|
+
Creating new redirects ...
|
12
|
+
Redirect welcome.php to /welcome: Success!
|
13
|
+
Redirect pets/dogs to /cats-and-dogs/wuf: Success!
|
14
|
+
Done! Go visit: http://jekyll-s3-test.net.s3-website-us-east-1.amazonaws.com/index.html
|
15
|
+
|
16
|
+
"""
|
@@ -31,6 +31,10 @@ Then /^report that it invalidated (\d+) Cloudfront item$/ do |expected|
|
|
31
31
|
@amount_of_invalidated_items.should == expected.to_i
|
32
32
|
end
|
33
33
|
|
34
|
+
Then /^report that it created (\d+) new redirects$/ do |expected|
|
35
|
+
@amount_of_new_redirects.should == expected.to_i
|
36
|
+
end
|
37
|
+
|
34
38
|
Then /^report that it deleted (\d+) file from S3$/ do |amount_of_deleted_files|
|
35
39
|
@amount_of_deleted_files.should == amount_of_deleted_files.to_i
|
36
40
|
end
|
@@ -43,6 +47,7 @@ def do_run
|
|
43
47
|
@amount_of_changed_files = result[:changed_files_count]
|
44
48
|
@amount_of_deleted_files = result[:deleted_files_count]
|
45
49
|
@amount_of_invalidated_items = result[:invalidated_items_count]
|
50
|
+
@amount_of_new_redirects = result[:changed_redirects_count]
|
46
51
|
}
|
47
52
|
end
|
48
53
|
|
File without changes
|
data/features/support/vcr.rb
CHANGED
data/jekyll-s3.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "jekyll-s3"
|
6
|
-
s.version = "2.
|
6
|
+
s.version = "2.8.0"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Philippe Creux", "Lauri Lehmijoki"]
|
9
9
|
s.email = ["pcreux@gmail.com", "lauri.lehmijoki@iki.fi"]
|
data/lib/jekyll-s3/cli.rb
CHANGED
@@ -10,15 +10,16 @@ module Jekyll
|
|
10
10
|
def run(site_dir, in_headless_mode = false)
|
11
11
|
CLI.check_configuration site_dir
|
12
12
|
config = Jekyll::S3::ConfigLoader.load_configuration site_dir
|
13
|
-
new_files_count, changed_files_count, deleted_files_count, changed_files =
|
13
|
+
new_files_count, changed_files_count, deleted_files_count, changed_files, changed_redirects =
|
14
14
|
Uploader.run(site_dir, config, in_headless_mode)
|
15
15
|
invalidated_items_count =
|
16
|
-
CLI.invalidate_cf_dist_if_configured(config, changed_files)
|
16
|
+
CLI.invalidate_cf_dist_if_configured(config, changed_files + changed_redirects)
|
17
17
|
{
|
18
18
|
:new_files_count => new_files_count,
|
19
19
|
:changed_files_count => changed_files_count,
|
20
20
|
:deleted_files_count => deleted_files_count,
|
21
|
-
:invalidated_items_count => invalidated_items_count
|
21
|
+
:invalidated_items_count => invalidated_items_count,
|
22
|
+
:changed_redirects_count => changed_redirects.size
|
22
23
|
}
|
23
24
|
rescue JekyllS3Error => e
|
24
25
|
puts e.message
|
data/lib/jekyll-s3/uploader.rb
CHANGED
@@ -16,14 +16,18 @@ module Jekyll
|
|
16
16
|
s3, config, site_dir
|
17
17
|
)
|
18
18
|
|
19
|
+
redirects = config['redirects'] || {}
|
20
|
+
changed_redirects = setup_redirects redirects, config, s3
|
21
|
+
|
19
22
|
deleted_files_count = remove_superfluous_files(s3, { :s3_bucket => config['s3_bucket'],
|
20
23
|
:site_dir => site_dir,
|
24
|
+
:redirects => redirects,
|
21
25
|
:in_headless_mode => in_headless_mode,
|
22
26
|
:ignore_on_server => config["ignore_on_server"] })
|
23
27
|
|
24
28
|
print_done_report config
|
25
29
|
|
26
|
-
[new_files_count, changed_files_count, deleted_files_count, changed_files]
|
30
|
+
[new_files_count, changed_files_count, deleted_files_count, changed_files, changed_redirects]
|
27
31
|
end
|
28
32
|
|
29
33
|
private
|
@@ -69,16 +73,53 @@ module Jekyll
|
|
69
73
|
end
|
70
74
|
end
|
71
75
|
|
76
|
+
def self.setup_redirects(redirects, config, s3)
|
77
|
+
operations = redirects.map do |path, target|
|
78
|
+
setup_redirect(path, target, s3, config)
|
79
|
+
end
|
80
|
+
performed_operations = operations.reject do |op|
|
81
|
+
op == :no_redirect_operation_performed
|
82
|
+
end
|
83
|
+
unless performed_operations.empty?
|
84
|
+
puts 'Creating new redirects ...'
|
85
|
+
end
|
86
|
+
performed_operations.each do |redirect_operation|
|
87
|
+
puts ' ' + redirect_operation[:report]
|
88
|
+
end
|
89
|
+
performed_operations.map do |redirect_operation|
|
90
|
+
redirect_operation[:path]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.setup_redirect(path, target, s3, config)
|
95
|
+
target = '/' + target unless target =~ %r{^(/|https?://)}
|
96
|
+
s3_object = s3.buckets[config['s3_bucket']].objects[path]
|
97
|
+
|
98
|
+
begin
|
99
|
+
current_head = s3_object.head
|
100
|
+
rescue AWS::S3::Errors::NoSuchKey
|
101
|
+
end
|
102
|
+
|
103
|
+
if current_head.nil? or current_head[:website_redirect_location] != target
|
104
|
+
s3_object.write('', :website_redirect_location => target)
|
105
|
+
{
|
106
|
+
:report => "Redirect #{path} to #{target}: Success!",
|
107
|
+
:path => path
|
108
|
+
}
|
109
|
+
else
|
110
|
+
:no_redirect_operation_performed
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
72
114
|
def self.remove_superfluous_files(s3, options)
|
73
115
|
s3_bucket_name = options.fetch(:s3_bucket)
|
74
116
|
site_dir = options.fetch(:site_dir)
|
75
117
|
in_headless_mode = options.fetch(:in_headless_mode)
|
76
118
|
|
77
119
|
remote_files = s3.buckets[s3_bucket_name].objects.map { |f| f.key }
|
78
|
-
local_files = load_all_local_files(site_dir)
|
120
|
+
local_files = load_all_local_files(site_dir) + options.fetch(:redirects).keys
|
79
121
|
files_to_delete = build_list_of_files_to_delete(remote_files, local_files, options[:ignore_on_server])
|
80
122
|
|
81
|
-
|
82
123
|
deleted_files_count = 0
|
83
124
|
if in_headless_mode
|
84
125
|
files_to_delete.each { |s3_object_key|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-05-
|
13
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|
@@ -240,6 +240,8 @@ files:
|
|
240
240
|
- Rakefile
|
241
241
|
- bin/jekyll-s3
|
242
242
|
- changelog.md
|
243
|
+
- example-configurations.md
|
244
|
+
- features/cassettes/cucumber_tags/create-redirect.yml
|
243
245
|
- features/cassettes/cucumber_tags/new-and-changed-files.yml
|
244
246
|
- features/cassettes/cucumber_tags/new-files-for-sydney.yml
|
245
247
|
- features/cassettes/cucumber_tags/new-files.yml
|
@@ -252,6 +254,7 @@ files:
|
|
252
254
|
- features/jekyll-s3-as-library.feature
|
253
255
|
- features/jekyll-s3-cloudfront.feature
|
254
256
|
- features/jekyll-s3-delete.feature
|
257
|
+
- features/jekyll-s3-redirects.feature
|
255
258
|
- features/jekyll-s3-upload.feature
|
256
259
|
- features/jekyll-s3-website-performance.feature
|
257
260
|
- features/step_definitions/steps.rb
|
@@ -262,6 +265,8 @@ files:
|
|
262
265
|
- features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_jekyll_s3.yml
|
263
266
|
- features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_site/css/styles.css
|
264
267
|
- features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_site/index.html
|
268
|
+
- features/support/test_site_dirs/create-redirects/_jekyll_s3.yml
|
269
|
+
- features/support/test_site_dirs/create-redirects/_site/.gitkeep
|
265
270
|
- features/support/test_site_dirs/index-and-assets.blog.fi/_jekyll_s3.yml
|
266
271
|
- features/support/test_site_dirs/index-and-assets.blog.fi/_site/assets/picture.gif
|
267
272
|
- features/support/test_site_dirs/index-and-assets.blog.fi/_site/css/styles.css
|
@@ -337,7 +342,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
337
342
|
version: '0'
|
338
343
|
segments:
|
339
344
|
- 0
|
340
|
-
hash:
|
345
|
+
hash: 1250183461535379030
|
341
346
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
342
347
|
none: false
|
343
348
|
requirements:
|
@@ -346,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
346
351
|
version: '0'
|
347
352
|
segments:
|
348
353
|
- 0
|
349
|
-
hash:
|
354
|
+
hash: 1250183461535379030
|
350
355
|
requirements: []
|
351
356
|
rubyforge_project:
|
352
357
|
rubygems_version: 1.8.25
|
@@ -354,6 +359,7 @@ signing_key:
|
|
354
359
|
specification_version: 3
|
355
360
|
summary: Push your Jekyll blog to S3
|
356
361
|
test_files:
|
362
|
+
- features/cassettes/cucumber_tags/create-redirect.yml
|
357
363
|
- features/cassettes/cucumber_tags/new-and-changed-files.yml
|
358
364
|
- features/cassettes/cucumber_tags/new-files-for-sydney.yml
|
359
365
|
- features/cassettes/cucumber_tags/new-files.yml
|
@@ -366,6 +372,7 @@ test_files:
|
|
366
372
|
- features/jekyll-s3-as-library.feature
|
367
373
|
- features/jekyll-s3-cloudfront.feature
|
368
374
|
- features/jekyll-s3-delete.feature
|
375
|
+
- features/jekyll-s3-redirects.feature
|
369
376
|
- features/jekyll-s3-upload.feature
|
370
377
|
- features/jekyll-s3-website-performance.feature
|
371
378
|
- features/step_definitions/steps.rb
|
@@ -376,6 +383,8 @@ test_files:
|
|
376
383
|
- features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_jekyll_s3.yml
|
377
384
|
- features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_site/css/styles.css
|
378
385
|
- features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_site/index.html
|
386
|
+
- features/support/test_site_dirs/create-redirects/_jekyll_s3.yml
|
387
|
+
- features/support/test_site_dirs/create-redirects/_site/.gitkeep
|
379
388
|
- features/support/test_site_dirs/index-and-assets.blog.fi/_jekyll_s3.yml
|
380
389
|
- features/support/test_site_dirs/index-and-assets.blog.fi/_site/assets/picture.gif
|
381
390
|
- features/support/test_site_dirs/index-and-assets.blog.fi/_site/css/styles.css
|