Skip to content

Commit

Permalink
fix quality
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Sep 11, 2024
1 parent 9c0ecaa commit c5d775a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions cms/embeds_finders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

from urllib.parse import urlparse

from django.conf import settings
from wagtail.embeds.finders.base import EmbedFinder

Expand All @@ -26,6 +26,7 @@ def find_embed(self, url, max_width=None):
"html": html,
}


class MetabaseFinder(EmbedFinder):
def __init__(self, **options):
pass
Expand All @@ -42,13 +43,13 @@ def resizer_url(self, url):
return f"//{self.metabase_domain(url)}{settings.WAGTAILEMBEDS_METABASE_IFRAME_RESIZER_URL}"

def find_embed(self, url, max_width=None):
html = f'''
html = f"""
<iframe src="{url}" height="{settings.WAGTAILEMBEDS_METABASE_HEIGHT}" width="100%"></iframe>
<script src="{self.resizer_url(url)}"></script>
<script>
iFrameResize({{}}, "iframe");
</script>
'''
"""
return {
"title": "Metabase Embed",
"author_name": "Plateforme de l'inclision",
Expand Down
1 change: 0 additions & 1 deletion well_known/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.urls import include, path


from .views import serve_text_file


Expand Down
7 changes: 4 additions & 3 deletions well_known/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os

from django.http import HttpResponse


def serve_text_file(request, file_name):
file_path = os.path.join('static', '.well-known', file_name)
file_path = os.path.join("static", ".well-known", file_name)
try:
with open(file_path, 'rb') as file:
with open(file_path, "rb") as file:
content = file.read()
return HttpResponse(content, content_type='text/plain; charset=utf-8')
return HttpResponse(content, content_type="text/plain; charset=utf-8")
except FileNotFoundError:
return HttpResponse(b"File not found.", status=404)

0 comments on commit c5d775a

Please sign in to comment.