Buy link on edit new post

merge-requests/30/head
Bob Mottram 2023-01-13 17:41:48 +00:00
parent 78bc0937e2
commit 6928de6465
29 changed files with 88 additions and 45 deletions

View File

@ -3671,6 +3671,7 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.default_post_language.get(nickname): if self.server.default_post_language.get(nickname):
default_post_language = \ default_post_language = \
self.server.default_post_language[nickname] self.server.default_post_language[nickname]
default_buy_site = ''
msg = \ msg = \
html_new_post({}, False, self.server.translate, html_new_post({}, False, self.server.translate,
base_dir, base_dir,
@ -3712,7 +3713,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.dogwhistles, self.server.dogwhistles,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
None, None, default_post_language, None, None, default_post_language,
self.server.buy_sites) self.server.buy_sites,
default_buy_site)
if msg: if msg:
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -3832,6 +3834,7 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.default_post_language.get(nickname): if self.server.default_post_language.get(nickname):
default_post_language = \ default_post_language = \
self.server.default_post_language[nickname] self.server.default_post_language[nickname]
default_buy_site = ''
msg = \ msg = \
html_new_post({}, False, self.server.translate, html_new_post({}, False, self.server.translate,
base_dir, base_dir,
@ -3872,7 +3875,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.dogwhistles, self.server.dogwhistles,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
None, None, default_post_language, None, None, default_post_language,
self.server.buy_sites) self.server.buy_sites,
default_buy_site)
if msg: if msg:
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -16268,7 +16272,7 @@ class PubServer(BaseHTTPRequestHandler):
nickname, nickname,
self.server.domain_full, self.server.domain_full,
self.server.person_cache) self.server.person_cache)
default_buy_site = ''
msg = \ msg = \
html_new_post(edit_post_params, media_instance, html_new_post(edit_post_params, media_instance,
translate, translate,
@ -16313,7 +16317,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
new_post_month, new_post_year, new_post_month, new_post_year,
default_post_language, default_post_language,
self.server.buy_sites) self.server.buy_sites,
default_buy_site)
if not msg: if not msg:
print('Error replying to ' + in_reply_to_url) print('Error replying to ' + in_reply_to_url)
self._404() self._404()

View File

