mirror of https://gitlab.com/bashrc2/epicyon
Check that type is a string
parent
9d1b20e1e1
commit
f4e8153383
137
webapp_post.py
137
webapp_post.py
|
|
@ -163,7 +163,7 @@ def _get_instance_software_html(title_str: str, software_name: str) -> str:
|
||||||
return ''
|
return ''
|
||||||
if software_name in title_str:
|
if software_name in title_str:
|
||||||
return ''
|
return ''
|
||||||
instance_str = \
|
instance_str: str = \
|
||||||
'<br><label class="instanceSoftware">' + \
|
'<br><label class="instanceSoftware">' + \
|
||||||
'<span itemprop="software">' + \
|
'<span itemprop="software">' + \
|
||||||
software_name + '</span></label>\n'
|
software_name + '</span></label>\n'
|
||||||
|
|
@ -188,14 +188,14 @@ def get_instance_software(base_dir: str, session,
|
||||||
if instance_software.get(instance_domain):
|
if instance_software.get(instance_domain):
|
||||||
return instance_domain + ' ' + instance_software[instance_domain]
|
return instance_domain + ' ' + instance_software[instance_domain]
|
||||||
# get the initial nodeinfo url
|
# get the initial nodeinfo url
|
||||||
nodeinfo1_url = \
|
nodeinfo1_url: str = \
|
||||||
instance_http_prefix + '://' + instance_domain + \
|
instance_http_prefix + '://' + instance_domain + \
|
||||||
'/.well-known/nodeinfo'
|
'/.well-known/nodeinfo'
|
||||||
profile_str = 'https://www.w3.org/ns/activitystreams'
|
profile_str: str = 'https://www.w3.org/ns/activitystreams'
|
||||||
headers = {
|
headers: dict = {
|
||||||
'Accept': 'application/ld+json; profile="' + profile_str + '"'
|
'Accept': 'application/ld+json; profile="' + profile_str + '"'
|
||||||
}
|
}
|
||||||
nodeinfo1_json = \
|
nodeinfo1_json: dict = \
|
||||||
get_json(signing_priv_key_pem,
|
get_json(signing_priv_key_pem,
|
||||||
session, nodeinfo1_url,
|
session, nodeinfo1_url,
|
||||||
headers, None, debug, mitm_servers,
|
headers, None, debug, mitm_servers,
|
||||||
|
|
@ -205,17 +205,17 @@ def get_instance_software(base_dir: str, session,
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG get_instance_software: ' + str(nodeinfo1_json))
|
print('DEBUG get_instance_software: ' + str(nodeinfo1_json))
|
||||||
# get the nodeinfo data
|
# get the nodeinfo data
|
||||||
nodeinfo_url = None
|
nodeinfo_url: str = None
|
||||||
if nodeinfo1_json.get('links'):
|
if nodeinfo1_json.get('links'):
|
||||||
if isinstance(nodeinfo1_json['links'], list):
|
if isinstance(nodeinfo1_json['links'], list):
|
||||||
if nodeinfo1_json['links']:
|
if nodeinfo1_json['links']:
|
||||||
if nodeinfo1_json['links'][0].get('href'):
|
if nodeinfo1_json['links'][0].get('href'):
|
||||||
href = nodeinfo1_json['links'][0]['href']
|
href: str = nodeinfo1_json['links'][0]['href']
|
||||||
if isinstance(href, str):
|
if isinstance(href, str):
|
||||||
nodeinfo_url = href
|
nodeinfo_url = href
|
||||||
if not nodeinfo_url:
|
if not nodeinfo_url:
|
||||||
return ''
|
return ''
|
||||||
nodeinfo_json = \
|
nodeinfo_json: dict = \
|
||||||
get_json(signing_priv_key_pem,
|
get_json(signing_priv_key_pem,
|
||||||
session, nodeinfo_url,
|
session, nodeinfo_url,
|
||||||
headers, None, debug, mitm_servers,
|
headers, None, debug, mitm_servers,
|
||||||
|
|
@ -230,13 +230,13 @@ def get_instance_software(base_dir: str, session,
|
||||||
return ''
|
return ''
|
||||||
if not nodeinfo_json['software'].get('name'):
|
if not nodeinfo_json['software'].get('name'):
|
||||||
return ''
|
return ''
|
||||||
software_name = nodeinfo_json['software']['name']
|
software_name: str = nodeinfo_json['software']['name']
|
||||||
if not isinstance(software_name, str):
|
if not isinstance(software_name, str):
|
||||||
return ''
|
return ''
|
||||||
software_name = remove_html(software_name)
|
software_name = remove_html(software_name)
|
||||||
instance_software[instance_domain] = software_name
|
instance_software[instance_domain] = software_name
|
||||||
if store:
|
if store:
|
||||||
instance_software_filename = \
|
instance_software_filename: str = \
|
||||||
data_dir(base_dir) + '/instance_software.json'
|
data_dir(base_dir) + '/instance_software.json'
|
||||||
save_json(instance_software, instance_software_filename)
|
save_json(instance_software, instance_software_filename)
|
||||||
return instance_domain + ' ' + software_name
|
return instance_domain + ' ' + software_name
|
||||||
|
|
@ -250,7 +250,7 @@ def _enforce_max_display_name_length(display_name: str) -> str:
|
||||||
return display_name
|
return display_name
|
||||||
|
|
||||||
if ':' in display_name:
|
if ':' in display_name:
|
||||||
display_name_short = display_name.split(':')[0].strip()
|
display_name_short: str = display_name.split(':')[0].strip()
|
||||||
if len(display_name_short) > 2:
|
if len(display_name_short) > 2:
|
||||||
display_name = display_name_short
|
display_name = display_name_short
|
||||||
|
|
||||||
|
|
@ -264,7 +264,7 @@ def _html_post_metadata_open_graph(domain: str, post_json_object: {},
|
||||||
system_language: str) -> str:
|
system_language: str) -> str:
|
||||||
"""Returns html OpenGraph metadata for a post
|
"""Returns html OpenGraph metadata for a post
|
||||||
"""
|
"""
|
||||||
metadata = \
|
metadata: str = \
|
||||||
" <link rel=\"schema.DC\" " + \
|
" <link rel=\"schema.DC\" " + \
|
||||||
"href=\"http://purl.org/dc/elements/1.1/\" />\n"
|
"href=\"http://purl.org/dc/elements/1.1/\" />\n"
|
||||||
metadata += \
|
metadata += \
|
||||||
|
|
@ -274,7 +274,7 @@ def _html_post_metadata_open_graph(domain: str, post_json_object: {},
|
||||||
" <meta content=\"" + domain + "\" property=\"og:site_name\" />\n"
|
" <meta content=\"" + domain + "\" property=\"og:site_name\" />\n"
|
||||||
metadata += \
|
metadata += \
|
||||||
" <meta content=\"article\" property=\"og:type\" />\n"
|
" <meta content=\"article\" property=\"og:type\" />\n"
|
||||||
obj_json = post_json_object
|
obj_json: dict = post_json_object
|
||||||
if has_object_dict(post_json_object):
|
if has_object_dict(post_json_object):
|
||||||
obj_json = post_json_object['object']
|
obj_json = post_json_object['object']
|
||||||
if obj_json.get('id'):
|
if obj_json.get('id'):
|
||||||
|
|
@ -284,13 +284,13 @@ def _html_post_metadata_open_graph(domain: str, post_json_object: {},
|
||||||
metadata += " <meta name=\"DC.title\" " + \
|
metadata += " <meta name=\"DC.title\" " + \
|
||||||
"content=\"" + obj_json['summary'] + "\">\n"
|
"content=\"" + obj_json['summary'] + "\">\n"
|
||||||
if obj_json.get('attributedTo'):
|
if obj_json.get('attributedTo'):
|
||||||
attrib_str = get_attributed_to(obj_json['attributedTo'])
|
attrib_str: str = get_attributed_to(obj_json['attributedTo'])
|
||||||
if attrib_str:
|
if attrib_str:
|
||||||
attrib = attrib_str
|
attrib = attrib_str
|
||||||
actor_nick = get_nickname_from_actor(attrib)
|
actor_nick: str = get_nickname_from_actor(attrib)
|
||||||
actor_domain, _ = get_domain_from_actor(attrib)
|
actor_domain, _ = get_domain_from_actor(attrib)
|
||||||
if actor_nick and actor_domain:
|
if actor_nick and actor_domain:
|
||||||
actor_handle = actor_nick + '@' + actor_domain
|
actor_handle: str = actor_nick + '@' + actor_domain
|
||||||
metadata += \
|
metadata += \
|
||||||
" <meta name=\"DC.creator\" " + \
|
" <meta name=\"DC.creator\" " + \
|
||||||
"scheme=\"DCTERMS.URI\" content=\"" + \
|
"scheme=\"DCTERMS.URI\" content=\"" + \
|
||||||
|
|
@ -299,8 +299,8 @@ def _html_post_metadata_open_graph(domain: str, post_json_object: {},
|
||||||
" <meta content=\"@" + actor_handle + \
|
" <meta content=\"@" + actor_handle + \
|
||||||
"\" property=\"og:title\" />\n"
|
"\" property=\"og:title\" />\n"
|
||||||
if obj_json.get('url'):
|
if obj_json.get('url'):
|
||||||
url_str = get_url_from_post(obj_json['url'])
|
url_str: str = get_url_from_post(obj_json['url'])
|
||||||
obj_url = remove_html(url_str)
|
obj_url: str = remove_html(url_str)
|
||||||
metadata += \
|
metadata += \
|
||||||
" <meta content=\"" + obj_url + \
|
" <meta content=\"" + obj_url + \
|
||||||
"\" property=\"og:url\" />\n"
|
"\" property=\"og:url\" />\n"
|
||||||
|
|
@ -314,11 +314,11 @@ def _html_post_metadata_open_graph(domain: str, post_json_object: {},
|
||||||
post_attachments = get_post_attachments(obj_json)
|
post_attachments = get_post_attachments(obj_json)
|
||||||
if not post_attachments or obj_json.get('sensitive'):
|
if not post_attachments or obj_json.get('sensitive'):
|
||||||
if 'content' in obj_json and not obj_json.get('sensitive'):
|
if 'content' in obj_json and not obj_json.get('sensitive'):
|
||||||
obj_content = obj_json['content']
|
obj_content: str = obj_json['content']
|
||||||
if 'contentMap' in obj_json:
|
if 'contentMap' in obj_json:
|
||||||
if obj_json['contentMap'].get(system_language):
|
if obj_json['contentMap'].get(system_language):
|
||||||
obj_content = obj_json['contentMap'][system_language]
|
obj_content = obj_json['contentMap'][system_language]
|
||||||
description = remove_html(obj_content)
|
description: str = remove_html(obj_content)
|
||||||
metadata += \
|
metadata += \
|
||||||
" <meta content=\"" + description + \
|
" <meta content=\"" + description + \
|
||||||
"\" name=\"description\">\n"
|
"\" name=\"description\">\n"
|
||||||
|
|
@ -337,7 +337,7 @@ def _html_post_metadata_open_graph(domain: str, post_json_object: {},
|
||||||
continue
|
continue
|
||||||
if not attach_json.get('name'):
|
if not attach_json.get('name'):
|
||||||
continue
|
continue
|
||||||
description = None
|
description: str = None
|
||||||
if attach_json['mediaType'].startswith('image/'):
|
if attach_json['mediaType'].startswith('image/'):
|
||||||
description = 'Attached: 1 image'
|
description = 'Attached: 1 image'
|
||||||
elif attach_json['mediaType'].startswith('video/'):
|
elif attach_json['mediaType'].startswith('video/'):
|
||||||
|
|
@ -389,7 +389,7 @@ def _log_post_timing(enable_timing_log: bool, post_start_time,
|
||||||
"""
|
"""
|
||||||
if not enable_timing_log:
|
if not enable_timing_log:
|
||||||
return
|
return
|
||||||
time_diff = int((time.time() - post_start_time) * 1000)
|
time_diff: int = int((time.time() - post_start_time) * 1000)
|
||||||
if time_diff > 100:
|
if time_diff > 100:
|
||||||
print('TIMING INDIV ' + debug_id + ' = ' + str(time_diff))
|
print('TIMING INDIV ' + debug_id + ' = ' + str(time_diff))
|
||||||
|
|
||||||
|
|
@ -404,12 +404,12 @@ def prepare_html_post_nickname(nickname: str, post_html: str) -> str:
|
||||||
This function changes the nicknames for the icon links.
|
This function changes the nicknames for the icon links.
|
||||||
"""
|
"""
|
||||||
# replace the nickname
|
# replace the nickname
|
||||||
users_str = ' href="/users/'
|
users_str: str = ' href="/users/'
|
||||||
if users_str not in post_html:
|
if users_str not in post_html:
|
||||||
return post_html
|
return post_html
|
||||||
|
|
||||||
user_found = True
|
user_found: bool = True
|
||||||
post_str = post_html
|
post_str: str = post_html
|
||||||
new_post_str: str = ''
|
new_post_str: str = ''
|
||||||
while user_found:
|
while user_found:
|
||||||
if users_str not in post_str:
|
if users_str not in post_str:
|
||||||
|
|
@ -437,11 +437,11 @@ def replace_link_variable(link: str, variable_name: str, value: str,
|
||||||
separator: str) -> str:
|
separator: str) -> str:
|
||||||
"""Replaces a variable within the given link
|
"""Replaces a variable within the given link
|
||||||
"""
|
"""
|
||||||
full_var = separator + variable_name + '='
|
full_var: str = separator + variable_name + '='
|
||||||
if full_var not in link:
|
if full_var not in link:
|
||||||
return link
|
return link
|
||||||
|
|
||||||
curr_str = link
|
curr_str: str = link
|
||||||
result: str = ''
|
result: str = ''
|
||||||
while full_var in curr_str:
|
while full_var in curr_str:
|
||||||
prefix = curr_str.split(full_var, 1)[0] + full_var
|
prefix = curr_str.split(full_var, 1)[0] + full_var
|
||||||
|
|
@ -470,8 +470,8 @@ def _prepare_media_post_from_html_cache(post_html: str,
|
||||||
if ending_tag not in section_str:
|
if ending_tag not in section_str:
|
||||||
new_post_html += section_str
|
new_post_html += section_str
|
||||||
continue
|
continue
|
||||||
markup = section_str.split(ending_tag)[0]
|
markup: str = section_str.split(ending_tag)[0]
|
||||||
ending = section_str.split(ending_tag)[1]
|
ending: str = section_str.split(ending_tag)[1]
|
||||||
url: str = ''
|
url: str = ''
|
||||||
description: str = ''
|
description: str = ''
|
||||||
# get the video/audio url if it exists
|
# get the video/audio url if it exists
|
||||||
|
|
@ -530,14 +530,14 @@ def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str,
|
||||||
post_html.replace('?page=' + page_number_str, '?page=-999')
|
post_html.replace('?page=' + page_number_str, '?page=-999')
|
||||||
|
|
||||||
# add the page number
|
# add the page number
|
||||||
with_page_number = \
|
with_page_number: str = \
|
||||||
post_html.replace(';-999;', ';' + str(page_number) + ';')
|
post_html.replace(';-999;', ';' + str(page_number) + ';')
|
||||||
with_page_number = \
|
with_page_number = \
|
||||||
with_page_number.replace('?page=-999', '?page=' + str(page_number))
|
with_page_number.replace('?page=-999', '?page=' + str(page_number))
|
||||||
|
|
||||||
# add first post in the timeline
|
# add first post in the timeline
|
||||||
if first_post_id is None:
|
if first_post_id is None:
|
||||||
first_post_id: str = ''
|
first_post_id = ''
|
||||||
|
|
||||||
first_post_id = first_post_id.replace('#', '/')
|
first_post_id = first_post_id.replace('#', '/')
|
||||||
if '?firstpost=' in with_page_number:
|
if '?firstpost=' in with_page_number:
|
||||||
|
|
@ -564,9 +564,9 @@ def _save_individual_post_as_html_to_cache(base_dir: str,
|
||||||
This is so that it can be quickly reloaded on subsequent
|
This is so that it can be quickly reloaded on subsequent
|
||||||
refresh of the timeline
|
refresh of the timeline
|
||||||
"""
|
"""
|
||||||
html_post_cache_dir = \
|
html_post_cache_dir: str = \
|
||||||
get_cached_post_directory(base_dir, nickname, domain)
|
get_cached_post_directory(base_dir, nickname, domain)
|
||||||
cached_post_filename = \
|
cached_post_filename: str = \
|
||||||
get_cached_post_filename(base_dir, nickname, domain, post_json_object)
|
get_cached_post_filename(base_dir, nickname, domain, post_json_object)
|
||||||
if not cached_post_filename:
|
if not cached_post_filename:
|
||||||
return False
|
return False
|
||||||
|
|
@ -633,7 +633,7 @@ def _get_post_from_recent_cache(session,
|
||||||
|
|
||||||
_log_post_timing(enable_timing_log, post_start_time, '2.2')
|
_log_post_timing(enable_timing_log, post_start_time, '2.2')
|
||||||
|
|
||||||
post_html = \
|
post_html: str = \
|
||||||
load_individual_post_as_html_from_cache(base_dir, nickname, domain,
|
load_individual_post_as_html_from_cache(base_dir, nickname, domain,
|
||||||
post_json_object)
|
post_json_object)
|
||||||
if not post_html:
|
if not post_html:
|
||||||
|
|
@ -665,7 +665,7 @@ def _get_avatar_image_html(show_avatar_options: bool,
|
||||||
avatar_link = \
|
avatar_link = \
|
||||||
' <a class="imageAnchor" href="' + \
|
' <a class="imageAnchor" href="' + \
|
||||||
post_actor + '" tabindex="10">'
|
post_actor + '" tabindex="10">'
|
||||||
show_profile_str = 'Show profile'
|
show_profile_str: str = 'Show profile'
|
||||||
if translate.get(show_profile_str):
|
if translate.get(show_profile_str):
|
||||||
show_profile_str = translate[show_profile_str]
|
show_profile_str = translate[show_profile_str]
|
||||||
avatar_link += \
|
avatar_link += \
|
||||||
|
|
@ -739,7 +739,8 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
|
||||||
attrib = get_attributed_to(post_json_object['object']['attributedTo'])
|
attrib = get_attributed_to(post_json_object['object']['attributedTo'])
|
||||||
if attrib:
|
if attrib:
|
||||||
reply_to_link += '?mention=' + attrib
|
reply_to_link += '?mention=' + attrib
|
||||||
content = get_base_content_from_post(post_json_object, system_language)
|
content: str = \
|
||||||
|
get_base_content_from_post(post_json_object, system_language)
|
||||||
if content:
|
if content:
|
||||||
mentioned_actors = \
|
mentioned_actors = \
|
||||||
get_mentions_from_html(content,
|
get_mentions_from_html(content,
|
||||||
|
|
@ -823,7 +824,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
|
||||||
"""Returns html for the edit icon/button
|
"""Returns html for the edit icon/button
|
||||||
"""
|
"""
|
||||||
edit_str: str = ''
|
edit_str: str = ''
|
||||||
actor = get_actor_from_post(post_json_object)
|
actor: str = get_actor_from_post(post_json_object)
|
||||||
# This should either be a post which you created,
|
# This should either be a post which you created,
|
||||||
# or it could be generated from the newswire (see
|
# or it could be generated from the newswire (see
|
||||||
# _add_blogs_to_newswire) in which case anyone with
|
# _add_blogs_to_newswire) in which case anyone with
|
||||||
|
|
@ -832,13 +833,13 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
|
||||||
(is_editor(base_dir, nickname) and
|
(is_editor(base_dir, nickname) and
|
||||||
actor.endswith('/' + domain_full + '/users/news'))):
|
actor.endswith('/' + domain_full + '/users/news'))):
|
||||||
|
|
||||||
post_id = remove_id_ending(post_json_object['object']['id'])
|
post_id: str = remove_id_ending(post_json_object['object']['id'])
|
||||||
|
|
||||||
if '/statuses/' not in post_id:
|
if '/statuses/' not in post_id:
|
||||||
return edit_str
|
return edit_str
|
||||||
|
|
||||||
reply_to: str = ''
|
reply_to: str = ''
|
||||||
reply_id = get_reply_to(post_json_object['object'])
|
reply_id: str = get_reply_to(post_json_object['object'])
|
||||||
if reply_id:
|
if reply_id:
|
||||||
reply_to = ';replyTo=' + reply_id
|
reply_to = ';replyTo=' + reply_id
|
||||||
|
|
||||||
|
|
@ -847,7 +848,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
|
||||||
first_post_str = ';firstpost=' + first_post_id
|
first_post_str = ';firstpost=' + first_post_id
|
||||||
|
|
||||||
if is_blog_post(post_json_object):
|
if is_blog_post(post_json_object):
|
||||||
edit_blog_post_str = 'Edit blog post'
|
edit_blog_post_str: str = 'Edit blog post'
|
||||||
if translate.get(edit_blog_post_str):
|
if translate.get(edit_blog_post_str):
|
||||||
edit_blog_post_str = translate[edit_blog_post_str]
|
edit_blog_post_str = translate[edit_blog_post_str]
|
||||||
if not is_news_post(post_json_object):
|
if not is_news_post(post_json_object):
|
||||||
|
|
@ -873,7 +874,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
|
||||||
edit_blog_post_str + '" alt="' + edit_blog_post_str + \
|
edit_blog_post_str + '" alt="' + edit_blog_post_str + \
|
||||||
' |" src="/icons/edit.png"/></a>\n'
|
' |" src="/icons/edit.png"/></a>\n'
|
||||||
elif is_event:
|
elif is_event:
|
||||||
edit_event_str = 'Edit event'
|
edit_event_str: str = 'Edit event'
|
||||||
if translate.get(edit_event_str):
|
if translate.get(edit_event_str):
|
||||||
edit_event_str = translate[edit_event_str]
|
edit_event_str = translate[edit_event_str]
|
||||||
edit_str += \
|
edit_str += \
|
||||||
|
|
@ -888,7 +889,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
|
||||||
' |" src="/icons/edit.png"/></a>\n'
|
' |" src="/icons/edit.png"/></a>\n'
|
||||||
elif is_public_post(post_json_object):
|
elif is_public_post(post_json_object):
|
||||||
# Edit a public post
|
# Edit a public post
|
||||||
edit_post_str = 'Edit post'
|
edit_post_str: str = 'Edit post'
|
||||||
if translate.get(edit_post_str):
|
if translate.get(edit_post_str):
|
||||||
edit_post_str = translate[edit_post_str]
|
edit_post_str = translate[edit_post_str]
|
||||||
edit_str += \
|
edit_str += \
|
||||||
|
|
@ -903,7 +904,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
|
||||||
' |" src="/icons/edit.png"/></a>\n'
|
' |" src="/icons/edit.png"/></a>\n'
|
||||||
elif is_reminder(post_json_object):
|
elif is_reminder(post_json_object):
|
||||||
# Edit a reminder
|
# Edit a reminder
|
||||||
edit_post_str = 'Edit reminder'
|
edit_post_str: str = 'Edit reminder'
|
||||||
if translate.get(edit_post_str):
|
if translate.get(edit_post_str):
|
||||||
edit_post_str = translate[edit_post_str]
|
edit_post_str = translate[edit_post_str]
|
||||||
edit_str += \
|
edit_str += \
|
||||||
|
|
@ -918,7 +919,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
|
||||||
' |" src="/icons/edit.png"/></a>\n'
|
' |" src="/icons/edit.png"/></a>\n'
|
||||||
elif is_dm(post_json_object):
|
elif is_dm(post_json_object):
|
||||||
# Edit a DM
|
# Edit a DM
|
||||||
edit_post_str = 'Edit post'
|
edit_post_str: str = 'Edit post'
|
||||||
if translate.get(edit_post_str):
|
if translate.get(edit_post_str):
|
||||||
edit_post_str = translate[edit_post_str]
|
edit_post_str = translate[edit_post_str]
|
||||||
edit_str += \
|
edit_str += \
|
||||||
|
|
@ -933,7 +934,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
|
||||||
' |" src="/icons/edit.png"/></a>\n'
|
' |" src="/icons/edit.png"/></a>\n'
|
||||||
elif is_unlisted_post(post_json_object):
|
elif is_unlisted_post(post_json_object):
|
||||||
# Edit an unlisted post
|
# Edit an unlisted post
|
||||||
edit_post_str = 'Edit post'
|
edit_post_str: str = 'Edit post'
|
||||||
if translate.get(edit_post_str):
|
if translate.get(edit_post_str):
|
||||||
edit_post_str = translate[edit_post_str]
|
edit_post_str = translate[edit_post_str]
|
||||||
edit_str += \
|
edit_str += \
|
||||||
|
|
@ -948,7 +949,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
|
||||||
' |" src="/icons/edit.png"/></a>\n'
|
' |" src="/icons/edit.png"/></a>\n'
|
||||||
elif is_followers_post(post_json_object):
|
elif is_followers_post(post_json_object):
|
||||||
# Edit a followers only post
|
# Edit a followers only post
|
||||||
edit_post_str = 'Edit post'
|
edit_post_str: str = 'Edit post'
|
||||||
if translate.get(edit_post_str):
|
if translate.get(edit_post_str):
|
||||||
edit_post_str = translate[edit_post_str]
|
edit_post_str = translate[edit_post_str]
|
||||||
edit_str += \
|
edit_str += \
|
||||||
|
|
@ -990,17 +991,17 @@ def _get_announce_icon_html(is_announced: bool,
|
||||||
return announce_str
|
return announce_str
|
||||||
|
|
||||||
# don't allow announce/repeat of your own posts
|
# don't allow announce/repeat of your own posts
|
||||||
announce_icon = 'repeat_inactive.png'
|
announce_icon: str = 'repeat_inactive.png'
|
||||||
announce_link = 'repeat'
|
announce_link: str = 'repeat'
|
||||||
announce_emoji: str = ''
|
announce_emoji: str = ''
|
||||||
if not is_public_repeat:
|
if not is_public_repeat:
|
||||||
announce_link = 'repeatprivate'
|
announce_link = 'repeatprivate'
|
||||||
repeat_this_post_str = 'Repeat this post'
|
repeat_this_post_str: str = 'Repeat this post'
|
||||||
if translate.get(repeat_this_post_str):
|
if translate.get(repeat_this_post_str):
|
||||||
repeat_this_post_str = translate[repeat_this_post_str]
|
repeat_this_post_str = translate[repeat_this_post_str]
|
||||||
announce_title = repeat_this_post_str
|
announce_title: str = repeat_this_post_str
|
||||||
unannounce_link_str: str = ''
|
unannounce_link_str: str = ''
|
||||||
announce_count = no_of_announces(post_json_object)
|
announce_count: int = no_of_announces(post_json_object)
|
||||||
|
|
||||||
announce_count_str: str = ''
|
announce_count_str: str = ''
|
||||||
if announce_count > 0:
|
if announce_count > 0:
|
||||||
|
|
@ -1083,13 +1084,13 @@ def _get_like_icon_html(nickname: str, domain_full: str,
|
||||||
if not show_like_button or is_moderation_post:
|
if not show_like_button or is_moderation_post:
|
||||||
return ''
|
return ''
|
||||||
like_str: str = ''
|
like_str: str = ''
|
||||||
like_icon = 'like_inactive.png'
|
like_icon: str = 'like_inactive.png'
|
||||||
like_link = 'like'
|
like_link: str = 'like'
|
||||||
like_title = 'Like this post'
|
like_title: str = 'Like this post'
|
||||||
if translate.get(like_title):
|
if translate.get(like_title):
|
||||||
like_title = translate[like_title]
|
like_title = translate[like_title]
|
||||||
like_emoji: str = ''
|
like_emoji: str = ''
|
||||||
like_count = no_of_likes(post_json_object)
|
like_count: int = no_of_likes(post_json_object)
|
||||||
|
|
||||||
_log_post_timing(enable_timing_log, post_start_time, '12.1')
|
_log_post_timing(enable_timing_log, post_start_time, '12.1')
|
||||||
|
|
||||||
|
|
@ -1176,10 +1177,10 @@ def _get_bookmark_icon_html(base_dir: str,
|
||||||
if not locate_post(base_dir, nickname, domain, post_url):
|
if not locate_post(base_dir, nickname, domain, post_url):
|
||||||
return bookmark_str
|
return bookmark_str
|
||||||
|
|
||||||
bookmark_icon = 'bookmark_inactive.png'
|
bookmark_icon: str = 'bookmark_inactive.png'
|
||||||
bookmark_link = 'bookmark'
|
bookmark_link: str = 'bookmark'
|
||||||
bookmark_emoji: str = ''
|
bookmark_emoji: str = ''
|
||||||
bookmark_title = 'Bookmark this post'
|
bookmark_title: str = 'Bookmark this post'
|
||||||
if translate.get(bookmark_title):
|
if translate.get(bookmark_title):
|
||||||
bookmark_title = translate[bookmark_title]
|
bookmark_title = translate[bookmark_title]
|
||||||
if bookmarked_by_person(post_json_object, nickname, domain_full):
|
if bookmarked_by_person(post_json_object, nickname, domain_full):
|
||||||
|
|
@ -1190,7 +1191,7 @@ def _get_bookmark_icon_html(base_dir: str,
|
||||||
if translate.get(bookmark_title):
|
if translate.get(bookmark_title):
|
||||||
bookmark_title = translate[bookmark_title]
|
bookmark_title = translate[bookmark_title]
|
||||||
_log_post_timing(enable_timing_log, post_start_time, '12.6')
|
_log_post_timing(enable_timing_log, post_start_time, '12.6')
|
||||||
bookmark_post_id = \
|
bookmark_post_id: str = \
|
||||||
remove_hash_from_post_id(post_json_object['object']['id'])
|
remove_hash_from_post_id(post_json_object['object']['id'])
|
||||||
bookmark_post_id = remove_id_ending(bookmark_post_id)
|
bookmark_post_id = remove_id_ending(bookmark_post_id)
|
||||||
|
|
||||||
|
|
@ -1198,8 +1199,8 @@ def _get_bookmark_icon_html(base_dir: str,
|
||||||
if first_post_id:
|
if first_post_id:
|
||||||
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
|
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
|
||||||
|
|
||||||
actor_url = get_actor_from_post(post_json_object)
|
actor_url: str = get_actor_from_post(post_json_object)
|
||||||
bookmark_str = \
|
bookmark_str: str = \
|
||||||
' <a class="imageAnchor" href="/users/' + nickname + '?' + \
|
' <a class="imageAnchor" href="/users/' + nickname + '?' + \
|
||||||
bookmark_link + '=' + bookmark_post_id + \
|
bookmark_link + '=' + bookmark_post_id + \
|
||||||
page_number_param + \
|
page_number_param + \
|
||||||
|
|
@ -1232,12 +1233,12 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {},
|
||||||
if not show_reaction_button or is_moderation_post:
|
if not show_reaction_button or is_moderation_post:
|
||||||
return reaction_str
|
return reaction_str
|
||||||
|
|
||||||
reaction_icon = 'reaction.png'
|
reaction_icon: str = 'reaction.png'
|
||||||
reaction_title = 'Select reaction'
|
reaction_title: str = 'Select reaction'
|
||||||
if translate.get(reaction_title):
|
if translate.get(reaction_title):
|
||||||
reaction_title = translate[reaction_title]
|
reaction_title = translate[reaction_title]
|
||||||
_log_post_timing(enable_timing_log, post_start_time, '12.65')
|
_log_post_timing(enable_timing_log, post_start_time, '12.65')
|
||||||
reaction_post_id = \
|
reaction_post_id: str = \
|
||||||
remove_hash_from_post_id(post_json_object['object']['id'])
|
remove_hash_from_post_id(post_json_object['object']['id'])
|
||||||
reaction_post_id = remove_id_ending(reaction_post_id)
|
reaction_post_id = remove_id_ending(reaction_post_id)
|
||||||
|
|
||||||
|
|
@ -1245,8 +1246,8 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {},
|
||||||
if first_post_id:
|
if first_post_id:
|
||||||
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
|
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
|
||||||
|
|
||||||
actor_url = get_actor_from_post(post_json_object)
|
actor_url: str = get_actor_from_post(post_json_object)
|
||||||
reaction_str = \
|
reaction_str: str = \
|
||||||
' <a class="imageAnchor" href="/users/' + nickname + \
|
' <a class="imageAnchor" href="/users/' + nickname + \
|
||||||
'?selreact=' + reaction_post_id + page_number_param + \
|
'?selreact=' + reaction_post_id + page_number_param + \
|
||||||
'?actor=' + actor_url + \
|
'?actor=' + actor_url + \
|
||||||
|
|
@ -1285,7 +1286,7 @@ def _get_mute_icon_html(is_muted: bool,
|
||||||
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
|
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
|
||||||
|
|
||||||
if not is_muted:
|
if not is_muted:
|
||||||
mute_this_post_str = 'Mute this post'
|
mute_this_post_str: str = 'Mute this post'
|
||||||
if translate.get('Mute this post'):
|
if translate.get('Mute this post'):
|
||||||
mute_this_post_str = translate[mute_this_post_str]
|
mute_this_post_str = translate[mute_this_post_str]
|
||||||
mute_str = \
|
mute_str = \
|
||||||
|
|
@ -1300,7 +1301,7 @@ def _get_mute_icon_html(is_muted: bool,
|
||||||
' |" title="' + mute_this_post_str + \
|
' |" title="' + mute_this_post_str + \
|
||||||
'" src="/icons/mute.png"/></a>\n'
|
'" src="/icons/mute.png"/></a>\n'
|
||||||
else:
|
else:
|
||||||
undo_mute_str = 'Undo mute'
|
undo_mute_str: str = 'Undo mute'
|
||||||
if translate.get(undo_mute_str):
|
if translate.get(undo_mute_str):
|
||||||
undo_mute_str = translate[undo_mute_str]
|
undo_mute_str = translate[undo_mute_str]
|
||||||
mute_str = \
|
mute_str = \
|
||||||
|
|
|
||||||
10
website.py
10
website.py
|
|
@ -63,6 +63,8 @@ def get_website(actor_json: {}, translate: {}) -> str:
|
||||||
continue
|
continue
|
||||||
if not property_value.get('type'):
|
if not property_value.get('type'):
|
||||||
continue
|
continue
|
||||||
|
if not isinstance(property_value['type'], str):
|
||||||
|
continue
|
||||||
prop_value_name, _ = \
|
prop_value_name, _ = \
|
||||||
get_attachment_property_value(property_value)
|
get_attachment_property_value(property_value)
|
||||||
if not prop_value_name:
|
if not prop_value_name:
|
||||||
|
|
@ -102,6 +104,8 @@ def get_gemini_link(actor_json: {}) -> str:
|
||||||
continue
|
continue
|
||||||
if not property_value.get('type'):
|
if not property_value.get('type'):
|
||||||
continue
|
continue
|
||||||
|
if not isinstance(property_value['type'], str):
|
||||||
|
continue
|
||||||
prop_value_name, _ = \
|
prop_value_name, _ = \
|
||||||
get_attachment_property_value(property_value)
|
get_attachment_property_value(property_value)
|
||||||
if not prop_value_name:
|
if not prop_value_name:
|
||||||
|
|
@ -117,6 +121,8 @@ def get_gemini_link(actor_json: {}) -> str:
|
||||||
continue
|
continue
|
||||||
if not property_value.get('type'):
|
if not property_value.get('type'):
|
||||||
continue
|
continue
|
||||||
|
if not isinstance(property_value['type'], str):
|
||||||
|
continue
|
||||||
prop_value_name, _ = \
|
prop_value_name, _ = \
|
||||||
get_attachment_property_value(property_value)
|
get_attachment_property_value(property_value)
|
||||||
if not prop_value_name:
|
if not prop_value_name:
|
||||||
|
|
@ -162,6 +168,8 @@ def set_website(actor_json: {}, website_url: str, translate: {}) -> None:
|
||||||
continue
|
continue
|
||||||
if not property_value.get('type'):
|
if not property_value.get('type'):
|
||||||
continue
|
continue
|
||||||
|
if not isinstance(property_value['type'], str):
|
||||||
|
continue
|
||||||
if property_value['name'].lower() not in match_strings:
|
if property_value['name'].lower() not in match_strings:
|
||||||
continue
|
continue
|
||||||
property_found = property_value
|
property_found = property_value
|
||||||
|
|
@ -210,6 +218,8 @@ def set_gemini_link(actor_json: {}, gemini_link: str) -> None:
|
||||||
continue
|
continue
|
||||||
if not property_value.get('type'):
|
if not property_value.get('type'):
|
||||||
continue
|
continue
|
||||||
|
if not isinstance(property_value['type'], str):
|
||||||
|
continue
|
||||||
if property_value['name'].lower() not in match_strings:
|
if property_value['name'].lower() not in match_strings:
|
||||||
continue
|
continue
|
||||||
property_found = property_value
|
property_found = property_value
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue