s3_website 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +81 -0
  6. data/LICENSE +42 -0
  7. data/README.md +332 -0
  8. data/Rakefile +18 -0
  9. data/bin/s3_website +38 -0
  10. data/changelog.md +7 -0
  11. data/example-configurations.md +60 -0
  12. data/features/as-library.feature +29 -0
  13. data/features/cassettes/cucumber_tags/create-redirect.yml +384 -0
  14. data/features/cassettes/cucumber_tags/new-and-changed-files.yml +303 -0
  15. data/features/cassettes/cucumber_tags/new-files-for-sydney.yml +211 -0
  16. data/features/cassettes/cucumber_tags/new-files.yml +355 -0
  17. data/features/cassettes/cucumber_tags/no-new-or-changed-files.yml +359 -0
  18. data/features/cassettes/cucumber_tags/one-file-to-delete.yml +390 -0
  19. data/features/cassettes/cucumber_tags/only-changed-files.yml +411 -0
  20. data/features/cassettes/cucumber_tags/s3-and-cloudfront-when-updating-a-file.yml +435 -0
  21. data/features/cassettes/cucumber_tags/s3-and-cloudfront.yml +290 -0
  22. data/features/cloudfront.feature +35 -0
  23. data/features/delete.feature +18 -0
  24. data/features/instructions-for-new-user.feature +94 -0
  25. data/features/redirects.feature +16 -0
  26. data/features/step_definitions/steps.rb +67 -0
  27. data/features/support/env.rb +26 -0
  28. data/features/support/test_site_dirs/cdn-powered.blog.fi/_site/css/styles.css +3 -0
  29. data/features/support/test_site_dirs/cdn-powered.blog.fi/_site/index.html +5 -0
  30. data/features/support/test_site_dirs/cdn-powered.blog.fi/s3_website.yml +4 -0
  31. data/features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_site/css/styles.css +3 -0
  32. data/features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_site/index.html +10 -0
  33. data/features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/s3_website.yml +4 -0
  34. data/features/support/test_site_dirs/create-redirects/_site/.gitkeep +0 -0
  35. data/features/support/test_site_dirs/create-redirects/s3_website.yml +6 -0
  36. data/features/support/test_site_dirs/index-and-assets.blog.fi/_site/assets/picture.gif +0 -0
  37. data/features/support/test_site_dirs/index-and-assets.blog.fi/_site/css/styles.css +3 -0
  38. data/features/support/test_site_dirs/index-and-assets.blog.fi/_site/index.html +5 -0
  39. data/features/support/test_site_dirs/index-and-assets.blog.fi/s3_website.yml +3 -0
  40. data/features/support/test_site_dirs/my.blog.com/_site/css/styles.css +3 -0
  41. data/features/support/test_site_dirs/my.blog.com/_site/index.html +5 -0
  42. data/features/support/test_site_dirs/my.blog.com/s3_website.yml +3 -0
  43. data/features/support/test_site_dirs/my.sydney.blog.au/_site/css/styles.css +3 -0
  44. data/features/support/test_site_dirs/my.sydney.blog.au/_site/index.html +5 -0
  45. data/features/support/test_site_dirs/my.sydney.blog.au/s3_website.yml +4 -0
  46. data/features/support/test_site_dirs/new-and-changed-files.com/_site/css/styles.css +4 -0
  47. data/features/support/test_site_dirs/new-and-changed-files.com/_site/index.html +8 -0
  48. data/features/support/test_site_dirs/new-and-changed-files.com/s3_website.yml +3 -0
  49. data/features/support/test_site_dirs/no-new-or-changed-files.com/_site/css/styles.css +3 -0
  50. data/features/support/test_site_dirs/no-new-or-changed-files.com/_site/index.html +5 -0
  51. data/features/support/test_site_dirs/no-new-or-changed-files.com/s3_website.yml +3 -0
  52. data/features/support/test_site_dirs/only-changed-files.com/_site/css/styles.css +3 -0
  53. data/features/support/test_site_dirs/only-changed-files.com/_site/index.html +9 -0
  54. data/features/support/test_site_dirs/only-changed-files.com/s3_website.yml +3 -0
  55. data/features/support/test_site_dirs/site.with.css-maxage.com/_site/css/styles.css +3 -0
  56. data/features/support/test_site_dirs/site.with.css-maxage.com/_site/index.html +5 -0
  57. data/features/support/test_site_dirs/site.with.css-maxage.com/s3_website.yml +5 -0
  58. data/features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/css/styles.css +3 -0
  59. data/features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/index.html +5 -0
  60. data/features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/s3_website.yml +5 -0
  61. data/features/support/test_site_dirs/site.with.gzipped-html.com/_site/css/styles.css +3 -0
  62. data/features/support/test_site_dirs/site.with.gzipped-html.com/_site/index.html +5 -0
  63. data/features/support/test_site_dirs/site.with.gzipped-html.com/s3_website.yml +5 -0
  64. data/features/support/test_site_dirs/site.with.maxage.com/_site/css/styles.css +3 -0
  65. data/features/support/test_site_dirs/site.with.maxage.com/_site/index.html +5 -0
  66. data/features/support/test_site_dirs/site.with.maxage.com/s3_website.yml +4 -0
  67. data/features/support/test_site_dirs/unpublish-a-post.com/_site/css/styles.css +3 -0
  68. data/features/support/test_site_dirs/unpublish-a-post.com/s3_website.yml +3 -0
  69. data/features/support/vcr.rb +18 -0
  70. data/features/sync.feature +80 -0
  71. data/features/website-performance.feature +57 -0
  72. data/lib/cloudfront/invalidator.rb +22 -0
  73. data/lib/s3_website.rb +20 -0
  74. data/lib/s3_website/config_loader.rb +56 -0
  75. data/lib/s3_website/diff_helper.rb +21 -0
  76. data/lib/s3_website/endpoint.rb +30 -0
  77. data/lib/s3_website/errors.rb +28 -0
  78. data/lib/s3_website/keyboard.rb +27 -0
  79. data/lib/s3_website/parallelism.rb +18 -0
  80. data/lib/s3_website/retry.rb +19 -0
  81. data/lib/s3_website/tasks.rb +42 -0
  82. data/lib/s3_website/upload.rb +103 -0
  83. data/lib/s3_website/uploader.rb +160 -0
  84. data/s3-website.gemspec +39 -0
  85. data/spec/lib/config_loader_spec.rb +20 -0
  86. data/spec/lib/endpoint_spec.rb +27 -0
  87. data/spec/lib/keyboard_spec.rb +59 -0
  88. data/spec/lib/parallelism_spec.rb +43 -0
  89. data/spec/lib/retry_spec.rb +34 -0
  90. data/spec/lib/upload_spec.rb +205 -0
  91. data/spec/lib/uploader_spec.rb +30 -0
  92. data/spec/sample_files/hyde_site/_site/.vimrc +5 -0
  93. data/spec/sample_files/hyde_site/_site/css/styles.css +3 -0
  94. data/spec/sample_files/hyde_site/_site/index.html +1 -0
  95. data/spec/sample_files/hyde_site/s3_website.yml +3 -0
  96. data/spec/sample_files/tokyo_site/_site/.vimrc +5 -0
  97. data/spec/sample_files/tokyo_site/_site/css/styles.css +3 -0
  98. data/spec/sample_files/tokyo_site/_site/index.html +1 -0
  99. data/spec/sample_files/tokyo_site/s3_website.yml +4 -0
  100. data/spec/spec_helper.rb +1 -0
  101. metadata +416 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: abf40795dc9d2a58f7c49cdca9aa4afe08719c83
