forked from indymedia/epicyon
Move image format functions to utils
parent
4f865d57e2
commit
050c87d0e4
20
utils.py
20
utils.py
|
@ -19,6 +19,26 @@ from calendar import monthrange
|
|||
from followingCalendar import addPersonToCalendar
|
||||
|
||||
|
||||
def getImageExtensions() -> []:
|
||||
"""Returns a list of the possible image file extensions
|
||||
"""
|
||||
return ('png', 'jpg', 'jpeg', 'gif', 'webp', 'avif')
|
||||
|
||||
|
||||
def getImageFormats() -> str:
|
||||
"""Returns a string of permissable image formats
|
||||
used when selecting an image for a new post
|
||||
"""
|
||||
imageExt = getImageExtensions()
|
||||
|
||||
imageFormats = ''
|
||||
for ext in imageExt:
|
||||
if imageFormats:
|
||||
imageFormats += ', '
|
||||
imageFormats += '.' + ext
|
||||
return imageFormats
|
||||
|
||||
|
||||
def removeHtml(content: str) -> str:
|
||||
"""Removes html links from the given content.
|
||||
Used to ensure that profile descriptions don't contain dubious content
|
||||
|
|
|
@ -14,6 +14,7 @@ from utils import isSystemAccount
|
|||
from utils import removeHtml
|
||||
from utils import loadJson
|
||||
from utils import getConfigParam
|
||||
from utils import getImageFormats
|
||||
from skills import getSkills
|
||||
from theme import getThemesList
|
||||
from person import personBoxJson
|
||||
|
@ -851,7 +852,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
defaultTimeline: str) -> str:
|
||||
"""Shows the edit profile screen
|
||||
"""
|
||||
imageFormats = '.png, .jpg, .jpeg, .gif, .webp, .avif'
|
||||
imageFormats = getImageFormats()
|
||||
path = path.replace('/inbox', '').replace('/outbox', '')
|
||||
path = path.replace('/shares', '')
|
||||
nickname = getNicknameFromActor(path)
|
||||
|
|
|
@ -9,6 +9,7 @@ __status__ = "Production"
|
|||
import os
|
||||
from collections import OrderedDict
|
||||
from session import getJson
|
||||
from utils import getImageExtensions
|
||||
from utils import getProtocolPrefixes
|
||||
from utils import loadJson
|
||||
from utils import getCachedPostFilename
|
||||
|
@ -248,12 +249,6 @@ def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
|
|||
return avatarImageFilename.replace(baseDir + '/cache', '')
|
||||
|
||||
|
||||
def getImageExtensions() -> []:
|
||||
"""Returns a list of the possible image file extensions
|
||||
"""
|
||||
return ('png', 'jpg', 'jpeg', 'gif', 'webp', 'avif')
|
||||
|
||||
|
||||
def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {},
|
||||
allowDownloads: bool) -> str:
|
||||
"""Returns the avatar url for the person
|
||||
|
|
Loading…
Reference in New Issue