Sfoglia il codice sorgente

[BS5] adjust whats new modal

FreddleSpl0it 3 anni fa
parent
commit
a4ec2d1d86
1 ha cambiato i file con 17 aggiunte e 7 eliminazioni
  1. 17 7
      data/web/js/site/admin.js

+ 17 - 7
data/web/js/site/admin.js

@@ -809,7 +809,7 @@ jQuery(function($){
       success: function (data) { 
       success: function (data) { 
         var md = window.markdownit();
         var md = window.markdownit();
         var result = md.render(data.body);
         var result = md.render(data.body);
-        result = parseGitHubLinks(result);
+        result = parseLinks(result);
 
 
         $('#showWhatsNew').find(".modal-body").html(`
         $('#showWhatsNew').find(".modal-body").html(`
           <h3>` + data.name + `</h3>
           <h3>` + data.name + `</h3>
@@ -826,17 +826,27 @@ jQuery(function($){
     }).show();
     }).show();
   }
   }
 
 
-  function parseGitHubLinks(inputText) {
+  function parseLinks(inputText) {
     var replacedText, replacePattern1;
     var replacedText, replacePattern1;
   
   
     replacePattern1 = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
     replacePattern1 = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
     replacedText = inputText.replace(replacePattern1, (matched, index, original, input_string) => {
     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 '<a href="' + matched + '" target="_blank">' + last_uri_path + '</a><br>';
+        };
   
   
-        last_uri_path = matched.split('/');
-        last_uri_path = last_uri_path[last_uri_path.length - 1];
-        
-        return '<a href="' + matched + '" target="_blank">' + last_uri_path + '</a>';
+        // if it's not a github link, return complete link
+        return '<a href="' + matched + '" target="_blank">' + matched + '</a>'; 
     });
     });
   
   
     return replacedText;
     return replacedText;