Bob Mottram 2022-12-28 22:43:55 +00:00
commit 894e1f84aa
17 changed files with 353 additions and 150 deletions

161
daemon.py
View File

@ -6470,7 +6470,8 @@ class PubServer(BaseHTTPRequestHandler):
license_str
else:
license_str = \
'https://creativecommons.org/licenses/by/4.0'
'https://creativecommons.org/' + \
'licenses/by-nc/4.0'
set_config_param(base_dir,
'contentLicenseUrl',
license_str)
@ -9088,6 +9089,13 @@ class PubServer(BaseHTTPRequestHandler):
repeat_url = path.split('?repeat=')[1]
if '?' in repeat_url:
repeat_url = repeat_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -9251,16 +9259,10 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
actor_absolute = self._get_instance_url(calling_domain) + actor
if announce_id:
first_post_id = announce_id.replace('/', '--')
else:
first_post_id = repeat_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + '?page=' + \
str(page_number) + first_post_id + timeline_bookmark
@ -9284,6 +9286,14 @@ class PubServer(BaseHTTPRequestHandler):
if '?' in repeat_url:
repeat_url = repeat_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -9381,7 +9391,7 @@ class PubServer(BaseHTTPRequestHandler):
actor_path_str = \
actor_absolute + '/' + timeline_str + '?page=' + \
str(page_number) + timeline_bookmark
str(page_number) + first_post_id + timeline_bookmark
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', '_undo_announce_button',
self.server.debug)
@ -9638,6 +9648,13 @@ class PubServer(BaseHTTPRequestHandler):
like_url = path.split('?like=')[1]
if '?' in like_url:
like_url = like_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -9808,7 +9825,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Liked post not found: ' + liked_post_filename)
# clear the icon from the cache so that it gets updated
@ -9820,9 +9837,6 @@ class PubServer(BaseHTTPRequestHandler):
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = like_url2.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -9847,6 +9861,13 @@ class PubServer(BaseHTTPRequestHandler):
like_url = path.split('?unlike=')[1]
if '?' in like_url:
like_url = like_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10008,7 +10029,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Unliked post not found: ' + liked_post_filename)
# clear the icon from the cache so that it gets updated
@ -10016,9 +10037,6 @@ class PubServer(BaseHTTPRequestHandler):
del self.server.iconsCache['like_inactive.png']
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = like_url2.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -10045,6 +10063,13 @@ class PubServer(BaseHTTPRequestHandler):
reaction_url = path.split('?react=')[1]
if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10237,7 +10262,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Emoji reaction post not found: ' +
reaction_post_filename)
@ -10247,9 +10272,6 @@ class PubServer(BaseHTTPRequestHandler):
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = reaction_url2.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -10274,6 +10296,13 @@ class PubServer(BaseHTTPRequestHandler):
reaction_url = path.split('?unreact=')[1]
if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10456,16 +10485,13 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Unreaction post not found: ' +
reaction_post_filename)
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = reaction_url2.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -10593,6 +10619,13 @@ class PubServer(BaseHTTPRequestHandler):
bookmark_url = path.split('?bookmark=')[1]
if '?' in bookmark_url:
bookmark_url = bookmark_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10720,7 +10753,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Bookmarked post not found: ' + bookmark_filename)
# self._post_to_outbox(bookmark_json,
@ -10728,9 +10761,6 @@ class PubServer(BaseHTTPRequestHandler):
# curr_session, proxy_type)
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = bookmark_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -10755,6 +10785,13 @@ class PubServer(BaseHTTPRequestHandler):
bookmark_url = path.split('?unbookmark=')[1]
if '?' in bookmark_url:
bookmark_url = bookmark_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -10884,15 +10921,12 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Unbookmarked post not found: ' +
bookmark_filename)
actor_absolute = self._get_instance_url(calling_domain) + actor
first_post_id = bookmark_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
actor_path_str = \
actor_absolute + '/' + timeline_str + \
'?page=' + str(page_number) + first_post_id + \
@ -11030,6 +11064,13 @@ class PubServer(BaseHTTPRequestHandler):
mute_url = path.split('?mute=')[1]
if '?' in mute_url:
mute_url = mute_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -11135,7 +11176,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Muted post not found: ' + mute_filename)
@ -11150,9 +11191,6 @@ class PubServer(BaseHTTPRequestHandler):
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', '_mute_button', self.server.debug)
first_post_id = mute_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
page_number_str = str(page_number)
redirect_str = \
actor + '/' + timeline_str + '?page=' + page_number_str + \
@ -11170,6 +11208,13 @@ class PubServer(BaseHTTPRequestHandler):
mute_url = path.split('?unmute=')[1]
if '?' in mute_url:
mute_url = mute_url.split('?')[0]
first_post_id = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
@ -11275,7 +11320,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
timezone, mitm, bold_reading,
self.server.dogwhistles,
minimize_all_images)
minimize_all_images, None)
else:
print('WARN: Unmuted post not found: ' + mute_filename)
if calling_domain.endswith('.onion') and onion_domain:
@ -11287,9 +11332,6 @@ class PubServer(BaseHTTPRequestHandler):
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', '_undo_mute_button', self.server.debug)
first_post_id = mute_url.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
page_number_str = str(page_number)
redirect_str = \
actor + '/' + timeline_str + '?page=' + page_number_str + \
@ -12456,6 +12498,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
last_post_id = None
if ';lastpost=' in path:
last_post_id = path.split(';lastpost=')[1]
if ';' in last_post_id:
last_post_id = last_post_id.split(';')[0]
msg = \
html_inbox(default_timeline,
recent_posts_cache,
@ -12500,7 +12547,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.dogwhistles,
ua_str,
self.server.min_images_for_accounts,
reverse_sequence)
reverse_sequence, last_post_id)
if getreq_start_time:
fitness_performance(getreq_start_time,
self.server.fitness,
@ -12636,6 +12683,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
last_post_id = None
if ';lastpost=' in path:
last_post_id = path.split(';lastpost=')[1]
if ';' in last_post_id:
last_post_id = last_post_id.split(';')[0]
msg = \
html_inbox_dms(self.server.default_timeline,
self.server.recent_posts_cache,
@ -12678,7 +12730,7 @@ class PubServer(BaseHTTPRequestHandler):
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts,
reverse_sequence)
reverse_sequence, last_post_id)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12804,6 +12856,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
last_post_id = None
if ';lastpost=' in path:
last_post_id = path.split(';lastpost=')[1]
if ';' in last_post_id:
last_post_id = last_post_id.split(';')[0]
msg = \
html_inbox_replies(self.server.default_timeline,
self.server.recent_posts_cache,
@ -12847,7 +12904,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.dogwhistles,
ua_str,
self.server.min_images_for_accounts,
reverse_sequence)
reverse_sequence, last_post_id)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12969,6 +13026,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
last_post_id = None
if ';lastpost=' in path:
last_post_id = path.split(';lastpost=')[1]
if ';' in last_post_id:
last_post_id = last_post_id.split(';')[0]
msg = \
html_inbox_media(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13012,7 +13074,7 @@ class PubServer(BaseHTTPRequestHandler):
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts,
reverse_sequence)
reverse_sequence, last_post_id)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13134,6 +13196,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False
if nickname in self.server.reverse_sequence:
reverse_sequence = True
last_post_id = None
if ';lastpost=' in path:
last_post_id = path.split(';lastpost=')[1]
if ';' in last_post_id:
last_post_id = last_post_id.split(';')[0]
msg = \
html_inbox_blogs(self.server.default_timeline,
self.server.recent_posts_cache,
@ -13177,7 +13244,7 @@ class PubServer(BaseHTTPRequestHandler):
timezone, bold_reading,
self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts,
reverse_sequence)
reverse_sequence, last_post_id)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -22555,7 +22622,7 @@ def run_daemon(max_hashtags: int,
# license for content of the instance
if not content_license_url:
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
httpd.content_license_url = content_license_url
# fitness metrics

View File

@ -1419,7 +1419,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
# TODO: this should probably be retrieved somehow from the server
signing_priv_key_pem = None
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
blocked_cache = {}
languages_understood = []

View File

@ -149,7 +149,8 @@ def _command_options() -> None:
default=None,
help='Location for an event when sending a c2s post')
parser.add_argument('--content_license_url', type=str,
default='https://creativecommons.org/licenses/by/4.0',
default='https://creativecommons.org/' +
'licenses/by-nc/4.0',
help='Url of the license used for the ' +
'instance content')
parser.add_argument('--import_emoji', type=str,

View File

@ -480,7 +480,8 @@ 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, minimize_all_images)
bold_reading, dogwhistles, minimize_all_images,
None)
def valid_inbox(base_dir: str, nickname: str, domain: str) -> bool:
@ -1388,7 +1389,7 @@ def receive_edit_to_post(recent_posts_cache: {}, message_json: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -1617,7 +1618,7 @@ def _receive_like(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -1742,7 +1743,7 @@ def _receive_undo_like(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -1899,7 +1900,7 @@ def _receive_reaction(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -2080,7 +2081,7 @@ def _receive_zot_reaction(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -2225,7 +2226,7 @@ def _receive_undo_reaction(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -2346,7 +2347,7 @@ def _receive_bookmark(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
return True
@ -2469,7 +2470,7 @@ def _receive_undo_bookmark(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists, lists_enabled,
timezone, mitm, bold_reading,
dogwhistles, minimize_all_images)
dogwhistles, minimize_all_images, None)
return True
@ -2710,7 +2711,7 @@ def _receive_announce(recent_posts_cache: {},
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if not announce_html:
print('WARN: Unable to generate html for announce ' +
str(message_json))
@ -3938,7 +3939,7 @@ def _receive_question_vote(server, base_dir: str, nickname: str, domain: str,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
# add id to inbox index
inbox_update_index('inbox', base_dir, handle,

View File

@ -570,7 +570,7 @@ def post_message_to_outbox(session, translate: {},
cw_lists, lists_enabled,
timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if is_edited_post:
message_json['type'] = 'Update'

View File

@ -996,6 +996,8 @@ def person_box_json(recent_posts_cache: {},
if ';firstpost=' in path:
first_post_id = \
path.split(';firstpost=')[1]
if ';' in first_post_id:
first_post_id = first_post_id.split(';')[0]
first_post_id = \
first_post_id.replace('--', '/')

View File

@ -173,6 +173,7 @@ from newswire import parse_feed_date
from newswire import limit_word_lengths
from mastoapiv1 import get_masto_api_v1id_from_nickname
from mastoapiv1 import get_nickname_from_masto_api_v1id
from webapp_post import replace_link_variable
from webapp_post import prepare_html_post_nickname
from speaker import speaker_replace_links
from markdown import markdown_to_html
@ -770,7 +771,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_is_article = False
conversation_id = None
translate = {}
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
create_public_post(path, nickname, domain, port, http_prefix,
"No wise fish would go anywhere without a porpoise",
test_save_to_file,
@ -839,7 +840,7 @@ def create_server_alice(path: str, domain: str, port: int,
max_like_count = 10
default_reply_interval_hrs = 9999999999
lists_enabled = ''
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
dyslexic_font = False
crawlers_allowed = []
check_actor_timeout = 2
@ -933,7 +934,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_location = None
test_is_article = False
conversation_id = None
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
translate = {}
create_public_post(path, nickname, domain, port, http_prefix,
"It's your life, live it your way.",
@ -1003,7 +1004,7 @@ def create_server_bob(path: str, domain: str, port: int,
max_like_count = 10
default_reply_interval_hrs = 9999999999
lists_enabled = ''
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
dyslexic_font = False
crawlers_allowed = []
check_actor_timeout = 2
@ -1089,7 +1090,7 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
low_bandwidth = True
default_reply_interval_hrs = 9999999999
lists_enabled = ''
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
dyslexic_font = False
crawlers_allowed = []
check_actor_timeout = 2
@ -1177,7 +1178,7 @@ def create_server_group(path: str, domain: str, port: int,
low_bandwidth = True
default_reply_interval_hrs = 9999999999
lists_enabled = ''
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
dyslexic_font = False
crawlers_allowed = []
check_actor_timeout = 2
@ -1229,7 +1230,7 @@ def test_post_message_between_servers(base_dir: str) -> None:
languages_understood = [system_language]
http_prefix = 'http'
proxy_type = None
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
if os.path.isdir(base_dir + '/.tests'):
shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None)
@ -1559,7 +1560,7 @@ def test_follow_between_servers(base_dir: str) -> None:
http_prefix = 'http'
proxy_type = None
federation_list = []
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
if os.path.isdir(base_dir + '/.tests'):
shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None)
@ -1753,7 +1754,7 @@ def test_shared_items_federation(base_dir: str) -> None:
http_prefix = 'http'
proxy_type = None
federation_list = []
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
if os.path.isdir(base_dir + '/.tests'):
shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None)
@ -2175,7 +2176,7 @@ def test_group_follow(base_dir: str) -> None:
http_prefix = 'http'
proxy_type = None
federation_list = []
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
if os.path.isdir(base_dir + '/.tests'):
shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None)
@ -2869,7 +2870,7 @@ def _test_create_person_account(base_dir: str):
conversation_id = None
low_bandwidth = True
translate = {}
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
content = \
"If your \"independent organization\" is government funded...\n\n" + \
"(yawn)\n\n...then it's not really independent.\n\n" + \
@ -2992,7 +2993,7 @@ def test_client_to_server(base_dir: str):
global TEST_SERVER_ALICE_RUNNING
global TEST_SERVER_BOB_RUNNING
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
TEST_SERVER_ALICE_RUNNING = False
TEST_SERVER_BOB_RUNNING = False
@ -4693,7 +4694,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
test_is_article = False
conversation_id = None
low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
translate = {}
reply = \
create_public_post(base_dir, nickname, domain, port, http_prefix,
@ -5643,7 +5644,7 @@ def _test_links_within_post(base_dir: str) -> None:
test_is_article = False
conversation_id = None
low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
translate = {}
post_json_object = \
@ -6733,7 +6734,7 @@ def _test_can_replyto(base_dir: str) -> None:
test_is_article = False
conversation_id = None
low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
translate = {}
post_json_object = \
@ -7668,6 +7669,25 @@ def _test_reply_language(base_dir: str) -> None:
assert not get_reply_language(base_dir, post_json_object)
def _test_replace_variable():
print('test_replace_variable')
link = 'red?firstpost=123'
result = replace_link_variable(link, 'firstpost', '456', '?')
expected = 'red?firstpost=456'
if result != expected:
print('expected: ' + expected)
print('result: ' + result)
assert result == expected
link = 'red?firstpost=123?test?firstpost=444?abc'
result = replace_link_variable(link, 'firstpost', '356', '?')
expected = 'red?firstpost=356?test?firstpost=356?abc'
if result != expected:
print('expected: ' + expected)
print('result: ' + result)
assert result == expected
def run_all_tests():
base_dir = os.getcwd()
print('Running tests...')
@ -7685,6 +7705,7 @@ def run_all_tests():
_test_checkbox_names()
_test_thread_functions()
_test_functions()
_test_replace_variable()
_test_missing_theme_colors(base_dir)
_test_reply_language(base_dir)
_test_emoji_in_actor_name(base_dir)

View File

@ -96,7 +96,7 @@ def html_confirm_delete(server,
False, False, False, False, False, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
delete_post_str += '<center>'
delete_post_str += \
' <p class="followText">' + \

View File

@ -96,7 +96,7 @@ def html_conversation_view(post_id: str,
cw_lists, lists_enabled,
timezone, False, bold_reading,
dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str:
conv_str += text_mode_separator + separator_str + post_str

View File

@ -429,7 +429,7 @@ def html_new_post(edit_post_params: {},
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
reply_str = '<input type="hidden" ' + \
'name="replyTo" value="' + in_reply_to + '">\n'

View File

@ -95,7 +95,7 @@ def _html_front_screen_posts(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str:
profile_str += post_str + separator_str
ctr += 1

View File

@ -113,7 +113,7 @@ def html_likers_of_post(base_dir: str, nickname: str,
cw_lists, lists_enabled,
timezone, mitm, bold_reading,
dogwhistles,
minimize_all_images)
minimize_all_images, None)
# show likers beneath the post
obj = post_json_object

View File

@ -88,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, reverse_sequence)
min_images_for_accounts, reverse_sequence, None)
def html_account_info(translate: {},

View File

@ -275,8 +275,31 @@ def prepare_html_post_nickname(nickname: str, post_html: str) -> str:
return new_post_str
def replace_link_variable(link: str, variable_name: str, value: str,
separator: str = '?') -> str:
"""Replaces a variable within the given link
"""
full_var = separator + variable_name + '='
if full_var not in link:
return link
curr_str = link
result = ''
while full_var in curr_str:
prefix = curr_str.split(full_var, 1)[0] + full_var
next_str = curr_str.split(full_var, 1)[1]
if separator in next_str:
next_str = next_str.split(separator, 1)[1]
result += prefix + value + separator
curr_str = next_str
else:
result += prefix + value
curr_str = ''
return result + curr_str
def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str,
page_number: int) -> str:
page_number: int, first_post_id: str) -> str:
"""Sets the page number on a cached html post
"""
# if on the bookmarks timeline then remain there
@ -289,10 +312,30 @@ def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str,
post_html = \
post_html.replace('?page=' + page_number_str, '?page=-999')
# add the page number
with_page_number = \
post_html.replace(';-999;', ';' + str(page_number) + ';')
with_page_number = \
with_page_number.replace('?page=-999', '?page=' + str(page_number))
# add first post in the timeline
if first_post_id is None:
first_post_id = ''
first_post_id = first_post_id.replace('#', '/')
if '?firstpost=' in with_page_number:
with_page_number = \
replace_link_variable(with_page_number,
'firstpost', first_post_id, '?')
elif ';firstpost=' in with_page_number:
with_page_number = \
replace_link_variable(with_page_number,
'firstpost', first_post_id, ';')
else:
with_page_number = \
with_page_number.replace('?page=',
'?firstpost=' + first_post_id +
'?page=')
return prepare_html_post_nickname(nickname, with_page_number)
@ -339,7 +382,8 @@ def _get_post_from_recent_cache(session,
page_number: int,
recent_posts_cache: {},
max_recent_posts: int,
signing_priv_key_pem: str) -> str:
signing_priv_key_pem: str,
first_post_id: str) -> str:
"""Attempts to get the html post from the recent posts cache in memory
"""
if box_name == 'tlmedia':
@ -378,7 +422,7 @@ def _get_post_from_recent_cache(session,
post_html = \
prepare_post_from_html_cache(nickname, post_html,
box_name, page_number)
box_name, page_number, first_post_id)
update_recent_posts_cache(recent_posts_cache, max_recent_posts,
post_json_object, post_html)
_log_post_timing(enable_timing_log, post_start_time, '3')
@ -539,7 +583,8 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
post_json_object: {}, actor_nickname: str,
translate: {}, is_event: bool) -> str:
translate: {}, is_event: bool,
first_post_id: str) -> str:
"""Returns html for the edit icon/button
"""
edit_str = ''
@ -561,6 +606,10 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
if post_json_object['object'].get('inReplyTo'):
reply_to = ';replyTo=' + post_json_object['object']['inReplyTo']
first_post_str = ''
if first_post_id:
first_post_str = ';firstpost=' + first_post_id
if is_blog_post(post_json_object):
edit_blog_post_str = 'Edit blog post'
if translate.get(edit_blog_post_str):
@ -571,7 +620,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '/tlblogs?editblogpost=' + \
post_id.split('/statuses/')[1] + \
';actor=' + actor_nickname + \
';actor=' + actor_nickname + first_post_str + \
'" title="' + edit_blog_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_blog_post_str + '" alt="' + edit_blog_post_str + \
@ -582,7 +631,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '/editnewspost=' + \
post_id.split('/statuses/')[1] + \
'?actor=' + actor_nickname + \
'?actor=' + actor_nickname + first_post_str + \
'" title="' + edit_blog_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_blog_post_str + '" alt="' + edit_blog_post_str + \
@ -596,7 +645,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + nickname + \
'/tlblogs?editeventpost=' + \
post_id.split('/statuses/')[1] + \
'?actor=' + actor_nickname + \
'?actor=' + actor_nickname + first_post_str + \
'" title="' + edit_event_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_event_str + '" alt="' + edit_event_str + \
@ -611,7 +660,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=public' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -626,7 +675,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=reminder' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -641,7 +690,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=dm' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -656,7 +705,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=unlisted' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -671,7 +720,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=followers' + \
';actor=' + actor_nickname + reply_to + \
';actor=' + actor_nickname + first_post_str + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
@ -692,7 +741,8 @@ def _get_announce_icon_html(is_announced: bool,
page_number_param: str,
timeline_post_bookmark: str,
box_name: str,
max_announce_count: int) -> str:
max_announce_count: int,
first_post_id: str) -> str:
"""Returns html for announce icon/button at the bottom of the post
"""
announce_str = ''
@ -759,13 +809,17 @@ def _get_announce_icon_html(is_announced: bool,
announce_count_str.replace('(', '').replace(')', '').strip()
announce_str += '</a></label>\n'
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
announce_link_str = '?' + \
announce_link + '=' + announce_post_id + page_number_param
announce_str += \
' <a class="imageAnchor" href="/users/' + \
nickname + announce_link_str + unannounce_link_str + \
'?actor=' + post_json_object['actor'] + \
'?bm=' + timeline_post_bookmark + \
'?bm=' + timeline_post_bookmark + first_post_str + \
'?tl=' + box_name + '" title="' + announce_title + '" tabindex="10">\n'
announce_str += \
@ -785,7 +839,8 @@ def _get_like_icon_html(nickname: str, domain_full: str,
translate: {}, page_number_param: str,
timeline_post_bookmark: str,
box_name: str,
max_like_count: int) -> str:
max_like_count: int,
first_post_id: str) -> str:
"""Returns html for like icon/button
"""
if not show_like_button or is_moderation_post:
@ -837,12 +892,16 @@ def _get_like_icon_html(nickname: str, domain_full: str,
like_str += like_count_str.replace('(', '').replace(')', '').strip()
like_str += '</a></label>\n'
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
like_str += \
' <a class="imageAnchor" href="/users/' + nickname + '?' + \
like_link + '=' + like_post_id + \
page_number_param + \
'?actor=' + post_json_object['actor'] + \
'?bm=' + timeline_post_bookmark + \
'?bm=' + timeline_post_bookmark + first_post_str + \
'?tl=' + box_name + '" title="' + like_title + like_count_str + \
'" tabindex="10">\n'
like_str += \
@ -861,7 +920,8 @@ def _get_bookmark_icon_html(nickname: str, domain_full: str,
enable_timing_log: bool,
post_start_time, box_name: str,
page_number_param: str,
timeline_post_bookmark: str) -> str:
timeline_post_bookmark: str,
first_post_id: str) -> str:
"""Returns html for bookmark icon/button
"""
bookmark_str = ''
@ -886,12 +946,17 @@ def _get_bookmark_icon_html(nickname: str, domain_full: str,
bookmark_post_id = \
remove_hash_from_post_id(post_json_object['object']['id'])
bookmark_post_id = remove_id_ending(bookmark_post_id)
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
bookmark_str = \
' <a class="imageAnchor" href="/users/' + nickname + '?' + \
bookmark_link + '=' + bookmark_post_id + \
page_number_param + \
'?actor=' + post_json_object['actor'] + \
'?bm=' + timeline_post_bookmark + \
'?bm=' + timeline_post_bookmark + first_post_str + \
'?tl=' + box_name + '" title="' + bookmark_title + \
'" tabindex="10">\n'
bookmark_str += \
@ -910,7 +975,8 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {},
enable_timing_log: bool,
post_start_time, box_name: str,
page_number_param: str,
timeline_post_reaction: str) -> str:
timeline_post_reaction: str,
first_post_id: str) -> str:
"""Returns html for reaction icon/button
"""
reaction_str = ''
@ -926,11 +992,16 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {},
reaction_post_id = \
remove_hash_from_post_id(post_json_object['object']['id'])
reaction_post_id = remove_id_ending(reaction_post_id)
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
reaction_str = \
' <a class="imageAnchor" href="/users/' + nickname + \
'?selreact=' + reaction_post_id + page_number_param + \
'?actor=' + post_json_object['actor'] + \
'?bm=' + timeline_post_reaction + \
'?bm=' + timeline_post_reaction + first_post_str + \
'?tl=' + box_name + '" title="' + reaction_title + \
'" tabindex="10">\n'
reaction_str += \
@ -950,7 +1021,8 @@ def _get_mute_icon_html(is_muted: bool,
page_number_param: str,
box_name: str,
timeline_post_bookmark: str,
translate: {}) -> str:
translate: {},
first_post_id: str) -> str:
"""Returns html for mute icon/button
"""
mute_str = ''
@ -959,6 +1031,10 @@ def _get_mute_icon_html(is_muted: bool,
message_id.startswith(post_actor))):
return mute_str
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
if not is_muted:
mute_this_post_str = 'Mute this post'
if translate.get('Mute this post'):
@ -966,7 +1042,7 @@ def _get_mute_icon_html(is_muted: bool,
mute_str = \
' <a class="imageAnchor" href="/users/' + nickname + \
'?mute=' + message_id + page_number_param + '?tl=' + box_name + \
'?bm=' + timeline_post_bookmark + \
'?bm=' + timeline_post_bookmark + first_post_str + \
'" title="' + mute_this_post_str + '" tabindex="10">\n'
mute_str += \
' ' + \
@ -982,7 +1058,8 @@ def _get_mute_icon_html(is_muted: bool,
' <a class="imageAnchor" href="/users/' + \
nickname + '?unmute=' + message_id + \
page_number_param + '?tl=' + box_name + '?bm=' + \
timeline_post_bookmark + '" title="' + undo_mute_str + \
timeline_post_bookmark + first_post_str + \
'" title="' + undo_mute_str + \
'" tabindex="10">\n'
mute_str += \
' ' + \
@ -999,7 +1076,8 @@ def _get_delete_icon_html(nickname: str, domain_full: str,
message_id: str,
post_json_object: {},
page_number_param: str,
translate: {}) -> str:
translate: {},
first_post_id: str) -> str:
"""Returns html for delete icon/button
"""
delete_str = ''
@ -1011,10 +1089,15 @@ def _get_delete_icon_html(nickname: str, domain_full: str,
delete_this_post_str = 'Delete this post'
if translate.get(delete_this_post_str):
delete_this_post_str = translate[delete_this_post_str]
first_post_str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id
delete_str = \
' <a class="imageAnchor" href="/users/' + \
nickname + \
'?delete=' + message_id + page_number_param + \
nickname + '?delete=' + message_id + \
page_number_param + first_post_str + \
'" title="' + delete_this_post_str + '" tabindex="10">\n'
delete_str += \
' ' + \
@ -1773,7 +1856,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
timezone: str,
mitm: bool, bold_reading: bool,
dogwhistles: {},
minimize_all_images: bool) -> str:
minimize_all_images: bool,
first_post_id: str) -> str:
""" Shows a single post as html
"""
if not post_json_object:
@ -1844,7 +1928,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
page_number,
recent_posts_cache,
max_recent_posts,
signing_priv_key_pem)
signing_priv_key_pem,
first_post_id)
if post_html:
return post_html
if use_cache_only and post_json_object['type'] != 'Announce':
@ -1975,7 +2060,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
page_number,
recent_posts_cache,
max_recent_posts,
signing_priv_key_pem)
signing_priv_key_pem,
first_post_id)
if post_html:
return post_html
@ -2104,7 +2190,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
edit_str = _get_edit_icon_html(base_dir, nickname, domain_full,
post_json_object, actor_nickname,
translate, False)
translate, False, first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '11')
@ -2120,7 +2206,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
translate,
page_number_param,
timeline_post_bookmark,
box_name, max_like_count)
box_name, max_like_count,
first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '12')
@ -2149,7 +2236,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
post_start_time,
translate, page_number_param,
timeline_post_bookmark,
box_name, max_like_count)
box_name, max_like_count,
first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '12.5')
@ -2161,7 +2249,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
enable_timing_log,
post_start_time, box_name,
page_number_param,
timeline_post_bookmark)
timeline_post_bookmark,
first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '12.9')
@ -2173,7 +2262,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
enable_timing_log,
post_start_time, box_name,
page_number_param,
timeline_post_bookmark)
timeline_post_bookmark,
first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '12.10')
@ -2191,7 +2281,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
page_number_param,
box_name,
timeline_post_bookmark,
translate)
translate, first_post_id)
delete_str = \
_get_delete_icon_html(nickname, domain_full,
@ -2200,7 +2290,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
message_id,
post_json_object,
page_number_param,
translate)
translate, first_post_id)
_log_post_timing(enable_timing_log, post_start_time, '13.1')
@ -2665,7 +2755,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
False, authorized, False, False, False, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
message_id = remove_id_ending(post_json_object['id'])
# show the previous posts
@ -2708,7 +2798,8 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
timezone, mitm,
bold_reading,
dogwhistles,
minimize_all_images) + post_str
minimize_all_images,
None) + post_str
# show the following posts
post_filename = locate_post(base_dir, nickname, domain, message_id)
@ -2748,7 +2839,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
@ -2810,7 +2901,7 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
@ -2869,7 +2960,7 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
False, False, False, False, False, False,
cw_lists, lists_enabled, timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
reactions_filename = base_dir + '/emoji/reactions.json'
if not os.path.isfile(reactions_filename):

