From d96ec913d45cd1d6b222e9b40245e93290b486ad Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Mon, 7 Nov 2022 20:35:23 +0100 Subject: [PATCH] Add support for displaying events from Mobilizon --- app/ap_object.py | 3 +++ app/scss/main.scss | 10 ++++++++++ app/templates/utils.html | 28 ++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/ap_object.py b/app/ap_object.py index 67543cb..788d267 100644 --- a/app/ap_object.py +++ b/app/ap_object.py @@ -96,6 +96,9 @@ class Object: def attachments(self) -> list["Attachment"]: attachments = [] for obj in ap.as_list(self.ap_object.get("attachment", [])): + if obj.get("type") == "PropertyValue": + continue + if obj.get("type") == "Link": attachments.append( Attachment.parse_obj( diff --git a/app/scss/main.scss b/app/scss/main.scss index fe9747d..dc99b1c 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -531,3 +531,13 @@ a.label-btn { text-decoration: underline; } } + +.ap-place { + h3 { + display: inline; + font-weight: normal; + } + h3::after { + content: ': '; + } +} diff --git a/app/templates/utils.html b/app/templates/utils.html index 18644a1..7a33730 100644 --- a/app/templates/utils.html +++ b/app/templates/utils.html @@ -383,6 +383,7 @@ {% block display_attachments scoped %} {% for attachment in object.attachments %} + {% if attachment.type != "PropertyValue" %} {% if object.sensitive and (attachment.type == "Image" or (attachment | has_media_type("image")) or attachment.type == "Video" or (attachment | has_media_type("video"))) %}
@@ -418,6 +419,7 @@ {% else %}
{% endif %} + {% endif %} {% endfor %} {% endblock %} {% endmacro %} @@ -425,7 +427,7 @@ {% macro display_object(object, likes=[], shares=[], webmentions=[], expanded=False, actors_metadata={}, is_object_page=False) %} {% block display_object scoped %} {% set is_article_mode = object.is_from_outbox and object.ap_type == "Article" and is_object_page %} -{% if object.ap_type in ["Note", "Article", "Video", "Page", "Question"] %} +{% if object.ap_type in ["Note", "Article", "Video", "Page", "Question", "Event"] %}
{% if is_article_mode %} @@ -444,10 +446,32 @@

{% endif %} - {% if object.ap_type == "Article" %} + {% if object.ap_type in ["Article", "Event"] %}

{{ object.name }}

{% endif %} + {% if object.ap_type == "Event" %} + {% if object.ap_object.get("endTime") and object.ap_object.get("startTime") %} +

On {{ object.ap_object.startTime | parse_datetime | format_date }} + (ends {{ object.ap_object.endTime | parse_datetime | format_date }})

+ {% endif %} + {% endif %} + + {% if object.ap_object.get("location") %} + {% set loc = object.ap_object.get("location") %} + {% if loc.type == "Place" and loc.latitude and loc.longitude %} +
+

Location

+ {% if loc.name %}{{ loc.name }}{% endif %} + + + + {{loc.latitude}},{{loc.longitude}} + +
+ {% endif %} + {% endif %} + {% if is_article_mode %} {% endif %}