comments.js: include error in reply html rather than using an alert
This commit is contained in:
parent
95f2f027ea
commit
c696db3e84
@ -1,5 +1,6 @@
|
|||||||
from youtube import util
|
from youtube import util
|
||||||
import flask
|
import flask
|
||||||
|
from flask import request
|
||||||
import settings
|
import settings
|
||||||
import traceback
|
import traceback
|
||||||
import re
|
import re
|
||||||
@ -55,6 +56,7 @@ def timestamps(text):
|
|||||||
|
|
||||||
@yt_app.errorhandler(500)
|
@yt_app.errorhandler(500)
|
||||||
def error_page(e):
|
def error_page(e):
|
||||||
|
slim = request.args.get('slim', False) # whether it was an ajax request
|
||||||
if (exc_info()[0] == util.FetchError
|
if (exc_info()[0] == util.FetchError
|
||||||
and exc_info()[1].code == '429'
|
and exc_info()[1].code == '429'
|
||||||
and settings.route_tor
|
and settings.route_tor
|
||||||
@ -64,8 +66,8 @@ def error_page(e):
|
|||||||
' using the New Identity button in the Tor Browser.')
|
' using the New Identity button in the Tor Browser.')
|
||||||
if exc_info()[1].ip:
|
if exc_info()[1].ip:
|
||||||
error_message += ' Exit node IP address: ' + exc_info()[1].ip
|
error_message += ' Exit node IP address: ' + exc_info()[1].ip
|
||||||
return flask.render_template('error.html', error_message=error_message), 502
|
return flask.render_template('error.html', error_message=error_message, slim=slim), 502
|
||||||
return flask.render_template('error.html', traceback=traceback.format_exc()), 500
|
return flask.render_template('error.html', traceback=traceback.format_exc(), slim=slim), 500
|
||||||
|
|
||||||
font_choices = {
|
font_choices = {
|
||||||
0: 'initial',
|
0: 'initial',
|
||||||
|
@ -41,9 +41,7 @@ function doXhr(url, callback=null) {
|
|||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", url);
|
xhr.open("GET", url);
|
||||||
xhr.onload = (e) => {
|
xhr.onload = (e) => {
|
||||||
let ok = xhr.status >= 200 && xhr.status < 300;
|
callback(e.currentTarget.response);
|
||||||
if (ok) callback(e.currentTarget.response);
|
|
||||||
else alert(`${xhr.responseURL} status code: ${xhr.status}`);
|
|
||||||
}
|
}
|
||||||
xhr.send();
|
xhr.send();
|
||||||
return xhr;
|
return xhr;
|
||||||
|
@ -1,29 +1,8 @@
|
|||||||
{% set page_title = 'Error' %}
|
{% set page_title = 'Error' %}
|
||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block style %}
|
{% if not slim %}
|
||||||
h1{
|
{% extends "base.html" %}
|
||||||
font-size: 2rem;
|
{% endif %}
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
#error-box, #error-message{
|
|
||||||
background-color: var(--interface-color);
|
|
||||||
width: 80%;
|
|
||||||
margin: auto;
|
|
||||||
margin-top: 20px;
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
#error-box > div, #error-box > p, #error-box > h1{
|
|
||||||
white-space: pre-wrap;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
.code-box{
|
|
||||||
padding: 5px;
|
|
||||||
border-style:solid;
|
|
||||||
border-width:1px;
|
|
||||||
border-radius:5px;
|
|
||||||
}
|
|
||||||
{% endblock style %}
|
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
{% if traceback %}
|
{% if traceback %}
|
||||||
|
@ -334,3 +334,26 @@ body{
|
|||||||
padding: 2px;
|
padding: 2px;
|
||||||
justify-self: start;
|
justify-self: start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* error page stuff */
|
||||||
|
h1{
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
#error-box, #error-message{
|
||||||
|
background-color: var(--interface-color);
|
||||||
|
width: 80%;
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
#error-box > div, #error-box > p, #error-box > h1{
|
||||||
|
white-space: pre-wrap;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.code-box{
|
||||||
|
padding: 5px;
|
||||||
|
border-style:solid;
|
||||||
|
border-width:1px;
|
||||||
|
border-radius:5px;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user