4
+ data.tar.gz: 49ece41b838b6ca727f0f7f801633c732c4cf414
5
+ SHA512:
6
+ metadata.gz: dce2b656e14459f9cdc879ef1a37035ba97b33f9627c3b5404bc2e1a7945d79d3af9a5e5f32b532f9725488e010d76073e74d3a9d7ca70e108d3c27f5d1bfb8f
7
+ data.tar.gz: b494dc93e43b2c6656c7bc5495320fdd275d1ba803deb593250795e5f20a845ba32b227b8e0eec8197c1d07611ec26c810c9812c6bc548a3cf2bb5a111a48c83
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .rvmrc
2
+ *.gem
3
+ .bundle
4
+ pkg/*
5
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ s3_website (0.1.0)
5
+ aws-sdk (~> 1.8.5)
6
+ configure-s3-website (~> 1)
7
+ erubis (~> 2.7.0)
8
+ filey-diff (~> 1)
9
+ mime-types (= 1.19)
10
+ simple-cloudfront-invalidator (~> 1)
11
+ thor (= 0.18.1)
12
+
13
+ GEM
14
+ remote: http://rubygems.org/
15
+ specs:
16
+ addressable (2.3.4)
17
+ aruba (0.5.3)
18
+ childprocess (>= 0.3.6)
19
+ cucumber (>= 1.1.1)
20
+ rspec-expectations (>= 2.7.0)
21
+ aws-sdk (1.8.5)
22
+ json (~> 1.4)
23
+ nokogiri (>= 1.4.4)
24
+ uuidtools (~> 2.1)
25
+ builder (3.2.2)
26
+ childprocess (0.3.9)
27
+ ffi (~> 1.0, >= 1.0.11)
28
+ colored (1.2)
29
+ configure-s3-website (1.4.0)
30
+ deep_merge (= 1.0.0)
31
+ crack (0.4.0)
32
+ safe_yaml (~> 0.9.0)
33
+ cucumber (1.3.2)
34
+ builder (>= 2.1.2)
35
+ diff-lcs (>= 1.1.3)
36
+ gherkin (~> 2.12.0)
37
+ multi_json (~> 1.3)
38
+ deep_merge (1.0.0)
39
+ diff-lcs (1.2.4)
40
+ erubis (2.7.0)
41
+ ffi (1.9.0)
42
+ filey-diff (1.2.1)
43
+ gherkin (2.12.0)
44
+ multi_json (~> 1.3)
45
+ json (1.8.0)
46
+ mime-types (1.19)
47
+ mini_portile (0.5.0)
48
+ multi_json (1.7.7)
49
+ nokogiri (1.6.0)
50
+ mini_portile (~> 0.5.0)
51
+ rake (10.1.0)
52
+ rspec (2.13.0)
53
+ rspec-core (~> 2.13.0)
54
+ rspec-expectations (~> 2.13.0)
55
+ rspec-mocks (~> 2.13.0)
56
+ rspec-core (2.13.1)
57
+ rspec-expectations (2.13.0)
58
+ diff-lcs (>= 1.1.3, < 2.0)
59
+ rspec-mocks (2.13.1)
60
+ safe_yaml (0.9.3)
61
+ simple-cloudfront-invalidator (1.0.0)
62
+ colored (= 1.2)
63
+ thor (0.18.1)
64
+ uuidtools (2.1.4)
65
+ vcr (2.5.0)
66
+ webmock (1.8.11)
67
+ addressable (>= 2.2.7)
68
+ crack (>= 0.1.7)
69
+
70
+ PLATFORMS
71
+ ruby
72
+
73
+ DEPENDENCIES
74
+ aruba (~> 0.5.1)
75
+ cucumber
76
+ rake
77
+ rspec
78
+ rspec-expectations
79
+ s3_website!
80
+ vcr (~> 2.5.0)
81
+ webmock (~> 1.8.0)
data/LICENSE ADDED
@@ -0,0 +1,42 @@
1
+ Copyright (c) 2013 Lauri Lehmijoki
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
21
+ (This software is derived from the Ruby gem jekyll-s3, which was created by
22
+ Philippe Creux. Below is the MIT license of jekyll-s3.)
23
+
24
+ Copyright (c) 2011 VersaPay, Philippe Creux.
25
+
26
+ Permission is hereby granted, free of charge, to any person obtaining a copy
27
+ of this software and associated documentation files (the "Software"), to deal
28
+ in the Software without restriction, including without limitation the rights
29
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
30
+ copies of the Software, and to permit persons to whom the Software is
31
+ furnished to do so, subject to the following conditions:
32
+
33
+ The above copyright notice and this permission notice shall be included in
34
+ all copies or substantial portions of the Software.
35
+
36
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
42
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,332 @@
1
+ # s3_website – Deploy your website to S3.
2
+
3
+ [![Build Status](https://secure.travis-ci.org/laurilehmijoki/s3_website.png)] (http://travis-ci.org/laurilehmijoki/s3_website)
4
+ [![Gem Version](https://fury-badge.herokuapp.com/rb/s3_website.png)](http://badge.fury.io/rb/s3_website)
5
+
6
+ ## What s3_website can do for you
7
+
8
+ * Upload your site to AWS S3
9
+ * Help you use AWS Cloudfront to distribute your website
10
+ * Create an S3 website for you
11
+ * Improve page speed with HTTP cache control and gzipping
12
+ * Set HTTP redirects for your website
13
+ * (for other features, see the documentation below)
14
+
15
+ ## Install
16
+
17
+ gem install s3_website
18
+
19
+ ## Usage
20
+
21
+ * Go to your website directory
22
+ * Run `s3_website cfg create`. It generates a configuration file called `s3_website.yml` that looks like this:
23
+ <pre>
24
+ s3_id: YOUR_AWS_S3_ACCESS_KEY_ID
25
+ s3_secret: YOUR_AWS_S3_SECRET_ACCESS_KEY
26
+ s3_bucket: your.blog.bucket.com
27
+ </pre>
28
+ * Edit it with your details (you can use [ERB](http://ruby-doc.org/stdlib-1.9.3/libdoc/erb/rdoc/ERB.html) in the file)
29
+ * Run `configure-s3-website --config-file s3_website.yml` This will configure
30
+ your bucket to function as an S3 website. If the bucket does not exist,
31
+ `configure-s3-website` will create it for you.
32
+
33
+ * Run `s3_website push` to push your website to S3. Congratulations! You are live.
34
+
35
+ (If you are using `s3_website` 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
+
39
+ ### Using environment variables
40
+
41
+ You can use ERB in your `s3_website.yml` file which incorporates environment variables:
42
+
43
+ ```yaml
44
+ s3_id: <%= ENV['S3_ID'] %>
45
+ s3_secret: <%= ENV['S3_SECRET'] %>
46
+ s3_bucket: blog.example.com
47
+ ```
48
+
49
+ ## Project goals
50
+
51
+ * Provide a command-line interface tool for deploying and managing S3 websites
52
+ * Let the user have all the S3 website configurations in a file
53
+ * Minimise or remove the need to use the AWS Console
54
+ * Allow the user to deliver the website via CloudFront
55
+ * Automatically detect the most common static website tools, such as Jekyll or
56
+ Nanoc
57
+ * Be simple to use: require only the S3 credentials and the name of the S3
58
+ bucket
59
+ * Let the power users benefit from advanced S3 website features such as
60
+ redirects, Cache-Control headers and gzip support
61
+ * Maintain 90% backward compatibility with the jekyll-s3 gem
62
+
63
+ ## Additional features
64
+
65
+ ### Cache Control
66
+
67
+ You can use the `max_age` configuration option to enable more effective browser
68
+ caching of your static assets. There are two possible ways to use the option:
69
+ you can specify a single age (in seconds) like so:
70
+
71
+ ```yaml
72
+ max_age: 300
73
+ ```
74
+
75
+ Or you can specify a hash of globs, and all files matching those globs will have
76
+ the specified age:
77
+
78
+ ```yaml
79
+ max_age:
80
+ "assets/*": 6000
81
+ "*": 300
82
+ ```
83
+
84
+ Place the configuration into the file `s3_website.yml`.
85
+
86
+ ### Gzip Compression
87
+
88
+ If you choose, you can use compress certain file types before uploading them to
89
+ S3. This is a recommended practice for maximizing page speed and minimizing
90
+ bandwidth usage.
91
+
92
+ To enable Gzip compression, simply add a `gzip` option to your `s3_website.yml`
93
+ configuration file:
94
+
95
+ ```yaml
96
+ gzip: true
97
+ ```
98
+
99
+ Note that you can additionally specify the file extensions you want to Gzip
100
+ (`.html`, `.css`, `.js`, and `.txt` will be compressed when `gzip: true`):
101
+
102
+ ```yaml
103
+ gzip:
104
+ - .html
105
+ - .css
106
+ - .md
107
+ ```
108
+
109
+ Remember that the extensions here are referring to the *compiled* extensions,
110
+ not the pre-processed extensions.
111
+
112
+ ### Using non-standard AWS regions
113
+
114
+ By default, `s3_website` uses the US Standard Region. You can upload your
115
+ website to other regions by adding the setting `s3_endpoint` into the
116
+ `s3_website.yml` file.
117
+
118
+ For example, the following line in `s3_website.yml` will instruct `s3_website` to
119
+ push your site into the Tokyo region:
120
+
121
+ ```yaml
122
+ s3_endpoint: ap-northeast-1
123
+ ```
124
+
125
+ The valid `s3_endpoint` values consist of the [S3 location constraint
126
+ values](http://docs.amazonwebservices.com/general/latest/gr/rande.html#s3_region).
127
+
128
+ ### Ignoring files you want to keep on AWS
129
+
130
+ Sometimes there are files or directories you want to keep on S3, but not on
131
+ your local machine. You may define a regular expression to ignore files like so:
132
+
133
+ ```yaml
134
+ ignore_on_server: that_folder_of_stuff_i_dont_keep_locally
135
+ ```
136
+
137
+ ### Reduced Redundancy
138
+
139
+ You can reduce the cost of hosting your blog on S3 by using Reduced Redundancy Storage:
140
+
141
+ * In `s3_website.yml`, set `s3_reduced_redundancy: true`
142
+ * All objects uploaded after this change will use the Reduced Redundancy Storage.
143
+ * If you want to change all of the files in the bucket, you can change them through the AWS console, or update the timestamp on the files before running `s3_website` again
144
+
145
+ ### How to use Cloudfront to deliver your blog
146
+
147
+ It is easy to deliver your S3-based web site via Cloudfront, the CDN of Amazon.
148
+
149
+ #### Creating a new CloudFront distribution
150
+
151
+ When you run the command `configure-s3-website`, it will ask you whether you
152
+ want to deliver your website via CloudFront. If you answer yes,
153
+ `configure-s3-website` will create a CloudFront distribution for you.
154
+
155
+ This feature was added into the version 1.3.0 of the `configure-s3-website` gem.
156
+ For more information, see the [gem's
157
+ documentation](https://github.com/laurilehmijoki/configure-s3-website).
158
+
159
+ #### Using your existing CloudFront distribution
160
+
161
+ If you already have a CloudFront distribution that serves data from your website
162
+ S3 bucket, just add the following line into the file `s3_website.yml`:
163
+
164
+ cloudfront_distribution_id: your-dist-id
165
+
166
+ Next time you run `s3_website`, it will invalidate the items on CloudFront and
167
+ thus force the CDN system to reload the changes from your website S3 bucket.
168
+
169
+ #### Specifying custom settings for your CloudFront distribution
170
+
171
+ The gem `configure-s3-website`, which is a dependency of `s3_website`, lets you
172
+ define custom settings for your CloudFront distribution.
173
+
174
+ For example, like this you can define a your own TTL and CNAME:
175
+
176
+ ```yaml
177
+ cloudfront_distribution_config:
178
+ default_cache_behavior:
179
+ min_TTL: <%= 60 * 60 * 24 %>
180
+ aliases:
181
+ quantity: 1
182
+ items:
183
+ CNAME: your.website.com
184
+ ```
185
+
186
+ See the [gem's
187
+ documentation](https://github.com/laurilehmijoki/configure-s3-website) for more
188
+ info.
189
+
190
+ ### The headless mode
191
+
192
+ s3_website has a headless mode, where human interactions are disabled.
193
+
194
+ In the headless mode, `s3_website` will automatically delete the files on the S3
195
+ bucket that are not on your local computer.
196
+
197
+ Enable the headless mode by adding the `--headless` or `-h` argument after
198
+ `s3_website`.
199
+
200
+ ### Configuring redirects on your S3 website
201
+
202
+ You can set HTTP redirects on your S3 website in two ways. If you only need
203
+ simple "301 Moved Premanently" redirects for certain keys, use the Simple
204
+ Redirects method. Otherwise, use the Routing Rules method.
205
+
206
+ #### Simple Redirects
207
+
208
+ For simple redirects `s3_website` uses Amazon S3's
209
+ [`x-amz-website-redirect-location`](http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html)
210
+ metadata. It will create zero-byte objects for each path you want
211
+ redirected with the appropriate `x-amz-website-redirect-location` value.
212
+
213
+ For setting up simple redirect rules, simply list each path and target
214
+ as key-value pairs under the `redirects` configuration option:
215
+
216
+ ```yaml
217
+ redirects:
218
+ index.php: /
219
+ about.php: about.html
220
+ music-files/promo.mp4: http://www.youtube.com/watch?v=dQw4w9WgXcQ
221
+ ```
222
+
223
+ #### Routing Rules
224
+
225
+ You can configure more complex redirect rules by adding the following
226
+ configuration into the `s3_website.yml` file:
227
+
228
+ ```yaml
229
+ routing_rules:
230
+ - condition:
231
+ key_prefix_equals: blog/some_path
232
+ redirect:
233
+ host_name: blog.example.com
234
+ replace_key_prefix_with: some_new_path/
235
+ http_redirect_code: 301
236
+ ```
237
+
238
+ After adding the configuration, run the command `configure-s3-website --config
239
+ s3_website.yml` on your command-line interface. This will apply the routing
240
+ rules on your S3 bucket.
241
+
242
+ For more information on configuring redirects, see the documentation of the
243
+ [configure-s3-website](https://github.com/laurilehmijoki/configure-s3-website#configuring-redirects)
244
+ gem, which comes as a transitive dependency of the `s3_website` gem.
245
+
246
+ ### Using `s3_website` as a library
247
+
248
+ By nature, `s3_website` is a command-line interface tool. You can, however, use
249
+ it programmatically by calling the same API as the executable `s3_website` does:
250
+
251
+ ````ruby
252
+ require 's3_website'
253
+ is_headless = true
254
+ S3Website::Tasks.push('/path/to/your/website/_site/', is_headless)
255
+ ````
256
+
257
+ You can also use a basic `Hash` instead of a `s3_website.yml` file:
258
+
259
+ ```ruby
260
+ config = {
261
+ "s3_id" => YOUR_AWS_S3_ACCESS_KEY_ID,
262
+ "s3_secret" => YOUR_AWS_S3_SECRET_ACCESS_KEY,
263
+ "s3_bucket" => "your.blog.bucket.com"
264
+ }
265
+ in_headless = true
266
+ S3Website::Uploader.run('/path/to/your/website/_site/', config, in_headless)
267
+ ```
268
+
269
+ The code above will assume that you have the `s3_website.yml` in the directory
270
+ `/path/to/your/website`.
271
+
272
+ ## Example configurations
273
+
274
+ See
275
+ <https://github.com/laurilehmijoki/s3_website/blob/master/example-configurations.md>.
276
+
277
+ ## Known issues
278
+
279
+ None. Please send a pull request if you spot any.
280
+
281
+ ## Development
282
+
283
+ ### Versioning
284
+
285
+ s3_website uses [Semantic Versioning](http://semver.org).
286
+
287
+ ### Tests
288
+
289
+ * Install bundler and run `bundle install`
290
+ * Run all tests by invoking `rake test`
291
+ * Run the integration tests by running `bundle exec cucumber`
292
+ * Run the unit tests by running `bundle exec rspec spec/lib/*.rb`
293
+
294
+ ### Contributing
295
+
296
+ We (users and developers of s3_website) welcome patches, pull requests and
297
+ ideas for improvement.
298
+
299
+ When sending pull requests, please accompany them with tests. Favor BDD style
300
+ in test descriptions. Use VCR-backed integration tests where possible. For
301
+ reference, you can look at the existing s3_website tests.
302
+
303
+ If you are not sure how to test your pull request, you can ask the [gem owners
304
+ ](http://rubygems.org/gems/s3_website) to supplement the request with tests.
305
+ However, by including proper tests, you increase the chances of your pull
306
+ request being incorporated into future releases.
307
+
308
+ ## License
309
+
310
+ MIT. See the LICENSE file for more information.
311
+
312
+ ## Contributors
313
+
314
+ This gem is created by [Lauri Lehmijoki](https://github.com/laurilehmijoki).
315
+ Without the valuable work of [Philippe Creux](https://github.com/pcreux) on
316
+ [jekyll-s3](https://github.com/laurilehmijoki/jekyll-s3), this project would not
317
+ exist.
318
+
319
+ Contributors (in alphabetical order)
320
+ * Alan deLevie
321
+ * Cory Kaufman-Schofield
322
+ * Chris Kelly
323
+ * Chris Moos
324
+ * David Michael Barr
325
+ * László Bácsi
326
+ * Mason Turner
327
+ * Michael Bleigh
328
+ * Philippe Creux
329
+ * Shigeaki Matsumura
330
+ * stanislas
331
+ * Trevor Fitzgerald
332
+ * Zee Spencer