From 05e462c70f02f8555b91340a355a161ac7d76735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginb=C3=BChl?= Date: Wed, 17 Apr 2024 23:28:53 +0200 Subject: [PATCH] samsing brouk --- happyMirror/config.py | 3 ++- happyMirror/widgets/clock/clock.py | 2 -- happyMirror/widgets/quote/widget_secrets.py | 2 +- happyMirror/widgets/simple_image/__init__.py | 1 + happyMirror/widgets/simple_image/images/01.jpg | 0 happyMirror/widgets/simple_image/images/01.png | 0 .../widgets/simple_image/simple_image.py | 18 ++++++++++++++++++ 7 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 happyMirror/widgets/simple_image/__init__.py create mode 100644 happyMirror/widgets/simple_image/images/01.jpg create mode 100644 happyMirror/widgets/simple_image/images/01.png create mode 100644 happyMirror/widgets/simple_image/simple_image.py diff --git a/happyMirror/config.py b/happyMirror/config.py index 9e33481..9d107d7 100644 --- a/happyMirror/config.py +++ b/happyMirror/config.py @@ -1,5 +1,6 @@ enabled_widgets = [ 'hello', 'clock', - 'quote' + 'quote', + 'simple_image' ] diff --git a/happyMirror/widgets/clock/clock.py b/happyMirror/widgets/clock/clock.py index daf67a3..f06cfa8 100644 --- a/happyMirror/widgets/clock/clock.py +++ b/happyMirror/widgets/clock/clock.py @@ -8,9 +8,7 @@ def __init__(self, config=None, secrets_config=None) -> None: pass def render(self) -> RenderResult: - # script_path = os.path.realpath(__file__).resolve('/static/js/clock.js') script_path = os.path.dirname(os.path.relpath(__file__)) + '/static/js/clock.js' - print("script_path: ", script_path) return { 'script': open(script_path, 'r').read(), diff --git a/happyMirror/widgets/quote/widget_secrets.py b/happyMirror/widgets/quote/widget_secrets.py index 64a82cb..0995baa 100644 --- a/happyMirror/widgets/quote/widget_secrets.py +++ b/happyMirror/widgets/quote/widget_secrets.py @@ -1 +1 @@ -api_key = 'secret' +api_key = 'yt1AXMJll6s0dFBRUZX/6A==xFhZOW7LWUzYeYn3' diff --git a/happyMirror/widgets/simple_image/__init__.py b/happyMirror/widgets/simple_image/__init__.py new file mode 100644 index 0000000..5ad7fe2 --- /dev/null +++ b/happyMirror/widgets/simple_image/__init__.py @@ -0,0 +1 @@ +# intentionally left empty diff --git a/happyMirror/widgets/simple_image/images/01.jpg b/happyMirror/widgets/simple_image/images/01.jpg new file mode 100644 index 0000000..e69de29 diff --git a/happyMirror/widgets/simple_image/images/01.png b/happyMirror/widgets/simple_image/images/01.png new file mode 100644 index 0000000..e69de29 diff --git a/happyMirror/widgets/simple_image/simple_image.py b/happyMirror/widgets/simple_image/simple_image.py new file mode 100644 index 0000000..00d5a00 --- /dev/null +++ b/happyMirror/widgets/simple_image/simple_image.py @@ -0,0 +1,18 @@ +import base64 +import os + +from flask import render_template_string + +from happyMirror.render import BaseRenderer, RenderResult + + +class Renderer(BaseRenderer): + def render(self) -> RenderResult: + image = '/' + os.path.dirname(os.path.relpath(__file__)) + '/images/01.png' + print(image) + + return { + 'view': render_template_string('', image=image) + } + +