8000 More compact display of vendor code in exception pages by javiereguiluz · Pull Request #26671 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

More compact display of vendor code in exception pages #26671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Hide vendors by default in exception pages
  • Loading branch information
javiereguiluz committed Mar 26, 2018
commit 6f1b03b4409d5160deb73abe3c1985664fb2d245
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,34 @@
<div class="trace-head">
<span class="sf-toggle" data-toggle-selector="#trace-html-{{ index }}" data-toggle-initial="{{ expand ? 'display' }}">
<h3 class="trace-class">
<span class="icon icon-close">{{ include('@Twig/images/icon-minus-square-o.svg') }}</span>
<span class="icon icon-open">{{ include('@Twig/images/icon-plus-square-o.svg') }}</span>

<span class="trace-namespace">
{{ exception.class|split('\\')|slice(0, -1)|join('\\') }}
{{- exception.class|split('\\')|length > 1 ? '\\' }}
</span>
{{ exception.class|split('\\')|last }}

<span class="icon icon-close">{{ include('@Twig/images/icon-minus-square-o.svg') }}</span>
<span class="icon icon-open">{{ include('@Twig/images/icon-plus-square-o.svg') }}</span>
</h3>

{% if exception.message is not empty and index > 1 %}
<p class="break-long-words trace-message">{{ exception.message }}</p>
{% endif %}
</span>

<form class="trace-toggle-vendors">
<input id="trace-html-{{ index }}-toggle-vendors" type="checkbox" checked aria-label="Toggle traces from vendors" onchange="var vendorTraces = document.querySelectorAll('#trace-html-{{ index }} .trace-from-vendor'); for (var i = 0; i < vendorTraces.length; i++) { vendorTraces[i].style.display = this.checked ? 'none' : 'block'; };" />
<label for="trace-html-{{ index }}-toggle-vendors">Hide vendors</label>
</form>
</div>

<div id="trace-html-{{ index }}" class="sf-toggle-content">
{% set _is_first_user_code = true %}
{% for i, trace in exception.trace %}
{% set _display_code_snippet = _is_first_user_code and ('/vendor/' not in trace.file) and ('/var/cache/' not in trace.file) and (trace.file is not empty) %}
{% set _is_vendor_trace = trace.file is not empty and ('/vendor/' in trace.file or '/var/cache/' in trace.file) %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work on Windows ?

{% set _display_code_snippet = _is_first_user_code and not _is_vendor_trace %}
{% if _display_code_snippet %}{% set _is_first_user_code = false %}{% endif %}
<div class="trace-line">
<div class="trace-line {{ _is_vendor_trace ? 'trace-from-vendor' }}">
{{ include('@Twig/Exception/trace.html.twig', { prefix: index, i: i, trace: trace, _display_code_snippet: _display_code_snippet }, with_context = false) }}
</div>
{% endfor %}
Expand Down
14 changes: 9 additions & 5 deletions src/Symfony/Bundle/TwigBundle/Resources/views/exception.css.twig
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,22 @@ header .container { display: flex; justify-content: space-between; }
.exception-illustration { flex-basis: 111px; flex-shrink: 0; height: 66px; margin-left: 15px; opacity: .7; }

.trace + .trace { margin-top: 30px; }
.trace-head { background-color: #e0e0e0; padding: 10px; }
.trace-head .trace-class { color: #222; font-size: 18px; font-weight: bold; line-height: 1.3; margin: 0; position: relative; }
.trace-head { background-color: #e0e0e0; padding: 10px; position: relative; }
.trace-head .trace-class { color: #222; font-size: 18px; font-weight: bold; line-height: 1.3; margin: 0; padding-left: 28px; position: relative; }
.trace-head .trace-namespace { color: #999; display: block; font-size: 13px; }
.trace-head .icon { position: absolute; right: 0; top: 0; }
.trace-head .icon { position: absolute; left: -3px; top: 0; }
.trace-head .icon svg { height: 24px; width: 24px; }

.trace-details { background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 1em 0; }
.trace-details { background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 1em 0; table-layout: fixed; }

.trace-message { font-size: 14px; font-weight: normal; margin: .5em 0 0; }
.trace-details { table-layout: fixed; }

.trace-toggle-vendors { position: absolute; top: 10px; right: 10px; }
.trace-toggle-vendors label { cursor: pointer; margin-left: 2px; }

.trace-line { position: relative; padding-top: 8px; padding-bottom: 8px; }
.trace-line:hover { background: #F5F5F5; }
.trace-line.trace-from-vendor { display: none; }
.trace-line a { color: #222; }
.trace-line .icon { opacity: .4; position: absolute; left: 10px; top: 11px; }
.trace-line .icon svg { height: 16px; width: 16px; }
Expand Down
0