Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2022-07-20 14:44:31 +01:00
commit 91190e2cd0
29 changed files with 158 additions and 36 deletions

View File

@ -1165,6 +1165,12 @@ def add_html_tags(base_dir: str, http_prefix: str,
now_playing_str = 'NowPlaying'
if translate.get(now_playing_str):
now_playing_str = translate[now_playing_str]
now_playing_lower_str = 'nowplaying'
if translate.get(now_playing_lower_str):
now_playing_lower_str = translate[now_playing_lower_str]
if '#' + now_playing_lower_str in content:
content = content.replace('#' + now_playing_lower_str,
'#' + now_playing_str)
content = _add_music_tag(content, now_playing_str)
words = _get_simplified_content(content).split(' ')

View File

@ -168,6 +168,7 @@ from webapp_minimalbutton import is_minimal
from webapp_utils import get_avatar_image_url
from webapp_utils import html_hashtag_blocked
from webapp_utils import html_following_list
from webapp_utils import csv_following_list
from webapp_utils import set_blog_address
from webapp_utils import html_show_share
from webapp_utils import get_pwa_theme_colors
@ -15657,11 +15658,14 @@ class PubServer(BaseHTTPRequestHandler):
# is this a html/ssml/icalendar request?
html_getreq = False
csv_getreq = False
ssml_getreq = False
icalendar_getreq = False
if self._has_accept(calling_domain):
if self._request_http():
html_getreq = True
elif self._request_csv():
csv_getreq = True
elif self._request_ssml():
ssml_getreq = True
elif self._request_icalendar():
@ -16368,8 +16372,9 @@ class PubServer(BaseHTTPRequestHandler):
self.server.debug)
# show a list of who you are following
if html_getreq and authorized and users_in_path and \
self.path.endswith('/followingaccounts'):
if (authorized and users_in_path and
(self.path.endswith('/followingaccounts') or
self.path.endswith('/followingaccounts.csv'))):
nickname = get_nickname_from_actor(self.path)
if not nickname:
self._404()
@ -16380,10 +16385,22 @@ class PubServer(BaseHTTPRequestHandler):
if not os.path.isfile(following_filename):
self._404()
return
msg = html_following_list(self.server.base_dir, following_filename)
msglen = len(msg)
self._login_headers('text/html', msglen, calling_domain)
self._write(msg.encode('utf-8'))
if self.path.endswith('/followingaccounts.csv'):
html_getreq = False
csv_getreq = True
if html_getreq:
msg = html_following_list(self.server.base_dir,
following_filename)
msglen = len(msg)
self._login_headers('text/html', msglen, calling_domain)
self._write(msg.encode('utf-8'))
elif csv_getreq:
msg = csv_following_list(following_filename)
msglen = len(msg)
self._login_headers('text/csv', msglen, calling_domain)
self._write(msg.encode('utf-8'))
else:
self._404()
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', 'following accounts shown',
self.server.debug)
@ -16393,6 +16410,41 @@ class PubServer(BaseHTTPRequestHandler):
'_GET', 'following accounts done',
self.server.debug)
# show a list of who are your followers
if authorized and users_in_path and \
self.path.endswith('/followersaccounts'):
nickname = get_nickname_from_actor(self.path)
if not nickname:
self._404()
return
followers_filename = \
acct_dir(self.server.base_dir,
nickname, self.server.domain) + '/followers.txt'
if not os.path.isfile(followers_filename):
self._404()
return
if html_getreq:
msg = html_following_list(self.server.base_dir,
followers_filename)
msglen = len(msg)
self._login_headers('text/html', msglen, calling_domain)
self._write(msg.encode('utf-8'))
elif csv_getreq:
msg = csv_following_list(followers_filename)
msglen = len(msg)
self._login_headers('text/csv', msglen, calling_domain)
self._write(msg.encode('utf-8'))
else:
self._404()
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', 'followers accounts shown',
self.server.debug)
return
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', 'followers accounts done',
self.server.debug)
if self.path.endswith('/about'):
if calling_domain.endswith('.onion'):
msg = \

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "كلمات Dogwhistle",
"Content warnings will be added for the following": "ستتم إضافة تحذيرات المحتوى لما يلي",
"nowplaying": "الان العب",
"NowPlaying": "الان العب"
"NowPlaying": "الان العب",
"Import and Export": "استيراد وتصدير"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "কুকুরের হুইসেল শব্দ",
"Content warnings will be added for the following": "নিম্নলিখিত জন্য বিষয়বস্তু সতর্কতা যোগ করা হবে",
"nowplaying": "এখন চলছে",
"NowPlaying": "এখন চলছে"
"NowPlaying": "এখন চলছে",
"Import and Export": "আমদানি এবং রপ্তানি"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Paraules de xiulet",
"Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent",
"nowplaying": "arajugant",
"NowPlaying": "AraJugant"
"NowPlaying": "AraJugant",
"Import and Export": "Importació i Exportació"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Geiriau chwibanogl",
"Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol",
"nowplaying": "nawrynchwarae",
"NowPlaying": "NawrYnChwarae"
"NowPlaying": "NawrYnChwarae",
"Import and Export": "Mewnforio ac Allforio"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Hundepfeife Worte",
"Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt",
"nowplaying": "läuftgerade",
"NowPlaying": "LäuftGerade"
"NowPlaying": "LäuftGerade",
"Import and Export": "Import und Export"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Σφυρίχτρα λέξεις",
"Content warnings will be added for the following": "Θα προστεθούν προειδοποιήσεις περιεχομένου για τα ακόλουθα",
"nowplaying": "τώραπαίζει",
"NowPlaying": "ΤώραΠαίζει"
"NowPlaying": "ΤώραΠαίζει",
"Import and Export": "Εισάγω και εξάγω"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Dogwhistle words",
"Content warnings will be added for the following": "Content warnings will be added for the following",
"nowplaying": "nowplaying",
"NowPlaying": "NowPlaying"
"NowPlaying": "NowPlaying",
"Import and Export": "Import and Export"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Palabras de silbato para perros",
"Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente",
"nowplaying": "jugandoahora",
"NowPlaying": "JugandoAhora"
"NowPlaying": "JugandoAhora",
"Import and Export": "Importar y exportar"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Mots de sifflet de chien",
"Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants",
"nowplaying": "lectureencours",
"NowPlaying": "LectureEnCours"
"NowPlaying": "LectureEnCours",
"Import and Export": "Importer et exporter"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Focail feadóg mhadra",
"Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas",
"nowplaying": "anoisagimirt",
"NowPlaying": "AnoisAgImirt"
"NowPlaying": "AnoisAgImirt",
"Import and Export": "Iompórtáil agus Easpórtáil"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "कुत्ते की सीटी शब्द",
"Content warnings will be added for the following": "निम्नलिखित के लिए सामग्री चेतावनियां जोड़ दी जाएंगी",
"nowplaying": "अब खेल रहे हैं",
"NowPlaying": "अब खेल रहे हैं"
"NowPlaying": "अब खेल रहे हैं",
"Import and Export": "आयात और निर्यात"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Parole da fischietto",
"Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue",
"nowplaying": "ora giocando",
"NowPlaying": "OraGiocando"
"NowPlaying": "OraGiocando",
"Import and Export": "Importazione e esportazione"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "犬笛の言葉",
"Content warnings will be added for the following": "以下のコンテンツ警告が追加されます",
"nowplaying": "再生中",
"NowPlaying": "再生中"
"NowPlaying": "再生中",
"Import and Export": "インポートとエクスポート"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "개 휘파람 단어",
"Content warnings will be added for the following": "다음에 대한 콘텐츠 경고가 추가됩니다.",
"nowplaying": "지금 재생",
"NowPlaying": "지금 재생"
"NowPlaying": "지금 재생",
"Import and Export": "가져오기 및 내보내기"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Peyvên kûçikê",
"Content warnings will be added for the following": "Hişyariyên naverokê dê ji bo jêrîn werin zêdekirin",
"nowplaying": "nihadilîze",
"NowPlaying": "NihaDilîze"
"NowPlaying": "NihaDilîze",
"Import and Export": "Import û Export"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Hondenfluitwoorden",
"Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:",
"nowplaying": "nuaanhetspelen",
"NowPlaying": "NuAanHetSpelen"
"NowPlaying": "NuAanHetSpelen",
"Import and Export": "Importeren en exporteren"
}

View File

@ -565,5 +565,6 @@
"Dogwhistle words": "Dogwhistle words",
"Content warnings will be added for the following": "Content warnings will be added for the following",
"nowplaying": "nowplaying",
"NowPlaying": "NowPlaying"
"NowPlaying": "NowPlaying",
"Import and Export": "Import and Export"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Słowa gwizdka na psa",
"Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących",
"nowplaying": "terazgra",
"NowPlaying": "TerazGra"
"NowPlaying": "TerazGra",
"Import and Export": "Importuj i eksportuj"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Palavras de apito",
"Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes",
"nowplaying": "agorajogando",
"NowPlaying": "AgoraJogando"
"NowPlaying": "AgoraJogando",
"Import and Export": "Importar e exportar"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Собачий свисток",
"Content warnings will be added for the following": "Предупреждения о содержании будут добавлены для следующих",
"nowplaying": "сейчасиграет",
"NowPlaying": "СейчасИграет"
"NowPlaying": "СейчасИграет",
"Import and Export": "Импорт и экспорт"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Maneno ya mbwa",
"Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo",
"nowplaying": "inachezasasa",
"NowPlaying": "InachezaSasa"
"NowPlaying": "InachezaSasa",
"Import and Export": "Ingiza na Hamisha"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "İtiraf sözleri",
"Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek",
"nowplaying": "şimdioynuyor",
"NowPlaying": "ŞimdiOynuyor"
"NowPlaying": "ŞimdiOynuyor",
"Import and Export": "İthalat ve ihracat"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "Собачі слова",
"Content warnings will be added for the following": "Попередження про вміст буде додано для наступних",
"nowplaying": "заразграє",
"NowPlaying": "ЗаразГрає"
"NowPlaying": "ЗаразГрає",
"Import and Export": "Імпорт та експорт"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "דאָגווהיסטלע ווערטער",
"Content warnings will be added for the following": "אינהאַלט וואָרנינגז וועט זיין מוסיף פֿאַר די פאלגענדע",
"nowplaying": "איצט פּלייַינג",
"NowPlaying": "איצט פּלייַינג"
"NowPlaying": "איצט פּלייַינג",
"Import and Export": "אַרייַנפיר און עקספּאָרט"
}

View File

@ -569,5 +569,6 @@
"Dogwhistle words": "狗哨的话",
"Content warnings will be added for the following": "将为以下内容添加内容警告",
"nowplaying": "现在玩",
"NowPlaying": "现在玩"
"NowPlaying": "现在玩",
"Import and Export": "进出口"
}

View File

@ -1982,7 +1982,6 @@ def _html_edit_profile_contact_info(nickname: str,
"""Contact Information section of edit profile screen
"""
edit_profile_form = begin_edit_section(translate['Contact Details'])
edit_profile_form += edit_text_field(translate['Email'],
'email', email_address)
edit_profile_form += edit_text_field(translate['XMPP'],
@ -1995,11 +1994,27 @@ def _html_edit_profile_contact_info(nickname: str,
briar_address)
edit_profile_form += edit_text_field('Cwtch', 'cwtchAddress',
cwtch_address)
edit_profile_form += \
'<a href="/users/' + nickname + \
'/followingaccounts"><label class="labels">' + \
translate['Following'] + '</label></a><br>\n'
edit_profile_form += end_edit_section()
return edit_profile_form
def _html_edit_profile_import_export(nickname: str, domain: str,
translate: {}) -> str:
"""Contact Information section of edit profile screen
"""
edit_profile_form = begin_edit_section(translate['Import and Export'])
edit_profile_form += \
'<p><a href="/users/' + nickname + \
'/followingaccounts"><label class="labels">' + \
translate['Following'] + '</label></a>'
edit_profile_form += \
' <a href="/users/' + nickname + '/followingaccounts.csv" ' + \
'download="' + nickname + '@' + domain + '_following.csv">' + \
'<label class="labels">⇩ CSV</label></a></p>\n'
edit_profile_form += \
'<p><a href="/users/' + nickname + \
'/followersaccounts"><label class="labels">' + \
translate['Followers'] + '</label></a><br></p>\n'
edit_profile_form += end_edit_section()
return edit_profile_form
@ -2404,6 +2419,10 @@ def html_edit_profile(server, translate: {},
briar_address,
cwtch_address, translate)
# Import and export
edit_profile_form += \
_html_edit_profile_import_export(nickname, domain, translate)
# Encryption Keys
edit_profile_form += \
_html_edit_profile_encryption_keys(pgp_fingerprint,

View File

@ -99,6 +99,26 @@ def html_following_list(base_dir: str, following_filename: str) -> str:
return ''
def csv_following_list(following_filename: str) -> str:
"""Returns a csv of handles being followed
"""
with open(following_filename, 'r', encoding='utf-8') as following_file:
msg = following_file.read()
following_list = msg.split('\n')
following_list.sort()
if following_list:
following_list_csv = ''
for following_address in following_list:
if not following_address:
continue
if following_list_csv:
following_list_csv += '\n'
following_list_csv += following_address + ',true'
msg = 'Account address,Show boosts\n' + following_list_csv
return msg
return ''
def html_hashtag_blocked(base_dir: str, translate: {}) -> str:
"""Show the screen for a blocked hashtag
"""