@ -610,5 +610,6 @@
"Registrations remaining": "التسجيلات المتبقية", "Registrations remaining": "التسجيلات المتبقية",
"Edit reminder": "تحرير التذكير", "Edit reminder": "تحرير التذكير",
"Purchase": "شراء", "Purchase": "شراء",
"Subscribe": "الإشتراك" "Subscribe": "الإشتراك",
"Buy link": "رابط شراء"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "রেজিস্ট্রেশন বাকি", "Registrations remaining": "রেজিস্ট্রেশন বাকি",
"Edit reminder": "অনুস্মারক সম্পাদনা করুন", "Edit reminder": "অনুস্মারক সম্পাদনা করুন",
"Purchase": "ক্রয়", "Purchase": "ক্রয়",
"Subscribe": "সাবস্ক্রাইব" "Subscribe": "সাবস্ক্রাইব",
"Buy link": "সংযোগ কেনা"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Inscripcions restants", "Registrations remaining": "Inscripcions restants",
"Edit reminder": "Edita el recordatori", "Edit reminder": "Edita el recordatori",
"Purchase": "Compra", "Purchase": "Compra",
"Subscribe": "Subscriu-te" "Subscribe": "Subscriu-te",
"Buy link": "Enllaç de compra"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Cofrestriadau ar ôl", "Registrations remaining": "Cofrestriadau ar ôl",
"Edit reminder": "Golygu nodyn atgoffa", "Edit reminder": "Golygu nodyn atgoffa",
"Purchase": "Prynu", "Purchase": "Prynu",
"Subscribe": "Tanysgrifio" "Subscribe": "Tanysgrifio",
"Buy link": "Prynu dolen"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Anmeldungen verbleiben", "Registrations remaining": "Anmeldungen verbleiben",
"Edit reminder": "Erinnerung bearbeiten", "Edit reminder": "Erinnerung bearbeiten",
"Purchase": "Kaufen", "Purchase": "Kaufen",
"Subscribe": "Abonnieren" "Subscribe": "Abonnieren",
"Buy link": "Link kaufen"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Απομένουν οι εγγραφές", "Registrations remaining": "Απομένουν οι εγγραφές",
"Edit reminder": "Επεξεργασία υπενθύμισης", "Edit reminder": "Επεξεργασία υπενθύμισης",
"Purchase": "Αγορά", "Purchase": "Αγορά",
"Subscribe": "Εγγραφείτε" "Subscribe": "Εγγραφείτε",
"Buy link": "Σύνδεσμος αγοράς"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Registrations remaining", "Registrations remaining": "Registrations remaining",
"Edit reminder": "Edit reminder", "Edit reminder": "Edit reminder",
"Purchase": "Purchase", "Purchase": "Purchase",
"Subscribe": "Subscribe" "Subscribe": "Subscribe",
"Buy link": "Buy link"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Registros restantes", "Registrations remaining": "Registros restantes",
"Edit reminder": "Editar recordatorio", "Edit reminder": "Editar recordatorio",
"Purchase": "Compra", "Purchase": "Compra",
"Subscribe": "Suscribir" "Subscribe": "Suscribir",
"Buy link": "Enlace de compra"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "ثبت نام باقی مانده است", "Registrations remaining": "ثبت نام باقی مانده است",
"Edit reminder": "ویرایش یادآوری", "Edit reminder": "ویرایش یادآوری",
"Purchase": "خرید", "Purchase": "خرید",
"Subscribe": "اشتراک در" "Subscribe": "اشتراک در",
"Buy link": "لینک خرید"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Inscriptions restantes", "Registrations remaining": "Inscriptions restantes",
"Edit reminder": "Modifier le rappel", "Edit reminder": "Modifier le rappel",
"Purchase": "Acheter", "Purchase": "Acheter",
"Subscribe": "S'abonner" "Subscribe": "S'abonner",
"Buy link": "Acheter un lien"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Clárúcháin fágtha", "Registrations remaining": "Clárúcháin fágtha",
"Edit reminder": "Cuir meabhrúchán in eagar", "Edit reminder": "Cuir meabhrúchán in eagar",
"Purchase": "Ceannach", "Purchase": "Ceannach",
"Subscribe": "Liostáil" "Subscribe": "Liostáil",
"Buy link": "Ceannaigh nasc"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "रजिस्ट्रेशन बाकी हैं", "Registrations remaining": "रजिस्ट्रेशन बाकी हैं",
"Edit reminder": "रिमाइंडर संपादित करें", "Edit reminder": "रिमाइंडर संपादित करें",
"Purchase": "खरीदना", "Purchase": "खरीदना",
"Subscribe": "सदस्यता लेने के" "Subscribe": "सदस्यता लेने के",
"Buy link": "लिंक खरीदें"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Iscrizioni rimanenti", "Registrations remaining": "Iscrizioni rimanenti",
"Edit reminder": "Modifica promemoria", "Edit reminder": "Modifica promemoria",
"Purchase": "Acquistare", "Purchase": "Acquistare",
"Subscribe": "Sottoscrivi" "Subscribe": "Sottoscrivi",
"Buy link": "Link per l'acquisto"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "残りの登録数", "Registrations remaining": "残りの登録数",
"Edit reminder": "リマインダーを編集", "Edit reminder": "リマインダーを編集",
"Purchase": "購入", "Purchase": "購入",
"Subscribe": "申し込む" "Subscribe": "申し込む",
"Buy link": "購入リンク"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "남은 등록", "Registrations remaining": "남은 등록",
"Edit reminder": "알림 수정", "Edit reminder": "알림 수정",
"Purchase": "구입", "Purchase": "구입",
"Subscribe": "구독하다" "Subscribe": "구독하다",
"Buy link": "구매 링크"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Registrations maye", "Registrations remaining": "Registrations maye",
"Edit reminder": "Bîranîna biguherîne", "Edit reminder": "Bîranîna biguherîne",
"Purchase": "Kirrîn", "Purchase": "Kirrîn",
"Subscribe": "Subscribe" "Subscribe": "Subscribe",
"Buy link": "Girêdanê bikirin"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Resterende inschrijvingen", "Registrations remaining": "Resterende inschrijvingen",
"Edit reminder": "Herinnering bewerken", "Edit reminder": "Herinnering bewerken",
"Purchase": "Aankoop", "Purchase": "Aankoop",
"Subscribe": "Abonneren" "Subscribe": "Abonneren",
"Buy link": "koop link"
} }

View File

@ -606,5 +606,6 @@
"Registrations remaining": "Registrations remaining", "Registrations remaining": "Registrations remaining",
"Edit reminder": "Edit reminder", "Edit reminder": "Edit reminder",
"Purchase": "Purchase", "Purchase": "Purchase",
"Subscribe": "Subscribe" "Subscribe": "Subscribe",
"Buy link": "Buy link"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Pozostały zapisy", "Registrations remaining": "Pozostały zapisy",
"Edit reminder": "Edytuj przypomnienie", "Edit reminder": "Edytuj przypomnienie",
"Purchase": "Zakup", "Purchase": "Zakup",
"Subscribe": "Subskrybuj" "Subscribe": "Subskrybuj",
"Buy link": "Kup Link"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Inscrições restantes", "Registrations remaining": "Inscrições restantes",
"Edit reminder": "Editar lembrete", "Edit reminder": "Editar lembrete",
"Purchase": "Comprar", "Purchase": "Comprar",
"Subscribe": "Se inscrever" "Subscribe": "Se inscrever",
"Buy link": "Link de compra"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Осталось регистраций", "Registrations remaining": "Осталось регистраций",
"Edit reminder": "Изменить напоминание", "Edit reminder": "Изменить напоминание",
"Purchase": "Покупка", "Purchase": "Покупка",
"Subscribe": "Подписаться" "Subscribe": "Подписаться",
"Buy link": "Купить ссылку"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Usajili uliosalia", "Registrations remaining": "Usajili uliosalia",
"Edit reminder": "Badilisha kikumbusho", "Edit reminder": "Badilisha kikumbusho",
"Purchase": "Nunua", "Purchase": "Nunua",
"Subscribe": "Jisajili" "Subscribe": "Jisajili",
"Buy link": "Nunua kiungo"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "kalan kayıtlar", "Registrations remaining": "kalan kayıtlar",
"Edit reminder": "Hatırlatıcıyı düzenle", "Edit reminder": "Hatırlatıcıyı düzenle",
"Purchase": "Satın alma", "Purchase": "Satın alma",
"Subscribe": "Abone" "Subscribe": "Abone",
"Buy link": "Bağlantı satın al"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "Залишилось реєстрацій", "Registrations remaining": "Залишилось реєстрацій",
"Edit reminder": "Редагувати нагадування", "Edit reminder": "Редагувати нагадування",
"Purchase": "Купівля", "Purchase": "Купівля",
"Subscribe": "Підпишіться" "Subscribe": "Підпишіться",
"Buy link": "Купити посилання"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "רעדזשיסטריישאַנז רוען", "Registrations remaining": "רעדזשיסטריישאַנז רוען",
"Edit reminder": "רעדאַגירן דערמאָנונג", "Edit reminder": "רעדאַגירן דערמאָנונג",
"Purchase": "קויפן", "Purchase": "קויפן",
"Subscribe": "אַבאָנירן" "Subscribe": "אַבאָנירן",
"Buy link": "קויפן לינק"
} }

View File

@ -610,5 +610,6 @@
"Registrations remaining": "剩余名额", "Registrations remaining": "剩余名额",
"Edit reminder": "编辑提醒", "Edit reminder": "编辑提醒",
"Purchase": "购买", "Purchase": "购买",
"Subscribe": "订阅" "Subscribe": "订阅",
"Buy link": "购买链接"
} }

View File

@ -24,6 +24,7 @@ from utils import get_currencies
from utils import get_category_types from utils import get_category_types
from utils import get_account_timezone from utils import get_account_timezone
from utils import get_supported_languages from utils import get_supported_languages
from webapp_utils import get_buy_links
from webapp_utils import html_following_data_list from webapp_utils import html_following_data_list
from webapp_utils import html_common_emoji from webapp_utils import html_common_emoji
from webapp_utils import begin_edit_section from webapp_utils import begin_edit_section
@ -240,7 +241,8 @@ def html_new_post(edit_post_params: {},
min_images_for_accounts: [], min_images_for_accounts: [],
default_month: int, default_year: int, default_month: int, default_year: int,
default_post_language: str, default_post_language: str,
buy_sites: {}) -> str: buy_sites: {},
default_buy_site: str) -> str:
"""New post screen """New post screen
""" """
# get the json if this is an edited post # get the json if this is an edited post
@ -257,6 +259,12 @@ def html_new_post(edit_post_params: {},
return '' return ''
if not edited_post_json: if not edited_post_json:
return '' return ''
buy_links = \
get_buy_links(edited_post_json, translate, buy_sites)
if buy_links:
for _, buy_url in buy_links.items():
default_buy_site = buy_url
break
if edited_post_json['object'].get('conversation'): if edited_post_json['object'].get('conversation'):
conversation_id = edited_post_json['object']['conversation'] conversation_id = edited_post_json['object']['conversation']
elif edited_post_json['object'].get('context'): elif edited_post_json['object'].get('context'):
@ -481,7 +489,6 @@ def html_new_post(edit_post_params: {},
' <textarea id="imageDescription" name="imageDescription" ' + \ ' <textarea id="imageDescription" name="imageDescription" ' + \
'style="height:' + str(image_description_height) + \ 'style="height:' + str(image_description_height) + \
'px" spellcheck="true" autocomplete="on"></textarea>\n' 'px" spellcheck="true" autocomplete="on"></textarea>\n'
new_post_image_section += end_edit_section() new_post_image_section += end_edit_section()
new_post_emoji_section = '' new_post_emoji_section = ''
@ -768,6 +775,9 @@ def html_new_post(edit_post_params: {},
' <label class="labels">' + \ ' <label class="labels">' + \
translate['Language used'] + '</label>\n' translate['Language used'] + '</label>\n'
replies_section += languages_dropdown replies_section += languages_dropdown
buy_link_str = '🛒 ' + translate['Buy link']
replies_section += edit_text_field(buy_link_str + ':', 'buySite',
default_buy_site, 'https://...')
replies_section += '</div>\n' replies_section += '</div>\n'
date_and_location = \ date_and_location = \

View File

@ -1844,19 +1844,21 @@ def _get_buy_footer(buy_links: {}, translate: {}) -> str:
if not buy_links: if not buy_links:
return '' return ''
icon_filename = 'buy.png' icon_filename = 'buy.png'
buy_title, buy_url = buy_links.items()[0] description = ''
if buy_title: buy_str = ''
description = buy_title for buy_title, buy_url in buy_links.items():
else: if buy_title:
description = translate['Buy'] description = buy_title
buy_str = \ else:
' ' + \ description = translate['Buy']
'<a class="imageAnchor" href="' + buy_url + \ buy_str = \
'" title="' + description + '" tabindex="10">' + \ ' ' + \
'<img loading="lazy" decoding="async" title="' + \ '<a class="imageAnchor" href="' + buy_url + \
description + '" alt="' + description + \ '" title="' + description + '" tabindex="10">' + \
' |" src="/icons/' + icon_filename + '"/></a>\n' '<img loading="lazy" decoding="async" title="' + \
description + '" alt="' + description + \
' |" src="/icons/' + icon_filename + '"/></a>\n'
break
return buy_str return buy_str