From 41d395c87da4f63cc54eaa67bd094b5c53c9c302 Mon Sep 17 00:00:00 2001 From: bashrc Date: Thu, 26 Feb 2026 09:28:14 +0000 Subject: [PATCH] Show map button on calendar --- webapp_calendar.py | 8 +++++++- webapp_post.py | 13 ++----------- webapp_utils.py | 10 ++++++++++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/webapp_calendar.py b/webapp_calendar.py index d075105a1..8993d42f2 100644 --- a/webapp_calendar.py +++ b/webapp_calendar.py @@ -8,6 +8,7 @@ __status__ = "Production" __module_group__ = "Calendar" import os +from auth import create_password from datetime import datetime from datetime import date from utils import browser_supports_download_filename @@ -30,6 +31,7 @@ from happening import get_todays_events from happening import get_calendar_events from happening import get_todays_events_icalendar from happening import get_month_events_icalendar +from webapp_utils import get_show_map_button from webapp_utils import get_banner_file from webapp_utils import set_custom_background from webapp_utils import html_header_with_external_style @@ -251,7 +253,11 @@ def _html_calendar_day(person_cache: {}, translate: {}, session_yggdrasil, '320', '320') if event_map: - event_place = event_map + if not post_id: + post_id = 'post' + str(create_password(8)) + event_place = \ + get_show_map_button(post_id, translate, + event_map) # prepend a link to the sender of the calendar item if sender_name and event_description: diff --git a/webapp_post.py b/webapp_post.py index 40882fa59..435c87d51 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -107,6 +107,7 @@ from content import add_auto_cw from person import is_person_snoozed from person import get_person_avatar_url from textmode import text_mode_browser +from webapp_utils import get_show_map_button from webapp_utils import mitm_warning_html from webapp_utils import get_buy_links from webapp_utils import get_banner_file @@ -2316,16 +2317,6 @@ def _mentions_to_person_options(html_str: str, nickname: str, domain: str, return html_str -def _get_show_map_button(post_id: str, translate: {}, - map_content: str) -> str: - """Returns the markup for a "show map" button - """ - return '
' + \ - translate['Show Map'] + '' + \ - '
' + map_content + \ - '
\n' - - def individual_post_as_html(signing_priv_key_pem: str, allow_downloads: bool, recent_posts_cache: {}, max_recent_posts: int, @@ -3441,7 +3432,7 @@ def individual_post_as_html(signing_priv_key_pem: str, if map_str: if not post_id: post_id = 'post' + str(create_password(8)) - map_str = _get_show_map_button(post_id, translate, map_str) + map_str = get_show_map_button(post_id, translate, map_str) post_html += \ content_str + citations_str + map_str + \ diff --git a/webapp_utils.py b/webapp_utils.py index 82abe1b76..14bdec8fe 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -271,6 +271,16 @@ def get_content_warning_button(post_id: str, translate: {}, '\n' +def get_show_map_button(post_id: str, translate: {}, + map_content: str) -> str: + """Returns the markup for a "show map" button + """ + return '
' + \ + translate['Show Map'] + '' + \ + '
' + map_content + \ + '
\n' + + def open_content_warning(text: str, translate: {}) -> str: """Opens content warning when replying to a post with a cw so that you can see what you are replying to