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

main
Bob Mottram 2022-11-26 22:41:17 +00:00
commit 3f37bbbb68
34 changed files with 378 additions and 82 deletions

112
daemon.py
View File

@ -83,6 +83,8 @@ from person import remove_account
from person import can_remove_post
from person import person_snooze
from person import person_unsnooze
from posts import get_max_profile_posts
from posts import set_max_profile_posts
from posts import get_post_expiry_keep_dms
from posts import set_post_expiry_keep_dms
from posts import get_post_expiry_days
@ -266,6 +268,8 @@ from languages import set_actor_languages
from languages import get_understood_languages
from like import update_likes_collection
from reaction import update_reaction_collection
from utils import load_reverse_timeline
from utils import save_reverse_timeline
from utils import load_min_images_for_accounts
from utils import set_minimize_all_images
from utils import get_json_content_from_accept
@ -6513,6 +6517,21 @@ class PubServer(BaseHTTPRequestHandler):
set_post_expiry_days(base_dir, nickname, domain, 0)
actor_changed = True
# set maximum preview posts on profile screen
max_profile_posts = \
get_max_profile_posts(base_dir, nickname, domain,
20)
if fields.get('maxRecentProfilePosts'):
if fields['maxRecentProfilePosts'] != \
str(max_profile_posts):
max_profile_posts = \
fields['maxRecentProfilePosts']
set_max_profile_posts(base_dir, nickname, domain,
max_profile_posts)
else:
set_max_profile_posts(base_dir, nickname, domain,
20)
# change tox address
current_tox_address = get_tox_address(actor_json)
if fields.get('toxAddress'):
@ -7171,6 +7190,21 @@ class PubServer(BaseHTTPRequestHandler):
'unable to delete ' +
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
if on_final_welcome_screen:
# default setting from welcome screen
@ -12247,6 +12281,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_inbox(default_timeline,
recent_posts_cache,
@ -12290,7 +12327,8 @@ class PubServer(BaseHTTPRequestHandler):
timezone, bold_reading,
self.server.dogwhistles,
ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
if getreq_start_time:
fitness_performance(getreq_start_time,
self.server.fitness,
@ -12423,6 +12461,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_inbox_dms(self.server.default_timeline,
self.server.recent_posts_cache,
@ -12464,7 +12505,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12587,6 +12629,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_inbox_replies(self.server.default_timeline,
self.server.recent_posts_cache,
@ -12629,7 +12674,8 @@ class PubServer(BaseHTTPRequestHandler):
timezone, bold_reading,
self.server.dogwhistles,
ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12748,6 +12794,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_inbox_media(self.server.default_timeline,
self.server.recent_posts_cache,
@ -12790,7 +12839,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12909,6 +12959,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_inbox_blogs(self.server.default_timeline,
self.server.recent_posts_cache,
@ -12951,7 +13004,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13077,6 +13131,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_inbox_news(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13120,7 +13177,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13250,6 +13308,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = True
min_images_for_accounts = \
self.server.min_images_for_accounts
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_inbox_features(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13293,7 +13354,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str,
min_images_for_accounts)
min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13378,6 +13440,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_shares(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13417,7 +13482,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled, timezone,
bold_reading, self.server.dogwhistles,
ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13475,6 +13541,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_wanted(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13514,7 +13583,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13610,6 +13680,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_bookmarks(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13652,7 +13725,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13768,6 +13842,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_outbox(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13808,7 +13885,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13919,6 +13997,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = True
min_images_for_accounts = \
self.server.min_images_for_accounts
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
msg = \
html_moderation(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13961,7 +14042,8 @@ class PubServer(BaseHTTPRequestHandler):
timezone, bold_reading,
self.server.dogwhistles,
ua_str,
min_images_for_accounts)
min_images_for_accounts,
reverse_sequence)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -15463,7 +15545,9 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
self.server.system_language,
self.server.min_images_for_accounts)
self.server.min_images_for_accounts,
self.server.max_recent_posts,
self.server.reverse_sequence)
if msg:
msg = msg.encode('utf-8')
msglen = len(msg)
@ -21870,6 +21954,8 @@ def run_daemon(max_hashtags: int,
# caches css files
httpd.css_cache = {}
httpd.reverse_sequence = load_reverse_timeline(base_dir)
httpd.clacks = get_config_param(base_dir, 'clacks')
if not httpd.clacks:
if clacks:

View File

@ -59,14 +59,14 @@ if [ -f /usr/bin/pacman ]; then
perl-image-exiftool python-numpy python-dateutil \
certbot flake8 git i2pd wget qrencode \
proxychains midori bandit
pip3 install pyLD pyqrcode pypng
pip3 install pyqrcode pypng
else
apt-get update
apt-get -y install imagemagick python3-cryptography \
python3-dateutil python3-idna python3-requests \
python3-numpy python3-pil.imagetk python3-pip \
python3-setuptools python3-socks python3-idna \
libimage-exiftool-perl python3-flake8 python3-pyld \
libimage-exiftool-perl python3-flake8 \
python3-django-timezone-field nginx git i2pd wget \
python3-pyqrcode qrencode python3-png \
proxychains midori python3-bandit

View File

@ -33,14 +33,14 @@ if [ -f /usr/bin/pacman ]; then
imagemagick python-pillow python-requests \
perl-image-exiftool python-numpy python-dateutil \
certbot flake8 git qrencode bandit
pip3 install pyLD pyqrcode pypng
pip3 install pyqrcode pypng
else
apt-get update
apt-get -y install imagemagick python3-cryptography \
python3-dateutil python3-idna python3-requests \
python3-numpy python3-pil.imagetk python3-pip \
python3-setuptools python3-socks python3-idna \
libimage-exiftool-perl python3-flake8 python3-pyld \
libimage-exiftool-perl python3-flake8 \
python3-django-timezone-field tor nginx git qrencode \
python3-pyqrcode python3-png python3-bandit
fi

View File

@ -5971,3 +5971,46 @@ def get_original_post_from_announce_url(announce_url: str, base_dir: str,
url = orig_post_id
return actor, url, orig_filename
def get_max_profile_posts(base_dir: str, nickname: str, domain: str,
max_recent_posts: int) -> int:
"""Returns the maximum number of posts to show on the profile screen
"""
max_posts_filename = \
acct_dir(base_dir, nickname, domain) + '/max_profile_posts.txt'
max_profile_posts = 4
if not os.path.isfile(max_posts_filename):
return max_profile_posts
try:
with open(max_posts_filename, 'r', encoding='utf-8') as fp_posts:
max_posts_str = fp_posts.read()
if max_posts_str:
if max_posts_str.isdigit():
max_profile_posts = int(max_posts_str)
except OSError:
print('EX: unable to read maximum profile posts ' +
max_posts_filename)
if max_profile_posts < 1:
max_profile_posts = 1
if max_profile_posts > max_recent_posts:
max_profile_posts = max_recent_posts
return max_profile_posts
def set_max_profile_posts(base_dir: str, nickname: str, domain: str,
max_recent_posts: int) -> bool:
"""Sets the maximum number of posts to show on the profile screen
"""
max_posts_filename = \
acct_dir(base_dir, nickname, domain) + '/max_profile_posts.txt'
max_recent_posts_str = str(max_recent_posts)
try:
with open(max_posts_filename, 'w+',
encoding='utf-8') as fp_posts:
fp_posts.write(max_recent_posts_str)
except OSError:
print('EX: unable to save maximum profile posts ' +
max_posts_filename)
return False
return True

View File

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

View File

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

View File

@ -600,5 +600,7 @@
"Allow announces": "Permet anuncis",
"Send": "Enviar",
"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",
"Reverse timelines": "Cronologia inversa"
}

View File

@ -600,5 +600,7 @@
"Allow announces": "Caniatáu cyhoeddiadau",
"Send": "Anfon",
"Minimize all images": "Lleihau pob delwedd",
"Edit post": "Golygu post"
"Edit post": "Golygu post",
"Preview posts on profile screen": "Rhagolwg postiadau ar sgrin proffil",
"Reverse timelines": "Gwrthdroi llinellau amser"
}

View File

@ -600,5 +600,7 @@
"Allow announces": "Zulassen kündigt an",
"Send": "Senden",
"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",
"Reverse timelines": "Umgekehrte Zeitlinien"
}

View File

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

View File

@ -600,5 +600,7 @@
"Allow announces": "Allow announces",
"Send": "Send",
"Minimize all images": "Minimize all images",
"Edit post": "Edit post"
"Edit post": "Edit post",
"Preview posts on profile screen": "Preview posts on profile screen",
"Reverse timelines": "Reverse timelines"
}

View File

@ -600,5 +600,7 @@
"Allow announces": "Permitir anuncios",
"Send": "Enviar",
"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",
"Reverse timelines": "Líneas de tiempo inversas"
}

View File

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

View File

@ -600,5 +600,7 @@
"Allow announces": "Autoriser les annonces",
"Send": "Envoyer",
"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",
"Reverse timelines": "Chronologies inversées"
}

View File

@ -600,5 +600,7 @@
"Allow announces": "Ceadaigh fógraí",
"Send": "Seol",
"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",
"Reverse timelines": "Amlínte droim ar ais"
}

View File

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

View File

@ -600,5 +600,7 @@
"Allow announces": "Consenti annunci",
"Send": "Inviare",
"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",
"Reverse timelines": "Invertire le tempistiche"
}

View File

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

View File

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

View File

@ -600,5 +600,7 @@
"Allow announces": "Destûr dide ragihandin",
"Send": "Şandin",
"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",
"Reverse timelines": "Reverse timelines"
}

View File

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

View File

@ -596,5 +596,7 @@
"Allow announces": "Allow announces",
"Send": "Send",
"Minimize all images": "Minimize all images",
"Edit post": "Edit post"
"Edit post": "Edit post",
"Preview posts on profile screen": "Preview posts on profile screen",
"Reverse timelines": "Reverse timelines"
}

