From 1f2544e357a7db571901212d6c4238e4e07abbaf Mon Sep 17 00:00:00 2001 From: Alexandr Karpov Date: Sat, 15 Apr 2023 14:44:59 +0300 Subject: [PATCH] added otf --- akarpov/files/previews/__init__.py | 4 ++- akarpov/files/previews/font/__init__.py | 1 + akarpov/files/previews/font/otf.py | 33 ++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/akarpov/files/previews/__init__.py b/akarpov/files/previews/__init__.py index 57b1184..2e0532e 100644 --- a/akarpov/files/previews/__init__.py +++ b/akarpov/files/previews/__init__.py @@ -1,4 +1,4 @@ -from . import application, audio, image, text, video +from . import application, audio, font, image, text, video previews = { "application": { @@ -37,6 +37,7 @@ "plain": text.plain.view, "csv": text.csv.view, }, + "font": {"otf": font.otf.view}, } source_code = {} @@ -62,4 +63,5 @@ "jar": application.zip.view, "mpeg": video.mp4.view, "oga": audio.oga.view, + "otf": font.otf.view, } | source_code diff --git a/akarpov/files/previews/font/__init__.py b/akarpov/files/previews/font/__init__.py index e69de29..01e422f 100644 --- a/akarpov/files/previews/font/__init__.py +++ b/akarpov/files/previews/font/__init__.py @@ -0,0 +1 @@ +from . import otf # noqa diff --git a/akarpov/files/previews/font/otf.py b/akarpov/files/previews/font/otf.py index 61dafa1..656e063 100644 --- a/akarpov/files/previews/font/otf.py +++ b/akarpov/files/previews/font/otf.py @@ -1,5 +1,36 @@ +import string + from akarpov.files.models import File def view(file: File): - ... + text = " ".join(string.printable) + name = file.file.path.split("/")[-1].split(".")[0] + static = ( + """ + + """ + ) + content = f""" +
+ {text} +
+ """ + return static, content