mirror of https://gitlab.com/bashrc2/epicyon
merge-requests/30/head
commit
609a118e55
|
@ -123,74 +123,76 @@ def download_conversation_posts(session, http_prefix: str, base_dir: str,
|
||||||
post_filename = \
|
post_filename = \
|
||||||
locate_post(base_dir, nickname, domain, post_id)
|
locate_post(base_dir, nickname, domain, post_id)
|
||||||
if post_filename:
|
if post_filename:
|
||||||
post_json = load_json(post_filename)
|
post_json_object = load_json(post_filename)
|
||||||
else:
|
else:
|
||||||
post_json = get_json(signing_priv_key_pem, session, post_id,
|
post_json_object = \
|
||||||
as_header, None, debug, __version__,
|
get_json(signing_priv_key_pem, session, post_id,
|
||||||
http_prefix, domain)
|
as_header, None, debug, __version__,
|
||||||
|
http_prefix, domain)
|
||||||
if debug:
|
if debug:
|
||||||
if not post_json:
|
if not post_json_object:
|
||||||
print(post_id + ' returned no json')
|
print(post_id + ' returned no json')
|
||||||
while post_json:
|
while post_json_object:
|
||||||
if not isinstance(post_json, dict):
|
if not isinstance(post_json_object, dict):
|
||||||
break
|
break
|
||||||
if not has_object_dict(post_json):
|
if not has_object_dict(post_json_object):
|
||||||
if not post_json.get('attributedTo'):
|
if not post_json_object.get('attributedTo'):
|
||||||
print(str(post_json))
|
print(str(post_json_object))
|
||||||
if debug:
|
if debug:
|
||||||
print(post_id + ' has no attributedTo')
|
print(post_id + ' has no attributedTo')
|
||||||
break
|
break
|
||||||
if not isinstance(post_json['attributedTo'], str):
|
if not isinstance(post_json_object['attributedTo'], str):
|
||||||
break
|
break
|
||||||
if not post_json.get('published'):
|
if not post_json_object.get('published'):
|
||||||
if debug:
|
if debug:
|
||||||
print(post_id + ' has no published date')
|
print(post_id + ' has no published date')
|
||||||
break
|
break
|
||||||
if not post_json.get('to'):
|
if not post_json_object.get('to'):
|
||||||
if debug:
|
if debug:
|
||||||
print(post_id + ' has no "to" list')
|
print(post_id + ' has no "to" list')
|
||||||
break
|
break
|
||||||
if not isinstance(post_json['to'], list):
|
if not isinstance(post_json_object['to'], list):
|
||||||
break
|
break
|
||||||
if 'cc' not in post_json:
|
if 'cc' not in post_json_object:
|
||||||
if debug:
|
if debug:
|
||||||
print(post_id + ' has no "cc" list')
|
print(post_id + ' has no "cc" list')
|
||||||
break
|
break
|
||||||
if not isinstance(post_json['cc'], list):
|
if not isinstance(post_json_object['cc'], list):
|
||||||
break
|
break
|
||||||
wrapped_post = {
|
wrapped_post = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'id': post_id + '/activity',
|
'id': post_id + '/activity',
|
||||||
'type': 'Create',
|
'type': 'Create',
|
||||||
'actor': post_json['attributedTo'],
|
'actor': post_json_object['attributedTo'],
|
||||||
'published': post_json['published'],
|
'published': post_json_object['published'],
|
||||||
'to': post_json['to'],
|
'to': post_json_object['to'],
|
||||||
'cc': post_json['cc'],
|
'cc': post_json_object['cc'],
|
||||||
'object': post_json
|
'object': post_json_object
|
||||||
}
|
}
|
||||||
post_json = wrapped_post
|
post_json_object = wrapped_post
|
||||||
if not post_json['object'].get('published'):
|
if not post_json_object['object'].get('published'):
|
||||||
break
|
break
|
||||||
|
|
||||||
# render harmless any dangerous markup
|
# render harmless any dangerous markup
|
||||||
harmless_markup(post_json)
|
harmless_markup(post_json_object)
|
||||||
|
|
||||||
conversation_view = [post_json] + conversation_view
|
conversation_view = [post_json_object] + conversation_view
|
||||||
if not post_json['object'].get('inReplyTo'):
|
if not post_json_object['object'].get('inReplyTo'):
|
||||||
if debug:
|
if debug:
|
||||||
print(post_id + ' is not a reply')
|
print(post_id + ' is not a reply')
|
||||||
break
|
break
|
||||||
post_id = post_json['object']['inReplyTo']
|
post_id = post_json_object['object']['inReplyTo']
|
||||||
post_id = remove_id_ending(post_id)
|
post_id = remove_id_ending(post_id)
|
||||||
post_filename = \
|
post_filename = \
|
||||||
locate_post(base_dir, nickname, domain, post_id)
|
locate_post(base_dir, nickname, domain, post_id)
|
||||||
if post_filename:
|
if post_filename:
|
||||||
post_json = load_json(post_filename)
|
post_json_object = load_json(post_filename)
|
||||||
else:
|
else:
|
||||||
post_json = get_json(signing_priv_key_pem, session, post_id,
|
post_json_object = \
|
||||||
as_header, None, debug, __version__,
|
get_json(signing_priv_key_pem, session, post_id,
|
||||||
http_prefix, domain)
|
as_header, None, debug, __version__,
|
||||||
|
http_prefix, domain)
|
||||||
if debug:
|
if debug:
|
||||||
if not post_json:
|
if not post_json_object:
|
||||||
print(post_id + ' returned no json')
|
print(post_id + ' returned no json')
|
||||||
return conversation_view
|
return conversation_view
|
||||||
|
|
|
@ -1726,7 +1726,7 @@ h3 {
|
||||||
font-size: var(--font-size-header);
|
font-size: var(--font-size-header);
|
||||||
font-family: 'Arial, Helvetica, sans-serif';
|
font-family: 'Arial, Helvetica, sans-serif';
|
||||||
padding: var(--button-height-padding);
|
padding: var(--button-height-padding);
|
||||||
max-width: 400px;
|
max-width: 80%;
|
||||||
min-width: 80px;
|
min-width: 80px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin: 0 5px;
|
margin: 0 5px;
|
||||||
|
@ -2540,7 +2540,7 @@ h3 {
|
||||||
font-size: var(--font-size3);
|
font-size: var(--font-size3);
|
||||||
font-family: 'Arial, Helvetica, sans-serif';
|
font-family: 'Arial, Helvetica, sans-serif';
|
||||||
padding: var(--button-height-padding-mobile);
|
padding: var(--button-height-padding-mobile);
|
||||||
max-width: 400px;
|
max-width: 80%;
|
||||||
min-width: 80px;
|
min-width: 80px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin: 0 15px;
|
margin: 0 15px;
|
||||||
|
@ -3352,7 +3352,7 @@ h3 {
|
||||||
font-size: var(--font-size3);
|
font-size: var(--font-size3);
|
||||||
font-family: 'Arial, Helvetica, sans-serif';
|
font-family: 'Arial, Helvetica, sans-serif';
|
||||||
padding: var(--button-height-padding-tiny);
|
padding: var(--button-height-padding-tiny);
|
||||||
max-width: 400px;
|
max-width: 80%;
|
||||||
min-width: 80px;
|
min-width: 80px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin: 0 15px;
|
margin: 0 15px;
|
||||||
|
|
|
@ -2729,12 +2729,23 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
|
||||||
by_str_handle = by_str_nickname + '@' + by_str_domain
|
by_str_handle = by_str_nickname + '@' + by_str_domain
|
||||||
if translate.get(by_text):
|
if translate.get(by_text):
|
||||||
by_text = translate[by_text]
|
by_text = translate[by_text]
|
||||||
post_str += \
|
# Liked by handle
|
||||||
'<p>' + by_text + ' <a href="' + by_str + '" tabindex="10">@' + \
|
|
||||||
by_str_handle + '</a>' + by_text_extra + '\n'
|
|
||||||
|
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
actor = '/users/' + nickname
|
actor = '/users/' + nickname
|
||||||
|
post_str += \
|
||||||
|
'<p>' + by_text + ' '
|
||||||
|
post_str += \
|
||||||
|
'<form method="POST" accept-charset="UTF-8" action="' + \
|
||||||
|
actor + '/searchhandle">\n' + \
|
||||||
|
'<input type="hidden" ' + \
|
||||||
|
'name="actor" value="' + actor + '">' + \
|
||||||
|
'<input type="hidden" ' + \
|
||||||
|
'name="searchtext" value="' + by_str + \
|
||||||
|
'"><button type="submit" ' + \
|
||||||
|
'class="followApproveHandle" ' + \
|
||||||
|
'name="submitSearch" tabindex="10">' + \
|
||||||
|
by_str_handle + '</button></form>'
|
||||||
|
post_str += by_text_extra + '\n'
|
||||||
follow_str = ' <form method="POST" ' + \
|
follow_str = ' <form method="POST" ' + \
|
||||||
'accept-charset="UTF-8" action="' + actor + '/searchhandle">\n'
|
'accept-charset="UTF-8" action="' + actor + '/searchhandle">\n'
|
||||||
follow_str += \
|
follow_str += \
|
||||||
|
|
Loading…
Reference in New Issue