s3_website 2.14.3 → 2.15.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.
- checksums.yaml +4 -4
- data/README.md +13 -36
- data/changelog.md +7 -1
- data/lib/s3_website/version.rb +1 -1
- data/src/main/scala/s3/website/model/Config.scala +18 -0
- data/src/main/scala/s3/website/model/Site.scala +2 -0
- data/src/main/scala/s3/website/model/push.scala +4 -1
- data/src/test/scala/s3/website/S3WebsiteSpec.scala +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3817c71cb9e62df94035abdb0c2a82518086f31f
|
4
|
+
data.tar.gz: f865711262a86542bbbbe79889fed47695f00ced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8fdf4cc12c1e05ed5189e1ad0e447e83794c510f7347786eca40cc08d22336fafb6f5d88a439451f7fd7d1002529b8aab9407c064f065993c991b8d43cae4ee
|
7
|
+
data.tar.gz: 462f392810758a973b71aece6a052651d95978b98740ae421cb6b35373c5167bcccf31e4d1d19ee4643ba3a83335714dafd3fe551c1cf4b55e621e8d41e809c8
|
data/README.md
CHANGED
@@ -146,6 +146,18 @@ cache_control:
|
|
146
146
|
After changing the `cache_control` setting, push with the `--force` option.
|
147
147
|
Force-pushing allows you to update the S3 object metadata of existing files.
|
148
148
|
|
149
|
+
### Content type detection
|
150
|
+
|
151
|
+
By default, s3_website automatically detects the content type of a file with the help of Apache Tika.
|
152
|
+
|
153
|
+
For some file types Tika's auto detection does not work correctly. Should this problem affect you, use the `content_type`
|
154
|
+
setting to override Tika's decision:
|
155
|
+
|
156
|
+
```yaml
|
157
|
+
content_type:
|
158
|
+
"*.myextension": application/my-custom-type
|
159
|
+
```
|
160
|
+
|
149
161
|
### Gzip Compression
|
150
162
|
|
151
163
|
If you choose, you can use compress certain file types before uploading them to
|
@@ -513,42 +525,7 @@ Creux](https://github.com/pcreux) on
|
|
513
525
|
[jekyll-s3](https://github.com/laurilehmijoki/jekyll-s3), this project would not
|
514
526
|
exist.
|
515
527
|
|
516
|
-
Contributors
|
517
|
-
* Akshay Karle
|
518
|
-
* Alan deLevie
|
519
|
-
* Almir Sarajčić
|
520
|
-
* Andrew T. Baker
|
521
|
-
* Cory Kaufman-Schofield
|
522
|
-
* Chris Kelly
|
523
|
-
* Chris Moos
|
524
|
-
* Christian Grobmeier
|
525
|
-
* Christopher Petersen
|
526
|
-
* David Michael Barr
|
527
|
-
* David Raffensperger
|
528
|
-
* Douglas Teoh
|
529
|
-
* Greg Karékinian
|
530
|
-
* Ian Hattendorf
|
531
|
-
* John Allison
|
532
|
-
* Jon Frisby
|
533
|
-
* Jordan White
|
534
|
-
* Justin Latimer
|
535
|
-
* László Bácsi
|
536
|
-
* Mason Turner
|
537
|
-
* Michael Bleigh
|
538
|
-
* maxberger
|
539
|
-
* Philip I. Thomas
|
540
|
-
* Philippe Creux
|
541
|
-
* Piotr Janik
|
542
|
-
* PJ Kelly
|
543
|
-
* Rodrigo Reis
|
544
|
-
* Ross Hunter
|
545
|
-
* Shigeaki Matsumura
|
546
|
-
* stanislas
|
547
|
-
* Tate Johnson
|
548
|
-
* Toby Marsden
|
549
|
-
* Tom Bell
|
550
|
-
* Trevor Fitzgerald
|
551
|
-
* Zee Spencer
|
528
|
+
See the [Contributors](https://github.com/laurilehmijoki/s3_website/graphs/contributors).
|
552
529
|
|
553
530
|
## Community articles
|
554
531
|
|
data/changelog.md
CHANGED
@@ -2,9 +2,15 @@
|
|
2
2
|
|
3
3
|
This project uses [Semantic Versioning](http://semver.org).
|
4
4
|
|
5
|
+
## 2.15.0
|
6
|
+
|
7
|
+
* Add new setting `content_type`
|
8
|
+
|
9
|
+
See <https://github.com/laurilehmijoki/s3_website/issues/232> for discussion
|
10
|
+
|
5
11
|
## 2.14.3
|
6
12
|
|
7
|
-
|
13
|
+
* Fix mime type of an already-gzipped .json file
|
8
14
|
|
9
15
|
See <https://github.com/laurilehmijoki/s3_website/pull/231>
|
10
16
|
|
data/lib/s3_website/version.rb
CHANGED
@@ -26,6 +26,7 @@ case class Config(
|
|
26
26
|
s3_reduced_redundancy: Option[Boolean],
|
27
27
|
cloudfront_distribution_id: Option[String],
|
28
28
|
cloudfront_invalidate_root: Option[Boolean],
|
29
|
+
content_type: Option[S3KeyGlob[String]],
|
29
30
|
redirects: Option[Map[S3Key, String]],
|
30
31
|
concurrency_level: Int,
|
31
32
|
cloudfront_wildcard_invalidation: Option[Boolean],
|
@@ -112,6 +113,23 @@ object Config {
|
|
112
113
|
yamlValue getOrElse Left(ErrorReport(s"The key $key has to have a string or (string -> string) value"))
|
113
114
|
}
|
114
115
|
|
116
|
+
def loadContentType(implicit unsafeYaml: UnsafeYaml): Either[ErrorReport, Option[S3KeyGlob[String]]] = {
|
117
|
+
val key = "content_type"
|
118
|
+
val yamlValue = for {
|
119
|
+
contentTypeOption <- loadOptionalValue(key)
|
120
|
+
} yield {
|
121
|
+
// TODO below we are using an unsafe call to asInstance of – we should implement error handling
|
122
|
+
Right(contentTypeOption.map { xs =>
|
123
|
+
val globs: Map[String, String] = xs.asInstanceOf[util.Map[String, String]].toMap
|
124
|
+
S3KeyGlob(globs)
|
125
|
+
}
|
126
|
+
)
|
127
|
+
}
|
128
|
+
|
129
|
+
yamlValue getOrElse Left(ErrorReport(s"The key $key has to have a string or (string -> string) value"))
|
130
|
+
}
|
131
|
+
|
132
|
+
|
115
133
|
def loadEndpoint(implicit unsafeYaml: UnsafeYaml): Either[ErrorReport, Option[S3Endpoint]] =
|
116
134
|
loadOptionalString("s3_endpoint").right flatMap { endpointString =>
|
117
135
|
endpointString.map(S3Endpoint.forString) match {
|
@@ -49,6 +49,7 @@ object Site {
|
|
49
49
|
s3_reduced_redundancy <- loadOptionalBoolean("s3_reduced_redundancy").right
|
50
50
|
cloudfront_distribution_id <- loadOptionalString("cloudfront_distribution_id").right
|
51
51
|
cloudfront_invalidate_root <- loadOptionalBoolean("cloudfront_invalidate_root").right
|
52
|
+
content_type <- loadContentType.right
|
52
53
|
concurrency_level <- loadOptionalInt("concurrency_level").right
|
53
54
|
cloudfront_wildcard_invalidation <- loadOptionalBoolean("cloudfront_wildcard_invalidation").right
|
54
55
|
redirects <- loadRedirects(s3_key_prefix).right
|
@@ -77,6 +78,7 @@ object Site {
|
|
77
78
|
s3_reduced_redundancy,
|
78
79
|
cloudfront_distribution_id,
|
79
80
|
cloudfront_invalidate_root,
|
81
|
+
content_type,
|
80
82
|
redirects,
|
81
83
|
concurrency_level.fold(20)(_ max 20),
|
82
84
|
cloudfront_wildcard_invalidation,
|
@@ -74,7 +74,10 @@ case class Upload(originalFile: File, uploadType: UploadType)(implicit site: Sit
|
|
74
74
|
} else {
|
75
75
|
originalFile
|
76
76
|
}
|
77
|
-
val mimeType =
|
77
|
+
val mimeType =
|
78
|
+
site.config.content_type
|
79
|
+
.flatMap { _.globMatch(s3Key) }
|
80
|
+
.getOrElse { tika.detect(file) }
|
78
81
|
if (mimeType.startsWith("text/") || mimeType == "application/json")
|
79
82
|
mimeType + "; charset=utf-8"
|
80
83
|
else
|
@@ -1052,6 +1052,18 @@ class S3WebsiteSpec extends Specification {
|
|
1052
1052
|
}
|
1053
1053
|
}
|
1054
1054
|
|
1055
|
+
"content_type in config file" should {
|
1056
|
+
"override tika's opinion" in new BasicSetup {
|
1057
|
+
config = """
|
1058
|
+
|content_type:
|
1059
|
+
| "*.html": text/foobar
|
1060
|
+
""".stripMargin
|
1061
|
+
setLocalFileWithContent(("index.html", "<html><body><h1>hi</h1></body></html>"))
|
1062
|
+
push()
|
1063
|
+
sentPutObjectRequest.getMetadata.getContentType must equalTo("text/foobar; charset=utf-8")
|
1064
|
+
}
|
1065
|
+
}
|
1066
|
+
|
1055
1067
|
"ERB in config file" should {
|
1056
1068
|
"be evaluated" in new BasicSetup {
|
1057
1069
|
config = """
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_website
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lauri Lehmijoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|