diff --git a/daemon.py b/daemon.py index 535861cdf..7a9ea8ab6 100644 --- a/daemon.py +++ b/daemon.py @@ -7882,6 +7882,40 @@ class PubServer(BaseHTTPRequestHandler): set_config_param(base_dir, 'crawlersAllowed', crawlers_allowed_str) + # save allowed buy domains + buy_sites = {} + if fields.get('buySitesStr'): + buy_sites_str = \ + fields['buySitesStr'] + buy_sites_list = \ + buy_sites_str.split('\n') + for site_url in buy_sites_list: + if ' ' in site_url: + site_url = site_url.split(' ')[-1] + buy_icon_text = \ + site_url.replace(site_url, '').strip() + if not buy_icon_text: + buy_icon_text = site_url + else: + buy_icon_text = site_url + if buy_sites.get(buy_icon_text): + continue + buy_sites[buy_icon_text] = site_url.strip() + if str(self.server.buy_sites) != \ + str(buy_sites): + self.server.buy_sites = buy_sites + buy_sites_filename = \ + base_dir + '/accounts/buy_sites.json' + if buy_sites: + save_json(buy_sites, buy_sites_filename) + else: + if os.path.isfile(buy_sites_filename): + try: + os.remove(buy_sites_filename) + except OSError: + print('EX: unable to delete ' + + buy_sites_filename) + # save peertube instances list peertube_instances_file = \ base_dir + '/accounts/peertube.txt' @@ -16398,7 +16432,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.system_language, self.server.min_images_for_accounts, self.server.max_recent_posts, - self.server.reverse_sequence) + self.server.reverse_sequence, + self.server.buy_sites) if msg: msg = msg.encode('utf-8') msglen = len(msg) diff --git a/translations/ar.json b/translations/ar.json index a905add84..d0e871237 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -611,5 +611,6 @@ "Edit reminder": "تحرير التذكير", "Purchase": "شراء", "Subscribe": "الإشتراك", - "Buy link": "رابط شراء" + "Buy link": "رابط شراء", + "Buy links are allowed from the following domains": "روابط الشراء مسموح بها من المجالات التالية" } diff --git a/translations/bn.json b/translations/bn.json index 6f8c9a2fa..75629536b 100644 --- a/translations/bn.json +++ b/translations/bn.json @@ -611,5 +611,6 @@ "Edit reminder": "অনুস্মারক সম্পাদনা করুন", "Purchase": "ক্রয়", "Subscribe": "সাবস্ক্রাইব", - "Buy link": "সংযোগ কেনা" + "Buy link": "সংযোগ কেনা", + "Buy links are allowed from the following domains": "নিম্নলিখিত ডোমেনগুলি থেকে লিঙ্কগুলি কেনার অনুমতি দেওয়া হয়েছে" } diff --git a/translations/ca.json b/translations/ca.json index 7d2a1a673..85b5bb3f1 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -611,5 +611,6 @@ "Edit reminder": "Edita el recordatori", "Purchase": "Compra", "Subscribe": "Subscriu-te", - "Buy link": "Enllaç de compra" + "Buy link": "Enllaç de compra", + "Buy links are allowed from the following domains": "Els enllaços de compra es permeten des dels dominis següents" } diff --git a/translations/cy.json b/translations/cy.json index 9b1c34612..56dcee7d0 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -611,5 +611,6 @@ "Edit reminder": "Golygu nodyn atgoffa", "Purchase": "Prynu", "Subscribe": "Tanysgrifio", - "Buy link": "Prynu dolen" + "Buy link": "Prynu dolen", + "Buy links are allowed from the following domains": "Caniateir dolenni prynu o'r parthau canlynol" } diff --git a/translations/de.json b/translations/de.json index e9381fe8f..8126e5514 100644 --- a/translations/de.json +++ b/translations/de.json @@ -611,5 +611,6 @@ "Edit reminder": "Erinnerung bearbeiten", "Purchase": "Kaufen", "Subscribe": "Abonnieren", - "Buy link": "Link kaufen" + "Buy link": "Link kaufen", + "Buy links are allowed from the following domains": "Kauflinks sind von den folgenden Domains erlaubt" } diff --git a/translations/el.json b/translations/el.json index f52794045..700da97fa 100644 --- a/translations/el.json +++ b/translations/el.json @@ -611,5 +611,6 @@ "Edit reminder": "Επεξεργασία υπενθύμισης", "Purchase": "Αγορά", "Subscribe": "Εγγραφείτε", - "Buy link": "Σύνδεσμος αγοράς" + "Buy link": "Σύνδεσμος αγοράς", + "Buy links are allowed from the following domains": "Οι σύνδεσμοι αγοράς επιτρέπονται από τους παρακάτω τομείς" } diff --git a/translations/en.json b/translations/en.json index b609436cc..4cfd16b63 100644 --- a/translations/en.json +++ b/translations/en.json @@ -611,5 +611,6 @@ "Edit reminder": "Edit reminder", "Purchase": "Purchase", "Subscribe": "Subscribe", - "Buy link": "Buy link" + "Buy link": "Buy link", + "Buy links are allowed from the following domains": "Buy links are allowed from the following domains" } diff --git a/translations/es.json b/translations/es.json index ce6b671ed..484fc52a8 100644 --- a/translations/es.json +++ b/translations/es.json @@ -611,5 +611,6 @@ "Edit reminder": "Editar recordatorio", "Purchase": "Compra", "Subscribe": "Suscribir", - "Buy link": "Enlace de compra" + "Buy link": "Enlace de compra", + "Buy links are allowed from the following domains": "Se permiten enlaces de compra de los siguientes dominios" } diff --git a/translations/fa.json b/translations/fa.json index 36b442958..61755dfbe 100644 --- a/translations/fa.json +++ b/translations/fa.json @@ -611,5 +611,6 @@ "Edit reminder": "ویرایش یادآوری", "Purchase": "خرید", "Subscribe": "اشتراک در", - "Buy link": "لینک خرید" + "Buy link": "لینک خرید", + "Buy links are allowed from the following domains": "لینک خرید از دامنه های زیر مجاز است" } diff --git a/translations/fr.json b/translations/fr.json index dff468ab6..cb8020e82 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -611,5 +611,6 @@ "Edit reminder": "Modifier le rappel", "Purchase": "Acheter", "Subscribe": "S'abonner", - "Buy link": "Acheter un lien" + "Buy link": "Acheter un lien", + "Buy links are allowed from the following domains": "Les liens d'achat sont autorisés à partir des domaines suivants" } diff --git a/translations/ga.json b/translations/ga.json index adde1a810..9416cc13b 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -611,5 +611,6 @@ "Edit reminder": "Cuir meabhrúchán in eagar", "Purchase": "Ceannach", "Subscribe": "Liostáil", - "Buy link": "Ceannaigh nasc" + "Buy link": "Ceannaigh nasc", + "Buy links are allowed from the following domains": "Ceadaítear naisc cheannaigh ó na fearainn seo a leanas" } diff --git a/translations/hi.json b/translations/hi.json index 4f0b54782..3f1c5fd6e 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -611,5 +611,6 @@ "Edit reminder": "रिमाइंडर संपादित करें", "Purchase": "खरीदना", "Subscribe": "सदस्यता लेने के", - "Buy link": "लिंक खरीदें" + "Buy link": "लिंक खरीदें", + "Buy links are allowed from the following domains": "निम्नलिखित डोमेन से खरीदें लिंक की अनुमति है" } diff --git a/translations/it.json b/translations/it.json index 94b851b07..f9bd2df67 100644 --- a/translations/it.json +++ b/translations/it.json @@ -611,5 +611,6 @@ "Edit reminder": "Modifica promemoria", "Purchase": "Acquistare", "Subscribe": "Sottoscrivi", - "Buy link": "Link per l'acquisto" + "Buy link": "Link per l'acquisto", + "Buy links are allowed from the following domains": "I link di acquisto sono consentiti dai seguenti domini" } diff --git a/translations/ja.json b/translations/ja.json index 9dfa8a408..f274f6bcf 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -611,5 +611,6 @@ "Edit reminder": "リマインダーを編集", "Purchase": "購入", "Subscribe": "申し込む", - "Buy link": "購入リンク" + "Buy link": "購入リンク", + "Buy links are allowed from the following domains": "次のドメインからの購入リンクが許可されています" } diff --git a/translations/ko.json b/translations/ko.json index 77ba773c2..71e437519 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -611,5 +611,6 @@ "Edit reminder": "알림 수정", "Purchase": "구입", "Subscribe": "구독하다", - "Buy link": "구매 링크" + "Buy link": "구매 링크", + "Buy links are allowed from the following domains": "다음 도메인에서 구매 링크가 허용됩니다." } diff --git a/translations/ku.json b/translations/ku.json index ac8e07cd7..29a310e21 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -611,5 +611,6 @@ "Edit reminder": "Bîranîna biguherîne", "Purchase": "Kirrîn", "Subscribe": "Subscribe", - "Buy link": "Girêdanê bikirin" + "Buy link": "Girêdanê bikirin", + "Buy links are allowed from the following domains": "Zencîreyên kirînê ji domên jêrîn têne destûr kirin" } diff --git a/translations/nl.json b/translations/nl.json index 61f2141a2..d8eb2d268 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -611,5 +611,6 @@ "Edit reminder": "Herinnering bewerken", "Purchase": "Aankoop", "Subscribe": "Abonneren", - "Buy link": "koop link" + "Buy link": "koop link", + "Buy links are allowed from the following domains": "Kooplinks zijn toegestaan vanaf de volgende domeinen" } diff --git a/translations/oc.json b/translations/oc.json index 3b7eeb875..bad9e02dd 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -607,5 +607,6 @@ "Edit reminder": "Edit reminder", "Purchase": "Purchase", "Subscribe": "Subscribe", - "Buy link": "Buy link" + "Buy link": "Buy link", + "Buy links are allowed from the following domains": "Buy links are allowed from the following domains" } diff --git a/translations/pl.json b/translations/pl.json index aac582b80..b85fe67e9 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -611,5 +611,6 @@ "Edit reminder": "Edytuj przypomnienie", "Purchase": "Zakup", "Subscribe": "Subskrybuj", - "Buy link": "Kup Link" + "Buy link": "Kup Link", + "Buy links are allowed from the following domains": "Kupuj linki są dozwolone z następujących domen" } diff --git a/translations/pt.json b/translations/pt.json index c597c1e21..9df0cdff5 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -611,5 +611,6 @@ "Edit reminder": "Editar lembrete", "Purchase": "Comprar", "Subscribe": "Se inscrever", - "Buy link": "Link de compra" + "Buy link": "Link de compra", + "Buy links are allowed from the following domains": "Links de compra são permitidos nos seguintes domínios" } diff --git a/translations/ru.json b/translations/ru.json index 8254236b3..bd3f0ce13 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -611,5 +611,6 @@ "Edit reminder": "Изменить напоминание", "Purchase": "Покупка", "Subscribe": "Подписаться", - "Buy link": "Купить ссылку" + "Buy link": "Купить ссылку", + "Buy links are allowed from the following domains": "Ссылки на покупку разрешены со следующих доменов" } diff --git a/translations/sw.json b/translations/sw.json index 40f4e4097..7bbf34f89 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -611,5 +611,6 @@ "Edit reminder": "Badilisha kikumbusho", "Purchase": "Nunua", "Subscribe": "Jisajili", - "Buy link": "Nunua kiungo" + "Buy link": "Nunua kiungo", + "Buy links are allowed from the following domains": "Viungo vya kununua vinaruhusiwa kutoka kwa vikoa vifuatavyo" } diff --git a/translations/tr.json b/translations/tr.json index aba9288a9..1606176b8 100644 --- a/translations/tr.json +++ b/translations/tr.json @@ -611,5 +611,6 @@ "Edit reminder": "Hatırlatıcıyı düzenle", "Purchase": "Satın alma", "Subscribe": "Abone", - "Buy link": "Bağlantı satın al" + "Buy link": "Bağlantı satın al", + "Buy links are allowed from the following domains": "Aşağıdaki alanlardan satın alma bağlantılarına izin verilir" } diff --git a/translations/uk.json b/translations/uk.json index 030935be9..590a799a1 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -611,5 +611,6 @@ "Edit reminder": "Редагувати нагадування", "Purchase": "Купівля", "Subscribe": "Підпишіться", - "Buy link": "Купити посилання" + "Buy link": "Купити посилання", + "Buy links are allowed from the following domains": "Посилання на купівлю дозволено з таких доменів" } diff --git a/translations/yi.json b/translations/yi.json index 343c45346..c3d62bf14 100644 --- a/translations/yi.json +++ b/translations/yi.json @@ -611,5 +611,6 @@ "Edit reminder": "רעדאַגירן דערמאָנונג", "Purchase": "קויפן", "Subscribe": "אַבאָנירן", - "Buy link": "קויפן לינק" + "Buy link": "קויפן לינק", + "Buy links are allowed from the following domains": "קויפן פֿאַרבינדונגען זענען ערלויבט פֿון די פאלגענדע דאָומיינז" } diff --git a/translations/zh.json b/translations/zh.json index 742429670..d7c5fb673 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -611,5 +611,6 @@ "Edit reminder": "编辑提醒", "Purchase": "购买", "Subscribe": "订阅", - "Buy link": "购买链接" + "Buy link": "购买链接", + "Buy links are allowed from the following domains": "允许来自以下域的购买链接" } diff --git a/webapp_profile.py b/webapp_profile.py index fd36d423a..3d201f4e0 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1884,7 +1884,8 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str, user_agents_blocked: str, crawlers_allowed: str, translate: {}, reply_interval_hours: int, - cw_lists: {}, lists_enabled: str) -> str: + cw_lists: {}, lists_enabled: str, + buy_sites: {}) -> str: """Filtering and blocking section of edit profile screen """ filter_str = '' @@ -2071,6 +2072,20 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str, 'crawlersAllowedStr', crawlers_allowed_str, 200, '', False) + buy_domains_list_str = '' + for buy_icon_text, buy_url in buy_sites.items(): + if buy_icon_text != buy_url: + buy_domains_list_str += \ + buy_icon_text + ' ' + buy_url.strip() + '\n' + else: + buy_domains_list_str += buy_url.strip() + '\n' + buy_domains_str = \ + "Buy links are allowed from the following domains" + edit_profile_form += \ + edit_text_area(translate[buy_domains_str], None, + 'buySitesStr', buy_domains_list_str, + 200, '', False) + cw_lists_str = '' for name, _ in cw_lists.items(): variablename = get_cw_list_variable(name) @@ -2513,7 +2528,8 @@ def html_edit_profile(server, translate: {}, system_language: str, min_images_for_accounts: [], max_recent_posts: int, - reverse_sequence: []) -> str: + reverse_sequence: [], + buy_sites: {}) -> str: """Shows the edit profile screen """ path = path.replace('/inbox', '').replace('/outbox', '') @@ -2754,7 +2770,7 @@ def html_edit_profile(server, translate: {}, _html_edit_profile_filtering(base_dir, nickname, domain, user_agents_blocked, crawlers_allowed, translate, reply_interval_hours, - cw_lists, lists_enabled) + cw_lists, lists_enabled, buy_sites) # git projects section edit_profile_form += \ diff --git a/webapp_utils.py b/webapp_utils.py index 17c000fc1..db99b2321 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -2148,7 +2148,7 @@ def get_buy_links(post_json_object: str, translate: {}, buy_sites: {}) -> {}: def load_buy_sites(base_dir: str) -> {}: """Loads domains from which buying is permitted """ - buy_sites_filename = base_dir + '/accounts/buy_sites.txt' + buy_sites_filename = base_dir + '/accounts/buy_sites.json' if os.path.isfile(buy_sites_filename): buy_sites_json = load_json(buy_sites_filename) if buy_sites_json: