Keep line breaks in values, handle scalar and string-array JSON

- esc() helper escapes free-text values and converts newlines to <br>;
  used for commit messages, SMS text, annotations, and all JSON values
- JSON parser accepts scalar bodies (string, number, bool, null) and
  renders them as a one-row table instead of falling back to the
  default template
- Arrays of plain values render as one table under their path
  breadcrumb, so nested string lists are no longer anonymous
- GitHub commits render as cards with a sha pill linked to the commit
This commit is contained in:
Andy Dixon
2026-09-12 18:55:21 +01:00
parent b3da9fbb25
commit 64c51d4f2b
5 changed files with 50 additions and 22 deletions
+4 -2
View File
@@ -66,10 +66,12 @@ HTML;
if ($commitCount > 0) {
$eventContent .= '<div class="section"><div class="section-title">Commits</div>';
foreach (array_slice($commits, 0, 10) as $commit) {
$message = htmlspecialchars($commit['message'] ?? '', ENT_QUOTES, 'UTF-8');
$message = esc($commit['message'] ?? '');
$author = htmlspecialchars($commit['author']['name'] ?? 'Unknown', ENT_QUOTES, 'UTF-8');
$sha = htmlspecialchars(substr($commit['id'] ?? '', 0, 7), ENT_QUOTES, 'UTF-8');
$eventContent .= "<div class=\"commit-item\"><strong>$sha</strong> $message <em>by $author</em></div>";
$url = htmlspecialchars($commit['url'] ?? '', ENT_QUOTES, 'UTF-8');
$shaHtml = $url ? "<a class=\"sha\" href=\"$url\">$sha</a>" : "<span class=\"sha\">$sha</span>";
$eventContent .= "<div class=\"commit-item\">$shaHtml <span class=\"who\">$author</span><div class=\"msg\">$message</div></div>";
}
$eventContent .= '</div>';
}