diff options
author | Jesús <heckyel@hyperbola.info> | 2020-12-15 21:52:04 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-12-15 21:52:04 -0500 |
commit | b9a3082e7c654d97cecc5410c086e13a7b046909 (patch) | |
tree | dc093ccb2246e7df0beaca5deb8b7467620b74a2 /youtube/__init__.py | |
parent | f4b36a220d085080a881dbe2f63e51b2fb28a003 (diff) | |
download | yt-local-b9a3082e7c654d97cecc5410c086e13a7b046909.tar.lz yt-local-b9a3082e7c654d97cecc5410c086e13a7b046909.tar.xz yt-local-b9a3082e7c654d97cecc5410c086e13a7b046909.zip |
pep8
Diffstat (limited to 'youtube/__init__.py')
-rw-r--r-- | youtube/__init__.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/youtube/__init__.py b/youtube/__init__.py index a8ca227..d9edbc6 100644 --- a/youtube/__init__.py +++ b/youtube/__init__.py @@ -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', ) |