From 3df5e6c0a8083d6f4907109ee2a133defcf94c2d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 17 Dec 2022 13:49:01 +0000 Subject: [PATCH] right to left text on calendar events --- daemon.py | 20 ++++++++++++++++++-- epicyon-calendar.css | 21 +++++++++++++++++++++ webapp_calendar.py | 21 ++++++++++++++++++--- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/daemon.py b/daemon.py index 0871ae78b..c16b8a38f 100644 --- a/daemon.py +++ b/daemon.py @@ -18296,6 +18296,13 @@ class PubServer(BaseHTTPRequestHandler): if self.server.key_shortcuts.get(nickname): access_keys = self.server.key_shortcuts[nickname] + languages_understood = \ + get_understood_languages(self.server.base_dir, + self.server.http_prefix, + nickname, + self.server.domain_full, + self.server.person_cache) + # show the calendar screen msg = html_calendar(self.server.person_cache, self.server.translate, @@ -18306,7 +18313,8 @@ class PubServer(BaseHTTPRequestHandler): access_keys, False, self.server.system_language, self.server.default_timeline, - self.server.theme_name) + self.server.theme_name, + languages_understood) if msg: msg = msg.encode('utf-8') msglen = len(msg) @@ -18338,6 +18346,13 @@ class PubServer(BaseHTTPRequestHandler): if self.server.key_shortcuts.get(nickname): access_keys = self.server.key_shortcuts[nickname] + languages_understood = \ + get_understood_languages(self.server.base_dir, + self.server.http_prefix, + nickname, + self.server.domain_full, + self.server.person_cache) + # show the calendar screen msg = html_calendar(self.server.person_cache, self.server.translate, @@ -18349,7 +18364,8 @@ class PubServer(BaseHTTPRequestHandler): True, self.server.system_language, self.server.default_timeline, - self.server.theme_name) + self.server.theme_name, + languages_understood) if msg: msg = msg.encode('utf-8') msglen = len(msg) diff --git a/epicyon-calendar.css b/epicyon-calendar.css index e61643985..a2b4d407c 100644 --- a/epicyon-calendar.css +++ b/epicyon-calendar.css @@ -172,13 +172,34 @@ a:focus { font-size: 28px; position: relative; padding: 20px; + direction: ltr; } + +.calendar__day__event__rtl { + color: var(--event-color); + background-color: var(--event-background-private); + float: left; + font-size: 28px; + position: relative; + padding: 20px; + direction: rtl; +} + .calendar__day__event__public { color: var(--event-public-color); float: left; font-size: 28px; position: relative; padding: 20px; + direction: ltr; +} +.calendar__day__event__public__rtl { + color: var(--event-public-color); + float: left; + font-size: 28px; + position: relative; + padding: 20px; + direction: rtl; } .place { color: var(--place-color); diff --git a/webapp_calendar.py b/webapp_calendar.py index fc8ed42c8..3be12e510 100644 --- a/webapp_calendar.py +++ b/webapp_calendar.py @@ -22,10 +22,12 @@ from utils import remove_domain_port from utils import acct_dir from utils import local_actor_url from utils import replace_users_with_at +from utils import get_language_from_post 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 language_right_to_left from webapp_utils import get_banner_file from webapp_utils import set_custom_background from webapp_utils import html_header_with_external_style @@ -108,7 +110,9 @@ def _html_calendar_day(person_cache: {}, translate: {}, year: int, month_number: int, day_number: int, nickname: str, domain: str, day_events: [], month_name: str, actor: str, - theme: str, access_keys: {}) -> str: + theme: str, access_keys: {}, + system_language: str, + languages_understood: []) -> str: """Show a day within the calendar """ account_dir = acct_dir(base_dir, nickname, domain) @@ -250,10 +254,19 @@ def _html_calendar_day(person_cache: {}, translate: {}, translate['Delete this event'] + '" src="/' + \ 'icons/delete.png" />\n' + content_language = \ + get_language_from_post(event_post, system_language, + languages_understood) + is_rtl = language_right_to_left(content_language) + event_class = 'calendar__day__event' + if is_rtl: + event_class = 'calendar__day__event__rtl' cal_item_class = 'calItem' if event_is_public: event_class = 'calendar__day__event__public' + if is_rtl: + event_class = 'calendar__day__event__public__trl' cal_item_class = 'calItemPublic' if event_time: if event_end_time: @@ -322,7 +335,8 @@ def html_calendar(person_cache: {}, translate: {}, http_prefix: str, domain_full: str, text_mode_banner: str, access_keys: {}, icalendar: bool, system_language: str, - default_timeline: str, theme: str) -> str: + default_timeline: str, theme: str, + languages_understood: []) -> str: """Show the calendar for a person """ domain = remove_domain_port(domain_full) @@ -401,7 +415,8 @@ def html_calendar(person_cache: {}, translate: {}, year, month_number, day_number, nickname, domain, day_events, month_name, actor, - theme, access_keys) + theme, access_keys, + system_language, languages_understood) if icalendar: return get_month_events_icalendar(base_dir, nickname, domain,