pep8
This commit is contained in:
@@ -12,10 +12,9 @@ yt_app.url_map.strict_slashes = False
|
||||
# yt_app.jinja_env.lstrip_blocks = True
|
||||
|
||||
|
||||
|
||||
|
||||
yt_app.add_url_rule('/settings', 'settings_page', settings.settings_page, methods=['POST', 'GET'])
|
||||
|
||||
|
||||
@yt_app.route('/')
|
||||
def homepage():
|
||||
return flask.render_template('home.html', title="Youtube local")
|
||||
@@ -27,6 +26,7 @@ theme_names = {
|
||||
2: 'dark_theme',
|
||||
}
|
||||
|
||||
|
||||
@yt_app.context_processor
|
||||
def inject_theme_preference():
|
||||
return {
|
||||
@@ -34,6 +34,7 @@ def inject_theme_preference():
|
||||
'settings': settings,
|
||||
}
|
||||
|
||||
|
||||
@yt_app.template_filter('commatize')
|
||||
def commatize(num):
|
||||
if num is None:
|
||||
@@ -42,6 +43,7 @@ def commatize(num):
|
||||
num = int(num)
|
||||
return '{:,}'.format(num)
|
||||
|
||||
|
||||
def timestamp_replacement(match):
|
||||
time_seconds = 0
|
||||
for part in match.group(0).split(':'):
|
||||
@@ -53,11 +55,15 @@ def timestamp_replacement(match):
|
||||
+ '</a>'
|
||||
)
|
||||
|
||||
|
||||
TIMESTAMP_RE = re.compile(r'\b(\d?\d:)?\d?\d:\d\d\b')
|
||||
|
||||
|
||||
@yt_app.template_filter('timestamps')
|
||||
def timestamps(text):
|
||||
return TIMESTAMP_RE.sub(timestamp_replacement, text)
|
||||
|
||||
|
||||
@yt_app.errorhandler(500)
|
||||
def error_page(e):
|
||||
slim = request.args.get('slim', False) # whether it was an ajax request
|
||||
@@ -75,6 +81,7 @@ def error_page(e):
|
||||
return flask.render_template('error.html', error_message=error_message, slim=slim), 502
|
||||
return flask.render_template('error.html', traceback=traceback.format_exc(), slim=slim), 500
|
||||
|
||||
|
||||
font_choices = {
|
||||
0: 'initial',
|
||||
1: 'arial, "liberation sans", sans-serif',
|
||||
@@ -83,11 +90,13 @@ font_choices = {
|
||||
4: 'tahoma, sans-serif',
|
||||
}
|
||||
|
||||
|
||||
@yt_app.route('/shared.css')
|
||||
def get_css():
|
||||
return flask.Response(
|
||||
flask.render_template('shared.css',
|
||||
font_family = font_choices[settings.font]
|
||||
flask.render_template(
|
||||
'shared.css',
|
||||
font_family=font_choices[settings.font]
|
||||
),
|
||||
mimetype='text/css',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user