Consistent page up on timeline

main
Bob Mottram 2022-12-28 14:14:44 +00:00
parent 41b3bf129c
commit 441459ce7e
4 changed files with 69 additions and 25 deletions

View File

@ -12457,6 +12457,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False reverse_sequence = False
if nickname in self.server.reverse_sequence: if nickname in self.server.reverse_sequence:
reverse_sequence = True 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 = \ msg = \
html_inbox(default_timeline, html_inbox(default_timeline,
recent_posts_cache, recent_posts_cache,
@ -12501,7 +12506,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.dogwhistles, self.server.dogwhistles,
ua_str, ua_str,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
if getreq_start_time: if getreq_start_time:
fitness_performance(getreq_start_time, fitness_performance(getreq_start_time,
self.server.fitness, self.server.fitness,
@ -12637,6 +12642,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False reverse_sequence = False
if nickname in self.server.reverse_sequence: if nickname in self.server.reverse_sequence:
reverse_sequence = True 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 = \ msg = \
html_inbox_dms(self.server.default_timeline, html_inbox_dms(self.server.default_timeline,
self.server.recent_posts_cache, self.server.recent_posts_cache,
@ -12679,7 +12689,7 @@ class PubServer(BaseHTTPRequestHandler):
timezone, bold_reading, timezone, bold_reading,
self.server.dogwhistles, ua_str, self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
self._set_headers('text/html', msglen, self._set_headers('text/html', msglen,
@ -12805,6 +12815,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False reverse_sequence = False
if nickname in self.server.reverse_sequence: if nickname in self.server.reverse_sequence:
reverse_sequence = True 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 = \ msg = \
html_inbox_replies(self.server.default_timeline, html_inbox_replies(self.server.default_timeline,
self.server.recent_posts_cache, self.server.recent_posts_cache,
@ -12848,7 +12863,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.dogwhistles, self.server.dogwhistles,
ua_str, ua_str,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
self._set_headers('text/html', msglen, self._set_headers('text/html', msglen,
@ -12970,6 +12985,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False reverse_sequence = False
if nickname in self.server.reverse_sequence: if nickname in self.server.reverse_sequence:
reverse_sequence = True 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 = \ msg = \
html_inbox_media(self.server.default_timeline, html_inbox_media(self.server.default_timeline,
self.server.recent_posts_cache, self.server.recent_posts_cache,
@ -13013,7 +13033,7 @@ class PubServer(BaseHTTPRequestHandler):
timezone, bold_reading, timezone, bold_reading,
self.server.dogwhistles, ua_str, self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
self._set_headers('text/html', msglen, self._set_headers('text/html', msglen,
@ -13135,6 +13155,11 @@ class PubServer(BaseHTTPRequestHandler):
reverse_sequence = False reverse_sequence = False
if nickname in self.server.reverse_sequence: if nickname in self.server.reverse_sequence:
reverse_sequence = True 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 = \ msg = \
html_inbox_blogs(self.server.default_timeline, html_inbox_blogs(self.server.default_timeline,
self.server.recent_posts_cache, self.server.recent_posts_cache,
@ -13178,7 +13203,7 @@ class PubServer(BaseHTTPRequestHandler):
timezone, bold_reading, timezone, bold_reading,
self.server.dogwhistles, ua_str, self.server.dogwhistles, ua_str,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
self._set_headers('text/html', msglen, self._set_headers('text/html', msglen,

View File

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

View File

@ -88,7 +88,7 @@ def html_moderation(default_timeline: str,
max_like_count, shared_items_federated_domains, max_like_count, shared_items_federated_domains,
signing_priv_key_pem, cw_lists, lists_enabled, signing_priv_key_pem, cw_lists, lists_enabled,
timezone, bold_reading, dogwhistles, ua_str, timezone, bold_reading, dogwhistles, ua_str,
min_images_for_accounts, reverse_sequence) min_images_for_accounts, reverse_sequence, None)
def html_account_info(translate: {}, def html_account_info(translate: {},

View File

@ -500,7 +500,8 @@ def html_timeline(default_timeline: str,
timezone: str, bold_reading: bool, timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str, dogwhistles: {}, ua_str: str,
min_images_for_accounts: [], min_images_for_accounts: [],
reverse_sequence: bool) -> str: reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the timeline as html """Show the timeline as html
""" """
enable_timing_log = False enable_timing_log = False
@ -925,10 +926,13 @@ def html_timeline(default_timeline: str,
tl_str += '<br>' + \ tl_str += '<br>' + \
page_number_buttons(users_path, box_name, page_number, page_number_buttons(users_path, box_name, page_number,
'timelineposts') 'timelineposts')
first_post_str = ''
if last_post_id:
first_post_str = ';firstpost=' + last_post_id
tl_str += \ tl_str += \
' <center>\n' + \ ' <center>\n' + \
' <a href="' + users_path + '/' + box_name + \ ' <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'] + '" ' + \ '#timelineposts" accesskey="' + access_keys['Page up'] + '" ' + \
'class="imageAnchor" tabindex="9">' + \ 'class="imageAnchor" tabindex="9">' + \
'<img loading="lazy" decoding="async" class="pageicon" src="/' + \ '<img loading="lazy" decoding="async" class="pageicon" src="/' + \
@ -949,6 +953,7 @@ def html_timeline(default_timeline: str,
if box_name == 'inbox': if box_name == 'inbox':
use_cache_only = True use_cache_only = True
first_post_id = ''
last_post_id = '' last_post_id = ''
last_item_str = '' last_item_str = ''
@ -986,6 +991,8 @@ def html_timeline(default_timeline: str,
curr_tl_str, curr_tl_str,
box_name, box_name,
page_number) page_number)
if not first_post_id:
first_post_id = post_id
last_post_id = post_id last_post_id = post_id
_log_timeline_timing(enable_timing_log, _log_timeline_timing(enable_timing_log,
timeline_start_time, timeline_start_time,
@ -1036,6 +1043,8 @@ def html_timeline(default_timeline: str,
last_item_str = text_mode_separator + curr_tl_str last_item_str = text_mode_separator + curr_tl_str
last_post_id = \ last_post_id = \
remove_id_ending(item['id']).replace('/', '#') remove_id_ending(item['id']).replace('/', '#')
if not first_post_id:
first_post_id = last_post_id
item_ctr += 1 item_ctr += 1
if not reverse_sequence: if not reverse_sequence:
tl_items_str += last_item_str tl_items_str += last_item_str
@ -1066,11 +1075,14 @@ def html_timeline(default_timeline: str,
first_post = '' first_post = ''
if last_post_id: if last_post_id:
first_post = ';firstpost=' + last_post_id.replace('#', '--') first_post = ';firstpost=' + last_post_id.replace('#', '--')
last_post = ''
if first_post_id:
last_post = ';lastpost=' + first_post_id.replace('#', '--')
tl_str += \ tl_str += \
' <br>\n' + \ ' <br>\n' + \
' <center>\n' + \ ' <center>\n' + \
' <a href="' + users_path + '/' + box_name + '?page=' + \ ' <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'] + '" ' + \ '#timelineposts" accesskey="' + access_keys['Page down'] + '" ' + \
'class="imageAnchor" tabindex="9">' + \ 'class="imageAnchor" tabindex="9">' + \
'<img loading="lazy" decoding="async" class="pageicon" src="/' + \ '<img loading="lazy" decoding="async" class="pageicon" src="/' + \
@ -1323,7 +1335,7 @@ def html_shares(default_timeline: str,
cw_lists, lists_enabled, timezone, cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str, bold_reading, dogwhistles, ua_str,
min_images_for_accounts, min_images_for_accounts,
reverse_sequence) reverse_sequence, None)
def html_wanted(default_timeline: str, def html_wanted(default_timeline: str,
@ -1388,7 +1400,7 @@ def html_wanted(default_timeline: str,
cw_lists, lists_enabled, timezone, cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str, bold_reading, dogwhistles, ua_str,
min_images_for_accounts, min_images_for_accounts,
reverse_sequence) reverse_sequence, None)
def html_inbox(default_timeline: str, def html_inbox(default_timeline: str,
@ -1421,7 +1433,8 @@ def html_inbox(default_timeline: str,
timezone: str, bold_reading: bool, timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str, dogwhistles: {}, ua_str: str,
min_images_for_accounts: [], min_images_for_accounts: [],
reverse_sequence: bool) -> str: reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the inbox as html """Show the inbox as html
""" """
manually_approve_followers = \ manually_approve_followers = \
@ -1454,7 +1467,7 @@ def html_inbox(default_timeline: str,
cw_lists, lists_enabled, timezone, cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str, bold_reading, dogwhistles, ua_str,
min_images_for_accounts, min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
def html_bookmarks(default_timeline: str, def html_bookmarks(default_timeline: str,
@ -1519,7 +1532,7 @@ def html_bookmarks(default_timeline: str,
cw_lists, lists_enabled, timezone, cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str, bold_reading, dogwhistles, ua_str,
min_images_for_accounts, min_images_for_accounts,
reverse_sequence) reverse_sequence, None)
def html_inbox_dms(default_timeline: str, def html_inbox_dms(default_timeline: str,
@ -1552,7 +1565,8 @@ def html_inbox_dms(default_timeline: str,
timezone: str, bold_reading: bool, timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str, dogwhistles: {}, ua_str: str,
min_images_for_accounts: [], min_images_for_accounts: [],
reverse_sequence: bool) -> str: reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the DM timeline as html """Show the DM timeline as html
""" """
artist = is_artist(base_dir, nickname) artist = is_artist(base_dir, nickname)
@ -1580,7 +1594,7 @@ def html_inbox_dms(default_timeline: str,
cw_lists, lists_enabled, timezone, cw_lists, lists_enabled, timezone,
bold_reading, dogwhistles, ua_str, bold_reading, dogwhistles, ua_str,
min_images_for_accounts, min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
def html_inbox_replies(default_timeline: str, def html_inbox_replies(default_timeline: str,
@ -1613,7 +1627,8 @@ def html_inbox_replies(default_timeline: str,
timezone: str, bold_reading: bool, timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str, dogwhistles: {}, ua_str: str,
min_images_for_accounts: [], min_images_for_accounts: [],
reverse_sequence: bool) -> str: reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the replies timeline as html """Show the replies timeline as html
""" """
artist = is_artist(base_dir, nickname) artist = is_artist(base_dir, nickname)
@ -1639,7 +1654,7 @@ def html_inbox_replies(default_timeline: str,
shared_items_federated_domains, signing_priv_key_pem, shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading, cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts, dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
def html_inbox_media(default_timeline: str, def html_inbox_media(default_timeline: str,
@ -1672,7 +1687,8 @@ def html_inbox_media(default_timeline: str,
timezone: str, bold_reading: bool, timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str, dogwhistles: {}, ua_str: str,
min_images_for_accounts: [], min_images_for_accounts: [],
reverse_sequence: bool) -> str: reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the media timeline as html """Show the media timeline as html
""" """
artist = is_artist(base_dir, nickname) artist = is_artist(base_dir, nickname)
@ -1698,7 +1714,7 @@ def html_inbox_media(default_timeline: str,
shared_items_federated_domains, signing_priv_key_pem, shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading, cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts, dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
def html_inbox_blogs(default_timeline: str, def html_inbox_blogs(default_timeline: str,
@ -1731,7 +1747,8 @@ def html_inbox_blogs(default_timeline: str,
timezone: str, bold_reading: bool, timezone: str, bold_reading: bool,
dogwhistles: {}, ua_str: str, dogwhistles: {}, ua_str: str,
min_images_for_accounts: [], min_images_for_accounts: [],
reverse_sequence: bool) -> str: reverse_sequence: bool,
last_post_id: str) -> str:
"""Show the blogs timeline as html """Show the blogs timeline as html
""" """
artist = is_artist(base_dir, nickname) artist = is_artist(base_dir, nickname)
@ -1757,7 +1774,7 @@ def html_inbox_blogs(default_timeline: str,
shared_items_federated_domains, signing_priv_key_pem, shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading, cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts, dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence) reverse_sequence, last_post_id)
def html_inbox_features(default_timeline: str, def html_inbox_features(default_timeline: str,
@ -1816,7 +1833,7 @@ def html_inbox_features(default_timeline: str,
shared_items_federated_domains, signing_priv_key_pem, shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading, cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts, dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence) reverse_sequence, None)
def html_inbox_news(default_timeline: str, def html_inbox_news(default_timeline: str,
@ -1874,7 +1891,7 @@ def html_inbox_news(default_timeline: str,
shared_items_federated_domains, signing_priv_key_pem, shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading, cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts, dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence) reverse_sequence, None)
def html_outbox(default_timeline: str, def html_outbox(default_timeline: str,
@ -1935,4 +1952,4 @@ def html_outbox(default_timeline: str,
shared_items_federated_domains, signing_priv_key_pem, shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading, cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles, ua_str, min_images_for_accounts, dogwhistles, ua_str, min_images_for_accounts,
reverse_sequence) reverse_sequence, None)