Add address field when creating new post

main
Bob Mottram 2025-04-25 17:14:57 +01:00
parent 709ee31474
commit c4c86fdb13
31 changed files with 120 additions and 40 deletions

View File

@ -159,6 +159,10 @@ def _receive_new_post_process_newpost(self, fields: {},
if fields.get('searchableByDropdown'):
set_searchable_by(base_dir, nickname, domain,
fields['searchableByDropdown'])
location_str = fields['location']
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>'
message_json = \
create_public_post(base_dir, nickname, domain,
port,
@ -175,7 +179,7 @@ def _receive_new_post_process_newpost(self, fields: {},
fields['eventDate'],
fields['eventTime'],
fields['eventEndTime'],
fields['location'], False,
location_str, False,
fields['languagesDropdown'],
conversation_id, convthread_id,
low_bandwidth,
@ -324,6 +328,10 @@ def _receive_new_post_process_newblog(self, fields: {},
if fields.get('searchableByDropdown'):
set_searchable_by(base_dir, nickname, domain,
fields['searchableByDropdown'])
location_str = fields['location']
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>'
message_json = \
create_blog_post(base_dir, nickname,
domain, port, http_prefix,
@ -338,7 +346,7 @@ def _receive_new_post_process_newblog(self, fields: {},
fields['eventDate'],
fields['eventTime'],
fields['eventEndTime'],
fields['location'],
location_str,
fields['languagesDropdown'],
conversation_id, convthread_id,
low_bandwidth,
@ -563,6 +571,10 @@ def _receive_new_post_process_newunlisted(self, fields: {},
video_transcript = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
location_str = fields['location']
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>'
message_json = \
create_unlisted_post(base_dir, nickname, domain, port,
http_prefix,
@ -580,7 +592,7 @@ def _receive_new_post_process_newunlisted(self, fields: {},
fields['eventDate'],
fields['eventTime'],
fields['eventEndTime'],
fields['location'],
location_str,
fields['languagesDropdown'],
conversation_id, convthread_id,
low_bandwidth,
@ -726,6 +738,10 @@ def _receive_new_post_process_newfollowers(self, fields: {},
if fields.get('searchableByDropdown'):
set_searchable_by(base_dir, nickname, domain,
fields['searchableByDropdown'])
location_str = fields['location']
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>'
message_json = \
create_followers_only_post(base_dir, nickname, domain,
port, http_prefix,
@ -744,7 +760,7 @@ def _receive_new_post_process_newfollowers(self, fields: {},
fields['eventDate'],
fields['eventTime'],
fields['eventEndTime'],
fields['location'],
location_str,
fields['languagesDropdown'],
conversation_id, convthread_id,
low_bandwidth,
@ -899,6 +915,11 @@ def _receive_new_post_process_newdm(self, fields: {},
video_transcript = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
location_str = fields['location']
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += \
' <address>' + fields['locationAddress'] + '</address>'
message_json = \
create_direct_message_post(base_dir, nickname, domain,
port, http_prefix,
@ -920,7 +941,7 @@ def _receive_new_post_process_newdm(self, fields: {},
fields['eventDate'],
fields['eventTime'],
fields['eventEndTime'],
fields['location'],
location_str,
fields['languagesDropdown'],
conversation_id, convthread_id,
low_bandwidth,
@ -1061,6 +1082,11 @@ def _receive_new_post_process_newreminder(self, fields: {}, nickname: str,
video_transcript = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
location_str = fields['location']
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += \
' <address>' + fields['locationAddress'] + '</address>'
message_json = \
create_direct_message_post(base_dir, nickname, domain,
port, http_prefix,
@ -1078,7 +1104,7 @@ def _receive_new_post_process_newreminder(self, fields: {}, nickname: str,
fields['eventDate'],
fields['eventTime'],
fields['eventEndTime'],
fields['location'],
location_str,
fields['languagesDropdown'],
conversation_id, convthread_id,
low_bandwidth,
@ -1409,6 +1435,11 @@ def _receive_new_post_process_newreading(self, fields: {},
if fields.get('searchableByDropdown'):
set_searchable_by(base_dir, nickname, domain,
fields['searchableByDropdown'])
location_str = fields['location']
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += \
' <address>' + fields['locationAddress'] + '</address>'
# reading status
message_json = \
create_reading_post(base_dir, nickname, domain,
@ -1427,7 +1458,7 @@ def _receive_new_post_process_newreading(self, fields: {},
fields['eventDate'],
fields['eventTime'],
fields['eventEndTime'],
fields['location'], False,
location_str, False,
fields['languagesDropdown'],
conversation_id, convthread_id,
low_bandwidth,
@ -1576,13 +1607,18 @@ def _receive_new_post_process_newshare(self, fields: {},
if fields.get('shareOnProfile'):
if fields['shareOnProfile'] == 'on':
share_on_profile = True
location_str = fields['location']
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += \
' <address>' + fields['locationAddress'] + '</address>'
add_share(base_dir, http_prefix, nickname, domain, port,
fields['subject'],
fields['message'],
filename,
item_qty, fields['itemType'],
fields['category'],
fields['location'],
location_str,
duration_str,
debug,
city, item_price, item_currency,
@ -1861,6 +1897,8 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
fields['eventEndTime'] = None
if not fields.get('location'):
fields['location'] = None
if not fields.get('locationAddress'):
fields['locationAddress'] = None
if not fields.get('languagesDropdown'):
fields['languagesDropdown'] = system_language
set_default_post_language(base_dir, nickname, domain,

View File

@ -1613,13 +1613,20 @@ def _create_post_place_and_time(event_date: str, end_date: str,
"endTime": end_date_str
})
if location and not event_uuid:
location_address = None
if '<address>' in location:
# separate out the address from the location
location_address = location.split('<address>')[1]
location_address = location_address.split('</address>')[0]
location = location.split('<address>')[0].strip()
latitude = longitude = None
if '://' in location:
_, latitude, longitude = \
geocoords_from_map_link(location, 'openstreetmap.org',
session)
location_tag_json = {}
if latitude and longitude:
tags.append({
location_tag_json = {
"@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
@ -1628,16 +1635,20 @@ def _create_post_place_and_time(event_date: str, end_date: str,
"name": location,
"latitude": latitude,
"longitude": longitude
})
}
else:
tags.append({
location_tag_json = {
"@context": [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'
],
"type": "Place",
"name": location
})
}
# add the address if it is available
if location_address:
location_tag_json['address'] = remove_html(location_address)
tags.append(location_tag_json)
return event_date_str

View File

@ -723,5 +723,6 @@
"DeltaChat": "دعوة إلى DeltaChat",
"Don't show recent public posts on your profile": "لا تعرض المنشورات العامة الأخيرة على ملفك الشخصي",
"Employers who reject DEI": "أصحاب العمل الذين يرفضون التنوع والمساواة والشمول",
"USA Right Wing Think Tank": "مركز أبحاث اليمين الأمريكي"
"USA Right Wing Think Tank": "مركز أبحاث اليمين الأمريكي",
"Address": "عنوان"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "ডেল্টাচ্যাট আমন্ত্রণ",
"Don't show recent public posts on your profile": "আপনার প্রোফাইলে সাম্প্রতিক পাবলিক পোস্টগুলি দেখাবেন না",
"Employers who reject DEI": "বৈচিত্র্য, সমতা এবং অন্তর্ভুক্তি প্রত্যাখ্যানকারী নিয়োগকর্তারা",
"USA Right Wing Think Tank": "মার্কিন যুক্তরাষ্ট্রের ডানপন্থী থিঙ্ক ট্যাঙ্ক"
"USA Right Wing Think Tank": "মার্কিন যুক্তরাষ্ট্রের ডানপন্থী থিঙ্ক ট্যাঙ্ক",
"Address": "জানুন"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Invitació de DeltaChat",
"Don't show recent public posts on your profile": "No mostris publicacions públiques recents al teu perfil",
"Employers who reject DEI": "Empresaris que rebutgen la diversitat, l'equitat i la inclusió",
"USA Right Wing Think Tank": "Think Tank de la dreta dels EUA"
"USA Right Wing Think Tank": "Think Tank de la dreta dels EUA",
"Address": "Adreça"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Gwahoddiad DeltaChat",
"Don't show recent public posts on your profile": "Peidiwch â dangos postiadau cyhoeddus diweddar ar eich proffil",
"Employers who reject DEI": "Cyflogwyr sy'n gwrthod Amrywiaeth, Tegwch a Chynhwysiant",
"USA Right Wing Think Tank": "Melin Drafod Adain Dde UDA"
"USA Right Wing Think Tank": "Melin Drafod Adain Dde UDA",
"Address": "Cyfeiriad"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "DeltaChat-Einladung",
"Don't show recent public posts on your profile": "Zeigen Sie keine aktuellen öffentlichen Beiträge in Ihrem Profil an",
"Employers who reject DEI": "Arbeitgeber, die Vielfalt, Gerechtigkeit und Inklusion ablehnen",
"USA Right Wing Think Tank": "Rechtsgerichteter Think Tank in den USA"
"USA Right Wing Think Tank": "Rechtsgerichteter Think Tank in den USA",
"Address": "Adresse"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Πρόσκληση DeltaChat",
"Don't show recent public posts on your profile": "Μην εμφανίζετε πρόσφατες δημόσιες αναρτήσεις στο προφίλ σας",
"Employers who reject DEI": "Εργοδότες που απορρίπτουν τη διαφορετικότητα, την ισότητα και την ένταξη",
"USA Right Wing Think Tank": "Δεξαμενή Σκέψης Δεξιάς Πτέρυγας ΗΠΑ"
"USA Right Wing Think Tank": "Δεξαμενή Σκέψης Δεξιάς Πτέρυγας ΗΠΑ",
"Address": "Διεύθυνση"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "DeltaChat invite",
"Don't show recent public posts on your profile": "Don't show recent public posts on your profile",
"Employers who reject DEI": "Employers who reject DEI",
"USA Right Wing Think Tank": "USA Right Wing Think Tank"
"USA Right Wing Think Tank": "USA Right Wing Think Tank",
"Address": "Address"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Invitación a DeltaChat",
"Don't show recent public posts on your profile": "No mostrar publicaciones públicas recientes en tu perfil",
"Employers who reject DEI": "Empleadores que rechazan la Diversidad, la Equidad y la Inclusión",
"USA Right Wing Think Tank": "Centro de estudios de derecha de EE.UU."
"USA Right Wing Think Tank": "Centro de estudios de derecha de EE.UU.",
"Address": "DIRECCIÓN"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "دعوت از دلتا چت",
"Don't show recent public posts on your profile": "پست های عمومی اخیر را در نمایه خود نشان ندهید",
"Employers who reject DEI": "کارفرمایانی که تنوع، برابری و شمول را رد می کنند",
"USA Right Wing Think Tank": "اتاق فکر جناح راست ایالات متحده آمریکا"
"USA Right Wing Think Tank": "اتاق فکر جناح راست ایالات متحده آمریکا",
"Address": "آدرس"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "DeltaChat-kutsu",
"Don't show recent public posts on your profile": "Älä näytä viimeisimmät julkiset viestit profiilissasi",
"Employers who reject DEI": "Työnantajat, jotka torjuvat monimuotoisuuden, tasa-arvon ja osallisuuden",
"USA Right Wing Think Tank": "USA:n oikeanpuoleinen ajatushautomo"
"USA Right Wing Think Tank": "USA:n oikeanpuoleinen ajatushautomo",
"Address": "Osoite"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Invitation DeltaChat",
"Don't show recent public posts on your profile": "Ne pas afficher les publications publiques récentes sur votre profil",
"Employers who reject DEI": "Les employeurs qui rejettent la diversité, l'équité et l'inclusion",
"USA Right Wing Think Tank": "Groupe de réflexion de droite américain"
"USA Right Wing Think Tank": "Groupe de réflexion de droite américain",
"Address": "Adresse"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Cuireadh DeltaChat",
"Don't show recent public posts on your profile": "Ná taispeáin postálacha poiblí le déanaí ar do phróifíl",
"Employers who reject DEI": "Fostóirí a dhiúltaíonn Éagsúlacht, Cothromas agus Cuimsiú",
"USA Right Wing Think Tank": "Umar Smaointeoireachta Eite deise SAM"
"USA Right Wing Think Tank": "Umar Smaointeoireachta Eite deise SAM",
"Address": "Seoladh"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "הזמנת DeltaChat",
"Don't show recent public posts on your profile": "אל תציג פוסטים ציבוריים אחרונים בפרופיל שלך",
"Employers who reject DEI": "מעסיקים הדוחים גיוון, שוויון והכלה",
"USA Right Wing Think Tank": "ארגון החשיבה הימני של ארהב"
"USA Right Wing Think Tank": "ארגון החשיבה הימני של ארהב",
"Address": "כְּתוֹבֶת"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "डेल्टाचैट आमंत्रण",
"Don't show recent public posts on your profile": "अपनी प्रोफ़ाइल पर हाल ही की सार्वजनिक पोस्ट न दिखाएँ",
"Employers who reject DEI": "नियोक्ता जो विविधता, समानता और समावेशन को अस्वीकार करते हैं",
"USA Right Wing Think Tank": "यूएसए राइट विंग थिंक टैंक"
"USA Right Wing Think Tank": "यूएसए राइट विंग थिंक टैंक",
"Address": "पता"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Invito DeltaChat",
"Don't show recent public posts on your profile": "Non mostrare i post pubblici recenti sul tuo profilo",
"Employers who reject DEI": "Datori di lavoro che rifiutano diversità, equità e inclusione",
"USA Right Wing Think Tank": "Think Tank di destra degli USA"
"USA Right Wing Think Tank": "Think Tank di destra degli USA",
"Address": "Indirizzo"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "DeltaChat 招待",
"Don't show recent public posts on your profile": "プロフィールに最近の公開投稿を表示しない",
"Employers who reject DEI": "多様性、公平性、包括性を拒否する雇用主",
"USA Right Wing Think Tank": "米国右翼シンクタンク"
"USA Right Wing Think Tank": "米国右翼シンクタンク",
"Address": "住所"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "DeltaChat 초대",
"Don't show recent public posts on your profile": "프로필에 최근 공개 게시물을 표시하지 마세요",
"Employers who reject DEI": "다양성, 형평성 및 포용성을 거부하는 고용주",
"USA Right Wing Think Tank": "미국 우익 싱크탱크"
"USA Right Wing Think Tank": "미국 우익 싱크탱크",
"Address": "주소"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "vexwendina DeltaChat",
"Don't show recent public posts on your profile": "Mesajên giştî yên dawî li ser profîla xwe nîşan nedin",
"Employers who reject DEI": "Kardêrên ku Pirrengî, Wekhevî û Tevliheviyê red dikin",
"USA Right Wing Think Tank": "Tank Think Wing USA"
"USA Right Wing Think Tank": "Tank Think Wing USA",
"Address": "Navnîşan"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "DeltaChat-uitnodiging",
"Don't show recent public posts on your profile": "Toon geen recente openbare berichten op uw profiel",
"Employers who reject DEI": "Werkgevers die Diversiteit, Gelijkheid en Inclusie afwijzen",
"USA Right Wing Think Tank": "Rechtse denktank van de VS"
"USA Right Wing Think Tank": "Rechtse denktank van de VS",
"Address": "Adres"
}

View File

@ -719,5 +719,6 @@
"DeltaChat": "DeltaChat invite",
"Don't show recent public posts on your profile": "Don't show recent public posts on your profile",
"Employers who reject DEI": "Employers who reject DEI",
"USA Right Wing Think Tank": "USA Right Wing Think Tank"
"USA Right Wing Think Tank": "USA Right Wing Think Tank",
"Address": "Address"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Zaproszenie do DeltaChat",
"Don't show recent public posts on your profile": "Nie pokazuj ostatnich publicznych postów na swoim profilu",
"Employers who reject DEI": "Pracodawcy odrzucający różnorodność, równość i integrację",
"USA Right Wing Think Tank": "USA Prawicowy Think Tank"
"USA Right Wing Think Tank": "USA Prawicowy Think Tank",
"Address": "Adres"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Convite DeltaChat",
"Don't show recent public posts on your profile": "Não mostrar publicações públicas recentes no seu perfil",
"Employers who reject DEI": "Empregadores que rejeitam a Diversidade, a Equidade e a Inclusão",
"USA Right Wing Think Tank": "EUA Grupo de reflexão de direita"
"USA Right Wing Think Tank": "EUA Grupo de reflexão de direita",
"Address": "Morada"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Приглашение DeltaChat",
"Don't show recent public posts on your profile": "Не показывать последние публичные публикации в вашем профиле",
"Employers who reject DEI": "Работодатели, которые отвергают разнообразие, равенство и инклюзивность",
"USA Right Wing Think Tank": "Аналитический центр правого крыла США"
"USA Right Wing Think Tank": "Аналитический центр правого крыла США",
"Address": "Адрес"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "mwaliko wa DeltaChat",
"Don't show recent public posts on your profile": "Usionyeshe machapisho ya hivi majuzi ya umma kwenye wasifu wako",
"Employers who reject DEI": "Waajiri wanaokataa Utofauti, Usawa na Ujumuisho",
"USA Right Wing Think Tank": "USA Right Wing Think Tank"
"USA Right Wing Think Tank": "USA Right Wing Think Tank",
"Address": "Anwani"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "DeltaChat daveti",
"Don't show recent public posts on your profile": "Profilinizde son genel paylaşımları göstermeyin",
"Employers who reject DEI": "Çeşitliliği, Eşitliği ve Kapsayıcılığı reddeden işverenler",
"USA Right Wing Think Tank": "ABD Sağ Kanat Düşünce Kuruluşu"
"USA Right Wing Think Tank": "ABD Sağ Kanat Düşünce Kuruluşu",
"Address": "Adres"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "Запрошення DeltaChat",
"Don't show recent public posts on your profile": "Не показувати останні загальнодоступні публікації у своєму профілі",
"Employers who reject DEI": "Роботодавці, які відкидають різноманітність, справедливість та інклюзивність",
"USA Right Wing Think Tank": "Правий мозковий центр США"
"USA Right Wing Think Tank": "Правий мозковий центр США",
"Address": "Адреса"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "דעלטאַטשאַט פאַרבעטן",
"Don't show recent public posts on your profile": "צי ניט ווייַזן לעצטע עפנטלעך הודעות אויף דיין פּראָפיל",
"Employers who reject DEI": "עמפּלויערס וואָס אָפּוואַרפן דייווערסיטי, יוישער און ינקלוזשאַן",
"USA Right Wing Think Tank": "USA רעכט פליגל טראַכטן טאַנק"
"USA Right Wing Think Tank": "USA רעכט פליגל טראַכטן טאַנק",
"Address": "אַדרעס"
}

View File

@ -723,5 +723,6 @@
"DeltaChat": "DeltaChat 邀请",
"Don't show recent public posts on your profile": "不要在你的个人资料上显示最近的公开帖子",
"Employers who reject DEI": "拒绝多元化、公平和包容的雇主",
"USA Right Wing Think Tank": "美国右翼智库"
"USA Right Wing Think Tank": "美国右翼智库",
"Address": "地址"
}

View File

@ -1079,6 +1079,9 @@ def html_new_post(edit_post_params: {},
edit_text_field(location_label_with_link, 'location',
default_location,
'https://www.openstreetmap.org/#map=') + '</p>\n'
address_str = translate['Address']
date_and_location += '<p>\n' + \
edit_text_field(address_str, 'locationAddress', '', '') + '</p>\n'
date_and_location += end_edit_section()
instance_title = get_config_param(base_dir, 'instanceTitle')