Option to reverse the sequence of timelines

merge-requests/30/head
Bob Mottram 2022-11-26 16:27:01 +00:00
parent 24e7c7f67c
commit 1b55d693e2
29 changed files with 114 additions and 30 deletions

View File

@ -269,6 +269,7 @@ from languages import get_understood_languages
from like import update_likes_collection from like import update_likes_collection
from reaction import update_reaction_collection from reaction import update_reaction_collection
from utils import load_reverse_timeline from utils import load_reverse_timeline
from utils import save_reverse_timeline
from utils import load_min_images_for_accounts from utils import load_min_images_for_accounts
from utils import set_minimize_all_images from utils import set_minimize_all_images
from utils import get_json_content_from_accept from utils import get_json_content_from_accept
@ -7189,6 +7190,21 @@ class PubServer(BaseHTTPRequestHandler):
'unable to delete ' + 'unable to delete ' +
bold_reading_filename) bold_reading_filename)
# reverse timelines checkbox
reverse = False
if fields.get('reverseTimelines'):
if fields['reverseTimelines'] == 'on':
reverse = True
if nickname not in self.server.reverse_sequence:
self.server.reverse_sequence.append(nickname)
save_reverse_timeline(base_dir,
self.server.reverse_sequence)
if not reverse:
if nickname in self.server.reverse_sequence:
self.server.reverse_sequence.remove(nickname)
save_reverse_timeline(base_dir,
self.server.reverse_sequence)
# notify about new Likes # notify about new Likes
if on_final_welcome_screen: if on_final_welcome_screen:
# default setting from welcome screen # default setting from welcome screen
@ -15530,7 +15546,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled, self.server.lists_enabled,
self.server.system_language, self.server.system_language,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
self.server.max_recent_posts) self.server.max_recent_posts,
self.server.reverse_sequence)
if msg: if msg:
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)

View File

@ -601,5 +601,6 @@
"Send": "إرسال", "Send": "إرسال",
"Minimize all images": "تصغير كل الصور", "Minimize all images": "تصغير كل الصور",
"Edit post": "تعديل المنشور", "Edit post": "تعديل المنشور",
"Preview posts on profile screen": "معاينة المشاركات على شاشة الملف الشخصي" "Preview posts on profile screen": "معاينة المشاركات على شاشة الملف الشخصي",
"Reverse timelines": "عكس الجداول الزمنية"
} }

View File

@ -601,5 +601,6 @@
"Send": "পাঠান", "Send": "পাঠান",
"Minimize all images": "সমস্ত ছবি ছোট করুন", "Minimize all images": "সমস্ত ছবি ছোট করুন",
"Edit post": "পোস্ট সম্পাদনা করুন", "Edit post": "পোস্ট সম্পাদনা করুন",
"Preview posts on profile screen": "প্রোফাইল স্ক্রিনে পোস্টের পূর্বরূপ দেখুন" "Preview posts on profile screen": "প্রোফাইল স্ক্রিনে পোস্টের পূর্বরূপ দেখুন",
"Reverse timelines": "বিপরীত সময়রেখা"
} }

View File

@ -601,5 +601,6 @@
"Send": "Enviar", "Send": "Enviar",
"Minimize all images": "Minimitzar totes les imatges", "Minimize all images": "Minimitzar totes les imatges",
"Edit post": "Edita la publicació", "Edit post": "Edita la publicació",
"Preview posts on profile screen": "Previsualitza les publicacions a la pantalla del perfil" "Preview posts on profile screen": "Previsualitza les publicacions a la pantalla del perfil",
"Reverse timelines": "Cronologia inversa"
} }

View File

@ -601,5 +601,6 @@
"Send": "Anfon", "Send": "Anfon",
"Minimize all images": "Lleihau pob delwedd", "Minimize all images": "Lleihau pob delwedd",
"Edit post": "Golygu post", "Edit post": "Golygu post",
"Preview posts on profile screen": "Rhagolwg postiadau ar sgrin proffil" "Preview posts on profile screen": "Rhagolwg postiadau ar sgrin proffil",
"Reverse timelines": "Gwrthdroi llinellau amser"
} }

View File

@ -601,5 +601,6 @@
"Send": "Senden", "Send": "Senden",
"Minimize all images": "Alle Bilder minimieren", "Minimize all images": "Alle Bilder minimieren",
"Edit post": "Beitrag bearbeiten", "Edit post": "Beitrag bearbeiten",
"Preview posts on profile screen": "Vorschau von Beiträgen auf dem Profilbildschirm" "Preview posts on profile screen": "Vorschau von Beiträgen auf dem Profilbildschirm",
"Reverse timelines": "Umgekehrte Zeitlinien"
} }

View File

@ -601,5 +601,6 @@
"Send": "Στείλετε", "Send": "Στείλετε",
"Minimize all images": "Ελαχιστοποίηση όλων των εικόνων", "Minimize all images": "Ελαχιστοποίηση όλων των εικόνων",
"Edit post": "Επεξεργασία ανάρτησης", "Edit post": "Επεξεργασία ανάρτησης",
"Preview posts on profile screen": "Προεπισκόπηση αναρτήσεων στην οθόνη προφίλ" "Preview posts on profile screen": "Προεπισκόπηση αναρτήσεων στην οθόνη προφίλ",
"Reverse timelines": "Αντίστροφα χρονοδιαγράμματα"
} }

View File

@ -601,5 +601,6 @@
"Send": "Send", "Send": "Send",
"Minimize all images": "Minimize all images", "Minimize all images": "Minimize all images",
"Edit post": "Edit post", "Edit post": "Edit post",
"Preview posts on profile screen": "Preview posts on profile screen" "Preview posts on profile screen": "Preview posts on profile screen",
"Reverse timelines": "Reverse timelines"
} }

View File

@ -601,5 +601,6 @@
"Send": "Enviar", "Send": "Enviar",
"Minimize all images": "Minimizar todas las imágenes", "Minimize all images": "Minimizar todas las imágenes",
"Edit post": "Editar post", "Edit post": "Editar post",
"Preview posts on profile screen": "Vista previa de publicaciones en la pantalla de perfil" "Preview posts on profile screen": "Vista previa de publicaciones en la pantalla de perfil",
"Reverse timelines": "Líneas de tiempo inversas"
} }

View File

@ -601,5 +601,6 @@
"Send": "ارسال", "Send": "ارسال",
"Minimize all images": "تمام تصاویر را به حداقل برسانید", "Minimize all images": "تمام تصاویر را به حداقل برسانید",
"Edit post": "ویرایش پست", "Edit post": "ویرایش پست",
"Preview posts on profile screen": "پیش نمایش پست ها در صفحه نمایه" "Preview posts on profile screen": "پیش نمایش پست ها در صفحه نمایه",
"Reverse timelines": "جدول های زمانی معکوس"
} }

View File

@ -601,5 +601,6 @@
"Send": "Envoyer", "Send": "Envoyer",
"Minimize all images": "Réduire toutes les images", "Minimize all images": "Réduire toutes les images",
"Edit post": "Modifier le message", "Edit post": "Modifier le message",
"Preview posts on profile screen": "Prévisualiser les messages sur l'écran de profil" "Preview posts on profile screen": "Prévisualiser les messages sur l'écran de profil",
"Reverse timelines": "Chronologies inversées"
} }

View File

@ -601,5 +601,6 @@
"Send": "Seol", "Send": "Seol",
"Minimize all images": "Íoslaghdaigh gach íomhá", "Minimize all images": "Íoslaghdaigh gach íomhá",
"Edit post": "Cuir postáil in eagar", "Edit post": "Cuir postáil in eagar",
"Preview posts on profile screen": "Réamhamhairc postálacha ar an scáileán próifíle" "Preview posts on profile screen": "Réamhamhairc postálacha ar an scáileán próifíle",
"Reverse timelines": "Amlínte droim ar ais"
} }

View File

@ -601,5 +601,6 @@
"Send": "भेजना", "Send": "भेजना",
"Minimize all images": "सभी छवियों को छोटा करें", "Minimize all images": "सभी छवियों को छोटा करें",
"Edit post": "संपादित पोस्ट", "Edit post": "संपादित पोस्ट",
"Preview posts on profile screen": "प्रोफ़ाइल स्क्रीन पर पोस्ट का पूर्वावलोकन करें" "Preview posts on profile screen": "प्रोफ़ाइल स्क्रीन पर पोस्ट का पूर्वावलोकन करें",
"Reverse timelines": "रिवर्स टाइमलाइन"
} }

View File

@ -601,5 +601,6 @@
"Send": "Inviare", "Send": "Inviare",
"Minimize all images": "Riduci a icona tutte le immagini", "Minimize all images": "Riduci a icona tutte le immagini",
"Edit post": "Modifica post", "Edit post": "Modifica post",
"Preview posts on profile screen": "Visualizza l'anteprima dei post nella schermata del profilo" "Preview posts on profile screen": "Visualizza l'anteprima dei post nella schermata del profilo",
"Reverse timelines": "Invertire le tempistiche"
} }

View File

@ -601,5 +601,6 @@
"Send": "送信", "Send": "送信",
"Minimize all images": "すべての画像を最小化", "Minimize all images": "すべての画像を最小化",
"Edit post": "投稿を編集", "Edit post": "投稿を編集",
"Preview posts on profile screen": "プロフィール画面で投稿をプレビュー" "Preview posts on profile screen": "プロフィール画面で投稿をプレビュー",
"Reverse timelines": "逆タイムライン"
} }

View File

@ -601,5 +601,6 @@
"Send": "보내기", "Send": "보내기",
"Minimize all images": "모든 이미지 최소화", "Minimize all images": "모든 이미지 최소화",
"Edit post": "게시물 수정", "Edit post": "게시물 수정",
"Preview posts on profile screen": "프로필 화면에서 게시물 미리보기" "Preview posts on profile screen": "프로필 화면에서 게시물 미리보기",
"Reverse timelines": "역방향 타임라인"
} }

View File

@ -601,5 +601,6 @@
"Send": "Şandin", "Send": "Şandin",
"Minimize all images": "Hemî wêneyan kêm bikin", "Minimize all images": "Hemî wêneyan kêm bikin",
"Edit post": "Biguherîne post", "Edit post": "Biguherîne post",
"Preview posts on profile screen": "Mesajên li ser ekrana profîlê pêşdîtin" "Preview posts on profile screen": "Mesajên li ser ekrana profîlê pêşdîtin",
"Reverse timelines": "Reverse timelines"
} }

View File

@ -601,5 +601,6 @@
"Send": "Versturen", "Send": "Versturen",
"Minimize all images": "Alle afbeeldingen minimaliseren", "Minimize all images": "Alle afbeeldingen minimaliseren",
"Edit post": "Bericht bewerken", "Edit post": "Bericht bewerken",
"Preview posts on profile screen": "Bekijk berichten op het profielscherm" "Preview posts on profile screen": "Bekijk berichten op het profielscherm",
"Reverse timelines": "Omgekeerde tijdlijnen"
} }

View File

@ -597,5 +597,6 @@
"Send": "Send", "Send": "Send",
"Minimize all images": "Minimize all images", "Minimize all images": "Minimize all images",
"Edit post": "Edit post", "Edit post": "Edit post",
"Preview posts on profile screen": "Preview posts on profile screen" "Preview posts on profile screen": "Preview posts on profile screen",
"Reverse timelines": "Reverse timelines"
} }

View File

@ -601,5 +601,6 @@
"Send": "Wysłać", "Send": "Wysłać",
"Minimize all images": "Zminimalizuj wszystkie obrazy", "Minimize all images": "Zminimalizuj wszystkie obrazy",
"Edit post": "Edytuj post", "Edit post": "Edytuj post",
"Preview posts on profile screen": "Podgląd postów na ekranie profilu" "Preview posts on profile screen": "Podgląd postów na ekranie profilu",
"Reverse timelines": "Odwróć ramy czasowe"
} }

View File

@ -601,5 +601,6 @@
"Send": "Mandar", "Send": "Mandar",
"Minimize all images": "Minimize todas as imagens", "Minimize all images": "Minimize todas as imagens",
"Edit post": "Editar post", "Edit post": "Editar post",
"Preview posts on profile screen": "Visualizar postagens na tela do perfil" "Preview posts on profile screen": "Visualizar postagens na tela do perfil",
"Reverse timelines": "Cronogramas reversos"
} }

View File

@ -601,5 +601,6 @@
"Send": "Отправлять", "Send": "Отправлять",
"Minimize all images": "Свернуть все изображения", "Minimize all images": "Свернуть все изображения",
"Edit post": "Редактировать сообщение", "Edit post": "Редактировать сообщение",
"Preview posts on profile screen": "Предварительный просмотр сообщений на экране профиля" "Preview posts on profile screen": "Предварительный просмотр сообщений на экране профиля",
"Reverse timelines": "Обратные сроки"
} }

View File

@ -601,5 +601,6 @@
"Send": "Tuma", "Send": "Tuma",
"Minimize all images": "Punguza picha zote", "Minimize all images": "Punguza picha zote",
"Edit post": "Badilisha chapisho", "Edit post": "Badilisha chapisho",
"Preview posts on profile screen": "Hakiki machapisho kwenye skrini ya wasifu" "Preview posts on profile screen": "Hakiki machapisho kwenye skrini ya wasifu",
"Reverse timelines": "Обратные сроки"
} }

View File

@ -601,5 +601,6 @@
"Send": "Göndermek", "Send": "Göndermek",
"Minimize all images": "Tüm görüntüleri simge durumuna küçült", "Minimize all images": "Tüm görüntüleri simge durumuna küçült",
"Edit post": "Gönderiyi düzenle", "Edit post": "Gönderiyi düzenle",
"Preview posts on profile screen": "Gönderileri profil ekranında önizleyin" "Preview posts on profile screen": "Gönderileri profil ekranında önizleyin",
"Reverse timelines": "Обратные сроки"
} }

View File

@ -601,5 +601,6 @@
"Send": "Надіслати", "Send": "Надіслати",
"Minimize all images": "Згорнути всі зображення", "Minimize all images": "Згорнути всі зображення",
"Edit post": "Редагувати пост", "Edit post": "Редагувати пост",
"Preview posts on profile screen": "Попередній перегляд дописів на екрані профілю" "Preview posts on profile screen": "Попередній перегляд дописів на екрані профілю",
"Reverse timelines": "Обратные сроки"
} }

View File

@ -601,5 +601,6 @@
"Send": "שיקן", "Send": "שיקן",
"Minimize all images": "מינאַמייז אַלע בילדער", "Minimize all images": "מינאַמייז אַלע בילדער",
"Edit post": "רעדאַגירן פּאָסטן", "Edit post": "רעדאַגירן פּאָסטן",
"Preview posts on profile screen": "פאָרויסיקע ווייַזונג אַרטיקלען אויף פּראָפיל פאַרשטעלן" "Preview posts on profile screen": "פאָרויסיקע ווייַזונג אַרטיקלען אויף פּראָפיל פאַרשטעלן",
"Reverse timelines": "פאַרקערט טיימליינז"
} }

View File

@ -601,5 +601,6 @@
"Send": "发送", "Send": "发送",
"Minimize all images": "最小化所有图像", "Minimize all images": "最小化所有图像",
"Edit post": "编辑帖子", "Edit post": "编辑帖子",
"Preview posts on profile screen": "在个人资料屏幕上预览帖子" "Preview posts on profile screen": "在个人资料屏幕上预览帖子",
"Reverse timelines": "倒转时间线"
} }

View File

@ -4040,3 +4040,33 @@ def load_reverse_timeline(base_dir: str) -> []:
reverse_sequence.append(nickname) reverse_sequence.append(nickname)
break break
return reverse_sequence return reverse_sequence
def save_reverse_timeline(base_dir: str, reverse_sequence: []) -> []:
"""Saves flags for each user indicating whether they prefer to
see reversed timelines
"""
for _, dirs, _ in os.walk(base_dir + '/accounts'):
for acct in dirs:
if not is_account_dir(acct):
continue
nickname = acct.split('@')[0]
domain = acct.split('@')[1]
reverse_filename = \
acct_dir(base_dir, nickname, domain) + '/.reverse_timeline'
if nickname in reverse_sequence:
if not os.path.isfile(reverse_filename):
try:
with open(reverse_filename, 'w+',
encoding='utf-8') as fp_reverse:
fp_reverse.write('\n')
except OSError:
print('EX: failed to save reverse ' + reverse_filename)
else:
if os.path.isfile(reverse_filename):
try:
os.remove(reverse_filename)
except OSError:
print('EX: failed to delete reverse ' +
reverse_filename)
break

View File

@ -2157,7 +2157,8 @@ def _html_edit_profile_options(is_admin: bool,
hide_reaction_button: str, hide_reaction_button: str,
translate: {}, bold_reading: bool, translate: {}, bold_reading: bool,
nickname: str, nickname: str,
min_images_for_accounts: []) -> str: min_images_for_accounts: [],
reverse_sequence: []) -> str:
"""option checkboxes section of edit profile screen """option checkboxes section of edit profile screen
""" """
edit_profile_form = ' <div class="container">\n' edit_profile_form = ' <div class="container">\n'
@ -2203,6 +2204,14 @@ def _html_edit_profile_options(is_admin: bool,
edit_profile_form += \ edit_profile_form += \
edit_check_box(minimize_all_images_str, 'minimizeAllImages', edit_check_box(minimize_all_images_str, 'minimizeAllImages',
minimize_all_images) minimize_all_images)
reverse = False
if nickname in reverse_sequence:
reverse = True
reverse_str = \
bold_reading_string(translate['Reverse timelines'])
edit_profile_form += \
edit_check_box(reverse_str, 'reverseTimelines', reverse)
edit_profile_form += ' </div>\n' edit_profile_form += ' </div>\n'
return edit_profile_form return edit_profile_form
@ -2374,7 +2383,8 @@ def html_edit_profile(server, translate: {},
cw_lists: {}, lists_enabled: str, cw_lists: {}, lists_enabled: str,
system_language: str, system_language: str,
min_images_for_accounts: [], min_images_for_accounts: [],
max_recent_posts: int) -> str: max_recent_posts: int,
reverse_sequence: []) -> str:
"""Shows the edit profile screen """Shows the edit profile screen
""" """
path = path.replace('/inbox', '').replace('/outbox', '') path = path.replace('/inbox', '').replace('/outbox', '')
@ -2569,7 +2579,8 @@ def html_edit_profile(server, translate: {},
notify_likes, notify_reactions, notify_likes, notify_reactions,
hide_like_button, hide_reaction_button, hide_like_button, hide_reaction_button,
translate, bold_reading, translate, bold_reading,
nickname, min_images_for_accounts) nickname, min_images_for_accounts,
reverse_sequence)
# Contact information # Contact information
edit_profile_form += \ edit_profile_form += \