From 125ddaa8da8dad8f3e8eeb54f79a775b865c58bf Mon Sep 17 00:00:00 2001 From: James Taylor Date: Tue, 20 Oct 2020 15:38:00 -0700 Subject: [PATCH] Add setting to change font. Change default to arial Closes #33 --- settings.py | 13 +++++++++++++ youtube/__init__.py | 17 +++++++++++++++++ youtube/templates/base.html | 2 +- youtube/{static => templates}/shared.css | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) rename youtube/{static => templates}/shared.css (99%) diff --git a/settings.py b/settings.py index 6bbb558..852310c 100644 --- a/settings.py +++ b/settings.py @@ -153,6 +153,19 @@ For security reasons, enabling this is not recommended.''', ], }), + ('font', { + 'type': int, + 'default': 1, + 'comment': '', + 'options': [ + (0, 'Browser default'), + (1, 'Arial'), + (2, 'Liberation Serif'), + (3, 'Verdana'), + (4, 'Tahoma'), + ], + }), + ('autocheck_subscriptions', { 'type': bool, 'default': 0, diff --git a/youtube/__init__.py b/youtube/__init__.py index 3c271f1..70ed5b2 100644 --- a/youtube/__init__.py +++ b/youtube/__init__.py @@ -66,3 +66,20 @@ def error_page(e): 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', traceback=traceback.format_exc()), 500 + +font_choices = { + 0: 'initial', + 1: 'arial, "liberation sans", sans-serif', + 2: '"liberation serif", "times new roman", calibri, carlito, serif', + 3: 'verdana, sans-serif', + 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] + ), + mimetype='text/css', + ) diff --git a/youtube/templates/base.html b/youtube/templates/base.html index 379419c..3d9f1e9 100644 --- a/youtube/templates/base.html +++ b/youtube/templates/base.html @@ -6,7 +6,7 @@ - + diff --git a/youtube/static/shared.css b/youtube/templates/shared.css similarity index 99% rename from youtube/static/shared.css rename to youtube/templates/shared.css index 7dd16e2..141465a 100644 --- a/youtube/static/shared.css +++ b/youtube/templates/shared.css @@ -12,7 +12,7 @@ address{ } html{ - font-family: "liberation serif", "times new roman", calibri, carlito, serif; + font-family: {{ font_family }}; } body{