From 08451d0e553a8baedb819654827d2dce28ce2e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Farka?= <stepanfarka11@gmail.com> Date: Fri, 1 Apr 2022 17:59:03 +0200 Subject: [PATCH] [ADD] embed from tv.pirati.cz --- .../0051_alter_districtarticlepage_content.py | 3 ++- district/templates/district/base.html | 1 + majak/settings/base.py | 8 ++++++++ .../0026_alter_regionarticlepage_content.py | 3 ++- region/templates/region/base.html | 1 + shared/finders.py | 9 +++++++++ shared/models.py | 1 + shared/static/shared/css/helpers.css | 13 +++++++++++++ .../0023_alter_uniwebarticlepage_content.py | 3 ++- 9 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 shared/finders.py create mode 100644 shared/static/shared/css/helpers.css diff --git a/district/migrations/0051_alter_districtarticlepage_content.py b/district/migrations/0051_alter_districtarticlepage_content.py index d89ac89a..c78c5d77 100644 --- a/district/migrations/0051_alter_districtarticlepage_content.py +++ b/district/migrations/0051_alter_districtarticlepage_content.py @@ -1,4 +1,4 @@ -# Generated by Django 4.0.3 on 2022-04-01 14:13 +# Generated by Django 4.0.3 on 2022-04-01 14:55 import wagtail.core.blocks import wagtail.core.fields @@ -28,6 +28,7 @@ class Migration(migrations.Migration): "bold", "italic", "ol", + "embed", "ul", "link", "document-link", diff --git a/district/templates/district/base.html b/district/templates/district/base.html index ea83320f..af425062 100644 --- a/district/templates/district/base.html +++ b/district/templates/district/base.html @@ -18,6 +18,7 @@ <!-- Styles --> <link rel="stylesheet" href="{% static "styleguide18/assets/css/styles.css" %}"> <link href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}" rel="stylesheet"> + <link rel="stylesheet" href="{% static "shared/css/helpers.css" %}"> <style type="text/css"> .inline-block { diff --git a/majak/settings/base.py b/majak/settings/base.py index 1af5e8f2..927b9215 100644 --- a/majak/settings/base.py +++ b/majak/settings/base.py @@ -230,6 +230,14 @@ WAGTAILSEARCH_BACKENDS = { } } +WAGTAILEMBEDS_FINDERS = [ + { + "class": "shared.finders.CustomPeertubeFinder", + }, +] + +WAGTAILEMBEDS_RESPONSIVE_HTML = True + # Base URL to use when referring to full URLs within the Wagtail admin backend - # e.g. in notification emails. Don't include '/admin' or a trailing slash BASE_URL = env.str("BASE_URL", default="https://majak.pirati.cz") diff --git a/region/migrations/0026_alter_regionarticlepage_content.py b/region/migrations/0026_alter_regionarticlepage_content.py index f81ad070..929b0470 100644 --- a/region/migrations/0026_alter_regionarticlepage_content.py +++ b/region/migrations/0026_alter_regionarticlepage_content.py @@ -1,4 +1,4 @@ -# Generated by Django 4.0.3 on 2022-04-01 14:13 +# Generated by Django 4.0.3 on 2022-04-01 14:55 import wagtail.core.blocks import wagtail.core.fields @@ -28,6 +28,7 @@ class Migration(migrations.Migration): "bold", "italic", "ol", + "embed", "ul", "link", "document-link", diff --git a/region/templates/region/base.html b/region/templates/region/base.html index 18eab8c0..d4e24e48 100644 --- a/region/templates/region/base.html +++ b/region/templates/region/base.html @@ -18,6 +18,7 @@ <!-- Styles --> <link rel="stylesheet" href="{% static "styleguide18/assets/css/styles.css" %}"> <link href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}" rel="stylesheet"> + <link rel="stylesheet" href="{% static "shared/css/helpers.css" %}"> <style type="text/css"> .inline-block { diff --git a/shared/finders.py b/shared/finders.py new file mode 100644 index 00000000..d75fc41d --- /dev/null +++ b/shared/finders.py @@ -0,0 +1,9 @@ +from wagtail.embeds.finders.oembed import OEmbedFinder + + +class CustomPeertubeFinder(OEmbedFinder): + def _get_endpoint(self, url): + return "https://tv.pirati.cz/services/oembed" + + +embed_finder_class = CustomPeertubeFinder diff --git a/shared/models.py b/shared/models.py index 6e847cac..847f5854 100644 --- a/shared/models.py +++ b/shared/models.py @@ -38,6 +38,7 @@ class ArticleMixin(models.Model): "bold", "italic", "ol", + "embed", "ul", "link", "document-link", diff --git a/shared/static/shared/css/helpers.css b/shared/static/shared/css/helpers.css new file mode 100644 index 00000000..0ba59e24 --- /dev/null +++ b/shared/static/shared/css/helpers.css @@ -0,0 +1,13 @@ +.responsive-object { + position: relative; +} + +.responsive-object iframe, +.responsive-object object, +.responsive-object embed { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} diff --git a/uniweb/migrations/0023_alter_uniwebarticlepage_content.py b/uniweb/migrations/0023_alter_uniwebarticlepage_content.py index 5745f5a1..368b1cb0 100644 --- a/uniweb/migrations/0023_alter_uniwebarticlepage_content.py +++ b/uniweb/migrations/0023_alter_uniwebarticlepage_content.py @@ -1,4 +1,4 @@ -# Generated by Django 4.0.3 on 2022-04-01 14:13 +# Generated by Django 4.0.3 on 2022-04-01 14:55 import wagtail.core.blocks import wagtail.core.fields @@ -28,6 +28,7 @@ class Migration(migrations.Migration): "bold", "italic", "ol", + "embed", "ul", "link", "document-link", -- GitLab