From a03206ca447f034e60efb228b116c3ba08ae14ab Mon Sep 17 00:00:00 2001
From: Martyn Welch <martyn.welch@collabora.com>
Date: Fri, 13 Nov 2020 15:45:52 +0000
Subject: [PATCH] List stable versions using shorcode

Add links to images using a shortcode to make the download page easier to
update. Improve page text.

Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
---
 content/download.md               | 78 +++++++++++--------------------
 data/releases.toml                | 12 +++++
 layouts/shortcodes/image-url.html | 31 ++++++++++++
 3 files changed, 71 insertions(+), 50 deletions(-)
 create mode 100644 data/releases.toml
 create mode 100644 layouts/shortcodes/image-url.html

diff --git a/content/download.md b/content/download.md
index 8cb526093..2170a9b4d 100644
--- a/content/download.md
+++ b/content/download.md
@@ -5,66 +5,44 @@ weight = 100
 title = "Image Download"
 +++
 
+The Apertis project provides a number of images, designed for evaluation and
+development purposes. The Apertis project recommends to use the current stable
+release images presented below for evaluation.
 
-<style>
-.tooltip {
-  position: relative;
-  display: inline-block;
-  border-bottom: 1px dotted black;
-}
-
-.tooltip .tooltiptext {
-  visibility: hidden;
-  width: 120px;
-  background-color: black;
-  color: #fff;
-  text-align: center;
-  border-radius: 6px;
-  padding: 5px 0;
-
-  /* Position the tooltip */
-  position: absolute;
-  z-index: 1;
-}
-
-.tooltip:hover .tooltiptext {
-  visibility: visible;
-}
-</style>
-
-
-<p>Note that the position of the tooltip text isn't very good. Go back to the tutorial and continue reading on how to position the tooltip in a desirable way.</p>
-
-
-The Apertis project provides a number of images, designed for evaluation and development purposes.
-
-**Please select the image type you require:**
-
-- **SDK**: The SDK is a development environment primarily designed to be run in [VirtualBox]({{< ref "virtualbox.md" >}}).
+- **SDK**: The SDK is a development environment primarily designed to be run in
+  [VirtualBox]({{< ref "virtualbox.md" >}}).
 
   | Image | Optional Downloads |
   | ----- | ------------------ |
-  | [Intel 64-bit (amd64)]() | |
+  | [Intel 64-bit (amd64)]({{< image-url Stable amd64 sdk >}}) | |
 
-- **Minimal**: A compact image, designed to be run as a headless system on target hardware.
+- **Minimal**: A compact image, designed to be run as a headless system on
+  [target hardware]({{< ref "reference_hardware" >}}).
 
   | Image | Optional Downloads |
   | ----- | ------------------ |
-  | [Intel 64-bit (amd64)]() | [bmap file]() |
-  | [ARM 32-bit (armhf)]() | [bmap file]() |
-  | [ARM 64-bit (arm64)]() | [bmap file]() |
+  | [Intel 64-bit (amd64)]({{< image-url Stable amd64 minimal >}}) | [bmap file]({{< image-url Stable amd64 minimal bmap >}}) |
+  | [ARM 32-bit (armhf)]({{< image-url Stable armhf minimal >}}) | [bmap file]({{< image-url Stable armhf minimal bmap >}}) |
+  | [ARM 64-bit (arm64)]({{< image-url Stable arm64 minimal >}}) | [bmap file]({{< image-url Stable arm64 minimal bmap >}}) |
 
-- **Target**: A more featureful image, providing an example graphical environment and designed to be run on target hardware.<br />
+- **Target**: A more featureful image, providing an example graphical
+  environment and designed to be run on [target hardware]({{< ref
+  "reference_hardware" >}}).
 
   | Image | Optional Downloads |
   | ----- | ------------------ |
-  | [Intel 64-bit (amd64)]() | [bmap file]() |
-  | [ARM 32-bit (armhf)]() | [bmap file]() |
-  | [ARM 64-bit (arm64)]() | [bmap file]() |
-
-{{% notice tip %}}
-Refer to the [reference hardware]({{< ref "reference_hardware" >}}) section for more information regarding the target platforms supported for each architecture.
+  | [Intel 64-bit (amd64)]({{< image-url Stable amd64 target >}}) | [bmap file]({{< image-url Stable amd64 target bmap >}}) |
+  | [ARM 32-bit (armhf)]({{< image-url Stable armhf target >}}) | [bmap file]({{< image-url Stable armhf target bmap >}}) |
+
+  {{% notice note %}}
+  No open graphical stack is available for the current stable release on the
+  arm64 reference hardware and thus target images aren't available.
+  {{% /notice %}}
+
+{{% notice info %}}
+Apertis provides a wider selection of [image types]({{< ref "images.md" >}})
+designed for other specific purposes and [versions]({{< ref "releases.md" >}})
+at differing points in the
+[release flow]({{< ref "release-flow.md#apertis-release-flow" >}}). These can
+be found on the [Apertis image site](https://images.apertis.org).
 {{% /notice %}}
-
-
-
diff --git a/data/releases.toml b/data/releases.toml
new file mode 100644
index 000000000..ba0d20374
--- /dev/null
+++ b/data/releases.toml
@@ -0,0 +1,12 @@
+[Development]
+# When promoting this to stable add arm64 target on download page
+version = "v2021dev3"
+revision = "0"
+
+[Stable]
+version = "v2020"
+revision = "2"
+
+[Old-stable]
+version = "v2019"
+revision = "4"
diff --git a/layouts/shortcodes/image-url.html b/layouts/shortcodes/image-url.html
new file mode 100644
index 000000000..a1723e548
--- /dev/null
+++ b/layouts/shortcodes/image-url.html
@@ -0,0 +1,31 @@
+{{ $baseurl := "https://images.apertis.org/release" }}
+
+{{ $release := (.Get 0) }}
+{{ $arch := (.Get 1) }}
+{{ $type := (.Get 2) }}
+
+{{ $scratch := newScratch }}
+
+{{ if eq $type "sdk" }}
+  {{ $scratch.Set "extension" ".vdi.gz" }}
+  {{ $scratch.Set "firmware" $type }}
+{{ else }}
+  {{ $scratch.Set "extension" ".img.gz" }}
+  {{ if eq $arch "amd64" }}
+    {{ $scratch.Set "firmware" "uefi" }}
+  {{ else }}
+    {{ $scratch.Set "firmware" "uboot" }}
+  {{ end }}
+{{ end }}
+{{ if eq (.Get 3) "bmap" }}
+  {{ $scratch.Set "extension" ".img.bmap" }}
+{{ end }}
+
+
+{{ $extension := $scratch.Get "extension" }}
+{{ $firmware := $scratch.Get "firmware" }}
+
+{{ $version := (index .Site.Data.releases $release).version }}
+{{ $revision := (index .Site.Data.releases $release).revision }}
+
+{{ $baseurl }}/{{ $version }}/{{ $version }}.{{ $revision }}/{{ $arch }}/{{ $type }}/apertis_{{ $version }}-{{ $type }}-{{ $arch }}-{{ $firmware }}_{{ $version}}.{{ $revision }}{{ $extension }}
-- 
GitLab