From a4ec2d1d8642e3ef289db3b4be55eab700211422 Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Mon, 8 Aug 2022 12:53:52 +0200 Subject: [PATCH] [BS5] adjust whats new modal --- data/web/js/site/admin.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/data/web/js/site/admin.js b/data/web/js/site/admin.js index f7bd628c..6402d4c6 100644 --- a/data/web/js/site/admin.js +++ b/data/web/js/site/admin.js @@ -809,7 +809,7 @@ jQuery(function($){ success: function (data) { var md = window.markdownit(); var result = md.render(data.body); - result = parseGitHubLinks(result); + result = parseLinks(result); $('#showWhatsNew').find(".modal-body").html(`

` + data.name + `

@@ -826,17 +826,27 @@ jQuery(function($){ }).show(); } - function parseGitHubLinks(inputText) { + function parseLinks(inputText) { var replacedText, replacePattern1; replacePattern1 = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim; replacedText = inputText.replace(replacePattern1, (matched, index, original, input_string) => { - if (!matched.includes('github.com')) return matched; + if (matched.includes('github.com')){ + // return short link if it's github link + last_uri_path = matched.split('/'); + last_uri_path = last_uri_path[last_uri_path.length - 1]; + + // adjust Full Changelog link to match last git version and new git version, if link is a compare link + if (matched.includes('/compare/') && mailcow_info.last_version_tag !== ''){ + matched = matched.replace(last_uri_path, mailcow_info.last_version_tag + '...' + mailcow_info.version_tag); + last_uri_path = mailcow_info.last_version_tag + '...' + mailcow_info.version_tag; + } + + return '' + last_uri_path + '
'; + }; - last_uri_path = matched.split('/'); - last_uri_path = last_uri_path[last_uri_path.length - 1]; - - return '' + last_uri_path + ''; + // if it's not a github link, return complete link + return '' + matched + ''; }); return replacedText;