set default page for docs (#1102)

This mirrors the current behaviour of docs.daml.com.
This commit is contained in:
Gary Verhaegen 2019-05-14 00:34:21 +02:00 committed by mergify[bot]
parent 1b6df13861
commit a244579470
6 changed files with 62 additions and 2 deletions

View File

@ -16,6 +16,7 @@ module "daml_docs" {
project = "${local.project}"
region = "${local.region}"
ssl_certificate = "${local.ssl_certificate}"
default_file = "docs"
// We do not want to delete anything here, but Terraform composition is hard
// so instead keep objects for 100 years.

View File

@ -19,6 +19,7 @@ It also makes a few assumptions:
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| cache\_retention\_days | The number of days to keep the objects around | string | n/a | yes |
| default\_file | The name of the file (from the files folder) to show for unknown paths. Currently one of cache or docs. | string | `"cache"` | no |
| labels | Labels to apply on all the resources | map | `<map>` | no |
| name | Name prefix for all the resources | string | n/a | yes |
| project | GCP project name | string | n/a | yes |
@ -32,4 +33,4 @@ It also makes a few assumptions:
| bucket\_name | Name of the GCS bucket that will receive the objects. |
| external\_ip | The external IP assigned to the global fowarding rule. |
<!-- END mdsh -->
<!-- END mdsh -->

View File

@ -0,0 +1,42 @@
<!-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Karla" rel="stylesheet">
</head>
<body>
<svg width="840px" height="226px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 840.2 226" style="display:block; margin:100px auto 50px; enable-background:new 0 0 840.2 226;" xml:space="preserve">
<style type="text/css">
.st0{fill:#21356A;}
.st1{fill-rule:evenodd;clip-rule:evenodd;fill:#517CD9;}
.st2{fill-rule:evenodd;clip-rule:evenodd;fill:url(#SVGID_1_);}
.st3{fill-rule:evenodd;clip-rule:evenodd;fill:#21356A;}
.st4{fill-rule:evenodd;clip-rule:evenodd;fill:#81A9FF;}
</style>
<path class="st0" d="M687.3,0h-59.2l-59.5,157.2L508.4,0h-60.2v226H499V85.9L549.2,226h38.6l48.6-140.1V226h50.9V0z"/>
<path class="st0" d="M776.1,180.8V0H724v226h116.2v-45.2H776.1z"/>
<path class="st0" d="M0,0v226h82.7c18.7,0,35.3-3.2,49.9-9.5c14.6-6.3,26.9-14.8,36.9-25.3c10-10.5,17.5-22.6,22.7-36.2
c5.1-13.6,7.7-27.5,7.7-42c0-14.4-2.6-28.4-7.9-42c-5.3-13.6-12.9-25.6-22.9-36.2c-10-10.5-22.2-19-36.7-25.3
C118,3.2,101.4,0,82.7,0H0z M80.1,45.2c10.5,0,19.9,1.9,28.2,5.6c8.3,3.8,15.2,8.8,20.9,15.2c5.7,6.4,10,13.6,13,21.8
c3,8.2,4.5,16.6,4.5,25.2c0,8.8-1.5,17.3-4.5,25.3c-3,8.1-7.4,15.3-13,21.6c-5.7,6.4-12.7,11.4-20.9,15.2
c-8.3,3.8-17.7,5.6-28.2,5.6h-28V45.2H80.1z"/>
<g>
<path class="st1" d="M285.4,2.1h50.3L406.1,226h-50.3L285.4,2.1z"/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="431.8985" y1="200.2006" x2="259.5836" y2="27.8857">
<stop offset="0" style="stop-color:#517CD9"/>
<stop offset="1" style="stop-color:#2C58B9"/>
</linearGradient>
<path class="st2" d="M285.4,2.1h50.3L406.1,226h-50.3L285.4,2.1z"/>
</g>
<polygon class="st3" points="290.4,146 265.3,226 215,226 240.1,146 "/>
<polygon class="st4" points="335.7,2.1 309.9,84.1 259.6,84.1 285.4,2.1 "/>
</svg>
<div style="text-align: center;">
<h1 style="font-family:Montserrat; font-weight:bold; font-size:30pt; color:#3A478F">There is nothing here</h1>
<a href="https://docs.daml.com/" style="font-family:Karla; font-size:20pt; color:#5C86DF">Back to safety</a>
</div>
</body>
</html>

View File

@ -41,6 +41,7 @@ resource "google_storage_bucket" "default" {
website {
main_page_suffix = "index.html"
not_found_page = "${var.default_file == "docs" ? "not-found.html" : ""}"
}
force_destroy = true
@ -53,9 +54,19 @@ resource "google_storage_bucket_acl" "default" {
}
resource "google_storage_bucket_object" "default" {
count = "${var.default_file == "cache" ? 1 : 0}"
name = "index.html"
bucket = "${google_storage_bucket.default.name}"
content = "${file("${path.module}/files/index.html")}"
content = "${file("${path.module}/files/${var.default_file}.html")}"
content_type = "text/html"
depends_on = ["google_storage_bucket_acl.default"]
}
resource "google_storage_bucket_object" "not_found" {
count = "${var.default_file == "docs" ? 1 : 0}"
name = "not-found.html"
bucket = "${google_storage_bucket.default.name}"
content = "${file("${path.module}/files/${var.default_file}.html")}"
content_type = "text/html"
depends_on = ["google_storage_bucket_acl.default"]
}

View File

@ -26,3 +26,8 @@ variable "ssl_certificate" {
variable "cache_retention_days" {
description = "The number of days to keep the objects around"
}
variable "default_file" {
description = "The name of the file (from the files folder) to show for unknown paths. Currently one of cache or docs."
default = "cache"
}