From a1b8e084921ca8d225c72599654c5b85d5f505d2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 19 May 2023 21:44:43 +0100 Subject: [PATCH] Link to blog on profile screen --- blog.py | 11 +++++++++++ webapp_profile.py | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/blog.py b/blog.py index b2e9b0ed1..6c9462bbb 100644 --- a/blog.py +++ b/blog.py @@ -950,3 +950,14 @@ def get_blog_address(actor_json: {}) -> str: if not result: result = get_actor_property_url(actor_json, 'My Blog') return result + + +def account_has_blog(base_dir: str, nickname: str, domain: str) -> bool: + """Returns true if the given account has a blog + """ + blogs_dir = acct_dir(base_dir, nickname, domain) + '/tlblogs' + if os.path.isdir(blogs_dir): + for path in os.listdir(blogs_dir): + if path.endswith('.json'): + return True + return False diff --git a/webapp_profile.py b/webapp_profile.py index cd788175e..9e097c179 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -84,6 +84,7 @@ from webapp_utils import edit_text_area from webapp_utils import begin_edit_section from webapp_utils import end_edit_section from blog import get_blog_address +from blog import account_has_blog from webapp_post import individual_post_as_html from webapp_timeline import html_individual_share from webapp_timeline import page_number_buttons @@ -531,10 +532,21 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str, html_str += \ '

@' + nickname + '@' + domain_full + \ actor_proxied + '
\n' + has_blog = account_has_blog(base_dir, nickname, domain) + acct_blog_str = '' + if has_blog: + acct_blog_str = \ + '📖' if joined_date: + html_str += '

' + if has_blog: + html_str += acct_blog_str + ' ' html_str += \ - '

' + translate['Joined'] + ' ' + \ + translate['Joined'] + ' ' + \ joined_date.split('T')[0] + '
\n' + elif has_blog: + html_str += '

' + acct_blog_str + '
\n' if moved_to: new_nickname = get_nickname_from_actor(moved_to) new_domain, new_port = get_domain_from_actor(moved_to)