middleman-s3_sync 4.0.1.rc.1 → 4.0.1.rc.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aa620355fa36d4086923227d59faf63c45d32d1
4
- data.tar.gz: 0eba8d4e743a9d1b73a7a6ee5ef5fcf28447cdf1
3
+ metadata.gz: c3d7517dd1c40614ca272b6b33c3ac6363532ce6
4
+ data.tar.gz: bfaedfa1b4485554a3446bd87e86a596db1d79c3
5
5
  SHA512:
6
- metadata.gz: 19f333be406383826315d40513bc14ab10cce8dfb9cc68767078caab99ed27b095336599d10f9370c5c7d8d12bd83bb2ef7d90478dbbbc339c84ff534748ab48
7
- data.tar.gz: b9606e5f31b4537dcac23e603d75e9a532d49675348733225ee6d1d5325f9ba9a78bcfd7c61de8fdea60a8767e540a3f4869e0c8f4cb3b4d5e3124b38e25e2ef
6
+ metadata.gz: f90ea23d7a08702f1299a1a00a61b33a8527ecc1f793abbd86adda2dff116791c8dfb51168d722b09a7a8023beb2d846578218765197b5eb4c0b1b62eca7192a
7
+ data.tar.gz: 2034640bb056f492c1188997bc83d61c70eb94299f73829cc20aa4f10d80c5f34d9acf404746ffd0b514221e702bba0340188af8302eab6f3ed20c7ea96650a2
data/README.md CHANGED
@@ -52,6 +52,8 @@ activate :s3_sync do |s3_sync|
52
52
  s3_sync.encryption = false
53
53
  s3_sync.prefix = ''
54
54
  s3_sync.version_bucket = false
55
+ s3_sync.index_document = 'index.html'
56
+ s3_sync.error_document = '404.html'
55
57
  end
56
58
  ```
57
59
 
@@ -333,6 +335,15 @@ headers will be set correctly. This will cause Amazon to serve the
333
335
  compressed version of the resource. In order for this to work, you need to
334
336
  have the `:gzip` extension activated in your `config.rb`.
335
337
 
338
+ #### Custom S3 Index and Error Documents
339
+
340
+ You can enable a custom [index document](http://docs.aws.amazon.com/AmazonS3/latest/dev/IndexDocumentSupport.html)
341
+ and [error document](http://docs.aws.amazon.com/AmazonS3/latest/dev/CustomErrorDocSupport.html)
342
+ settings. The ```index_document``` option tells which file name gets used as
343
+ the index document of a directory (typically, ```index.html```), while
344
+ ```error_document``` specifies the document to display for 4xx errors (ie,
345
+ the 404 page).
346
+
336
347
  ## A Debt of Gratitude
337
348
 
338
349
  I used Middleman Sync as a template for building a Middleman extension.
@@ -23,6 +23,8 @@ module Middleman
23
23
  option :version_bucket, false, 'Whether to enable versionning on the S3 bucket content'
24
24
  option :verbose, false, 'Whether to provide more verbose output'
25
25
  option :dry_run, false, 'Whether to perform a dry-run'
26
+ option :index_document, nil, 'S3 custom index document path'
27
+ option :error_document, nil, 'S3 custom error document path'
26
28
 
27
29
  # S3Sync must be the last action in the manipulator chain
28
30
  self.resource_list_manipulator_priority = 9999
@@ -37,6 +37,8 @@ module Middleman
37
37
 
38
38
  update_bucket_versioning
39
39
 
40
+ update_bucket_website
41
+
40
42
  ignore_resources
41
43
  create_resources
42
44
  update_resources
@@ -75,6 +77,21 @@ module Middleman
75
77
  connection.put_bucket_versioning(s3_sync_options.bucket, "Enabled") if s3_sync_options.version_bucket
76
78
  end
77
79
 
80
+ def update_bucket_website
81
+ opts = {}
82
+ opts[:IndexDocument] = s3_sync_options.index_document if s3_sync_options.index_document
83
+ opts[:ErrorDocument] = s3_sync_options.error_document if s3_sync_options.error_document
84
+
85
+ if opts[:ErrorDocument] && !opts[:IndexDocument]
86
+ raise 'S3 requires `index_document` if `error_document` is specified'
87
+ end
88
+
89
+ unless opts.empty?
90
+ say_status "Putting bucket website: #{opts.to_json}"
91
+ connection.put_bucket_website(s3_sync_options.bucket, opts)
92
+ end
93
+ end
94
+
78
95
  def connection
79
96
  connection_options = {
80
97
  :region => s3_sync_options.region,
@@ -185,4 +202,3 @@ module Middleman
185
202
  end
186
203
  end
187
204
  end
188
-
@@ -21,7 +21,9 @@ module Middleman
21
21
  :version_bucket,
22
22
  :dry_run,
23
23
  :verbose,
24
- :content_types
24
+ :content_types,
25
+ :index_document,
26
+ :error_document
25
27
  ]
26
28
  attr_accessor *OPTIONS
27
29
 
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module S3Sync
3
- VERSION = "4.0.1.rc.1"
3
+ VERSION = "4.0.1.rc.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-s3_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1.rc.1
4
+ version: 4.0.1.rc.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederic Jean
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-30 00:00:00.000000000 Z
12
+ date: 2015-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: middleman-core