From aa04230c0edf5e95f65e9f387a8b1ee73790fa3a Mon Sep 17 00:00:00 2001 From: Antoine Goutenoir Date: Tue, 29 Sep 2020 03:02:03 +0200 Subject: [PATCH] feat: add support for icons, _the right way_© --- flaskr/__init__.py | 2 ++ flaskr/content.py | 1 + flaskr/extensions.py | 10 +++++++++- flaskr/static/css/common/main.css | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/flaskr/__init__.py b/flaskr/__init__.py index 5721f0e..913ae3a 100755 --- a/flaskr/__init__.py +++ b/flaskr/__init__.py @@ -34,6 +34,7 @@ from flaskr.extensions import ( mail, session, captcha, + icon2html, ) from flaskr.content import content from flaskr.core import increment_hit_counter, get_hit_counter @@ -109,6 +110,7 @@ def create_app(object_name): # Markdown jinja2 filter @app.template_filter('markdown') def markdown_filter(text): + text = icon2html(text) return markdown(text, extensions=['extra']) # Authentication Gate for the Admin diff --git a/flaskr/content.py b/flaskr/content.py index 728210b..0d5e93c 100644 --- a/flaskr/content.py +++ b/flaskr/content.py @@ -33,6 +33,7 @@ class Struct(object): content = Struct(content_dict) +# Move this to ENV, perhaps base_url = "https://travel-footprint-calculator.irap.omp.eu" diff --git a/flaskr/extensions.py b/flaskr/extensions.py index 781ca43..ac8ba17 100644 --- a/flaskr/extensions.py +++ b/flaskr/extensions.py @@ -50,7 +50,6 @@ def load_user(userid): def send_email(to_recipient, subject, message): - if 'production' != getenv('FLASK_ENV', 'production'): print("Skipping sending email because we are not in production.") return @@ -70,3 +69,12 @@ def send_email(to_recipient, subject, message): print("ERROR Sending email:\n%s" % str(e)) traceback.print_exc(file=sys.stderr) + +def icon2html(text): + import re + icon_html = r"""""" + return re.sub( + "", + icon_html, + text + ) diff --git a/flaskr/static/css/common/main.css b/flaskr/static/css/common/main.css index b099f48..3e4993b 100755 --- a/flaskr/static/css/common/main.css +++ b/flaskr/static/css/common/main.css @@ -160,4 +160,13 @@ span[title] { opacity: 0; } +} + + +/** BOOTSTRAP ICONS **********************************************************/ + +svg.bi { + /* vertical alignment is … sketchy, let's do this the old way */ + position: relative; + top: 2px; } \ No newline at end of file -- libgit2 0.21.2