mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Merge 034ce0100d
into 545a5937d8
This commit is contained in:
commit
7db91a664f
4 changed files with 55 additions and 46 deletions
|
@ -219,9 +219,7 @@ function get_youtube_comments() {
|
||||||
'&hl=' + video_data.preferences.locale +
|
'&hl=' + video_data.preferences.locale +
|
||||||
'&thin_mode=' + video_data.preferences.thin_mode;
|
'&thin_mode=' + video_data.preferences.thin_mode;
|
||||||
|
|
||||||
var onNon200 = function (xhr) { comments.innerHTML = fallback; };
|
var onNon200 = function (xhr) { comments.innerHTML = xhr.response.errorHtml; };
|
||||||
if (video_data.params.comments[1] === 'youtube')
|
|
||||||
onNon200 = function (xhr) {};
|
|
||||||
|
|
||||||
helpers.xhr('GET', url, {retries: 5, entity_name: 'comments'}, {
|
helpers.xhr('GET', url, {retries: 5, entity_name: 'comments'}, {
|
||||||
on200: function (response) {
|
on200: function (response) {
|
||||||
|
|
|
@ -28,6 +28,30 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
|
||||||
env.response.content_type = "text/html"
|
env.response.content_type = "text/html"
|
||||||
env.response.status_code = status_code
|
env.response.status_code = status_code
|
||||||
|
|
||||||
|
error_message = error_template_message(env, exception)
|
||||||
|
|
||||||
|
# Don't show the usual "next steps" widget. The same options are
|
||||||
|
# proposed above the error message, just worded differently.
|
||||||
|
next_steps = ""
|
||||||
|
|
||||||
|
return templated "error"
|
||||||
|
end
|
||||||
|
|
||||||
|
def error_template_helper(env : HTTP::Server::Context, status_code : Int32, message : String)
|
||||||
|
env.response.content_type = "text/html"
|
||||||
|
env.response.status_code = status_code
|
||||||
|
|
||||||
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
|
error_message = translate(locale, message)
|
||||||
|
next_steps = error_redirect_helper(env)
|
||||||
|
|
||||||
|
return templated "error"
|
||||||
|
end
|
||||||
|
|
||||||
|
def error_template_message(env : HTTP::Server::Context, exception : Exception)
|
||||||
|
String.build do |str|
|
||||||
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
issue_title = "#{exception.message} (#{exception.class})"
|
issue_title = "#{exception.message} (#{exception.class})"
|
||||||
|
|
||||||
issue_template = <<-TEXT
|
issue_template = <<-TEXT
|
||||||
|
@ -50,7 +74,7 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
|
||||||
url_new_issue += "?labels=bug&template=bug_report.md&title="
|
url_new_issue += "?labels=bug&template=bug_report.md&title="
|
||||||
url_new_issue += URI.encode_www_form("[Bug] " + issue_title)
|
url_new_issue += URI.encode_www_form("[Bug] " + issue_title)
|
||||||
|
|
||||||
error_message = <<-END_HTML
|
str << <<-END_HTML
|
||||||
<div class="error_message">
|
<div class="error_message">
|
||||||
<h2>#{translate(locale, "crash_page_you_found_a_bug")}</h2>
|
<h2>#{translate(locale, "crash_page_you_found_a_bug")}</h2>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
@ -70,24 +94,7 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
|
||||||
<pre style="padding: 20px; background: rgba(0, 0, 0, 0.12345);">#{issue_template}</pre>
|
<pre style="padding: 20px; background: rgba(0, 0, 0, 0.12345);">#{issue_template}</pre>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
END_HTML
|
||||||
|
end
|
||||||
# Don't show the usual "next steps" widget. The same options are
|
|
||||||
# proposed above the error message, just worded differently.
|
|
||||||
next_steps = ""
|
|
||||||
|
|
||||||
return templated "error"
|
|
||||||
end
|
|
||||||
|
|
||||||
def error_template_helper(env : HTTP::Server::Context, status_code : Int32, message : String)
|
|
||||||
env.response.content_type = "text/html"
|
|
||||||
env.response.status_code = status_code
|
|
||||||
|
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
|
||||||
|
|
||||||
error_message = translate(locale, message)
|
|
||||||
next_steps = error_redirect_helper(env)
|
|
||||||
|
|
||||||
return templated "error"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
|
@ -337,7 +337,7 @@ module Invidious::Routes::API::V1::Videos
|
||||||
rescue ex : NotFoundException
|
rescue ex : NotFoundException
|
||||||
return error_json(404, ex)
|
return error_json(404, ex)
|
||||||
rescue ex
|
rescue ex
|
||||||
return error_json(500, ex)
|
return error_json(500, ex, {"errorHtml" => error_template_message(env, ex)})
|
||||||
end
|
end
|
||||||
|
|
||||||
return comments
|
return comments
|
||||||
|
|
|
@ -103,6 +103,8 @@ module Invidious::Routes::Watch
|
||||||
|
|
||||||
comment_html = Comments.fill_links(comment_html, "https", "www.reddit.com")
|
comment_html = Comments.fill_links(comment_html, "https", "www.reddit.com")
|
||||||
comment_html = Comments.replace_links(comment_html)
|
comment_html = Comments.replace_links(comment_html)
|
||||||
|
else
|
||||||
|
comment_html = error_template_message(env, ex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif source == "reddit"
|
elsif source == "reddit"
|
||||||
|
@ -115,6 +117,8 @@ module Invidious::Routes::Watch
|
||||||
rescue ex
|
rescue ex
|
||||||
if preferences.comments[1] == "youtube"
|
if preferences.comments[1] == "youtube"
|
||||||
comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"]
|
comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"]
|
||||||
|
else
|
||||||
|
comment_html = error_template_message(env, ex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue