mirror of https://gitlab.com/bashrc2/epicyon
Show source repos on person options
parent
4fff59c0a2
commit
3d62e4dbb1
|
@ -450,6 +450,7 @@ from maps import map_format_from_tagmaps_path
|
|||
from relationships import get_moved_feed
|
||||
from relationships import get_inactive_feed
|
||||
from relationships import update_moved_actors
|
||||
from git import get_repo_url
|
||||
|
||||
# maximum number of posts to list in outbox feed
|
||||
MAX_POSTS_IN_FEED = 12
|
||||
|
@ -9010,6 +9011,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
locked_account = False
|
||||
also_known_as = None
|
||||
moved_to = ''
|
||||
repo_url = None
|
||||
actor_json = \
|
||||
get_person_from_cache(base_dir,
|
||||
options_actor,
|
||||
|
@ -9040,6 +9042,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
pgp_fingerprint = get_pgp_fingerprint(actor_json)
|
||||
if actor_json.get('alsoKnownAs'):
|
||||
also_known_as = remove_html(actor_json['alsoKnownAs'])
|
||||
repo_url = get_repo_url(actor_json)
|
||||
|
||||
access_keys = self.server.access_keys
|
||||
nickname = 'instance'
|
||||
|
@ -9096,7 +9099,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
authorized,
|
||||
access_keys, is_group,
|
||||
self.server.theme_name,
|
||||
self.server.blocked_cache)
|
||||
self.server.blocked_cache,
|
||||
repo_url)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
|
|
39
git.py
39
git.py
|
@ -12,6 +12,8 @@ import html
|
|||
from utils import acct_dir
|
||||
from utils import has_object_string_type
|
||||
from utils import text_in_file
|
||||
from utils import get_attachment_property_value
|
||||
from utils import remove_html
|
||||
|
||||
|
||||
def _git_format_content(content: str) -> str:
|
||||
|
@ -220,3 +222,40 @@ def receive_git_patch(base_dir: str, nickname: str, domain: str,
|
|||
except OSError as ex:
|
||||
print('EX: receive_git_patch ' + patch_filename + ' ' + str(ex))
|
||||
return False
|
||||
|
||||
|
||||
def get_repo_url(actor_json: {}) -> str:
|
||||
"""Returns a link used for code repo
|
||||
"""
|
||||
if not actor_json.get('attachment'):
|
||||
return ''
|
||||
repo_type = ('github', 'gitlab', 'codeberg', 'launchpad',
|
||||
'sourceforge', 'bitbucket', 'gitea')
|
||||
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 repo_type:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
continue
|
||||
prop_value_name, prop_value = \
|
||||
get_attachment_property_value(property_value)
|
||||
if not prop_value:
|
||||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
if '<a href="' in property_value[prop_value_name]:
|
||||
repo_url = property_value[prop_value_name].split('<a href="')[1]
|
||||
if '"' in repo_url:
|
||||
repo_url = repo_url.split('"')[0]
|
||||
else:
|
||||
repo_url = property_value[prop_value_name]
|
||||
if '.' not in repo_url:
|
||||
continue
|
||||
return remove_html(repo_url)
|
||||
return ''
|
||||
|
|
|
@ -164,7 +164,8 @@ def html_person_options(default_timeline: str,
|
|||
access_keys: {},
|
||||
is_group: bool,
|
||||
theme: str,
|
||||
blocked_cache: []) -> str:
|
||||
blocked_cache: [],
|
||||
repo_url: str) -> str:
|
||||
"""Show options for a person: view/follow/block/report
|
||||
"""
|
||||
options_link_str = ''
|
||||
|
@ -364,6 +365,13 @@ def html_person_options(default_timeline: str,
|
|||
options_str += \
|
||||
' <p class="imText">🌐 <a href="' + web_str + '">' + \
|
||||
web_address + '</a></p>\n'
|
||||
if repo_url:
|
||||
repo_str = remove_html(repo_url)
|
||||
if '://' not in repo_str:
|
||||
repo_str = 'https://' + repo_str
|
||||
options_str += \
|
||||
' <p class="imText">💻 <a href="' + repo_str + '">' + \
|
||||
repo_url + '</a></p>\n'
|
||||
if gemini_link:
|
||||
gemini_str = remove_html(gemini_link)
|
||||
if '://' not in gemini_str:
|
||||
|
|
Loading…
Reference in New Issue