mirror of https://gitlab.com/bashrc2/epicyon
Remove unused font upload code
parent
8d3d8ba03e
commit
3e9948374c
68
content.py
68
content.py
|
@ -664,74 +664,6 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
return filename, attachmentMediaType
|
return filename, attachmentMediaType
|
||||||
|
|
||||||
|
|
||||||
def saveFontInFormPOST(fontBytes, debug: bool,
|
|
||||||
filenameBase=None) -> (str, str):
|
|
||||||
"""Saves the given font bytes extracted from http form POST
|
|
||||||
Returns the filename and attachment type
|
|
||||||
"""
|
|
||||||
if not fontBytes:
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: No font found within POST')
|
|
||||||
return None, None
|
|
||||||
|
|
||||||
fontLocation = -1
|
|
||||||
searchStr = ''
|
|
||||||
filename = None
|
|
||||||
|
|
||||||
# directly search the binary array for the beginning
|
|
||||||
# of a font file
|
|
||||||
extensionList = {
|
|
||||||
'wOFF': 'font/woff',
|
|
||||||
'wOF2': 'font/woff2',
|
|
||||||
'ttf': 'font/ttf',
|
|
||||||
'OTTO': 'font/otf'
|
|
||||||
}
|
|
||||||
detectedExtension = None
|
|
||||||
for extension, contentType in extensionList.items():
|
|
||||||
# font binaries
|
|
||||||
searchStr = extension.encode('utf8', 'ignore')
|
|
||||||
fontLocation = fontBytes.find(searchStr)
|
|
||||||
if fontLocation > -1:
|
|
||||||
if extension == 'wOFF':
|
|
||||||
detectedExtension = 'woff'
|
|
||||||
elif extension == 'wOF2':
|
|
||||||
detectedExtension = 'woff2'
|
|
||||||
elif extension == 'OTTO':
|
|
||||||
detectedExtension = 'otf'
|
|
||||||
|
|
||||||
if detectedExtension:
|
|
||||||
filename = filenameBase + '.' + detectedExtension
|
|
||||||
attachmentMediaType = contentType
|
|
||||||
break
|
|
||||||
|
|
||||||
if not filename:
|
|
||||||
# default to ttf if file type not explicitly detected
|
|
||||||
detectedExtension = 'ttf'
|
|
||||||
filename = filenameBase + '.' + detectedExtension
|
|
||||||
attachmentMediaType = 'ttf'
|
|
||||||
fontLocation = 0
|
|
||||||
|
|
||||||
startPos = fontLocation
|
|
||||||
|
|
||||||
# remove any existing image files with a different format
|
|
||||||
extensionTypes = ('woff', 'woff2', 'ttf', 'otf')
|
|
||||||
for ex in extensionTypes:
|
|
||||||
if ex == detectedExtension:
|
|
||||||
continue
|
|
||||||
possibleOtherFormat = \
|
|
||||||
filename.replace('.temp', '').replace('.' +
|
|
||||||
detectedExtension, '.' +
|
|
||||||
ex)
|
|
||||||
if os.path.isfile(possibleOtherFormat):
|
|
||||||
os.remove(possibleOtherFormat)
|
|
||||||
|
|
||||||
fd = open(filename, 'wb')
|
|
||||||
fd.write(fontBytes[startPos:])
|
|
||||||
fd.close()
|
|
||||||
|
|
||||||
return filename, attachmentMediaType
|
|
||||||
|
|
||||||
|
|
||||||
def extractTextFieldsInPOST(postBytes, boundary, debug: bool) -> {}:
|
def extractTextFieldsInPOST(postBytes, boundary, debug: bool) -> {}:
|
||||||
"""Returns a dictionary containing the text fields of a http form POST
|
"""Returns a dictionary containing the text fields of a http form POST
|
||||||
The boundary argument comes from the http header
|
The boundary argument comes from the http header
|
||||||
|
|
33
daemon.py
33
daemon.py
|
@ -162,7 +162,6 @@ from content import replaceEmojiFromTags
|
||||||
from content import addHtmlTags
|
from content import addHtmlTags
|
||||||
from content import extractMediaInFormPOST
|
from content import extractMediaInFormPOST
|
||||||
from content import saveMediaInFormPOST
|
from content import saveMediaInFormPOST
|
||||||
from content import saveFontInFormPOST
|
|
||||||
from content import extractTextFieldsInPOST
|
from content import extractTextFieldsInPOST
|
||||||
from media import removeMetaData
|
from media import removeMetaData
|
||||||
from cache import storePersonInCache
|
from cache import storePersonInCache
|
||||||
|
@ -170,7 +169,6 @@ from cache import getPersonFromCache
|
||||||
from httpsig import verifyPostHeaders
|
from httpsig import verifyPostHeaders
|
||||||
from theme import setTheme
|
from theme import setTheme
|
||||||
from theme import getTheme
|
from theme import getTheme
|
||||||
from theme import setCustomFont
|
|
||||||
from schedule import runPostSchedule
|
from schedule import runPostSchedule
|
||||||
from schedule import runPostScheduleWatchdog
|
from schedule import runPostScheduleWatchdog
|
||||||
from schedule import removeScheduledPosts
|
from schedule import removeScheduledPosts
|
||||||
|
@ -5444,24 +5442,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if mType == 'instanceLogo':
|
if mType == 'instanceLogo':
|
||||||
filenameBase = \
|
filenameBase = \
|
||||||
self.server.baseDir + '/accounts/login.temp'
|
self.server.baseDir + '/accounts/login.temp'
|
||||||
elif mType == 'customFont':
|
|
||||||
filenameBase = \
|
|
||||||
self.server.baseDir + '/fonts/' + \
|
|
||||||
'custom.temp'
|
|
||||||
else:
|
else:
|
||||||
filenameBase = \
|
filenameBase = \
|
||||||
self.server.baseDir + '/accounts/' + \
|
self.server.baseDir + '/accounts/' + \
|
||||||
nickname + '@' + self.server.domain + \
|
nickname + '@' + self.server.domain + \
|
||||||
'/' + mType + '.temp'
|
'/' + mType + '.temp'
|
||||||
|
|
||||||
if mType == 'customFont':
|
filename, attachmentMediaType = \
|
||||||
filename, attachmentMediaType = \
|
saveMediaInFormPOST(mediaBytes, self.server.debug,
|
||||||
saveFontInFormPOST(mediaBytes, self.server.debug,
|
filenameBase)
|
||||||
filenameBase)
|
|
||||||
else:
|
|
||||||
filename, attachmentMediaType = \
|
|
||||||
saveMediaInFormPOST(mediaBytes, self.server.debug,
|
|
||||||
filenameBase)
|
|
||||||
if filename:
|
if filename:
|
||||||
print('Profile update POST ' + mType +
|
print('Profile update POST ' + mType +
|
||||||
' media or font filename is ' + filename)
|
' media or font filename is ' + filename)
|
||||||
|
@ -5471,20 +5460,14 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
postImageFilename = filename.replace('.temp', '')
|
postImageFilename = filename.replace('.temp', '')
|
||||||
if mType == 'customFont':
|
if self.server.debug:
|
||||||
os.rename(filename, postImageFilename)
|
print('DEBUG: POST ' + mType +
|
||||||
setCustomFont(self.server.baseDir)
|
' media removing metadata')
|
||||||
print('profile POST ' + mType +
|
removeMetaData(filename, postImageFilename)
|
||||||
' image or font filename ' + postImageFilename)
|
|
||||||
else:
|
|
||||||
if self.server.debug:
|
|
||||||
print('DEBUG: POST ' + mType +
|
|
||||||
' media removing metadata')
|
|
||||||
removeMetaData(filename, postImageFilename)
|
|
||||||
if os.path.isfile(postImageFilename):
|
if os.path.isfile(postImageFilename):
|
||||||
print('profile update POST ' + mType +
|
print('profile update POST ' + mType +
|
||||||
' image or font saved to ' + postImageFilename)
|
' image or font saved to ' + postImageFilename)
|
||||||
if mType != 'instanceLogo' and mType != 'customFont':
|
if mType != 'instanceLogo':
|
||||||
lastPartOfImageFilename = \
|
lastPartOfImageFilename = \
|
||||||
postImageFilename.split('/')[-1]
|
postImageFilename.split('/')[-1]
|
||||||
profileMediaTypesUploaded[mType] = \
|
profileMediaTypesUploaded[mType] = \
|
||||||
|
|
Loading…
Reference in New Issue