s3_website 2.15.1 → 2.16.0

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: 74e389d709a1b22628c825ed08d0b10ed70a3203
4
- data.tar.gz: 36fe9d03a05edd81fe46d640a658adab56190d82
3
+ metadata.gz: dbdc951c8ea3b23bf048f87a0933c7b9d628051d
4
+ data.tar.gz: 421087147bcdc04094e45bb5b1b30e88e151f86e
5
5
  SHA512:
6
- metadata.gz: f7e14464bf2b8a3b3ea49f475dce49fc8642f5710a6c9e2b6bd07c4d7b2522854fd6e603c0c913fd2ad899804d11d638949fc2e56eb16556e88c80828bd69df7
7
- data.tar.gz: 7b30125db36d4bbbca1443c2455e2f71a1d38205a7e1622963a334ca634d314212c41f9e072dd5a6e51677844385f5a3e6f0cd7714bc286c406d1b735d78c712
6
+ metadata.gz: a3a4f0b01963fead41546f12aaebe02569b5f801fc8824ea946094172079da18e3655c0121f671e1eb2fcf0503a84159125da68817e07d398784e529a7b49bdf
7
+ data.tar.gz: 2b833de71c10e473b022e40c119d18c0cc74d3159ddaecd9fff51ba67bd7bb948f65a7f5afdeea4c5e49294454a34006b4d38ca279bde688832a9fabd0df6d26
data/README.md CHANGED
@@ -25,7 +25,7 @@ and [Java](http://java.com) to run. (S3_website is partly written in Scala, henc
25
25
  Here's how you can get started:
26
26
 
27
27
  * Create API credentials that have sufficient permissions to S3. More info
28
- [here](additional-docs/setting-up-aws-credentials.md).
28
+ [here](https://github.com/laurilehmijoki/s3_website/tree/master/additional-docs/setting-up-aws-credentials.md).
29
29
  * Go to your website directory
30
30
  * Run `s3_website cfg create`. This generates a configuration file called `s3_website.yml`.
31
31
  * Put your AWS credentials and the S3 bucket name into the file
@@ -525,6 +525,8 @@ See the [Contributors](https://github.com/laurilehmijoki/s3_website/graphs/contr
525
525
  ## Community articles
526
526
 
527
527
  * [Deploying websites to FTP or Amazon S3 with BitBucket Pipelines](https://www.savjee.be/2016/06/Deploying-website-to-ftp-or-amazon-s3-with-BitBucket-Pipelines/)
528
+ * [How To: Hosting on Amazon S3 with CloudFront](https://paulstamatiou.com/hosting-on-amazon-s3-with-cloudfront/)
529
+ * [PageSpeed 100 with Jekyll, S3 and CloudFront](https://habd.as/pagespeed-100-with-jekyll-s3-and-cloudfront/)
528
530
 
529
531
  ## Donations
530
532
 
data/bin/s3_website CHANGED
@@ -124,6 +124,17 @@ class Cli < Thor
124
124
  end
125
125
  end
126
126
 
127
+ desc 'install', 'Download s3_website.jar'
128
+ long_desc <<-LONGDESC
129
+ Use `s3_website install` to download the s3_website.jar dependency
130
+ before you run `s3_website push` (good for CI dependency caching).
131
+ LONGDESC
132
+ def install
133
+ project_root = File.expand_path(File.dirname(__FILE__)+ '/..')
134
+ logger = Logger.new(options[:verbose])
135
+ resolve_jar(project_root, logger)
136
+ end
137
+
127
138
  desc 'cfg SUBCOMMAND ...ARGS', 'Operate on the config file'
128
139
  subcommand 'cfg', Cfg
129
140
  end
data/changelog.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This project uses [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## 2.16.0
6
+
7
+ * Add command `s3_website install`
8
+
5
9
  ## 2.15.1
6
10
 
7
11
  * Support all AWS regions
@@ -1,3 +1,3 @@
1
1
  module S3Website
2
- VERSION = '2.15.1'
2
+ VERSION = '2.16.0'
3
3
  end
@@ -132,7 +132,7 @@ object Config {
132
132
 
133
133
  def loadEndpoint(implicit unsafeYaml: UnsafeYaml): Either[ErrorReport, Option[S3Endpoint]] =
134
134
  loadOptionalString("s3_endpoint").right map { endpointString =>
135
- endpointString.map(S3Endpoint(_))
135
+ endpointString.map(S3Endpoint.fromString)
136
136
  }
137
137
 
138
138
  def loadRedirects(s3_key_prefix: Option[String])(implicit unsafeYaml: UnsafeYaml): Either[ErrorReport, Option[Map[S3Key, String]]] = {
@@ -1,12 +1,11 @@
1
1
  package s3.website.model
2
2
 
3
3
  case class S3Endpoint(
4
- s3WebsiteHostname: String,
5
- s3Hostname: String
4
+ s3WebsiteHostname: String
6
5
  )
7
6
 
8
7
  object S3Endpoint {
9
- def defaultEndpoint = S3Endpoint("us-east-1")
8
+ def defaultEndpoint = S3Endpoint.fromString("us-east-1")
10
9
 
11
10
  val oldRegions = Seq(
12
11
  "us-east-1",
@@ -19,9 +18,9 @@ object S3Endpoint {
19
18
  "sa-east-1"
20
19
  )
21
20
 
22
- def apply(region: String): S3Endpoint = {
21
+ def fromString(region: String): S3Endpoint = {
23
22
  if (region == "EU") {
24
- return S3Endpoint("eu-west-1")
23
+ return S3Endpoint.fromString("eu-west-1")
25
24
  }
26
25
 
27
26
  val isOldRegion = oldRegions.contains(region)
@@ -30,14 +29,7 @@ object S3Endpoint {
30
29
  s"s3-website-$region.amazonaws.com"
31
30
  else
32
31
  s"s3-website.$region.amazonaws.com"
33
- val s3Hostname =
34
- if (region == "us-east-1")
35
- "s3.amazonaws.com"
36
- else if (isOldRegion)
37
- s"s3-$region.amazonaws.com"
38
- else
39
- s"s3.$region.amazonaws.com"
40
32
 
41
- S3Endpoint(s3WebsiteHostname = s3WebsiteHostname, s3Hostname = s3Hostname)
33
+ S3Endpoint(s3WebsiteHostname = s3WebsiteHostname)
42
34
  }
43
35
  }
@@ -1,20 +1,16 @@
1
1
  package s3.website.model
2
2
 
3
- import com.amazonaws.services.s3.model.S3ObjectSummary
3
+ import java.io.File.createTempFile
4
4
  import java.io._
5
-
6
- import org.apache.commons.codec.digest.DigestUtils
7
5
  import java.util.zip.{GZIPInputStream, GZIPOutputStream}
8
6
 
7
+ import com.amazonaws.services.s3.model.S3ObjectSummary
8
+ import org.apache.commons.codec.digest.DigestUtils
9
+ import org.apache.commons.io.IOUtils
9
10
  import org.apache.tika.Tika
10
- import s3.website.Ruby._
11
11
  import s3.website._
12
+ import s3.website.model.Encoding.{Gzip, Zopfli}
12
13
  import s3.website.model.Upload.{amountOfMagicGzipBytes, tika}
13
- import s3.website.model.Encoding.{Gzip, Zopfli, encodingOnS3}
14
- import java.io.File.createTempFile
15
-
16
- import org.apache.commons.io.{FileUtils, IOUtils}
17
- import org.apache.commons.io.IOUtils._
18
14
 
19
15
  import scala.concurrent.{ExecutionContextExecutor, Future}
20
16
  import scala.util.Try
@@ -25,20 +21,6 @@ object Encoding {
25
21
 
26
22
  case class Gzip()
27
23
  case class Zopfli()
28
-
29
- def encodingOnS3(s3Key: S3Key)(implicit config: Config): Option[Either[Gzip, Zopfli]] =
30
- config.gzip.flatMap { (gzipSetting: Either[Boolean, Seq[String]]) =>
31
- val shouldZipThisFile = gzipSetting.fold(
32
- shouldGzip => defaultGzipExtensions exists s3Key.key.endsWith,
33
- fileExtensions => fileExtensions exists s3Key.key.endsWith
34
- )
35
- if (shouldZipThisFile && config.gzip_zopfli.isDefined)
36
- Some(Right(Zopfli()))
37
- else if (shouldZipThisFile)
38
- Some(Left(Gzip()))
39
- else
40
- None
41
- }
42
24
  }
43
25
 
44
26
  sealed trait UploadType {
@@ -59,7 +41,20 @@ case object RedirectFile extends UploadType {
59
41
  case class Upload(originalFile: File, uploadType: UploadType)(implicit site: Site, logger: Logger) {
60
42
  lazy val s3Key = site.resolveS3Key(originalFile)
61
43
 
62
- lazy val encodingOnS3 = Encoding.encodingOnS3(s3Key)
44
+ lazy val encodingOnS3: Option[Either[Gzip, Zopfli]] =
45
+ site.config.gzip.flatMap { (gzipSetting: Either[Boolean, Seq[String]]) =>
46
+ val shouldZipThisFile = gzipSetting.fold(
47
+ shouldGzip => Encoding.defaultGzipExtensions exists s3Key.key.endsWith,
48
+ fileExtensions => fileExtensions exists s3Key.key.endsWith
49
+ )
50
+ if (shouldZipThisFile && site.config.gzip_zopfli.isDefined)
51
+ Some(Right(Zopfli()))
52
+ else if (shouldZipThisFile)
53
+ Some(Left(Gzip()))
54
+ else
55
+ None
56
+ }
57
+
63
58
  lazy val gzipEnabledByConfig: Boolean = encodingOnS3.fold(false)((algorithm: Either[Gzip, Zopfli]) => true)
64
59
 
65
60
  lazy val contentType: Try[String] = tika map { tika =>
@@ -0,0 +1,15 @@
1
+ package s3.website
2
+
3
+ import org.specs2.mutable.Specification
4
+ import s3.website.model.S3Endpoint
5
+
6
+ class S3EndpointSpec extends Specification {
7
+
8
+ "S3Endpoint" should {
9
+ "map EU to eu-west-1" in {
10
+ S3Endpoint.fromString("EU").s3WebsiteHostname must equalTo("s3-website-eu-west-1.amazonaws.com")
11
+ }
12
+ }
13
+
14
+ }
15
+
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.15.1
4
+ version: 2.16.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-09-07 00:00:00.000000000 Z
11
+ date: 2016-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -142,6 +142,7 @@ files:
142
142
  - src/main/scala/s3/website/model/ssg.scala
143
143
  - src/main/scala/s3/website/package.scala
144
144
  - src/test/scala/s3/website/AwsSdkSpec.scala
145
+ - src/test/scala/s3/website/S3EndpointSpec.scala
145
146
  - src/test/scala/s3/website/S3WebsiteSpec.scala
146
147
  - src/test/scala/s3/website/UnitTest.scala
147
148
  - vagrant/Vagrantfile
@@ -171,5 +172,6 @@ specification_version: 4
171
172
  summary: Manage your S3 website
172
173
  test_files:
173
174
  - src/test/scala/s3/website/AwsSdkSpec.scala
175
+ - src/test/scala/s3/website/S3EndpointSpec.scala
174
176
  - src/test/scala/s3/website/S3WebsiteSpec.scala
175
177
  - src/test/scala/s3/website/UnitTest.scala