mirror of https://git.skyjake.fi/gemini/bubble.git
Fixed: Strip links in profile description
The Featured Link is the only link that is supposed to appear in the profile.
This commit is contained in:
parent
1b0d2b6acc
commit
90120f7df7
4
feeds.py
4
feeds.py
|
@ -739,7 +739,7 @@ def make_feed_page(session):
|
|||
else:
|
||||
if c_user and (c_user.info or c_user.url or c_user.flair):
|
||||
if c_user.info:
|
||||
topinfo += c_user.info + '\n'
|
||||
topinfo += clean_description(c_user.info) + '\n'
|
||||
if c_user.url:
|
||||
topinfo += f'=> {c_user.url}\n'
|
||||
if c_user.flair:
|
||||
|
@ -747,7 +747,7 @@ def make_feed_page(session):
|
|||
topinfo += f'\n{flair}'
|
||||
elif context:
|
||||
if context.info:
|
||||
topinfo += context.info + '\n'
|
||||
topinfo += clean_description(context.info) + '\n'
|
||||
if context.url:
|
||||
topinfo += f'=> {context.url}\n'
|
||||
# Users moderating this subspace.
|
||||
|
|
|
@ -388,7 +388,7 @@ def make_settings_page(session):
|
|||
elif req.path == session.path + 'settings/info/' + token:
|
||||
if req.query == None:
|
||||
return 10, 'Enter profile description:'
|
||||
db.update_user(session.user, info=clean_query(req))
|
||||
db.update_user(session.user, info=clean_description(clean_query(req)))
|
||||
return 30, '/settings/profile'
|
||||
|
||||
elif req.path == session.path + 'settings/email':
|
||||
|
|
|
@ -247,7 +247,7 @@ def subspace_admin_actions(session, action):
|
|||
if action == 'info':
|
||||
if req.query == None:
|
||||
return 10, f"Description for {session.context.title()}:"
|
||||
db.update_subspace(session.context, info=clean_title(clean_query(req)), actor_id=user.id)
|
||||
db.update_subspace(session.context, info=clean_description(clean_query(req)), actor_id=user.id)
|
||||
return 30, admin_link
|
||||
|
||||
if action == 'url':
|
||||
|
@ -437,12 +437,12 @@ def make_search_page(session):
|
|||
if isinstance(obj, User):
|
||||
page += f'=> /u/{obj.name} {obj.avatar} u/{obj.name}\n'
|
||||
if obj.info:
|
||||
page += f'{obj.info[:300].strip()}\n'
|
||||
page += f'{clean_title(strip_links(obj.info))[:300].strip()}\n'
|
||||
|
||||
elif isinstance(obj, Subspace):
|
||||
page += f'=> /s/{obj.name} s/{obj.name}\n'
|
||||
if obj.info:
|
||||
page += f'{obj.info[:300].strip()}\n'
|
||||
page += f'{clean_title(strip_links(obj.info))[:300].strip()}\n'
|
||||
|
||||
elif isinstance(obj, Post):
|
||||
ctx = ("u/" if obj.sub_owner else "s/") + obj.sub_name
|
||||
|
|
15
utils.py
15
utils.py
|
@ -166,6 +166,21 @@ def clean_title(title):
|
|||
return title
|
||||
|
||||
|
||||
def clean_description(desc):
|
||||
# Strip links but keep other formatting.
|
||||
cleaned = []
|
||||
pre = False
|
||||
for line in desc.split('\n'):
|
||||
line = line.strip()
|
||||
if line.startswith('```'):
|
||||
pre = not pre
|
||||
if not pre:
|
||||
if line.startswith('=>'):
|
||||
continue
|
||||
cleaned.append(line)
|
||||
return '\n'.join(cleaned)
|
||||
|
||||
|
||||
def clean_tinylog(text):
|
||||
# Clean it up as per Tinylog specification.
|
||||
clean = []
|
||||
|
|
Loading…
Reference in New Issue