View File

@ -406,7 +406,7 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
i += 1
if i >= 8:
break
@ -1291,7 +1291,7 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
cw_lists, lists_enabled,
timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str and item_id not in shown_items:
profile_str += post_str + separator_str
shown_items.append(item_id)
@ -1537,7 +1537,7 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
content_license_url = \
get_config_param(base_dir, 'contentLicenseUrl')
if not content_license_url:
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
instance_str = begin_edit_section(translate['Instance Settings'])

View File

@ -807,7 +807,7 @@ def html_history_search(translate: {}, base_dir: str,
cw_lists, lists_enabled,
timezone, False, bold_reading,
dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str:
history_search_form += separator_str + post_str
index += 1
@ -1026,7 +1026,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
store_to_sache, False, cw_lists,
lists_enabled, timezone, False,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images, None)
if post_str:
hashtag_search_form += separator_str + post_str
index += 1

View File

@ -500,7 +500,8 @@ def html_timeline(default_timeline: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the timeline as html
"""
enable_timing_log = False
@ -925,10 +926,14 @@ def html_timeline(default_timeline: str,
tl_str += '<br>' + \
page_number_buttons(users_path, box_name, page_number,
'timelineposts')
first_post_str = ''
if page_number > 2:
if last_post_id:
first_post_str = ';firstpost=' + last_post_id
tl_str += \
' <center>\n' + \
' <a href="' + users_path + '/' + box_name + \
'?page=' + str(page_number - 1) + \
'?page=' + str(page_number - 1) + first_post_str + \
'#timelineposts" accesskey="' + access_keys['Page up'] + '" ' + \
'class="imageAnchor" tabindex="9">' + \
'<img loading="lazy" decoding="async" class="pageicon" src="/' + \
@ -949,6 +954,7 @@ def html_timeline(default_timeline: str,
if box_name == 'inbox':
use_cache_only = True
first_post_id = ''
last_post_id = ''
last_item_str = ''
@ -980,13 +986,16 @@ def html_timeline(default_timeline: str,
if box_name != 'tlmedia' and recent_posts_cache.get('html'):
post_id = remove_id_ending(item['id']).replace('/', '#')
if recent_posts_cache['html'].get(post_id):
if not first_post_id:
first_post_id = post_id
last_post_id = post_id
curr_tl_str = recent_posts_cache['html'][post_id]
curr_tl_str = \
prepare_post_from_html_cache(nickname,
curr_tl_str,
box_name,
page_number)
last_post_id = post_id
page_number,
first_post_id)
_log_timeline_timing(enable_timing_log,
timeline_start_time,
box_name, '10')
@ -1027,7 +1036,8 @@ def html_timeline(default_timeline: str,
cw_lists, lists_enabled,
timezone, mitm,
bold_reading, dogwhistles,
minimize_all_images)
minimize_all_images,
first_post_id)
_log_timeline_timing(enable_timing_log,
timeline_start_time, box_name, '12')
@ -1036,6 +1046,8 @@ def html_timeline(default_timeline: str,
last_item_str = text_mode_separator + curr_tl_str
last_post_id = \
remove_id_ending(item['id']).replace('/', '#')
if not first_post_id:
first_post_id = last_post_id
item_ctr += 1
if not reverse_sequence:
tl_items_str += last_item_str
@ -1066,11 +1078,14 @@ def html_timeline(default_timeline: str,
first_post = ''
if last_post_id:
first_post = ';firstpost=' + last_post_id.replace('#', '--')
last_post = ''
if first_post_id:
last_post = ';lastpost=' + first_post_id.replace('#', '--')
tl_str += \
' <br>\n' + \
' <center>\n' + \
' <a href="' + users_path + '/' + box_name + '?page=' + \
str(page_number + 1) + first_post + \
str(page_number + 1) + last_post + first_post + \
'#timelineposts" accesskey="' + access_keys['Page down'] + '" ' + \
'class="imageAnchor" tabindex="9">' + \
'<img loading="lazy" decoding="async" class="pageicon" src="/' + \
@ -1323,7 +1338,7 @@ def html_shares(default_timeline: str,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts,
reverse_sequence)
reverse_sequence, None)
def html_wanted(default_timeline: str,
@ -1388,7 +1403,7 @@ def html_wanted(default_timeline: str,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts,
reverse_sequence)
reverse_sequence, None)
def html_inbox(default_timeline: str,
@ -1421,7 +1436,8 @@ def html_inbox(default_timeline: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the inbox as html
"""
manually_approve_followers = \
@ -1454,7 +1470,7 @@ def html_inbox(default_timeline: str,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts,
reverse_sequence)
reverse_sequence, last_post_id)
def html_bookmarks(default_timeline: str,
@ -1519,7 +1535,7 @@ def html_bookmarks(default_timeline: str,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts,
reverse_sequence)
reverse_sequence, None)
def html_inbox_dms(default_timeline: str,
@ -1552,7 +1568,8 @@ def html_inbox_dms(default_timeline: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the DM timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1580,7 +1597,7 @@ def html_inbox_dms(default_timeline: str,
cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str,
min_images_for_accounts,
reverse_sequence)
reverse_sequence, last_post_id)
def html_inbox_replies(default_timeline: str,
@ -1613,7 +1630,8 @@ def html_inbox_replies(default_timeline: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the replies timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1639,7 +1657,7 @@ def html_inbox_replies(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,
reverse_sequence)
reverse_sequence, last_post_id)
def html_inbox_media(default_timeline: str,
@ -1672,7 +1690,8 @@ def html_inbox_media(default_timeline: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the media timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1698,7 +1717,7 @@ def html_inbox_media(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,
reverse_sequence)
reverse_sequence, last_post_id)
def html_inbox_blogs(default_timeline: str,
@ -1731,7 +1750,8 @@ def html_inbox_blogs(default_timeline: str,
timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str,
min_images_for_accounts: [],
reverse_sequence: bool) -> str:
reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the blogs timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1757,7 +1777,7 @@ def html_inbox_blogs(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,
reverse_sequence)
reverse_sequence, last_post_id)
def html_inbox_features(default_timeline: str,
@ -1816,7 +1836,7 @@ def html_inbox_features(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,
reverse_sequence)
reverse_sequence, None)
def html_inbox_news(default_timeline: str,
@ -1874,7 +1894,7 @@ def html_inbox_news(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,
reverse_sequence)
reverse_sequence, None)
def html_outbox(default_timeline: str,
@ -1935,4 +1955,4 @@ def html_outbox(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,
reverse_sequence)
reverse_sequence, None)