From 3d897f33f668f16bcb34c0ae0b1a61bb33ad5051 Mon Sep 17 00:00:00 2001 From: Dmitrii Derepko Date: Sat, 22 Jun 2024 10:50:02 +0300 Subject: [PATCH 1/8] Sort headers, fix overflowing, copy curl --- src/Renderer/HtmlRenderer.php | 14 +++++++----- templates/_call-stack-item.php | 2 +- templates/development.css | 22 ++++++++++-------- templates/development.php | 41 +++++++++++++++++++++++++--------- 4 files changed, 53 insertions(+), 26 deletions(-) diff --git a/src/Renderer/HtmlRenderer.php b/src/Renderer/HtmlRenderer.php index b3449d5..5f56ff3 100644 --- a/src/Renderer/HtmlRenderer.php +++ b/src/Renderer/HtmlRenderer.php @@ -341,17 +341,19 @@ public function renderRequest(ServerRequestInterface $request): string { $output = $request->getMethod() . ' ' . $request->getUri() . "\n"; - foreach ($request->getHeaders() as $name => $values) { - if ($name === 'Host') { - continue; - } + $headers = $request->getHeaders(); + unset($headers['Host']); + ksort($headers); + foreach ($headers as $name => $values) { foreach ($values as $value) { $output .= "$name: $value\n"; } } - $output .= "\n" . $request->getBody() . "\n\n"; + if (!empty($request->getBody())) { + $output .= "\n" . $request->getBody() . "\n\n"; + } return '
' . $this->htmlEncode(rtrim($output, "\n")) . '
'; } @@ -371,7 +373,7 @@ public function renderCurl(ServerRequestInterface $request): string return $this->htmlEncode('Error generating curl command: ' . $e->getMessage()); } - return '
' . $this->htmlEncode($output) . '
'; + return $output; } /** diff --git a/templates/_call-stack-item.php b/templates/_call-stack-item.php index 4a55ff5..d94380a 100644 --- a/templates/_call-stack-item.php +++ b/templates/_call-stack-item.php @@ -21,7 +21,7 @@
  • -
    +
    htmlEncode($file)}" ?> diff --git a/templates/development.css b/templates/development.css index 2a5ca02..2da71c9 100644 --- a/templates/development.css +++ b/templates/development.css @@ -3,12 +3,6 @@ html, body, div, span, -h1, -h2, -h3, -h4, -h5, -h6, p, pre, a, @@ -344,13 +338,13 @@ header .previous h3 { height: 150px; } -#copy-stacktrace { +.copy-clipboard { position: absolute; right: 40px; top: 44px; } -#copy-stacktrace:hover svg path { +.copy-clipboard:hover svg path { fill: var(--icon-hover-color); } @@ -387,6 +381,10 @@ main { flex: 1; } +.mw-100 { + max-width: 100%; +} + /* call stack */ .call-stack ul li, .request { @@ -460,6 +458,9 @@ main { .call-stack ul li .element-wrap .function-info { display: inline-block; + line-break: normal; + overflow-wrap: break-word; + word-break: break-word; } .call-stack ul li.application .element-wrap { @@ -557,12 +558,15 @@ main { /* request */ .request { - padding: 20px 30px; + position: relative; font-size: 14px; line-height: 18px; overflow-x: auto; font-family: JetBrains Mono, Consolas, monospace; } +.request .body { + overflow: auto; +} /* end request */ /* footer */ diff --git a/templates/development.php b/templates/development.php index 5b61714..896dea1 100644 --- a/templates/development.php +++ b/templates/development.php @@ -87,7 +87,7 @@ Copied! - + @@ -101,12 +101,25 @@
    renderRequest($request)) !== ''): ?>
    - +

    Request info

    +
    + +
    renderCurl($request)) !== 'curl'): ?>