kopia lustrzana https://github.com/magicbug/Cloudlog
Correctly format Markdown output for release notes
rodzic
660cdc6b24
commit
f3ffab92ef
|
@ -6,6 +6,29 @@
|
|||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<script src="<?php echo base_url('assets/js/showdown.min.js'); ?>"></script>
|
||||
|
||||
<script>
|
||||
function convertMarkdownToHTML() {
|
||||
// Get the Markdown content from the div
|
||||
var markdownContent = document.getElementById('markdownDiv').innerText;
|
||||
|
||||
// Create a new Showdown Converter with simplifiedAutoLink option enabled
|
||||
var converter = new showdown.Converter({
|
||||
simplifiedAutoLink: true
|
||||
});
|
||||
|
||||
// Convert Markdown to HTML
|
||||
var html = converter.makeHtml(markdownContent);
|
||||
|
||||
// Set the HTML content of the div
|
||||
document.getElementById('formattedHTMLDiv').innerHTML = html;
|
||||
}
|
||||
|
||||
convertMarkdownToHTML();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$versionDialogMode = isset($this->optionslib) ? $this->optionslib->get_option('version_dialog') : 'release_notes';
|
||||
if ($versionDialogMode == 'custom_text' || $versionDialogMode == 'both') {
|
||||
|
@ -25,44 +48,45 @@
|
|||
}
|
||||
if ($versionDialogMode == 'release_notes' || $versionDialogMode == 'both' || $versionDialogMode == 'disabled') {
|
||||
?>
|
||||
<div>
|
||||
<?php
|
||||
$url = 'https://api.github.com/repos/magicbug/Cloudlog/releases';
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => 'User-Agent: Cloudlog - Amateur Radio Logbook'
|
||||
]
|
||||
];
|
||||
$context = stream_context_create($options);
|
||||
$response = file_get_contents($url, false, $context);
|
||||
<div>
|
||||
<?php
|
||||
$url = 'https://api.github.com/repos/magicbug/Cloudlog/releases';
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => 'User-Agent: Cloudlog - Amateur Radio Logbook'
|
||||
]
|
||||
];
|
||||
$context = stream_context_create($options);
|
||||
$response = file_get_contents($url, false, $context);
|
||||
|
||||
if ($response !== false) {
|
||||
$data = json_decode($response, true);
|
||||
if ($response !== false) {
|
||||
$data = json_decode($response, true);
|
||||
|
||||
$current_version=$this->optionslib->get_option('version');
|
||||
if ($data !== null && !empty($data)) {
|
||||
foreach ($data as $singledata) {
|
||||
if ($singledata['tag_name']==$current_version) {
|
||||
$firstRelease = $singledata;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$current_version = $this->optionslib->get_option('version');
|
||||
if ($data !== null && !empty($data)) {
|
||||
foreach ($data as $singledata) {
|
||||
if ($singledata['tag_name'] == $current_version) {
|
||||
$firstRelease = $singledata;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$releaseBody = isset($firstRelease['body']) ? $firstRelease['body'] : 'No release information available';
|
||||
$htmlReleaseBody = htmlspecialchars($releaseBody);
|
||||
$htmlReleaseBodyWithLinks = preg_replace('/(https?:\/\/[^\s<]+)/', '<a href="$1" target="_blank">$1</a>', $htmlReleaseBody);
|
||||
$releaseBody = isset($firstRelease['body']) ? $firstRelease['body'] : 'No release information available';
|
||||
$htmlReleaseBody = htmlspecialchars($releaseBody);
|
||||
$htmlReleaseBodyWithLinks = preg_replace('/(https?:\/\/[^\s<]+)/', '<a href="$1" target="_blank">$1</a>', $htmlReleaseBody);
|
||||
|
||||
$releaseName = isset($firstRelease['name']) ? $firstRelease['name'] : 'No version name information available';
|
||||
echo "<h4>v".$releaseName."</h4>";
|
||||
echo nl2br($htmlReleaseBodyWithLinks);
|
||||
$releaseName = isset($firstRelease['name']) ? $firstRelease['name'] : 'No version name information available';
|
||||
echo "<h4>v" . $releaseName . "</h4>";
|
||||
echo "<div id='markdownDiv' style='display: none;'>" . $releaseBody . "</div>";
|
||||
echo "<div id='formattedHTMLDiv'></div>";
|
||||
} else {
|
||||
echo 'Error decoding JSON data or received empty response.';
|
||||
}
|
||||
} else {
|
||||
echo 'Fehler beim Decodieren der JSON-Daten oder leere Antwort erhalten.';
|
||||
echo 'Error retrieving data from the GitHub API.';
|
||||
}
|
||||
} else {
|
||||
echo 'Fehler beim Abrufen der Daten von der GitHub API.';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
@ -71,7 +95,7 @@
|
|||
<?php
|
||||
if ($versionDialogMode !== 'disabled') {
|
||||
?>
|
||||
<button class="btn btn-secondary" onclick="dismissVersionDialog()" data-bs-dismiss="modal"><?php echo lang('options_version_dialog_dismiss'); ?></button>
|
||||
<button class="btn btn-secondary" onclick="dismissVersionDialog()" data-bs-dismiss="modal"><?php echo lang('options_version_dialog_dismiss'); ?></button>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
@ -79,4 +103,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -19,6 +19,7 @@ $('#version_dialog_mode').on('change', function () {
|
|||
showCustomTextarea();
|
||||
});
|
||||
|
||||
|
||||
// JavaScript-Funktion displayVersionDialog für Bootstrap 5
|
||||
function displayVersionDialog() {
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Ładowanie…
Reference in New Issue