Skip to content

Commit

Permalink
Add markdown support in changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
KOWX712 committed Jan 2, 2025
1 parent 7e2c185 commit ec330a4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion module/common/get_extra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ release_note() {
awk '
/^### v[0-9]+\.[0-9]+$/ {
if (!found) {
version = $2;
version = $0;
found = 1;
next
} else {
Expand Down
6 changes: 6 additions & 0 deletions module/webui/scripts/marked.min.js

Large diffs are not rendered by default.

23 changes: 16 additions & 7 deletions module/webui/scripts/update.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { basePath, execCommand, showPrompt, noConnection } from './main.js';
import { basePath, execCommand, showPrompt, noConnection, linkRedirect } from './main.js';
import { updateCard } from './applist.js';

const updateCardText = document.getElementById('redirect-to-release');
Expand Down Expand Up @@ -55,14 +55,23 @@ function setupUpdateMenu() {
showPrompt("prompt.downloaded");
}
const changelog = await execCommand(`sh ${basePath}common/get_extra.sh --release-note`);
const lines = changelog
window.linkRedirect = linkRedirect;
marked.setOptions({
sanitize: true,
walkTokens(token) {
if (token.type === 'link') {
const href = token.href;
token.href = "javascript:void(0);";
token.type = "html";
token.text = `<a href="javascript:void(0);" onclick="linkRedirect('${href}')">${token.text}</a>`;
}
}
});
const cleanedChangelog = changelog
.split('\n')
.filter(line => line.trim() !== '')
.map(line => line.startsWith('- ') ? line.slice(2) : line);
const formattedChangelog = `
<li class="changelog-title">${lines[0]}</li>
${lines.slice(1).map(line => `<li>${line}</li>`).join('')}
`;
.join('\n');
const formattedChangelog = marked.parse(cleanedChangelog);
releaseNotes.innerHTML = formattedChangelog;
openUpdateMenu();
} catch (error) {
Expand Down
30 changes: 18 additions & 12 deletions module/webui/styles/applist.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,37 +85,39 @@
overflow-y: auto;
}

.update-content ul {
padding-left: 0;
margin: 0;
.update-content h3 {
font-size: 22px;
}

.changelog-title {
font-weight: bold;
font-size: 22px;
list-style-type: none;
.update-content ul {
padding-left: 0;
margin: 0;
}

.update-content ul li {
margin-left: 15px;
margin-bottom: 5px;
list-style-type: disc;
}

.update-content ul li:not(:first-child) {
list-style-type: disc;
margin-left: 15px;
.update-content a {
color: #6E6E6E;
cursor: none;
}

.update-content a:active {
color: blue;
}

.update-button-container {
width: 100%;
padding: 0;
padding-top: 10px;
display: flex;
justify-content: flex-end;
}

.install,
.reboot {
margin-left: 0;
margin-top: 10px;
margin-bottom: 15px;
font-weight: bold;
Expand Down Expand Up @@ -357,4 +359,8 @@
.update-menu {
background-color: #343434;
}

.update-content a {
color: #C2C2C2;
}
}

0 comments on commit ec330a4

Please sign in to comment.