mirror of https://gitlab.com/bashrc2/epicyon
Add gemini link to profile
parent
44982265ba
commit
b16f14b478
17
daemon.py
17
daemon.py
|
@ -58,6 +58,8 @@ from donate import get_donation_url
|
|||
from donate import set_donation_url
|
||||
from donate import get_website
|
||||
from donate import set_website
|
||||
from donate import get_gemini_link
|
||||
from donate import set_gemini_link
|
||||
from person import clear_person_qrcodes
|
||||
from person import add_alternate_domains
|
||||
from person import add_actor_update_timestamp
|
||||
|
@ -6452,6 +6454,21 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
set_website(actor_json, '', self.server.translate)
|
||||
actor_changed = True
|
||||
|
||||
# change gemini link
|
||||
current_gemini_link = \
|
||||
get_gemini_link(actor_json, self.server.translate)
|
||||
if fields.get('geminiLink'):
|
||||
if fields['geminiLink'] != current_gemini_link:
|
||||
set_gemini_link(actor_json,
|
||||
fields['geminiLink'],
|
||||
self.server.translate)
|
||||
actor_changed = True
|
||||
else:
|
||||
if current_gemini_link:
|
||||
set_gemini_link(actor_json, '',
|
||||
self.server.translate)
|
||||
actor_changed = True
|
||||
|
||||
# account moved to new address
|
||||
moved_to = ''
|
||||
if actor_json.get('movedTo'):
|
||||
|
|
76
donate.py
76
donate.py
|
@ -21,6 +21,10 @@ def _get_website_strings() -> []:
|
|||
return ['www', 'website', 'web', 'homepage']
|
||||
|
||||
|
||||
def _get_gemini_strings() -> []:
|
||||
return ('gemini', 'capsule', 'gemlog')
|
||||
|
||||
|
||||
def get_donation_url(actor_json: {}) -> str:
|
||||
"""Returns a link used for donations
|
||||
"""
|
||||
|
@ -82,6 +86,34 @@ def get_website(actor_json: {}, translate: {}) -> str:
|
|||
return ''
|
||||
|
||||
|
||||
def get_gemini_link(actor_json: {}, translate: {}) -> str:
|
||||
"""Returns a gemini link
|
||||
"""
|
||||
if not actor_json.get('attachment'):
|
||||
return ''
|
||||
match_strings = _get_gemini_strings()
|
||||
for property_value in actor_json['attachment']:
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if name_value.lower() not in match_strings:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
continue
|
||||
prop_value_name, _ = \
|
||||
get_attachment_property_value(property_value)
|
||||
if not prop_value_name:
|
||||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
return property_value[prop_value_name]
|
||||
return ''
|
||||
|
||||
|
||||
def set_donation_url(actor_json: {}, donate_url: str) -> None:
|
||||
"""Sets a link used for donations
|
||||
"""
|
||||
|
@ -203,3 +235,47 @@ def set_website(actor_json: {}, website_url: str, translate: {}) -> None:
|
|||
"value": website_url
|
||||
}
|
||||
actor_json['attachment'].append(new_entry)
|
||||
|
||||
|
||||
def set_gemini_link(actor_json: {}, gemini_link: str, translate: {}) -> None:
|
||||
"""Sets a gemini link
|
||||
"""
|
||||
gemini_link = gemini_link.strip()
|
||||
not_link = False
|
||||
if '.' not in gemini_link:
|
||||
not_link = True
|
||||
if '://' not in gemini_link:
|
||||
not_link = True
|
||||
if ' ' in gemini_link:
|
||||
not_link = True
|
||||
if '<' in gemini_link:
|
||||
not_link = True
|
||||
|
||||
if not actor_json.get('attachment'):
|
||||
actor_json['attachment'] = []
|
||||
|
||||
match_strings = _get_gemini_strings()
|
||||
match_strings.append('gemini')
|
||||
|
||||
# remove any existing value
|
||||
property_found = None
|
||||
for property_value in actor_json['attachment']:
|
||||
if not property_value.get('name'):
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
continue
|
||||
if property_value['name'].lower() not in match_strings:
|
||||
continue
|
||||
property_found = property_value
|
||||
break
|
||||
if property_found:
|
||||
actor_json['attachment'].remove(property_found)
|
||||
if not_link:
|
||||
return
|
||||
|
||||
new_entry = {
|
||||
"name": 'Gemini',
|
||||
"type": "PropertyValue",
|
||||
"value": gemini_link
|
||||
}
|
||||
actor_json['attachment'].append(new_entry)
|
||||
|
|
|
@ -46,6 +46,7 @@ from posts import parse_user_feed
|
|||
from posts import is_create_inside_announce
|
||||
from donate import get_donation_url
|
||||
from donate import get_website
|
||||
from donate import get_gemini_link
|
||||
from xmpp import get_xmpp_address
|
||||
from matrix import get_matrix_address
|
||||
from ssb import get_ssb_address
|
||||
|
@ -699,6 +700,7 @@ def html_profile(signing_priv_key_pem: str,
|
|||
donate_section = ''
|
||||
donate_url = get_donation_url(profile_json)
|
||||
website_url = get_website(profile_json, translate)
|
||||
gemini_link = get_gemini_link(profile_json, translate)
|
||||
blog_address = get_blog_address(profile_json)
|
||||
enigma_pub_key = get_enigma_pub_key(profile_json)
|
||||
pgp_pub_key = get_pgp_pub_key(profile_json)
|
||||
|
@ -2168,8 +2170,8 @@ def _get_supported_languagesSorted(base_dir: str) -> str:
|
|||
|
||||
def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str,
|
||||
moved_to: str, donate_url: str, website_url: str,
|
||||
blog_address: str, actor_json: {},
|
||||
translate: {},
|
||||
gemini_link: str, blog_address: str,
|
||||
actor_json: {}, translate: {},
|
||||
nickname: str, domain: str) -> str:
|
||||
"""main info on edit profile screen
|
||||
"""
|
||||
|
@ -2225,6 +2227,10 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str,
|
|||
edit_text_field(translate['Website'], 'websiteUrl',
|
||||
website_url, 'https://...')
|
||||
|
||||
edit_profile_form += \
|
||||
edit_text_field('Gemini', 'geminiLink',
|
||||
gemini_link, 'gemini://...')
|
||||
|
||||
edit_profile_form += \
|
||||
edit_text_field('Blog', 'blogAddress', blog_address, 'https://...')
|
||||
|
||||
|
@ -2330,7 +2336,7 @@ def html_edit_profile(server, translate: {},
|
|||
notify_likes = notify_reactions = ''
|
||||
hide_like_button = hide_reaction_button = media_instance_str = ''
|
||||
blogs_instance_str = news_instance_str = moved_to = twitter_str = ''
|
||||
bio_str = donate_url = website_url = email_address = ''
|
||||
bio_str = donate_url = website_url = gemini_link = email_address = ''
|
||||
pgp_pub_key = enigma_pub_key = ''
|
||||
pgp_fingerprint = xmpp_address = matrix_address = ''
|
||||
ssb_address = blog_address = tox_address = ''
|
||||
|
@ -2343,6 +2349,7 @@ def html_edit_profile(server, translate: {},
|
|||
moved_to = actor_json['movedTo']
|
||||
donate_url = get_donation_url(actor_json)
|
||||
website_url = get_website(actor_json, translate)
|
||||
gemini_link = get_gemini_link(actor_json, translate)
|
||||
xmpp_address = get_xmpp_address(actor_json)
|
||||
matrix_address = get_matrix_address(actor_json)
|
||||
ssb_address = get_ssb_address(actor_json)
|
||||
|
@ -2484,6 +2491,7 @@ def html_edit_profile(server, translate: {},
|
|||
edit_profile_form += \
|
||||
_html_edit_profile_main(base_dir, display_nickname, bio_str,
|
||||
moved_to, donate_url, website_url,
|
||||
gemini_link,
|
||||
blog_address, actor_json, translate,
|
||||
nickname, domain)
|
||||
|
||||
|
|
Loading…
Reference in New Issue