From 4385028bdea8318956ce83b879d68e3d648adcb4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 2 May 2023 22:51:30 +0100 Subject: [PATCH] Show featured hashtags within edit profile screen --- translations/ar.json | 3 ++- translations/bn.json | 3 ++- translations/ca.json | 3 ++- translations/cy.json | 3 ++- translations/de.json | 3 ++- translations/el.json | 3 ++- translations/en.json | 3 ++- translations/es.json | 3 ++- translations/fa.json | 3 ++- translations/fr.json | 3 ++- translations/ga.json | 3 ++- translations/hi.json | 3 ++- translations/it.json | 3 ++- translations/ja.json | 3 ++- translations/ko.json | 3 ++- translations/ku.json | 3 ++- translations/nl.json | 3 ++- translations/oc.json | 3 ++- translations/pl.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/sw.json | 3 ++- translations/tr.json | 3 ++- translations/uk.json | 3 ++- translations/yi.json | 3 ++- translations/zh.json | 3 ++- webapp_profile.py | 55 ++++++++++++++++++++++++++++++++++++++++---- 27 files changed, 103 insertions(+), 30 deletions(-) diff --git a/translations/ar.json b/translations/ar.json index 329b09dc0..fa8360a41 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -621,5 +621,6 @@ "Import Blocks": "استيراد مثيلات محظورة", "Export Blocks": "تصدير المثيلات المحظورة", "Transcript": "نص", - "Show vote posts": "إظهار مشاركات التصويت" + "Show vote posts": "إظهار مشاركات التصويت", + "Featured hashtags": "علامات التجزئة المميزة" } diff --git a/translations/bn.json b/translations/bn.json index 9e38322bb..84a6d8c98 100644 --- a/translations/bn.json +++ b/translations/bn.json @@ -621,5 +621,6 @@ "Import Blocks": "অবরুদ্ধ দৃষ্টান্ত আমদানি করুন", "Export Blocks": "অবরুদ্ধ দৃষ্টান্ত রপ্তানি করুন", "Transcript": "প্রতিলিপি", - "Show vote posts": "ভোট পোস্ট দেখান" + "Show vote posts": "ভোট পোস্ট দেখান", + "Featured hashtags": "বৈশিষ্ট্যযুক্ত হ্যাশট্যাগ" } diff --git a/translations/ca.json b/translations/ca.json index 3ffabe415..dcddfe08a 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -621,5 +621,6 @@ "Import Blocks": "Importa instàncies bloquejades", "Export Blocks": "Exporta instàncies bloquejades", "Transcript": "Transcripció", - "Show vote posts": "Mostra les publicacions de vot" + "Show vote posts": "Mostra les publicacions de vot", + "Featured hashtags": "Hashtags destacats" } diff --git a/translations/cy.json b/translations/cy.json index 8cbffe7b3..d3d2d6898 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -621,5 +621,6 @@ "Import Blocks": "Mewnforio Achosion wedi'u Rhwystro", "Export Blocks": "Allforio Achosion wedi'u Rhwystro", "Transcript": "Trawsgrifiad", - "Show vote posts": "Dangos postiadau pleidlais" + "Show vote posts": "Dangos postiadau pleidlais", + "Featured hashtags": "Hashtags dan sylw" } diff --git a/translations/de.json b/translations/de.json index ae5ccd6b0..38b888ab0 100644 --- a/translations/de.json +++ b/translations/de.json @@ -621,5 +621,6 @@ "Import Blocks": "Blockierte Instanzen importieren", "Export Blocks": "Blockierte Instanzen exportieren", "Transcript": "Abschrift", - "Show vote posts": "Abstimmungsbeiträge anzeigen" + "Show vote posts": "Abstimmungsbeiträge anzeigen", + "Featured hashtags": "Ausgewählte Hashtags" } diff --git a/translations/el.json b/translations/el.json index a74a985a9..025d1138c 100644 --- a/translations/el.json +++ b/translations/el.json @@ -621,5 +621,6 @@ "Import Blocks": "Εισαγωγή αποκλεισμένων παρουσιών", "Export Blocks": "Εξαγωγή αποκλεισμένων παρουσιών", "Transcript": "Αντίγραφο", - "Show vote posts": "Εμφάνιση ψηφοφοριακών αναρτήσεων" + "Show vote posts": "Εμφάνιση ψηφοφοριακών αναρτήσεων", + "Featured hashtags": "Επιλεγμένα hashtag" } diff --git a/translations/en.json b/translations/en.json index 579ebd5c3..c21434c2c 100644 --- a/translations/en.json +++ b/translations/en.json @@ -621,5 +621,6 @@ "Import Blocks": "Import Blocks", "Export Blocks": "Export Blocks", "Transcript": "Transcript", - "Show vote posts": "Show vote posts" + "Show vote posts": "Show vote posts", + "Featured hashtags": "Featured hashtags" } diff --git a/translations/es.json b/translations/es.json index c82779fb4..761430538 100644 --- a/translations/es.json +++ b/translations/es.json @@ -621,5 +621,6 @@ "Import Blocks": "Importar instancias bloqueadas", "Export Blocks": "Exportar instancias bloqueadas", "Transcript": "Transcripción", - "Show vote posts": "Mostrar publicaciones de votos" + "Show vote posts": "Mostrar publicaciones de votos", + "Featured hashtags": "Hashtags destacados" } diff --git a/translations/fa.json b/translations/fa.json index b4061cbd7..de11e9989 100644 --- a/translations/fa.json +++ b/translations/fa.json @@ -621,5 +621,6 @@ "Import Blocks": "وارد کردن موارد مسدود شده", "Export Blocks": "نمونه های مسدود شده را صادر کنید", "Transcript": "رونوشت", - "Show vote posts": "نمایش پست های رای" + "Show vote posts": "نمایش پست های رای", + "Featured hashtags": "هشتگ های ویژه" } diff --git a/translations/fr.json b/translations/fr.json index 6f8b1ec0b..97e82dac5 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -621,5 +621,6 @@ "Import Blocks": "Importer des instances bloquées", "Export Blocks": "Exporter les instances bloquées", "Transcript": "Transcription", - "Show vote posts": "Afficher les messages de vote" + "Show vote posts": "Afficher les messages de vote", + "Featured hashtags": "Mots-clics en vedette" } diff --git a/translations/ga.json b/translations/ga.json index 3c47db41c..8743dec1f 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -621,5 +621,6 @@ "Import Blocks": "Iompórtáil Cásanna Blocáilte", "Export Blocks": "Easpórtáil Cásanna Blocáilte", "Transcript": "Athscríbhinn", - "Show vote posts": "Taispeáin postálacha vótaí" + "Show vote posts": "Taispeáin postálacha vótaí", + "Featured hashtags": "Hashtags faoi thrácht" } diff --git a/translations/hi.json b/translations/hi.json index a0f1e2aa8..0f40fa6ea 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -621,5 +621,6 @@ "Import Blocks": "अवरोधित उदाहरण आयात करें", "Export Blocks": "निर्यात अवरुद्ध उदाहरण", "Transcript": "प्रतिलिपि", - "Show vote posts": "वोट पोस्ट दिखाएं" + "Show vote posts": "वोट पोस्ट दिखाएं", + "Featured hashtags": "विशेष रुप से प्रदर्शित हैशटैग" } diff --git a/translations/it.json b/translations/it.json index 369728726..462d356c9 100644 --- a/translations/it.json +++ b/translations/it.json @@ -621,5 +621,6 @@ "Import Blocks": "Importa istanze bloccate", "Export Blocks": "Esporta istanze bloccate", "Transcript": "Trascrizione", - "Show vote posts": "Mostra messaggi di voto" + "Show vote posts": "Mostra messaggi di voto", + "Featured hashtags": "Hashtag in primo piano" } diff --git a/translations/ja.json b/translations/ja.json index eceee9296..a65950fcb 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -621,5 +621,6 @@ "Import Blocks": "ブロックされたインスタンスのインポート", "Export Blocks": "ブロックされたインスタンスのエクスポート", "Transcript": "成績証明書", - "Show vote posts": "投票投稿を表示" + "Show vote posts": "投票投稿を表示", + "Featured hashtags": "注目のハッシュタグ" } diff --git a/translations/ko.json b/translations/ko.json index 4566e4b12..5fea54953 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -621,5 +621,6 @@ "Import Blocks": "차단된 인스턴스 가져오기", "Export Blocks": "차단된 인스턴스 내보내기", "Transcript": "성적 증명서", - "Show vote posts": "투표 게시물 표시" + "Show vote posts": "투표 게시물 표시", + "Featured hashtags": "추천 해시태그" } diff --git a/translations/ku.json b/translations/ku.json index 93641927a..32c4558e9 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -621,5 +621,6 @@ "Import Blocks": "Mînakên Astengkirî Import", "Export Blocks": "Mînakên Astengkirî Export", "Transcript": "Transcript", - "Show vote posts": "Mesajên dengdanê nîşan bide" + "Show vote posts": "Mesajên dengdanê nîşan bide", + "Featured hashtags": "Hashtagên taybetmendî" } diff --git a/translations/nl.json b/translations/nl.json index 3c55d1750..4b155e6d9 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -621,5 +621,6 @@ "Import Blocks": "Importeer geblokkeerde instanties", "Export Blocks": "Exporteer geblokkeerde instanties", "Transcript": "Vertaling", - "Show vote posts": "Toon stemberichten" + "Show vote posts": "Toon stemberichten", + "Featured hashtags": "Aanbevolen hashtags" } diff --git a/translations/oc.json b/translations/oc.json index 33e34ce08..c3d43b2d1 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -617,5 +617,6 @@ "Import Blocks": "Import Blocks", "Export Blocks": "Export Blocks", "Transcript": "Transcript", - "Show vote posts": "Show vote posts" + "Show vote posts": "Show vote posts", + "Featured hashtags": "Featured hashtags" } diff --git a/translations/pl.json b/translations/pl.json index 5febf1fbd..b483f1c5f 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -621,5 +621,6 @@ "Import Blocks": "Importuj zablokowane instancje", "Export Blocks": "Eksportuj zablokowane instancje", "Transcript": "Transkrypcja", - "Show vote posts": "Pokaż posty z głosowaniem" + "Show vote posts": "Pokaż posty z głosowaniem", + "Featured hashtags": "Polecane hashtagi" } diff --git a/translations/pt.json b/translations/pt.json index 6baf46567..15c098d0c 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -621,5 +621,6 @@ "Import Blocks": "Importar instâncias bloqueadas", "Export Blocks": "Exportar instâncias bloqueadas", "Transcript": "Transcrição", - "Show vote posts": "Mostrar postagens de votação" + "Show vote posts": "Mostrar postagens de votação", + "Featured hashtags": "Hashtags em destaque" } diff --git a/translations/ru.json b/translations/ru.json index 240e1b7ed..3cd307beb 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -621,5 +621,6 @@ "Import Blocks": "Импорт заблокированных экземпляров", "Export Blocks": "Экспорт заблокированных экземпляров", "Transcript": "Стенограмма", - "Show vote posts": "Показать сообщения для голосования" + "Show vote posts": "Показать сообщения для голосования", + "Featured hashtags": "Избранные хэштеги" } diff --git a/translations/sw.json b/translations/sw.json index ae55e4ca8..ded5b9011 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -621,5 +621,6 @@ "Import Blocks": "Ingiza Matukio Yaliyozuiwa", "Export Blocks": "Hamisha Matukio Yaliyozuiwa", "Transcript": "Nakala", - "Show vote posts": "Onyesha machapisho ya kura" + "Show vote posts": "Onyesha machapisho ya kura", + "Featured hashtags": "Reli zilizoangaziwa" } diff --git a/translations/tr.json b/translations/tr.json index 1a4cf0b84..2d8496d94 100644 --- a/translations/tr.json +++ b/translations/tr.json @@ -621,5 +621,6 @@ "Import Blocks": "Engellenen Örnekleri İçe Aktar", "Export Blocks": "Engellenen Örnekleri Dışa Aktar", "Transcript": "Deşifre metni", - "Show vote posts": "Oy gönderilerini göster" + "Show vote posts": "Oy gönderilerini göster", + "Featured hashtags": "Öne çıkan etiketler" } diff --git a/translations/uk.json b/translations/uk.json index 0bf7a99ce..06f0ac326 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -621,5 +621,6 @@ "Import Blocks": "Імпортувати заблоковані екземпляри", "Export Blocks": "Експортувати заблоковані екземпляри", "Transcript": "Стенограма", - "Show vote posts": "Показати повідомлення про голосування" + "Show vote posts": "Показати повідомлення про голосування", + "Featured hashtags": "Рекомендовані хештеги" } diff --git a/translations/yi.json b/translations/yi.json index 01a218570..3c0c648e8 100644 --- a/translations/yi.json +++ b/translations/yi.json @@ -621,5 +621,6 @@ "Import Blocks": "ימפּאָרט בלאַקט ינסטאַנסיז", "Export Blocks": "עקספּאָרט בלאַקט ינסטאַנסיז", "Transcript": "טראַנסקריפּט", - "Show vote posts": "ווייַזן שטימען אַרטיקלען" + "Show vote posts": "ווייַזן שטימען אַרטיקלען", + "Featured hashtags": "פֿעיִקייטן פון hashtags" } diff --git a/translations/zh.json b/translations/zh.json index ca8325c6c..c7f0b816e 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -621,5 +621,6 @@ "Import Blocks": "导入被阻止的实例", "Export Blocks": "导出被阻止的实例", "Transcript": "成绩单", - "Show vote posts": "显示投票帖子" + "Show vote posts": "显示投票帖子", + "Featured hashtags": "特色标签" } diff --git a/webapp_profile.py b/webapp_profile.py index 9f8eaaebe..cba60210d 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -10,6 +10,7 @@ __module_group__ = "Web Interface" import os from pprint import pprint from webfinger import webfinger_handle +from utils import valid_hash_tag from utils import remove_id_ending from utils import standardize_text from utils import get_display_name @@ -2437,7 +2438,8 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str, gemini_link: str, blog_address: str, actor_json: {}, translate: {}, nickname: str, domain: str, - max_recent_posts: int) -> str: + max_recent_posts: int, + featured_hashtags: str) -> str: """main info on edit profile screen """ image_formats = get_image_formats() @@ -2452,6 +2454,10 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str, edit_text_area(translate['Your bio'], None, 'bio', bio_str, 200, '', True) + edit_profile_form += \ + edit_text_field(translate['Featured hashtags'], 'featuredHashtags', + featured_hashtags, '#tag1 #tag2') + edit_profile_form += \ ' \n' + \ @@ -2570,6 +2576,45 @@ def _html_edit_profile_top_banner(base_dir: str, return edit_profile_form +def _get_featured_hashtags(actor_json: {}) -> str: + """returns a string containing featured hashtags + """ + result = '' + if not actor_json.get('tag'): + return result + if not isinstance(actor_json['tag'], list): + return result + for tag_dict in actor_json['tag']: + if not tag_dict.get('type'): + continue + if not isinstance(tag_dict['type'], str): + continue + if not tag_dict['type'].endswith('Hashtag'): + continue + if not tag_dict.get('name'): + continue + if not isinstance(tag_dict['name'], str): + continue + if not tag_dict.get('href'): + continue + if not isinstance(tag_dict['href'], str): + continue + tag_name = tag_dict['name'] + if not tag_name: + continue + if tag_name.startswith('#'): + tag_name = tag_name[1:] + if not tag_name: + continue + tag_url = tag_dict['href'] + if '://' not in tag_url or '.' not in tag_url: + continue + if not valid_hash_tag(tag_name): + continue + result += '#' + tag_name + ' ' + return result.strip() + + def html_edit_profile(server, translate: {}, base_dir: str, path: str, domain: str, port: int, @@ -2612,8 +2657,8 @@ def html_edit_profile(server, translate: {}, notify_likes = notify_reactions = '' hide_like_button = hide_reaction_button = media_instance_str = '' blogs_instance_str = news_instance_str = moved_to = twitter_str = '' - bio_str = donate_url = website_url = gemini_link = email_address = '' - pgp_pub_key = enigma_pub_key = '' + bio_str = donate_url = website_url = gemini_link = '' + email_address = featured_hashtags = pgp_pub_key = enigma_pub_key = '' pgp_fingerprint = xmpp_address = matrix_address = '' ssb_address = blog_address = tox_address = '' cwtch_address = briar_address = '' @@ -2623,6 +2668,7 @@ def html_edit_profile(server, translate: {}, if actor_json: if actor_json.get('movedTo'): moved_to = actor_json['movedTo'] + featured_hashtags = _get_featured_hashtags(actor_json) donate_url = get_donation_url(actor_json) website_url = get_website(actor_json, translate) gemini_link = get_gemini_link(actor_json, translate) @@ -2769,7 +2815,8 @@ def html_edit_profile(server, translate: {}, moved_to, donate_url, website_url, gemini_link, blog_address, actor_json, translate, - nickname, domain, max_recent_posts) + nickname, domain, max_recent_posts, + featured_hashtags) # whether to show votes show_vote_posts = True