mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
e1a90cd319
commit
a6cda457b5
52
person.py
52
person.py
|
@ -116,10 +116,16 @@ def setProfileImage(baseDir: str, httpPrefix: str, nickname: str, domain: str,
|
||||||
imageFilename.endswith('.jpeg'):
|
imageFilename.endswith('.jpeg'):
|
||||||
mediaType = 'image/jpeg'
|
mediaType = 'image/jpeg'
|
||||||
iconFilename = iconFilenameBase + '.jpg'
|
iconFilename = iconFilenameBase + '.jpg'
|
||||||
if imageFilename.endswith('.gif'):
|
elif imageFilename.endswith('.gif'):
|
||||||
mediaType = 'image/gif'
|
mediaType = 'image/gif'
|
||||||
iconFilename = iconFilenameBase + '.gif'
|
iconFilename = iconFilenameBase + '.gif'
|
||||||
if imageFilename.endswith('.svg'):
|
elif imageFilename.endswith('.webp'):
|
||||||
|
mediaType = 'image/webp'
|
||||||
|
iconFilename = iconFilenameBase + '.webp'
|
||||||
|
elif imageFilename.endswith('.avif'):
|
||||||
|
mediaType = 'image/avif'
|
||||||
|
iconFilename = iconFilenameBase + '.avif'
|
||||||
|
elif imageFilename.endswith('.svg'):
|
||||||
mediaType = 'image/svg+xml'
|
mediaType = 'image/svg+xml'
|
||||||
iconFilename = iconFilenameBase + '.svg'
|
iconFilename = iconFilenameBase + '.svg'
|
||||||
profileFilename = baseDir + '/accounts/' + handle + '/' + iconFilename
|
profileFilename = baseDir + '/accounts/' + handle + '/' + iconFilename
|
||||||
|
@ -590,8 +596,7 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
||||||
# if the older skills format is being used then switch
|
# if the older skills format is being used then switch
|
||||||
# to the new one
|
# to the new one
|
||||||
if not personJson.get('hasOccupation'):
|
if not personJson.get('hasOccupation'):
|
||||||
personJson['hasOccupation'] = [
|
personJson['hasOccupation'] = [{
|
||||||
{
|
|
||||||
'@type': 'Occupation',
|
'@type': 'Occupation',
|
||||||
'name': occupationName,
|
'name': occupationName,
|
||||||
"occupationLocation": {
|
"occupationLocation": {
|
||||||
|
@ -599,8 +604,7 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
||||||
"name": "Fediverse"
|
"name": "Fediverse"
|
||||||
},
|
},
|
||||||
'skills': []
|
'skills': []
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
updateActor = True
|
updateActor = True
|
||||||
|
|
||||||
# remove the old skills format
|
# remove the old skills format
|
||||||
|
@ -615,8 +619,7 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
||||||
updateActor = True
|
updateActor = True
|
||||||
|
|
||||||
if not isinstance(personJson['hasOccupation'], list):
|
if not isinstance(personJson['hasOccupation'], list):
|
||||||
personJson['hasOccupation'] = [
|
personJson['hasOccupation'] = [{
|
||||||
{
|
|
||||||
'@type': 'Occupation',
|
'@type': 'Occupation',
|
||||||
'name': occupationName,
|
'name': occupationName,
|
||||||
'occupationLocation': {
|
'occupationLocation': {
|
||||||
|
@ -624,8 +627,7 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
||||||
'name': 'Fediverse'
|
'name': 'Fediverse'
|
||||||
},
|
},
|
||||||
'skills': []
|
'skills': []
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
updateActor = True
|
updateActor = True
|
||||||
else:
|
else:
|
||||||
# add location if it is missing
|
# add location if it is missing
|
||||||
|
@ -1209,27 +1211,17 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
handle = handle.replace(prefix, '')
|
handle = handle.replace(prefix, '')
|
||||||
handle = handle.replace('/@', '/users/')
|
handle = handle.replace('/@', '/users/')
|
||||||
if '/users/' in handle:
|
paths = (
|
||||||
nickname = handle.split('/users/')[1]
|
'/users/', '/profile/', '/channel/', '/accounts/', '/u/'
|
||||||
|
)
|
||||||
|
userPathFound = False
|
||||||
|
for userPath in paths:
|
||||||
|
if userPath in handle:
|
||||||
|
nickname = handle.split(userPath)[1]
|
||||||
nickname = nickname.replace('\n', '').replace('\r', '')
|
nickname = nickname.replace('\n', '').replace('\r', '')
|
||||||
domain = handle.split('/users/')[0]
|
domain = handle.split(userPath)[0]
|
||||||
elif '/profile/' in handle:
|
break
|
||||||
nickname = handle.split('/profile/')[1]
|
if not userPathFound and '://' in originalHandle:
|
||||||
nickname = nickname.replace('\n', '').replace('\r', '')
|
|
||||||
domain = handle.split('/profile/')[0]
|
|
||||||
elif '/channel/' in handle:
|
|
||||||
nickname = handle.split('/channel/')[1]
|
|
||||||
nickname = nickname.replace('\n', '').replace('\r', '')
|
|
||||||
domain = handle.split('/channel/')[0]
|
|
||||||
elif '/accounts/' in handle:
|
|
||||||
nickname = handle.split('/accounts/')[1]
|
|
||||||
nickname = nickname.replace('\n', '').replace('\r', '')
|
|
||||||
domain = handle.split('/accounts/')[0]
|
|
||||||
elif '/u/' in handle:
|
|
||||||
nickname = handle.split('/u/')[1]
|
|
||||||
nickname = nickname.replace('\n', '').replace('\r', '')
|
|
||||||
domain = handle.split('/u/')[0]
|
|
||||||
elif '://' in originalHandle:
|
|
||||||
domain = originalHandle.split('://')[1]
|
domain = originalHandle.split('://')[1]
|
||||||
if '/' in domain:
|
if '/' in domain:
|
||||||
domain = domain.split('/')[0]
|
domain = domain.split('/')[0]
|
||||||
|
|
Loading…
Reference in New Issue