Skip to content

Commit

Permalink
BlueScreen: clickable classes in exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 2, 2020
1 parent 5e016cc commit f1a9d2c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/Tracy/BlueScreen/BlueScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ private function renderTemplate(\Throwable $exception, string $template, $toScre
'<i>$0</i>',
$messageHtml
);
$messageHtml = preg_replace_callback(
'#\w+\\\\[\w\\\\]+\w#',
function ($m) {
return class_exists($m[0], false) || interface_exists($m[0], false)
? '<a href="' . Helpers::escapeHtml(Helpers::editorUri((new \ReflectionClass($m[0]))->getFileName())) . '">' . $m[0] . '</a>'
: $m[0];
},
$messageHtml
);

$info = array_filter($this->info);
$source = Helpers::getSource();
Expand Down
8 changes: 6 additions & 2 deletions src/Tracy/BlueScreen/assets/bluescreen.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,21 @@
}

#tracy-bs-error a {
border-bottom-color: rgba(255, 255, 255, .3) !important;
}

#tracy-bs-error a.action {
color: white !important;
opacity: 0;
font-size: .7em;
border-bottom: none !important;
}

#tracy-bs-error:hover a {
#tracy-bs-error:hover a.action {
opacity: .6;
}

#tracy-bs-error a:hover {
#tracy-bs-error a.action:hover {
opacity: 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tracy/BlueScreen/assets/content.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';

<h1><span><?= $messageHtml ?: Helpers::escapeHtml(Dumper::encodeString($title . $code, self::MAX_MESSAGE_LENGTH)) ?></span>
<?php foreach ($actions as $item): ?>
<a href="<?= Helpers::escapeHtml($item['link']) ?>"<?= empty($item['external']) ? '' : ' target="_blank" rel="noreferrer noopener"'?>><?= Helpers::escapeHtml($item['label']) ?>&#x25ba;</a>
<a href="<?= Helpers::escapeHtml($item['link']) ?>" class="action"<?= empty($item['external']) ? '' : ' target="_blank" rel="noreferrer noopener"'?>><?= Helpers::escapeHtml($item['label']) ?>&#x25ba;</a>
<?php endforeach ?></h1>
</div>

Expand Down

0 comments on commit f1a9d2c

Please sign in to comment.