forked from indymedia/epicyon
Fill screen image
parent
583c4a239d
commit
77633238a6
25
daemon.py
25
daemon.py
|
@ -81,6 +81,7 @@ from roles import setRole
|
|||
from roles import clearModeratorStatus
|
||||
from skills import outboxSkills
|
||||
from availability import outboxAvailability
|
||||
from webinterface import htmlFullScreenImage
|
||||
from webinterface import htmlDeletePost
|
||||
from webinterface import htmlAbout
|
||||
from webinterface import htmlRemoveSharedItem
|
||||
|
@ -753,6 +754,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'/emoji/' not in self.path and \
|
||||
'/tags/' not in self.path and \
|
||||
'/avatars/' not in self.path and \
|
||||
'/fullscreen?' not in self.path and \
|
||||
'/icons/' not in self.path:
|
||||
divertToLoginScreen=True
|
||||
if self.path.startswith('/users/'):
|
||||
|
@ -797,6 +799,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/css',len(msg),cookie)
|
||||
self._write(msg)
|
||||
return
|
||||
|
||||
# image on login screen
|
||||
if self.path=='/login.png':
|
||||
mediaFilename= \
|
||||
|
@ -818,7 +821,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._write(mediaBinary)
|
||||
return
|
||||
self._404()
|
||||
return
|
||||
return
|
||||
|
||||
# login screen background image
|
||||
if self.path=='/login-background.png':
|
||||
mediaFilename= \
|
||||
|
@ -841,6 +845,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return
|
||||
self._404()
|
||||
return
|
||||
|
||||
# follow screen background image
|
||||
if self.path=='/follow-background.png':
|
||||
mediaFilename= \
|
||||
|
@ -863,6 +868,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return
|
||||
self._404()
|
||||
return
|
||||
|
||||
# emoji images
|
||||
if '/emoji/' in self.path:
|
||||
if self.path.endswith('.png') or \
|
||||
|
@ -886,6 +892,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return
|
||||
self._404()
|
||||
return
|
||||
|
||||
# show media
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if '/media/' in self.path:
|
||||
|
@ -922,6 +929,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return
|
||||
self._404()
|
||||
return
|
||||
|
||||
# show shared item images
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if '/sharefiles/' in self.path:
|
||||
|
@ -946,6 +954,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return
|
||||
self._404()
|
||||
return
|
||||
|
||||
# icon images
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if self.path.startswith('/icons/'):
|
||||
|
@ -962,6 +971,20 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return
|
||||
self._404()
|
||||
return
|
||||
|
||||
# full screen images shown from the media timeline
|
||||
if authorized and self.path.startswith('/fullscreen?'):
|
||||
fullscreenImageStr=self.path.split('?')
|
||||
imageFilename=fullscreenImageStr[1]
|
||||
imageDescription=None
|
||||
if len(fullscreenImageStr)>2:
|
||||
imageDescription=fullscreenImageStr[2]
|
||||
msg=htmlFullScreenImage(imageFilename,imageDescription)
|
||||
self._login_headers('text/html',len(msg))
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
return
|
||||
|
||||
# cached avatar images
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if self.path.startswith('/avatars/'):
|
||||
|
|
|
@ -51,6 +51,44 @@ from skills import getSkills
|
|||
from cache import getPersonFromCache
|
||||
from cache import storePersonInCache
|
||||
|
||||
def htmlFullScreenImage(imageFilename: str,description: str) -> str:
|
||||
"""On the media timeline show a full screen image when selecting it
|
||||
"""
|
||||
htmlStr='<!DOCTYPE html>\n'
|
||||
htmlStr+='<html>\n'
|
||||
htmlStr+='<head>\n'
|
||||
htmlStr+='<meta name="viewport" content="width=device-width, initial-scale=1">\n'
|
||||
htmlStr+='<style>\n'
|
||||
htmlStr+='body, html {\n'
|
||||
htmlStr+=' height: 100%;\n'
|
||||
htmlStr+=' margin: 0;\n'
|
||||
htmlStr+='}\n'
|
||||
htmlStr+='\n'
|
||||
htmlStr+='.bg {\n'
|
||||
htmlStr+=' background-image: url("'+imageFilename+'");\n'
|
||||
htmlStr+='\n'
|
||||
if description:
|
||||
htmlStr+=' height: 90%;\n'
|
||||
else:
|
||||
htmlStr+=' height: 100%;\n'
|
||||
htmlStr+=''
|
||||
htmlStr+=' background-position: center;\n'
|
||||
htmlStr+=' background-repeat: no-repeat;\n'
|
||||
htmlStr+=' background-size: cover;\n'
|
||||
htmlStr+='}\n'
|
||||
htmlStr+='</style>\n'
|
||||
htmlStr+='</head>\n'
|
||||
htmlStr+='<body>\n'
|
||||
htmlStr+='\n'
|
||||
htmlStr+='<div class="bg"></div>\n'
|
||||
htmlStr+='\n'
|
||||
if description:
|
||||
htmlStr+='<p>'+description+'</p>\n'
|
||||
htmlStr+='\n'
|
||||
htmlStr+='</body>\n'
|
||||
htmlStr+='</html>'
|
||||
return htmlStr
|
||||
|
||||
def updateAvatarImageCache(session,baseDir: str,httpPrefix: str,actor: str,avatarUrl: str,personCache: {},force=False) -> str:
|
||||
"""Updates the cached avatar for the given actor
|
||||
"""
|
||||
|
@ -1885,7 +1923,7 @@ def individualPostAsHtml(iconsDir: str,translate: {}, \
|
|||
galleryStr+= \
|
||||
'<div class="gallery">\n' \
|
||||
' <a href="'+messageId+'">\n' \
|
||||
' <img loading="lazy" src="'+attach['url']+'" alt="'+imageDescription+'" title="'+imageDescription+'" width="600" height="400">\n' \
|
||||
' <img loading="lazy" src="/fullscreen?'+attach['url']+'" alt="'+imageDescription+'" title="'+imageDescription+'" width="600" height="400">\n' \
|
||||
' </a>\n</div>\n'
|
||||
attachmentStr+= \
|
||||
'<a href="'+attach['url']+'">' \
|
||||
|
|
Loading…
Reference in New Issue