View File

@ -600,5 +600,7 @@
"Allow announces": "Zezwól na ogłoszenia",
"Send": "Wysłać",
"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",
"Reverse timelines": "Odwróć ramy czasowe"
}

View File

@ -600,5 +600,7 @@
"Allow announces": "Permitir anúncios",
"Send": "Mandar",
"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",
"Reverse timelines": "Cronogramas reversos"
}

View File

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

View File

@ -600,5 +600,7 @@
"Allow announces": "Ruhusu matangazo",
"Send": "Tuma",
"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",
"Reverse timelines": "Обратные сроки"
}

View File

@ -600,5 +600,7 @@
"Allow announces": "Duyurulara izin ver",
"Send": "Göndermek",
"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",
"Reverse timelines": "Обратные сроки"
}

View File

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

View File

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

View File

@ -600,5 +600,7 @@
"Allow announces": "לאָזן אַנאַונסיז",
"Send": "发送",
"Minimize all images": "最小化所有图像",
"Edit post": "编辑帖子"
"Edit post": "编辑帖子",
"Preview posts on profile screen": "在个人资料屏幕上预览帖子",
"Reverse timelines": "倒转时间线"
}

View File

@ -4020,3 +4020,53 @@ def set_minimize_all_images(base_dir: str,
os.remove(filename)
except OSError:
print('EX: unable to delete ' + filename)
def load_reverse_timeline(base_dir: str) -> []:
"""Loads flags for each user indicating whether they prefer to
see reversed timelines
"""
reverse_sequence = []
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 os.path.isfile(reverse_filename):
if nickname not in reverse_sequence:
reverse_sequence.append(nickname)
break
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

@ -60,7 +60,8 @@ def html_moderation(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the moderation feed as html
This is what you see when selecting the "mod" timeline
"""
@ -87,7 +88,7 @@ def html_moderation(default_timeline: str,
max_like_count, shared_items_federated_domains,
signing_priv_key_pem, cw_lists, lists_enabled,
timezone, bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
min_images_for_accounts, reverse_sequence)
def html_account_info(translate: {},

View File

@ -44,6 +44,7 @@ from posts import get_person_box
from posts import is_moderator
from posts import parse_user_feed
from posts import is_create_inside_announce
from posts import get_max_profile_posts
from donate import get_donation_url
from donate import get_website
from donate import get_gemini_link
@ -1071,9 +1072,11 @@ def html_profile(signing_priv_key_pem: str,
translate['Get the source code'] + '" src="/icons/agpl.png" /></a>'
if selected == 'posts':
max_profile_posts = \
get_max_profile_posts(base_dir, nickname, domain, 20)
min_images_for_accounts = []
profile_str += \
_html_profile_posts(recent_posts_cache, max_recent_posts,
_html_profile_posts(recent_posts_cache, max_profile_posts,
translate,
base_dir, http_prefix, authorized,
nickname, domain, port,
@ -1089,7 +1092,8 @@ def html_profile(signing_priv_key_pem: str,
signing_priv_key_pem,
cw_lists, lists_enabled,
timezone, bold_reading, {},
min_images_for_accounts) + license_str
min_images_for_accounts,
max_profile_posts) + license_str
if not is_group:
if selected == 'following':
profile_str += \
@ -1164,13 +1168,14 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {},
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
max_profile_posts: int) -> str:
"""Shows posts on the profile screen
These should only be public posts
"""
separator_str = html_post_separator(base_dir, None)
profile_str = ''
max_items = 4
max_items = max_profile_posts
ctr = 0
curr_page = 1
box_name = 'outbox'
@ -1192,7 +1197,10 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
break
if len(outbox_feed['orderedItems']) == 0:
break
shown_items = []
for item in outbox_feed['orderedItems']:
if not item.get('id'):
continue
if item['type'] == 'Create':
post_str = \
individual_post_as_html(signing_priv_key_pem,
@ -1219,8 +1227,9 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
if post_str:
if post_str and item['id'] not in shown_items:
profile_str += post_str + separator_str
shown_items.append(item['id'])
ctr += 1
if ctr >= max_items:
break
@ -2152,7 +2161,8 @@ def _html_edit_profile_options(is_admin: bool,
hide_reaction_button: str,
translate: {}, bold_reading: bool,
nickname: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: []) -> str:
"""option checkboxes section of edit profile screen
"""
edit_profile_form = ' <div class="container">\n'
@ -2198,6 +2208,14 @@ def _html_edit_profile_options(is_admin: bool,
edit_profile_form += \
edit_check_box(minimize_all_images_str, 'minimizeAllImages',
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'
return edit_profile_form
@ -2222,7 +2240,8 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str,
moved_to: str, donate_url: str, website_url: str,
gemini_link: str, blog_address: str,
actor_json: {}, translate: {},
nickname: str, domain: str) -> str:
nickname: str, domain: str,
max_recent_posts: int) -> str:
"""main info on edit profile screen
"""
image_formats = get_image_formats()
@ -2306,6 +2325,13 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str,
edit_check_box(translate['Keep DMs during post expiry'],
'expiryKeepDMs', keep_dms)
max_profile_posts = \
get_max_profile_posts(base_dir, nickname, domain, max_recent_posts)
edit_profile_form += \
edit_number_field(translate['Preview posts on profile screen'],
'maxRecentProfilePosts', max_profile_posts,
1, 20, max_recent_posts)
edit_profile_form += ' </div>\n'
return edit_profile_form
@ -2360,7 +2386,9 @@ def html_edit_profile(server, translate: {},
default_reply_interval_hrs: int,
cw_lists: {}, lists_enabled: str,
system_language: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
max_recent_posts: int,
reverse_sequence: []) -> str:
"""Shows the edit profile screen
"""
path = path.replace('/inbox', '').replace('/outbox', '')
@ -2544,7 +2572,7 @@ def html_edit_profile(server, translate: {},
moved_to, donate_url, website_url,
gemini_link,
blog_address, actor_json, translate,
nickname, domain)
nickname, domain, max_recent_posts)
# Option checkboxes
edit_profile_form += \
@ -2555,7 +2583,8 @@ def html_edit_profile(server, translate: {},
notify_likes, notify_reactions,
hide_like_button, hide_reaction_button,
translate, bold_reading,
nickname, min_images_for_accounts)
nickname, min_images_for_accounts,
reverse_sequence)
# Contact information
edit_profile_form += \

View File

@ -499,7 +499,8 @@ def html_timeline(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the timeline as html
"""
enable_timing_log = False
@ -962,6 +963,7 @@ def html_timeline(default_timeline: str,
minimize_all_images = True
# show each post in the timeline
tl_items_str = ''
for item in timeline_json['orderedItems']:
if item['type'] == 'Create' or \
item['type'] == 'Announce':
@ -1029,13 +1031,24 @@ def html_timeline(default_timeline: str,
timeline_start_time, box_name, '12')
if curr_tl_str:
if curr_tl_str not in tl_str:
if curr_tl_str not in tl_items_str:
last_post_id = \
remove_id_ending(item['id']).replace('/', '#')
item_ctr += 1
tl_str += text_mode_separator + curr_tl_str
if separator_str:
tl_str += separator_str
if not reverse_sequence:
tl_items_str += text_mode_separator + curr_tl_str
if separator_str:
tl_items_str += separator_str
else:
tl_items_str = \
text_mode_separator + curr_tl_str + \
tl_items_str
if separator_str:
tl_items_str = \
text_mode_separator + curr_tl_str + \
separator_str + tl_items_str
tl_str += tl_items_str
if box_name == 'tlmedia':
tl_str += '</div>\n'
@ -1272,7 +1285,8 @@ def html_shares(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the shares timeline as html
"""
manually_approve_followers = \
@ -1304,7 +1318,8 @@ def html_shares(default_timeline: str,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
min_images_for_accounts,
reverse_sequence)
def html_wanted(default_timeline: str,
@ -1335,7 +1350,8 @@ def html_wanted(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the wanted timeline as html
"""
manually_approve_followers = \
@ -1367,7 +1383,8 @@ def html_wanted(default_timeline: str,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
min_images_for_accounts,
reverse_sequence)
def html_inbox(default_timeline: str,
@ -1399,7 +1416,8 @@ def html_inbox(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the inbox as html
"""
manually_approve_followers = \
@ -1431,7 +1449,8 @@ def html_inbox(default_timeline: str,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
min_images_for_accounts,
reverse_sequence)
def html_bookmarks(default_timeline: str,
@ -1463,7 +1482,8 @@ def html_bookmarks(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the bookmarks as html
"""
manually_approve_followers = \
@ -1494,7 +1514,8 @@ def html_bookmarks(default_timeline: str,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
min_images_for_accounts,
reverse_sequence)
def html_inbox_dms(default_timeline: str,
@ -1526,7 +1547,8 @@ def html_inbox_dms(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the DM timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1553,7 +1575,8 @@ def html_inbox_dms(default_timeline: str,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
min_images_for_accounts,
reverse_sequence)
def html_inbox_replies(default_timeline: str,
@ -1585,7 +1608,8 @@ def html_inbox_replies(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the replies timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1610,7 +1634,8 @@ def html_inbox_replies(default_timeline: str,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts)
dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence)
def html_inbox_media(default_timeline: str,
@ -1642,7 +1667,8 @@ def html_inbox_media(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the media timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1667,7 +1693,8 @@ def html_inbox_media(default_timeline: str,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts)
dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence)
def html_inbox_blogs(default_timeline: str,
@ -1699,7 +1726,8 @@ def html_inbox_blogs(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the blogs timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1724,7 +1752,8 @@ def html_inbox_blogs(default_timeline: str,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts)
dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence)
def html_inbox_features(default_timeline: str,
@ -1757,7 +1786,8 @@ def html_inbox_features(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the features timeline as html
"""
return html_timeline(default_timeline,
@ -1781,7 +1811,8 @@ def html_inbox_features(default_timeline: str,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts)
dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence)
def html_inbox_news(default_timeline: str,
@ -1813,7 +1844,8 @@ def html_inbox_news(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the news timeline as html
"""
return html_timeline(default_timeline,
@ -1837,7 +1869,8 @@ def html_inbox_news(default_timeline: str,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts)
dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence)
def html_outbox(default_timeline: str,
@ -1869,7 +1902,8 @@ def html_outbox(default_timeline: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
"""Show the Outbox as html
"""
manually_approve_followers = \
@ -1896,4 +1930,5 @@ def html_outbox(default_timeline: str,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts)
dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence)