mirror of
https://github.com/iv-org/invidious.git
synced 2025-05-19 21:11:14 +00:00
Improve design of placeholder item
Also makes it show the error backtrace
This commit is contained in:
parent
dbeee71457
commit
9de69c0052
@ -816,3 +816,50 @@ h1, h2, h3, h4, h5, p,
|
|||||||
#download_widget {
|
#download_widget {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 25px;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid black;
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card > .explanation {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: max-content 1fr;
|
||||||
|
grid-template-rows: 1fr max-content;
|
||||||
|
column-gap: 10px;
|
||||||
|
row-gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card > .explanation > i {
|
||||||
|
grid-area: 1 / 1 / 2 / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card > .explanation > h4 {
|
||||||
|
grid-area: 1 / 2 / 2 / 3;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card > .explanation > p {
|
||||||
|
grid-area: 2 / 2 / 3 / 3;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card details {
|
||||||
|
margin-top: 10px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card summary {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card pre {
|
||||||
|
height: 300px;
|
||||||
|
}
|
@ -501,5 +501,7 @@
|
|||||||
"toggle_theme": "Toggle Theme",
|
"toggle_theme": "Toggle Theme",
|
||||||
"carousel_slide": "Slide {{current}} of {{total}}",
|
"carousel_slide": "Slide {{current}} of {{total}}",
|
||||||
"carousel_skip": "Skip the Carousel",
|
"carousel_skip": "Skip the Carousel",
|
||||||
"carousel_go_to": "Go to slide `x`"
|
"carousel_go_to": "Go to slide `x`",
|
||||||
|
"timeline_parse_error_placeholder_heading": "Unable to parse item",
|
||||||
|
"timeline_parse_error_placeholder_message": "Invidious encountered an error while trying to parse this item. For more information see below:"
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,7 @@ def github_details(summary : String, content : String)
|
|||||||
return HTML.escape(details)
|
return HTML.escape(details)
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exception : Exception)
|
def get_issue_template(env : HTTP::Server::Context, exception : Exception) : Tuple(String, String)
|
||||||
if exception.is_a?(InfoException)
|
|
||||||
return error_template_helper(env, status_code, exception.message || "")
|
|
||||||
end
|
|
||||||
|
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
|
||||||
|
|
||||||
env.response.content_type = "text/html"
|
|
||||||
env.response.status_code = status_code
|
|
||||||
|
|
||||||
issue_title = "#{exception.message} (#{exception.class})"
|
issue_title = "#{exception.message} (#{exception.class})"
|
||||||
|
|
||||||
issue_template = <<-TEXT
|
issue_template = <<-TEXT
|
||||||
@ -40,6 +31,24 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
|
|||||||
|
|
||||||
issue_template += github_details("Backtrace", exception.inspect_with_backtrace)
|
issue_template += github_details("Backtrace", exception.inspect_with_backtrace)
|
||||||
|
|
||||||
|
return {issue_title, issue_template}
|
||||||
|
end
|
||||||
|
|
||||||
|
def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exception : Exception)
|
||||||
|
if exception.is_a?(InfoException)
|
||||||
|
return error_template_helper(env, status_code, exception.message || "")
|
||||||
|
end
|
||||||
|
|
||||||
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
|
env.response.content_type = "text/html"
|
||||||
|
env.response.status_code = status_code
|
||||||
|
|
||||||
|
# Unpacking into issue_title, issue_template directly causes a compiler error
|
||||||
|
# I have no idea why.
|
||||||
|
issue_template_components = get_issue_template(env, exception)
|
||||||
|
issue_title, issue_template = issue_template_components
|
||||||
|
|
||||||
# URLs for the error message below
|
# URLs for the error message below
|
||||||
url_faq = "https://github.com/iv-org/documentation/blob/master/docs/faq.md"
|
url_faq = "https://github.com/iv-org/documentation/blob/master/docs/faq.md"
|
||||||
url_search_issues = "https://github.com/iv-org/invidious/issues"
|
url_search_issues = "https://github.com/iv-org/invidious/issues"
|
||||||
|
@ -98,8 +98,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<% when Category %>
|
<% when Category %>
|
||||||
<% when ProblematicTimelineItem %>
|
<% when ProblematicTimelineItem %>
|
||||||
<div>
|
<div class="error-card">
|
||||||
<h4> Unable to parse this item </h4>
|
<div class="explanation">
|
||||||
|
<i class="icon ion-ios-alert"></i>
|
||||||
|
<h4><%=translate(locale, "timeline_parse_error_placeholder_heading")%></h4>
|
||||||
|
<p><%=translate(locale, "timeline_parse_error_placeholder_message")%></p>
|
||||||
|
</div>
|
||||||
|
<details>
|
||||||
|
<summary class="pure-button pure-button-secondary"> Show technical details </summary>
|
||||||
|
<pre style="padding: 20px; background: rgba(0, 0, 0, 0.12345);"><%=get_issue_template(env, item.parse_exception)[1]%></pre>
|
||||||
|
</details>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%-
|
<%-
|
||||||
|
Loading…
x
Reference in New Issue
Block a user