mirror of https://gitlab.com/bashrc2/epicyon
Move function
parent
b8e1868b9e
commit
662483c499
30
person.py
30
person.py
|
@ -49,10 +49,12 @@ from utils import getConfigParam
|
||||||
from utils import refreshNewswire
|
from utils import refreshNewswire
|
||||||
from utils import getProtocolPrefixes
|
from utils import getProtocolPrefixes
|
||||||
from utils import hasUsersPath
|
from utils import hasUsersPath
|
||||||
|
from utils import getImageExtensions
|
||||||
from session import createSession
|
from session import createSession
|
||||||
from session import getJson
|
from session import getJson
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
from cache import getPersonFromCache
|
||||||
|
|
||||||
|
|
||||||
def generateRSAKey() -> (str, str):
|
def generateRSAKey() -> (str, str):
|
||||||
|
@ -1347,3 +1349,31 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
||||||
pprint(personJson)
|
pprint(personJson)
|
||||||
return personJson, asHeader
|
return personJson, asHeader
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
|
def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {},
|
||||||
|
allowDownloads: bool) -> str:
|
||||||
|
"""Returns the avatar url for the person
|
||||||
|
"""
|
||||||
|
personJson = \
|
||||||
|
getPersonFromCache(baseDir, personUrl, personCache, allowDownloads)
|
||||||
|
if not personJson:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# get from locally stored image
|
||||||
|
if not personJson.get('id'):
|
||||||
|
return None
|
||||||
|
actorStr = personJson['id'].replace('/', '-')
|
||||||
|
avatarImagePath = baseDir + '/cache/avatars/' + actorStr
|
||||||
|
|
||||||
|
imageExtension = getImageExtensions()
|
||||||
|
for ext in imageExtension:
|
||||||
|
if os.path.isfile(avatarImagePath + '.' + ext):
|
||||||
|
return '/avatars/' + actorStr + '.' + ext
|
||||||
|
elif os.path.isfile(avatarImagePath.lower() + '.' + ext):
|
||||||
|
return '/avatars/' + actorStr.lower() + '.' + ext
|
||||||
|
|
||||||
|
if personJson.get('icon'):
|
||||||
|
if personJson['icon'].get('url'):
|
||||||
|
return personJson['icon']['url']
|
||||||
|
return None
|
||||||
|
|
|
@ -52,9 +52,9 @@ from content import removeLongWords
|
||||||
from content import getMentionsFromHtml
|
from content import getMentionsFromHtml
|
||||||
from content import switchWords
|
from content import switchWords
|
||||||
from person import isPersonSnoozed
|
from person import isPersonSnoozed
|
||||||
|
from person import getPersonAvatarUrl
|
||||||
from announce import announcedByPerson
|
from announce import announcedByPerson
|
||||||
from webapp_utils import getAvatarImageUrl
|
from webapp_utils import getAvatarImageUrl
|
||||||
from webapp_utils import getPersonAvatarUrl
|
|
||||||
from webapp_utils import updateAvatarImageCache
|
from webapp_utils import updateAvatarImageCache
|
||||||
from webapp_utils import loadIndividualPostAsHtmlFromCache
|
from webapp_utils import loadIndividualPostAsHtmlFromCache
|
||||||
from webapp_utils import addEmojiToDisplayName
|
from webapp_utils import addEmojiToDisplayName
|
||||||
|
|
|
@ -26,6 +26,7 @@ from skills import getSkills
|
||||||
from theme import getThemesList
|
from theme import getThemesList
|
||||||
from person import personBoxJson
|
from person import personBoxJson
|
||||||
from person import getActorJson
|
from person import getActorJson
|
||||||
|
from person import getPersonAvatarUrl
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
from posts import parseUserFeed
|
from posts import parseUserFeed
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
|
@ -45,7 +46,6 @@ from webapp_frontscreen import htmlFrontScreen
|
||||||
from webapp_utils import htmlKeyboardNavigation
|
from webapp_utils import htmlKeyboardNavigation
|
||||||
from webapp_utils import htmlHideFromScreenReader
|
from webapp_utils import htmlHideFromScreenReader
|
||||||
from webapp_utils import scheduledPostsExist
|
from webapp_utils import scheduledPostsExist
|
||||||
from webapp_utils import getPersonAvatarUrl
|
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
from webapp_utils import htmlHeaderWithPersonMarkup
|
from webapp_utils import htmlHeaderWithPersonMarkup
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
|
|
|
@ -16,10 +16,10 @@ from utils import getProtocolPrefixes
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from cache import getPersonFromCache
|
|
||||||
from cache import storePersonInCache
|
from cache import storePersonInCache
|
||||||
from content import addHtmlTags
|
from content import addHtmlTags
|
||||||
from content import replaceEmojiFromTags
|
from content import replaceEmojiFromTags
|
||||||
|
from person import getPersonAvatarUrl
|
||||||
|
|
||||||
|
|
||||||
def _markdownEmphasisHtml(markdown: str) -> str:
|
def _markdownEmphasisHtml(markdown: str) -> str:
|
||||||
|
@ -533,34 +533,6 @@ def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
|
||||||
return avatarImageFilename.replace(baseDir + '/cache', '')
|
return avatarImageFilename.replace(baseDir + '/cache', '')
|
||||||
|
|
||||||
|
|
||||||
def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {},
|
|
||||||
allowDownloads: bool) -> str:
|
|
||||||
"""Returns the avatar url for the person
|
|
||||||
"""
|
|
||||||
personJson = \
|
|
||||||
getPersonFromCache(baseDir, personUrl, personCache, allowDownloads)
|
|
||||||
if not personJson:
|
|
||||||
return None
|
|
||||||
|
|
||||||
# get from locally stored image
|
|
||||||
if not personJson.get('id'):
|
|
||||||
return None
|
|
||||||
actorStr = personJson['id'].replace('/', '-')
|
|
||||||
avatarImagePath = baseDir + '/cache/avatars/' + actorStr
|
|
||||||
|
|
||||||
imageExtension = getImageExtensions()
|
|
||||||
for ext in imageExtension:
|
|
||||||
if os.path.isfile(avatarImagePath + '.' + ext):
|
|
||||||
return '/avatars/' + actorStr + '.' + ext
|
|
||||||
elif os.path.isfile(avatarImagePath.lower() + '.' + ext):
|
|
||||||
return '/avatars/' + actorStr.lower() + '.' + ext
|
|
||||||
|
|
||||||
if personJson.get('icon'):
|
|
||||||
if personJson['icon'].get('url'):
|
|
||||||
return personJson['icon']['url']
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def scheduledPostsExist(baseDir: str, nickname: str, domain: str) -> bool:
|
def scheduledPostsExist(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
"""Returns true if there are posts scheduled to be delivered
|
"""Returns true if there are posts scheduled to be delivered
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue