Ability to minimize all images by default

main
Bob Mottram 2022-11-13 18:54:11 +00:00
parent df07bdb977
commit f81e2f32ae
15 changed files with 552 additions and 294 deletions

View File

@ -269,6 +269,7 @@ def _html_blog_post_content(debug: bool, session, authorized: bool,
languages_understood = get_actor_languages_list(actor_json)
json_content = get_content_from_post(post_json_object, system_language,
languages_understood)
minimize_all_images = False
attachment_str, _ = \
get_post_attachments_as_html(base_dir, nickname, domain,
domain_full, post_json_object,
@ -277,7 +278,8 @@ def _html_blog_post_content(debug: bool, session, authorized: bool,
reply_str, announce_str,
like_str, bookmark_str,
delete_str, mute_str,
json_content)
json_content,
minimize_all_images)
if attachment_str:
blog_str += '<br><center>' + attachment_str + '</center>'
if json_content:

477
daemon.py
View File

@ -1730,7 +1730,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
self.server.content_license_url,
self.server.dogwhistles)
self.server.dogwhistles,
self.server.min_images_for_accounts)
def _get_outbox_thread_index(self, nickname: str,
max_outbox_threads_per_account: int) -> int:
@ -3337,47 +3338,51 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.bold_reading.get(chooser_nickname):
bold_reading = True
msg = html_new_post(False, self.server.translate,
base_dir,
http_prefix,
report_path, None,
[options_actor], None, None,
page_number, '',
chooser_nickname,
domain,
domain_full,
self.server.default_timeline,
self.server.newswire,
self.server.theme_name,
True, access_keys,
custom_submit_text,
conversation_id,
self.server.recent_posts_cache,
self.server.max_recent_posts,
curr_session,
self.server.cached_webfingers,
self.server.person_cache,
self.server.port,
None,
self.server.project_version,
self.server.yt_replace_domain,
self.server.twitter_replacement_domain,
self.server.show_published_date_only,
self.server.peertube_instances,
self.server.allow_local_network_access,
self.server.system_language,
self.server.max_like_count,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
self.server.default_timeline,
reply_is_chat,
bold_reading,
self.server.dogwhistles).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)
self._write(msg)
msg = \
html_new_post(False, self.server.translate,
base_dir,
http_prefix,
report_path, None,
[options_actor], None, None,
page_number, '',
chooser_nickname,
domain,
domain_full,
self.server.default_timeline,
self.server.newswire,
self.server.theme_name,
True, access_keys,
custom_submit_text,
conversation_id,
self.server.recent_posts_cache,
self.server.max_recent_posts,
curr_session,
self.server.cached_webfingers,
self.server.person_cache,
self.server.port,
None,
self.server.project_version,
self.server.yt_replace_domain,
self.server.twitter_replacement_domain,
self.server.show_published_date_only,
self.server.peertube_instances,
self.server.allow_local_network_access,
self.server.system_language,
self.server.max_like_count,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
self.server.default_timeline,
reply_is_chat,
bold_reading,
self.server.dogwhistles,
self.server.min_images_for_accounts)
if msg:
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)
self._write(msg)
self.server.postreq_busy = False
return
@ -3480,46 +3485,50 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.bold_reading.get(chooser_nickname):
bold_reading = True
msg = html_new_post(False, self.server.translate,
base_dir,
http_prefix,
report_path, None, [],
None, post_url, page_number, '',
chooser_nickname,
domain,
domain_full,
self.server.default_timeline,
self.server.newswire,
self.server.theme_name,
True, access_keys,
custom_submit_text,
conversation_id,
self.server.recent_posts_cache,
self.server.max_recent_posts,
curr_session,
self.server.cached_webfingers,
self.server.person_cache,
self.server.port,
None,
self.server.project_version,
self.server.yt_replace_domain,
self.server.twitter_replacement_domain,
self.server.show_published_date_only,
self.server.peertube_instances,
self.server.allow_local_network_access,
self.server.system_language,
self.server.max_like_count,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
self.server.default_timeline,
reply_is_chat,
bold_reading,
self.server.dogwhistles).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)
self._write(msg)
msg = \
html_new_post(False, self.server.translate,
base_dir,
http_prefix,
report_path, None, [],
None, post_url, page_number, '',
chooser_nickname,
domain,
domain_full,
self.server.default_timeline,
self.server.newswire,
self.server.theme_name,
True, access_keys,
custom_submit_text,
conversation_id,
self.server.recent_posts_cache,
self.server.max_recent_posts,
curr_session,
self.server.cached_webfingers,
self.server.person_cache,
self.server.port,
None,
self.server.project_version,
self.server.yt_replace_domain,
self.server.twitter_replacement_domain,
self.server.show_published_date_only,
self.server.peertube_instances,
self.server.allow_local_network_access,
self.server.system_language,
self.server.max_like_count,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
self.server.default_timeline,
reply_is_chat,
bold_reading,
self.server.dogwhistles,
self.server.min_images_for_accounts)
if msg:
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)
self._write(msg)
self.server.postreq_busy = False
return
@ -4086,7 +4095,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.dogwhistles,
self.server.map_format,
self.server.access_keys,
'search')
'search',
self.server.min_images_for_accounts)
if hashtag_str:
msg = hashtag_str.encode('utf-8')
msglen = len(msg)
@ -4196,7 +4206,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles,
self.server.access_keys)
self.server.access_keys,
self.server.min_images_for_accounts)
if history_str:
msg = history_str.encode('utf-8')
msglen = len(msg)
@ -4278,7 +4289,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles,
self.server.access_keys)
self.server.access_keys,
self.server.min_images_for_accounts)
if bookmarks_str:
msg = bookmarks_str.encode('utf-8')
msglen = len(msg)
@ -4416,6 +4428,8 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.bold_reading.get(nickname):
bold_reading = True
min_images_for_accounts = \
self.server.min_images_for_accounts
profile_str = \
html_profile_after_search(recent_posts_cache,
self.server.max_recent_posts,
@ -4449,7 +4463,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.onion_domain,
self.server.i2p_domain,
bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
min_images_for_accounts)
if profile_str:
msg = profile_str.encode('utf-8')
msglen = len(msg)
@ -8701,7 +8716,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.dogwhistles,
self.server.map_format,
self.server.access_keys,
'search')
'search',
self.server.min_images_for_accounts)
if hashtag_str:
msg = hashtag_str.encode('utf-8')
msglen = len(msg)
@ -8923,6 +8939,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(self.post_to_nickname):
bold_reading = True
minimize_all_images = False
if self.post_to_nickname in self.server.min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(self.server.signing_priv_key_pem, False,
self.server.recent_posts_cache,
self.server.max_recent_posts,
@ -8952,7 +8971,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
minimize_all_images)
actor_absolute = self._get_instance_url(calling_domain) + actor
actor_path_str = \
@ -9461,6 +9481,10 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(self.post_to_nickname):
bold_reading = True
minimize_all_images = False
if self.post_to_nickname in \
self.server.min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(self.server.signing_priv_key_pem,
False,
self.server.recent_posts_cache,
@ -9492,7 +9516,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
minimize_all_images)
else:
print('WARN: Liked post not found: ' + liked_post_filename)
# clear the icon from the cache so that it gets updated
@ -9649,6 +9674,10 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(self.post_to_nickname):
bold_reading = True
minimize_all_images = False
if self.post_to_nickname in \
self.server.min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(self.server.signing_priv_key_pem,
False,
self.server.recent_posts_cache,
@ -9680,7 +9709,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
minimize_all_images)
else:
print('WARN: Unliked post not found: ' + liked_post_filename)
# clear the icon from the cache so that it gets updated
@ -9866,6 +9896,10 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(self.post_to_nickname):
bold_reading = True
minimize_all_images = False
if self.post_to_nickname in \
self.server.min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(self.server.signing_priv_key_pem,
False,
self.server.recent_posts_cache,
@ -9897,7 +9931,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
minimize_all_images)
else:
print('WARN: Emoji reaction post not found: ' +
reaction_post_filename)
@ -10073,6 +10108,10 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(self.post_to_nickname):
bold_reading = True
minimize_all_images = False
if self.post_to_nickname in \
self.server.min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(self.server.signing_priv_key_pem,
False,
self.server.recent_posts_cache,
@ -10104,7 +10143,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
minimize_all_images)
else:
print('WARN: Unreaction post not found: ' +
reaction_post_filename)
@ -10210,7 +10250,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timeline_str, page_number,
timezone, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10324,6 +10365,10 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(self.post_to_nickname):
bold_reading = True
minimize_all_images = False
if self.post_to_nickname in \
self.server.min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(self.server.signing_priv_key_pem,
False,
self.server.recent_posts_cache,
@ -10355,7 +10400,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
minimize_all_images)
else:
print('WARN: Bookmarked post not found: ' + bookmark_filename)
# self._post_to_outbox(bookmark_json,
@ -10476,6 +10522,10 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(self.post_to_nickname):
bold_reading = True
minimize_all_images = False
if self.post_to_nickname in \
self.server.min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(self.server.signing_priv_key_pem,
False,
self.server.recent_posts_cache,
@ -10507,7 +10557,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
minimize_all_images)
else:
print('WARN: Unbookmarked post not found: ' +
bookmark_filename)
@ -10618,7 +10669,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
self.server.dogwhistles)
self.server.dogwhistles,
self.server.min_images_for_accounts)
if delete_str:
delete_str_len = len(delete_str)
self._set_headers('text/html', delete_str_len,
@ -10714,6 +10766,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
minimize_all_images = False
if nickname in self.server.min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(self.server.signing_priv_key_pem,
allow_downloads,
self.server.recent_posts_cache,
@ -10746,7 +10801,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
minimize_all_images)
else:
print('WARN: Muted post not found: ' + mute_filename)
@ -10842,6 +10898,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
minimize_all_images = False
if nickname in self.server.min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(self.server.signing_priv_key_pem,
allow_downloads,
self.server.recent_posts_cache,
@ -10874,7 +10933,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
minimize_all_images)
else:
print('WARN: Unmuted post not found: ' + mute_filename)
if calling_domain.endswith('.onion') and onion_domain:
@ -11001,7 +11061,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -11107,7 +11168,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -11547,7 +11609,9 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
'inbox', self.server.default_timeline,
bold_reading, self.server.dogwhistles)
bold_reading,
self.server.dogwhistles,
self.server.min_images_for_accounts)
if not msg:
self._404()
return True
@ -11612,6 +11676,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
'inbox', self.server.default_timeline,
bold_reading, self.server.dogwhistles,
self.server.min_images_for_accounts,
'shares')
if not msg:
self._404()
@ -11700,7 +11765,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles)
self.server.dogwhistles,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -11972,48 +12038,50 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
msg = html_inbox(default_timeline,
recent_posts_cache,
max_recent_posts,
translate,
page_number, MAX_POSTS_IN_FEED,
curr_session,
base_dir,
cached_webfingers,
person_cache,
nickname,
domain,
port,
inbox_feed,
allow_deletion,
http_prefix,
project_version,
minimal_nick,
yt_replace_domain,
twitter_replacement_domain,
self.server.show_published_date_only,
self.server.newswire,
self.server.positive_voting,
self.server.show_publish_as_icon,
full_width_tl_button_header,
self.server.icons_as_buttons,
self.server.rss_icon_at_top,
self.server.publish_button_at_top,
authorized,
self.server.theme_name,
self.server.peertube_instances,
allow_local_network_access,
self.server.text_mode_banner,
access_keys,
self.server.system_language,
self.server.max_like_count,
shared_items_federated_domains,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles,
ua_str)
msg = \
html_inbox(default_timeline,
recent_posts_cache,
max_recent_posts,
translate,
page_number, MAX_POSTS_IN_FEED,
curr_session,
base_dir,
cached_webfingers,
person_cache,
nickname,
domain,
port,
inbox_feed,
allow_deletion,
http_prefix,
project_version,
minimal_nick,
yt_replace_domain,
twitter_replacement_domain,
self.server.show_published_date_only,
self.server.newswire,
self.server.positive_voting,
self.server.show_publish_as_icon,
full_width_tl_button_header,
self.server.icons_as_buttons,
self.server.rss_icon_at_top,
self.server.publish_button_at_top,
authorized,
self.server.theme_name,
self.server.peertube_instances,
allow_local_network_access,
self.server.text_mode_banner,
access_keys,
self.server.system_language,
self.server.max_like_count,
shared_items_federated_domains,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles,
ua_str,
self.server.min_images_for_accounts)
if getreq_start_time:
fitness_performance(getreq_start_time,
self.server.fitness,
@ -12184,7 +12252,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str)
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12346,7 +12415,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles,
ua_str)
ua_str,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12504,7 +12574,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str)
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12662,7 +12733,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str)
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12828,7 +12900,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str)
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12954,6 +13027,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
min_images_for_accounts = \
self.server.min_images_for_accounts
msg = \
html_inbox_features(self.server.default_timeline,
self.server.recent_posts_cache,
@ -12996,7 +13071,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str)
self.server.dogwhistles, ua_str,
min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13117,7 +13193,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled, timezone,
bold_reading, self.server.dogwhistles,
ua_str)
ua_str,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13211,7 +13288,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str)
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13346,7 +13424,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str)
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13499,7 +13578,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles, ua_str)
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13606,6 +13686,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
min_images_for_accounts = \
self.server.min_images_for_accounts
msg = \
html_moderation(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13647,7 +13729,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, bold_reading,
self.server.dogwhistles,
ua_str)
ua_str,
min_images_for_accounts)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -14998,49 +15081,52 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.bold_reading.get(nickname):
bold_reading = True
msg = html_new_post(media_instance,
translate,
base_dir,
http_prefix,
path, in_reply_to_url,
reply_to_list,
share_description, None,
reply_page_number,
reply_category,
nickname, domain,
domain_full,
self.server.default_timeline,
self.server.newswire,
self.server.theme_name,
no_drop_down, access_keys,
custom_submit_text,
conversation_id,
self.server.recent_posts_cache,
self.server.max_recent_posts,
curr_session,
self.server.cached_webfingers,
self.server.person_cache,
self.server.port,
post_json_object,
self.server.project_version,
self.server.yt_replace_domain,
self.server.twitter_replacement_domain,
self.server.show_published_date_only,
self.server.peertube_instances,
self.server.allow_local_network_access,
self.server.system_language,
self.server.max_like_count,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
self.server.default_timeline,
reply_is_chat,
bold_reading,
self.server.dogwhistles).encode('utf-8')
msg = \
html_new_post(media_instance,
translate,
base_dir,
http_prefix,
path, in_reply_to_url,
reply_to_list,
share_description, None,
reply_page_number,
reply_category,
nickname, domain,
domain_full,
self.server.default_timeline,
self.server.newswire,
self.server.theme_name,
no_drop_down, access_keys,
custom_submit_text,
conversation_id,
self.server.recent_posts_cache,
self.server.max_recent_posts,
curr_session,
self.server.cached_webfingers,
self.server.person_cache,
self.server.port,
post_json_object,
self.server.project_version,
self.server.yt_replace_domain,
self.server.twitter_replacement_domain,
self.server.show_published_date_only,
self.server.peertube_instances,
self.server.allow_local_network_access,
self.server.system_language,
self.server.max_like_count,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
self.server.default_timeline,
reply_is_chat,
bold_reading,
self.server.dogwhistles,
self.server.min_images_for_accounts)
if not msg:
print('Error replying to ' + in_reply_to_url)
self._404()
return True
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)
@ -21247,6 +21333,9 @@ def run_daemon(map_format: str,
# scan the theme directory for any svg files containing scripts
assert not scan_themes_for_scripts(base_dir)
# which accounts should minimize all attached images by default
httpd.min_images_for_accounts = []
# caches css files
httpd.css_cache = {}

139
inbox.py
View File

@ -445,7 +445,8 @@ def _inbox_store_post_to_html_cache(recent_posts_cache: {},
timezone: str,
mitm: bool,
bold_reading: bool,
dogwhistles: {}) -> None:
dogwhistles: {},
min_images_for_accounts: []) -> None:
"""Converts the json post into html and stores it in a cache
This enables the post to be quickly displayed later
"""
@ -457,6 +458,9 @@ def _inbox_store_post_to_html_cache(recent_posts_cache: {},
not_dm = not is_dm(post_json_object)
yt_replace_domain = get_config_param(base_dir, 'youtubedomain')
twitter_replacement_domain = get_config_param(base_dir, 'twitterdomain')
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem,
True, recent_posts_cache, max_recent_posts,
translate, page_number,
@ -471,7 +475,7 @@ def _inbox_store_post_to_html_cache(recent_posts_cache: {},
theme_name, system_language, max_like_count,
not_dm, True, True, False, True, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles, minimize_all_images)
def valid_inbox(base_dir: str, nickname: str, domain: str) -> bool:
@ -1150,7 +1154,8 @@ def _receive_edit_to_post(recent_posts_cache: {}, message_json: {},
show_published_date_only: bool,
peertube_instances: [],
theme_name: str, max_like_count: int,
cw_lists: {}, dogwhistles: {}) -> bool:
cw_lists: {}, dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""A post was edited
"""
if not has_object_dict(message_json):
@ -1256,6 +1261,9 @@ def _receive_edit_to_post(recent_posts_cache: {}, message_json: {},
bold_reading = True
timezone = get_account_timezone(base_dir, nickname, domain)
lists_enabled = get_config_param(base_dir, "listsEnabled")
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem, False,
recent_posts_cache, max_recent_posts,
translate, page_number, base_dir,
@ -1274,7 +1282,8 @@ def _receive_edit_to_post(recent_posts_cache: {}, message_json: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
return True
@ -1294,7 +1303,8 @@ def _receive_update_activity(recent_posts_cache: {}, session, base_dir: str,
show_published_date_only: bool,
peertube_instances: [],
theme_name: str, max_like_count: int,
cw_lists: {}, dogwhistles: {}) -> bool:
cw_lists: {}, dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""Receives an Update activity within the POST section of HTTPServer
"""
@ -1334,7 +1344,8 @@ def _receive_update_activity(recent_posts_cache: {}, session, base_dir: str,
show_published_date_only,
peertube_instances,
theme_name, max_like_count,
cw_lists, dogwhistles):
cw_lists, dogwhistles,
min_images_for_accounts):
print('EDITPOST: received ' + message_json['object']['id'])
return True
else:
@ -1384,7 +1395,8 @@ def _receive_like(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str,
bold_reading: bool, dogwhistles: {}) -> bool:
bold_reading: bool, dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""Receives a Like activity within the POST section of HTTPServer
"""
if message_json['type'] != 'Like':
@ -1474,6 +1486,9 @@ def _receive_like(recent_posts_cache: {},
mitm = False
if os.path.isfile(post_filename.replace('.json', '') + '.mitm'):
mitm = True
minimize_all_images = False
if handle_name in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem, False,
recent_posts_cache, max_recent_posts,
translate, page_number, base_dir,
@ -1493,7 +1508,8 @@ def _receive_like(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
return True
@ -1513,7 +1529,8 @@ def _receive_undo_like(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str,
bold_reading: bool, dogwhistles: {}) -> bool:
bold_reading: bool, dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""Receives an undo like activity within the POST section of HTTPServer
"""
if message_json['type'] != 'Undo':
@ -1593,6 +1610,9 @@ def _receive_undo_like(recent_posts_cache: {},
mitm = False
if os.path.isfile(post_filename.replace('.json', '') + '.mitm'):
mitm = True
minimize_all_images = False
if handle_name in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem, False,
recent_posts_cache, max_recent_posts,
translate, page_number, base_dir,
@ -1612,7 +1632,8 @@ def _receive_undo_like(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
return True
@ -1633,7 +1654,8 @@ def _receive_reaction(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str, bold_reading: bool,
dogwhistles: {}) -> bool:
dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""Receives an emoji reaction within the POST section of HTTPServer
"""
if message_json['type'] != 'EmojiReact':
@ -1744,6 +1766,9 @@ def _receive_reaction(recent_posts_cache: {},
mitm = False
if os.path.isfile(post_filename.replace('.json', '') + '.mitm'):
mitm = True
minimize_all_images = False
if handle_name in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem, False,
recent_posts_cache, max_recent_posts,
translate, page_number, base_dir,
@ -1764,7 +1789,8 @@ def _receive_reaction(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
return True
@ -1785,7 +1811,8 @@ def _receive_zot_reaction(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str, bold_reading: bool,
dogwhistles: {}) -> bool:
dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""Receives an zot-style emoji reaction within the POST section of
HTTPServer A zot style emoji reaction is an ordinary reply Note whose
content is exactly one emoji
@ -1920,6 +1947,9 @@ def _receive_zot_reaction(recent_posts_cache: {},
mitm = False
if os.path.isfile(post_filename.replace('.json', '') + '.mitm'):
mitm = True
minimize_all_images = False
if handle_name in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem, False,
recent_posts_cache, max_recent_posts,
translate, page_number, base_dir,
@ -1940,7 +1970,8 @@ def _receive_zot_reaction(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
return True
@ -1962,7 +1993,8 @@ def _receive_undo_reaction(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str,
bold_reading: bool, dogwhistles: {}) -> bool:
bold_reading: bool, dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""Receives an undo emoji reaction within the POST section of HTTPServer
"""
if message_json['type'] != 'Undo':
@ -2059,6 +2091,9 @@ def _receive_undo_reaction(recent_posts_cache: {},
mitm = False
if os.path.isfile(post_filename.replace('.json', '') + '.mitm'):
mitm = True
minimize_all_images = False
if handle_name in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem, False,
recent_posts_cache, max_recent_posts,
translate, page_number, base_dir,
@ -2079,7 +2114,8 @@ def _receive_undo_reaction(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
return True
@ -2098,7 +2134,8 @@ def _receive_bookmark(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: {}, bold_reading: bool,
dogwhistles: {}) -> bool:
dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""Receives a bookmark activity within the POST section of HTTPServer
"""
if not message_json.get('type'):
@ -2176,6 +2213,9 @@ def _receive_bookmark(recent_posts_cache: {},
mitm = False
if os.path.isfile(post_filename.replace('.json', '') + '.mitm'):
mitm = True
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem, False,
recent_posts_cache, max_recent_posts,
translate, page_number, base_dir,
@ -2195,7 +2235,8 @@ def _receive_bookmark(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
return True
@ -2216,7 +2257,8 @@ def _receive_undo_bookmark(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str, bold_reading: bool,
dogwhistles: {}) -> bool:
dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""Receives an undo bookmark activity within the POST section of HTTPServer
"""
if not message_json.get('type'):
@ -2295,6 +2337,9 @@ def _receive_undo_bookmark(recent_posts_cache: {},
mitm = False
if os.path.isfile(post_filename.replace('.json', '') + '.mitm'):
mitm = True
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem, False,
recent_posts_cache, max_recent_posts,
translate, page_number, base_dir,
@ -2314,7 +2359,7 @@ def _receive_undo_bookmark(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists, lists_enabled,
timezone, mitm, bold_reading,
dogwhistles)
dogwhistles, minimize_all_images)
return True
@ -2411,7 +2456,8 @@ def _receive_announce(recent_posts_cache: {},
peertube_instances: [],
max_like_count: int, cw_lists: {},
lists_enabled: str, bold_reading: bool,
dogwhistles: {}, mitm: bool) -> bool:
dogwhistles: {}, mitm: bool,
min_images_for_accounts: []) -> bool:
"""Receives an announce activity within the POST section of HTTPServer
"""
if message_json['type'] != 'Announce':
@ -2528,7 +2574,9 @@ def _receive_announce(recent_posts_cache: {},
mitm_file.write('\n')
except OSError:
print('EX: unable to write mitm ' + post_filename_mitm)
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
announce_html = \
individual_post_as_html(signing_priv_key_pem, True,
recent_posts_cache, max_recent_posts,
@ -2549,7 +2597,8 @@ def _receive_announce(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
if not announce_html:
print('WARN: Unable to generate html for announce ' +
str(message_json))
@ -3702,7 +3751,8 @@ def _receive_question_vote(server, base_dir: str, nickname: str, domain: str,
theme_name: str, system_language: str,
max_like_count: int,
cw_lists: {}, lists_enabled: bool,
bold_reading: bool, dogwhistles: {}) -> None:
bold_reading: bool, dogwhistles: {},
min_images_for_accounts: []) -> None:
"""Updates the votes on a Question/poll
"""
# if this is a reply to a question then update the votes
@ -3736,6 +3786,9 @@ def _receive_question_vote(server, base_dir: str, nickname: str, domain: str,
mitm = False
if os.path.isfile(question_post_filename.replace('.json', '') + '.mitm'):
mitm = True
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem, False,
recent_posts_cache, max_recent_posts,
translate, page_number, base_dir,
@ -3755,7 +3808,8 @@ def _receive_question_vote(server, base_dir: str, nickname: str, domain: str,
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
# add id to inbox index
inbox_update_index('inbox', base_dir, handle,
@ -3975,7 +4029,8 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading, dogwhistles):
bold_reading, dogwhistles,
server.min_images_for_accounts):
if debug:
print('DEBUG: Like accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -4000,7 +4055,8 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading, dogwhistles):
bold_reading, dogwhistles,
server.min_images_for_accounts):
if debug:
print('DEBUG: Undo like accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -4026,7 +4082,8 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading, dogwhistles):
bold_reading, dogwhistles,
server.min_images_for_accounts):
if debug:
print('DEBUG: Reaction accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -4052,7 +4109,8 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading, dogwhistles):
bold_reading, dogwhistles,
server.min_images_for_accounts):
if debug:
print('DEBUG: Zot reaction accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -4079,7 +4137,8 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading, dogwhistles):
bold_reading, dogwhistles,
server.min_images_for_accounts):
if debug:
print('DEBUG: Undo reaction accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -4106,7 +4165,8 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading, dogwhistles):
bold_reading, dogwhistles,
server.min_images_for_accounts):
if debug:
print('DEBUG: Bookmark accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -4133,7 +4193,8 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading, dogwhistles):
bold_reading, dogwhistles,
server.min_images_for_accounts):
if debug:
print('DEBUG: Undo bookmark accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -4168,7 +4229,8 @@ def _inbox_after_initial(server, inbox_start_time,
allow_deletion,
peertube_instances,
max_like_count, cw_lists, lists_enabled,
bold_reading, dogwhistles, mitm):
bold_reading, dogwhistles, mitm,
server.min_images_for_accounts):
if debug:
print('DEBUG: Announce accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -4311,7 +4373,8 @@ def _inbox_after_initial(server, inbox_start_time,
theme_name, system_language,
max_like_count,
cw_lists, lists_enabled,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
server.min_images_for_accounts)
fitness_performance(inbox_start_time, server.fitness,
'INBOX', '_receive_question_vote',
debug)
@ -4533,6 +4596,8 @@ def _inbox_after_initial(server, inbox_start_time,
'INBOX', 'get_account_timezone',
debug)
inbox_start_time = time.time()
min_img_for_accounts = \
server.min_images_for_accounts
_inbox_store_post_to_html_cache(recent_posts_cache,
max_recent_posts,
translate, base_dir,
@ -4556,7 +4621,8 @@ def _inbox_after_initial(server, inbox_start_time,
lists_enabled,
timezone, mitm,
bold_reading,
dogwhistles)
dogwhistles,
min_img_for_accounts)
fitness_performance(inbox_start_time,
server.fitness,
'INBOX',
@ -5614,7 +5680,8 @@ def run_inbox_queue(server,
show_published_date_only,
peertube_instances,
theme_name, max_like_count,
cw_lists, dogwhistles):
cw_lists, dogwhistles,
server.min_images_for_accounts):
if debug:
print('Queue: Update accepted from ' + key_id)
if os.path.isfile(queue_filename):

View File

@ -235,7 +235,8 @@ def post_message_to_outbox(session, translate: {},
max_recent_posts: int, cw_lists: {},
lists_enabled: str,
content_license_url: str,
dogwhistles: {}) -> bool:
dogwhistles: {},
min_images_for_accounts: []) -> bool:
"""post is received by the outbox
Client to server message post
https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery
@ -525,6 +526,9 @@ def post_message_to_outbox(session, translate: {},
if os.path.isfile(saved_filename.replace('.json', '') +
'.mitm'):
mitm = True
minimize_all_images = False
if post_to_nickname in min_images_for_accounts:
minimize_all_images = True
individual_post_as_html(signing_priv_key_pem,
False, recent_posts_cache,
max_recent_posts,
@ -550,7 +554,8 @@ def post_message_to_outbox(session, translate: {},
False, True, use_cache_only,
cw_lists, lists_enabled,
timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
if outbox_announce(recent_posts_cache,
base_dir, message_json, debug):

View File

@ -145,7 +145,8 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
httpd.cw_lists,
httpd.lists_enabled,
httpd.content_license_url,
httpd.dogwhistles):
httpd.dogwhistles,
httpd.min_images_for_accounts):
index_lines.remove(line)
try:
os.remove(post_filename)

View File

@ -39,7 +39,8 @@ def html_confirm_delete(server,
theme_name: str, system_language: str,
max_like_count: int, signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
dogwhistles: {}) -> str:
dogwhistles: {},
min_images_for_accounts: []) -> str:
"""Shows a screen asking to confirm the deletion of a post
"""
if '/statuses/' not in message_id:
@ -75,6 +76,9 @@ def html_confirm_delete(server,
bold_reading = False
if server.bold_reading.get(nickname):
bold_reading = True
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
delete_post_str += \
individual_post_as_html(signing_priv_key_pem,
True, recent_posts_cache, max_recent_posts,
@ -91,7 +95,8 @@ def html_confirm_delete(server,
theme_name, system_language, max_like_count,
False, False, False, False, False, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
delete_post_str += '<center>'
delete_post_str += \
' <p class="followText">' + \

View File

@ -225,7 +225,8 @@ def html_new_post(media_instance: bool, translate: {},
cw_lists: {}, lists_enabled: str,
box_name: str,
reply_is_chat: bool, bold_reading: bool,
dogwhistles: {}) -> str:
dogwhistles: {},
min_images_for_accounts: []) -> str:
"""New post screen
"""
reply_str = ''
@ -279,6 +280,9 @@ def html_new_post(media_instance: bool, translate: {},
if post_json_object:
timezone = \
get_account_timezone(base_dir, nickname, domain)
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
new_post_text += \
individual_post_as_html(signing_priv_key_pem,
True, recent_posts_cache,
@ -304,7 +308,8 @@ def html_new_post(media_instance: bool, translate: {},
False, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
reply_str = '<input type="hidden" ' + \
'name="replyTo" value="' + in_reply_to + '">\n'

View File

@ -39,7 +39,8 @@ def _html_front_screen_posts(recent_posts_cache: {}, max_recent_posts: int,
signing_priv_key_pem: str, cw_lists: {},
lists_enabled: str,
bold_reading: bool,
dogwhistles: {}) -> str:
dogwhistles: {},
min_images_for_accounts: []) -> str:
"""Shows posts on the front screen of a news instance
These should only be public blog posts from the features timeline
which is the blog timeline of the news actor
@ -67,6 +68,9 @@ def _html_front_screen_posts(recent_posts_cache: {}, max_recent_posts: int,
for item in outbox_feed['orderedItems']:
if item['type'] == 'Create':
timezone = get_account_timezone(base_dir, nickname, domain)
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
post_str = \
individual_post_as_html(signing_priv_key_pem,
True, recent_posts_cache,
@ -90,7 +94,8 @@ def _html_front_screen_posts(recent_posts_cache: {}, max_recent_posts: int,
True, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
if post_str:
profile_str += post_str + separator_str
ctr += 1
@ -122,7 +127,8 @@ def html_front_screen(signing_priv_key_pem: str,
page_number: int,
max_items_per_page: int,
cw_lists: {}, lists_enabled: str,
dogwhistles: {}) -> str:
dogwhistles: {},
min_images_for_accounts: []) -> str:
"""Show the news instance front screen
"""
bold_reading = False
@ -197,7 +203,8 @@ def html_front_screen(signing_priv_key_pem: str,
max_like_count,
signing_priv_key_pem,
cw_lists, lists_enabled,
bold_reading, dogwhistles) + license_str
bold_reading, dogwhistles,
min_images_for_accounts) + license_str
# Footer which is only used for system accounts
profile_footer_str = ' </td>\n'

View File

@ -42,6 +42,7 @@ def html_likers_of_post(base_dir: str, nickname: str,
cw_lists: {}, lists_enabled: str,
box_name: str, default_timeline: str,
bold_reading: bool, dogwhistles: {},
min_images_for_accounts: [],
dict_name: str = 'likes') -> str:
"""Returns html for a screen showing who liked a post
"""
@ -83,6 +84,9 @@ def html_likers_of_post(base_dir: str, nickname: str,
mitm = False
if os.path.isfile(filename.replace('.json', '') + '.mitm'):
mitm = True
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
html_str += \
individual_post_as_html(signing_priv_key_pem,
True, recent_posts_cache,
@ -108,7 +112,8 @@ def html_likers_of_post(base_dir: str, nickname: str,
False, False, False,
cw_lists, lists_enabled,
timezone, mitm, bold_reading,
dogwhistles)
dogwhistles,
minimize_all_images)
# show likers beneath the post
obj = post_json_object

View File

@ -58,7 +58,8 @@ def html_moderation(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the moderation feed as html
This is what you see when selecting the "mod" timeline
"""
@ -84,7 +85,8 @@ def html_moderation(default_timeline: str,
text_mode_banner, 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)
timezone, bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
def html_account_info(translate: {},

View File

@ -1597,7 +1597,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
lists_enabled: str,
timezone: str,
mitm: bool, bold_reading: bool,
dogwhistles: {}) -> str:
dogwhistles: {},
minimize_all_images: bool) -> str:
""" Shows a single post as html
"""
if not post_json_object:
@ -2072,7 +2073,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
is_muted, avatar_link,
reply_str, announce_str, like_str,
bookmark_str, delete_str, mute_str,
content_str)
content_str,
minimize_all_images)
published_str = \
_get_published_date_str(post_json_object, show_published_date_only,
@ -2399,7 +2401,8 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
max_like_count: int, signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, mitm: bool,
bold_reading: bool, dogwhistles: {}) -> str:
bold_reading: bool, dogwhistles: {},
min_images_for_accounts: []) -> str:
"""Show an individual post as html
"""
original_post_json = post_json_object
@ -2451,6 +2454,9 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
follow_str += ' </form>\n'
post_str += follow_str + '</p>\n'
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
post_str += \
individual_post_as_html(signing_priv_key_pem,
True, recent_posts_cache, max_recent_posts,
@ -2468,7 +2474,8 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
system_language, max_like_count,
False, authorized, False, False, False, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
message_id = remove_id_ending(post_json_object['id'])
# show the previous posts
@ -2510,7 +2517,8 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, mitm,
bold_reading,
dogwhistles) + post_str
dogwhistles,
minimize_all_images) + post_str
# show the following posts
post_filename = locate_post(base_dir, nickname, domain, message_id)
@ -2549,7 +2557,8 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
False, False, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
@ -2578,11 +2587,15 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int,
signing_priv_key_pem: str, cw_lists: {},
lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
dogwhistles: {},
min_images_for_accounts: []) -> str:
"""Show the replies to an individual post as html
"""
replies_str = ''
if replies_json.get('orderedItems'):
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
for item in replies_json['orderedItems']:
replies_str += \
individual_post_as_html(signing_priv_key_pem,
@ -2605,7 +2618,8 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int,
False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
@ -2635,9 +2649,13 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
cw_lists: {}, lists_enabled: str,
box_name: str, page_number: int,
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
dogwhistles: {},
min_images_for_accounts: []) -> str:
"""Returns the emoji picker screen
"""
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
reacted_to_post_str = \
'<br><center><label class="followText">' + \
translate['Select reaction'].title() + '</label></center>\n' + \
@ -2659,7 +2677,8 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
max_like_count,
False, False, False, False, False, False,
cw_lists, lists_enabled, timezone, False,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
reactions_filename = base_dir + '/emoji/reactions.json'
if not os.path.isfile(reactions_filename):

View File

@ -156,7 +156,8 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
cw_lists: {}, lists_enabled: str,
timezone: str,
onion_domain: str, i2p_domain: str,
bold_reading: bool, dogwhistles: {}) -> str:
bold_reading: bool, dogwhistles: {},
min_images_for_accounts: []) -> str:
"""Show a profile page after a search for a fediverse address
"""
http = False
@ -369,6 +370,9 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
session, outbox_url, as_header, project_version,
http_prefix, from_domain, debug)
if user_feed:
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
i = 0
for item in user_feed:
show_item, post_json_object = \
@ -398,7 +402,8 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
False, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
i += 1
if i >= 8:
break
@ -635,6 +640,7 @@ def html_profile(signing_priv_key_pem: str,
if not nickname:
return ""
if is_system_account(nickname):
min_images_for_accounts = []
return html_front_screen(signing_priv_key_pem,
rss_icon_at_top,
icons_as_buttons,
@ -652,7 +658,8 @@ def html_profile(signing_priv_key_pem: str,
system_language, max_like_count,
shared_items_federated_domains, None,
page_number, max_items_per_page, cw_lists,
lists_enabled, {})
lists_enabled, {},
min_images_for_accounts)
domain, port = get_domain_from_actor(profile_json['id'])
if not domain:
@ -1063,6 +1070,7 @@ def html_profile(signing_priv_key_pem: str,
translate['Get the source code'] + '" src="/icons/agpl.png" /></a>'
if selected == 'posts':
min_images_for_accounts = []
profile_str += \
_html_profile_posts(recent_posts_cache, max_recent_posts,
translate,
@ -1079,7 +1087,8 @@ def html_profile(signing_priv_key_pem: str,
max_like_count,
signing_priv_key_pem,
cw_lists, lists_enabled,
timezone, bold_reading, {}) + license_str
timezone, bold_reading, {},
min_images_for_accounts) + license_str
if not is_group:
if selected == 'following':
profile_str += \
@ -1153,7 +1162,8 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
dogwhistles: {},
min_images_for_accounts: []) -> str:
"""Shows posts on the profile screen
These should only be public posts
"""
@ -1163,6 +1173,9 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
ctr = 0
curr_page = 1
box_name = 'outbox'
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
while ctr < max_items and curr_page < 4:
outbox_feed_path_str = \
'/users/' + nickname + '/' + box_name + '?page=' + \
@ -1203,7 +1216,8 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
True, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
if post_str:
profile_str += post_str + separator_str
ctr += 1

View File

@ -695,7 +695,8 @@ def html_history_search(translate: {}, base_dir: str,
cw_lists: {},
lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, access_keys: {}) -> str:
dogwhistles: {}, access_keys: {},
min_images_for_accounts: []) -> str:
"""Show a page containing search results for your post history
"""
if historysearch.startswith("'"):
@ -765,6 +766,9 @@ def html_history_search(translate: {}, base_dir: str,
end_index = no_of_box_filenames - 1
index = start_index
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
while index <= end_index:
post_filename = box_filenames[index]
if not post_filename:
@ -800,7 +804,8 @@ def html_history_search(translate: {}, base_dir: str,
False, False, False, False,
cw_lists, lists_enabled,
timezone, False, bold_reading,
dogwhistles)
dogwhistles,
minimize_all_images)
if post_str:
history_search_form += separator_str + post_str
index += 1
@ -827,7 +832,8 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, map_format: str,
access_keys: {}, box_name: str) -> str:
access_keys: {}, box_name: str,
min_images_for_accounts: []) -> str:
"""Show a page containing search results for a hashtag
or after selecting a hashtag from the swarm
"""
@ -989,6 +995,9 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
allow_downloads = True
avatar_url = None
show_avatar_options = True
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
post_str = \
individual_post_as_html(signing_priv_key_pem,
allow_downloads, recent_posts_cache,
@ -1014,7 +1023,8 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
show_public_only,
store_to_sache, False, cw_lists,
lists_enabled, timezone, False,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
if post_str:
hashtag_search_form += separator_str + post_str
index += 1

View File

@ -498,7 +498,8 @@ def html_timeline(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the timeline as html
"""
enable_timing_log = False
@ -954,6 +955,10 @@ def html_timeline(default_timeline: str,
tl_str += '<br>'
tl_str += '<div class="galleryContainer">\n'
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
# show each post in the timeline
for item in timeline_json['orderedItems']:
if item['type'] == 'Create' or \
@ -1015,7 +1020,8 @@ def html_timeline(default_timeline: str,
False, True, use_cache_only,
cw_lists, lists_enabled,
timezone, mitm,
bold_reading, dogwhistles)
bold_reading, dogwhistles,
minimize_all_images)
_log_timeline_timing(enable_timing_log,
timeline_start_time, box_name, '12')
@ -1257,7 +1263,8 @@ def html_shares(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the shares timeline as html
"""
manually_approve_followers = \
@ -1288,7 +1295,8 @@ def html_shares(default_timeline: str,
shared_items_federated_domains,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str)
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
def html_wanted(default_timeline: str,
@ -1318,7 +1326,8 @@ def html_wanted(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the wanted timeline as html
"""
manually_approve_followers = \
@ -1349,7 +1358,8 @@ def html_wanted(default_timeline: str,
shared_items_federated_domains,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str)
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
def html_inbox(default_timeline: str,
@ -1380,7 +1390,8 @@ def html_inbox(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the inbox as html
"""
manually_approve_followers = \
@ -1411,7 +1422,8 @@ def html_inbox(default_timeline: str,
shared_items_federated_domains,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str)
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
def html_bookmarks(default_timeline: str,
@ -1442,7 +1454,8 @@ def html_bookmarks(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the bookmarks as html
"""
manually_approve_followers = \
@ -1472,7 +1485,8 @@ def html_bookmarks(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)
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
def html_inbox_dms(default_timeline: str,
@ -1503,7 +1517,8 @@ def html_inbox_dms(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the DM timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1529,7 +1544,8 @@ def html_inbox_dms(default_timeline: str,
shared_items_federated_domains,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str)
bold_reading, dogwhistles, ua_str,
min_images_for_accounts)
def html_inbox_replies(default_timeline: str,
@ -1560,7 +1576,8 @@ def html_inbox_replies(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the replies timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1585,7 +1602,7 @@ 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)
dogwhistles, ua_str, min_images_for_accounts)
def html_inbox_media(default_timeline: str,
@ -1616,7 +1633,8 @@ def html_inbox_media(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the media timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1641,7 +1659,7 @@ 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)
dogwhistles, ua_str, min_images_for_accounts)
def html_inbox_blogs(default_timeline: str,
@ -1672,7 +1690,8 @@ def html_inbox_blogs(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the blogs timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1697,7 +1716,7 @@ 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)
dogwhistles, ua_str, min_images_for_accounts)
def html_inbox_features(default_timeline: str,
@ -1729,7 +1748,8 @@ def html_inbox_features(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the features timeline as html
"""
return html_timeline(default_timeline,
@ -1753,7 +1773,7 @@ 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)
dogwhistles, ua_str, min_images_for_accounts)
def html_inbox_news(default_timeline: str,
@ -1784,7 +1804,8 @@ def html_inbox_news(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the news timeline as html
"""
return html_timeline(default_timeline,
@ -1808,7 +1829,7 @@ 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)
dogwhistles, ua_str, min_images_for_accounts)
def html_outbox(default_timeline: str,
@ -1839,7 +1860,8 @@ def html_outbox(default_timeline: str,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str) -> str:
dogwhistles: {}, ua_str: str,
min_images_for_accounts: []) -> str:
"""Show the Outbox as html
"""
manually_approve_followers = \
@ -1866,4 +1888,4 @@ 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)
dogwhistles, ua_str, min_images_for_accounts)

View File

@ -1204,7 +1204,8 @@ def get_post_attachments_as_html(base_dir: str,
like_str: str,
bookmark_str: str, delete_str: str,
mute_str: str,
content: str) -> (str, str):
content: str,
minimize_all_images: bool) -> (str, str):
"""Returns a string representing any attachments
"""
attachment_str = ''
@ -1302,10 +1303,14 @@ def get_post_attachments_as_html(base_dir: str,
get_nickname_from_actor(attributed_actor)
following_domain, _ = \
get_domain_from_actor(attributed_actor)
minimize_images = \
minimizing_attached_images(base_dir, nickname, domain,
following_nickname,
following_domain)
if minimize_all_images:
minimize_images = True
else:
minimize_images = \
minimizing_attached_images(base_dir,
nickname, domain,
following_nickname,
following_domain)
# minimize any NSFW images
if not minimize_images and content: