From ebc8d3315a3e1f15d0ae9f4b4905425a19e54e39 Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Sat, 4 Jan 2025 18:25:01 +0100 Subject: [PATCH] Automatically update try links on release pages Direct download for current and future releases, link to try page for older releases --- content/releases/3-10/release.txt | 2 -- content/releases/3-6/release.txt | 2 -- content/releases/3-7/release.txt | 2 -- content/releases/3-8/release.txt | 2 -- content/releases/3-9/release.txt | 2 -- content/releases/4/release.txt | 4 +--- content/releases/5/release.txt | 4 +--- site/models/release.php | 14 ++++++++++++++ site/snippets/templates/releases/cta.php | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/content/releases/3-10/release.txt b/content/releases/3-10/release.txt index 7a4859fb5d..e4c1a37c37 100644 --- a/content/releases/3-10/release.txt +++ b/content/releases/3-10/release.txt @@ -6,8 +6,6 @@ Version: 3.10 ---- ogimage: opengraph.png ---- -Link: https://github.com/getkirby/kirby/releases/tag/3.10.0 ----- Cover: - kirby-3-10.png ---- diff --git a/content/releases/3-6/release.txt b/content/releases/3-6/release.txt index 4aa2b51b52..f4941ca510 100644 --- a/content/releases/3-6/release.txt +++ b/content/releases/3-6/release.txt @@ -8,8 +8,6 @@ Description: Improvements all over: New way to present your content, an improved ---- Cover: kirby-3-6.png ---- -Link: https://github.com/getkirby/kirby/releases/tag/3.6.0 ----- Area: ```php diff --git a/content/releases/3-7/release.txt b/content/releases/3-7/release.txt index 0d1234d316..4e27c1079b 100644 --- a/content/releases/3-7/release.txt +++ b/content/releases/3-7/release.txt @@ -6,8 +6,6 @@ Version: 3.7 ---- ogimage: opengraph.png ---- -Link: https://github.com/getkirby/kirby/releases/tag/3.7.0 ----- Description: The Panel is in the focus of this new release with a fresh look, a stats section that turns your dashboard into a smart report, a new table layout, and a new system view that gives you an overview about everything regarding your installation. ---- diff --git a/content/releases/3-8/release.txt b/content/releases/3-8/release.txt index de63572ecb..7abc196c74 100644 --- a/content/releases/3-8/release.txt +++ b/content/releases/3-8/release.txt @@ -6,8 +6,6 @@ Version: 3.8 ---- ogimage: opengraph.png ---- -Link: https://github.com/getkirby/kirby/releases/tag/3.8.0 ----- Cover: - kirby-3-8.png ---- Description: Lost relations are a thing of the past with the new UUID and permalink features for pages, files and users. diff --git a/content/releases/3-9/release.txt b/content/releases/3-9/release.txt index 49e655c71c..475e1b1c84 100644 --- a/content/releases/3-9/release.txt +++ b/content/releases/3-9/release.txt @@ -6,8 +6,6 @@ Version: 3.9 ---- ogimage: opengraph.png ---- -Link: https://github.com/getkirby/kirby/releases/tag/3.9.0 ----- Cover: - kirby-3-9.png ---- diff --git a/content/releases/4/release.txt b/content/releases/4/release.txt index 692da9043e..d1b6a6d21c 100644 --- a/content/releases/4/release.txt +++ b/content/releases/4/release.txt @@ -10,6 +10,4 @@ Description: Kirby 4 is all about a new editing experience for users, with a bra ---- Docs: /docs ---- -Cover: - kirby-4-0.png ----- -Link: https://github.com/getkirby/kirby/archive/refs/tags/4.3.1.zip +Cover: - kirby-4-0.png \ No newline at end of file diff --git a/content/releases/5/release.txt b/content/releases/5/release.txt index b769c88601..6fed47c037 100644 --- a/content/releases/5/release.txt +++ b/content/releases/5/release.txt @@ -12,6 +12,4 @@ Description: Kirby 5 is taking existing features to new levels: collaborate on c ---- Docs: /releases/5/changes ---- -Cover: - kirby-5-0.png ----- -Link: https://github.com/getkirby/kirby/archive/refs/tags/5.0.0-beta.1.zip +Cover: - kirby-5-0.png \ No newline at end of file diff --git a/site/models/release.php b/site/models/release.php index 74bc6ad279..f812d68389 100644 --- a/site/models/release.php +++ b/site/models/release.php @@ -1,5 +1,6 @@ template ??= $this->kirby()->template($template); } + public function tryLink(): Field + { + $field = parent::tryLink(); + + // never link to downloads of previous major releases + if (Str::before($this->kirby()->version(), '.') > $this->version()) { + return $field; + } + + $url = 'https://github.com/getkirby/kirby/archive/refs/tags/' . $this->latestRelease() . '.zip'; + return $field->or($url); + } + public function url($options = null): string { return $this->parent()->url() . '/' . str_replace('-', '.', $this->slug()); diff --git a/site/snippets/templates/releases/cta.php b/site/snippets/templates/releases/cta.php index e8073099e3..041911484a 100644 --- a/site/snippets/templates/releases/cta.php +++ b/site/snippets/templates/releases/cta.php @@ -10,7 +10,7 @@ ], [ 'text' => 'Try now', - 'link' => $page->link(), + 'link' => $page->tryLink()->or('/try'), 'icon' => 'download' ], ],