forked from indymedia/epicyon
Support different background formats
parent
69749a958c
commit
a428372e8e
114
daemon.py
114
daemon.py
|
@ -1840,35 +1840,36 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
|
||||
self._benchmarkGETtimings(GETstartTime, GETtimings, 16)
|
||||
|
||||
# login screen background image
|
||||
if self.path == '/login-background.png':
|
||||
mediaFilename = \
|
||||
self.server.baseDir + '/accounts/login-background.png'
|
||||
if os.path.isfile(mediaFilename):
|
||||
if self._etag_exists(mediaFilename):
|
||||
# The file has not changed
|
||||
self._304()
|
||||
return
|
||||
for ext in ('png', 'jpg', 'gif'):
|
||||
# login screen background image
|
||||
if self.path == '/login-background.' + ext:
|
||||
mediaFilename = \
|
||||
self.server.baseDir + '/accounts/login-background.' + ext
|
||||
if os.path.isfile(mediaFilename):
|
||||
if self._etag_exists(mediaFilename):
|
||||
# The file has not changed
|
||||
self._304()
|
||||
return
|
||||
|
||||
tries = 0
|
||||
mediaBinary = None
|
||||
while tries < 5:
|
||||
try:
|
||||
with open(mediaFilename, 'rb') as avFile:
|
||||
mediaBinary = avFile.read()
|
||||
break
|
||||
except Exception as e:
|
||||
print(e)
|
||||
time.sleep(1)
|
||||
tries += 1
|
||||
if mediaBinary:
|
||||
self._set_headers_etag(mediaFilename, 'image/png',
|
||||
mediaBinary, cookie,
|
||||
callingDomain)
|
||||
self._write(mediaBinary)
|
||||
return
|
||||
self._404()
|
||||
return
|
||||
tries = 0
|
||||
mediaBinary = None
|
||||
while tries < 5:
|
||||
try:
|
||||
with open(mediaFilename, 'rb') as avFile:
|
||||
mediaBinary = avFile.read()
|
||||
break
|
||||
except Exception as e:
|
||||
print(e)
|
||||
time.sleep(1)
|
||||
tries += 1
|
||||
if mediaBinary:
|
||||
self._set_headers_etag(mediaFilename, 'image/' + ext,
|
||||
mediaBinary, cookie,
|
||||
callingDomain)
|
||||
self._write(mediaBinary)
|
||||
return
|
||||
self._404()
|
||||
return
|
||||
|
||||
# QR code for account handle
|
||||
if '/users/' in self.path and \
|
||||
|
@ -1941,35 +1942,36 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
|
||||
self._benchmarkGETtimings(GETstartTime, GETtimings, 17)
|
||||
|
||||
# follow screen background image
|
||||
if self.path == '/follow-background.png':
|
||||
mediaFilename = \
|
||||
self.server.baseDir + '/accounts/follow-background.png'
|
||||
if os.path.isfile(mediaFilename):
|
||||
if self._etag_exists(mediaFilename):
|
||||
# The file has not changed
|
||||
self._304()
|
||||
return
|
||||
for ext in ('png', 'jpg', 'gif'):
|
||||
# follow screen background image
|
||||
if self.path == '/follow-background.' + ext:
|
||||
mediaFilename = \
|
||||
self.server.baseDir + '/accounts/follow-background.' + ext
|
||||
if os.path.isfile(mediaFilename):
|
||||
if self._etag_exists(mediaFilename):
|
||||
# The file has not changed
|
||||
self._304()
|
||||
return
|
||||
|
||||
tries = 0
|
||||
mediaBinary = None
|
||||
while tries < 5:
|
||||
try:
|
||||
with open(mediaFilename, 'rb') as avFile:
|
||||
mediaBinary = avFile.read()
|
||||
break
|
||||
except Exception as e:
|
||||
print(e)
|
||||
time.sleep(1)
|
||||
tries += 1
|
||||
if mediaBinary:
|
||||
self._set_headers_etag(mediaFilename, 'image/png',
|
||||
mediaBinary, cookie,
|
||||
callingDomain)
|
||||
self._write(mediaBinary)
|
||||
return
|
||||
self._404()
|
||||
return
|
||||
tries = 0
|
||||
mediaBinary = None
|
||||
while tries < 5:
|
||||
try:
|
||||
with open(mediaFilename, 'rb') as avFile:
|
||||
mediaBinary = avFile.read()
|
||||
break
|
||||
except Exception as e:
|
||||
print(e)
|
||||
time.sleep(1)
|
||||
tries += 1
|
||||
if mediaBinary:
|
||||
self._set_headers_etag(mediaFilename, 'image/' + ext,
|
||||
mediaBinary, cookie,
|
||||
callingDomain)
|
||||
self._write(mediaBinary)
|
||||
return
|
||||
self._404()
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime, GETtimings, 18)
|
||||
|
||||
|
|
3
theme.py
3
theme.py
|
@ -646,8 +646,7 @@ def setThemeImages(baseDir: str, name: str) -> None:
|
|||
else:
|
||||
backgroundImageFilename = \
|
||||
baseDir + '/img/' + backgroundType + \
|
||||
'_background_' + \
|
||||
themeNameLower + '.' + ext
|
||||
'_background_' + themeNameLower + '.' + ext
|
||||
|
||||
if os.path.isfile(backgroundImageFilename):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue