mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
b011c90d0f
95
daemon.py
95
daemon.py
|
@ -2157,6 +2157,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
resetThemeDesignerSettings(baseDir, themeName, domain,
|
||||
allowLocalNetworkAccess,
|
||||
systemLanguage)
|
||||
setTheme(baseDir, themeName, domain,
|
||||
allowLocalNetworkAccess, systemLanguage)
|
||||
|
||||
if callingDomain.endswith('.onion') and onionDomain:
|
||||
originPathStr = \
|
||||
|
@ -2204,6 +2206,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
allowLocalNetworkAccess,
|
||||
systemLanguage)
|
||||
|
||||
# set boolean values
|
||||
if 'rss-icon-at-top' in themeDesignerParams:
|
||||
if themeDesignerParams['rss-icon-at-top'].lower() == 'true':
|
||||
self.server.rssIconAtTop = True
|
||||
|
@ -7298,55 +7301,57 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
baseDir: str, GETstartTime) -> None:
|
||||
"""Shows an icon
|
||||
"""
|
||||
if path.endswith('.png'):
|
||||
mediaStr = path.split('/icons/')[1]
|
||||
if '/' not in mediaStr:
|
||||
if not self.server.themeName:
|
||||
theme = 'default'
|
||||
else:
|
||||
theme = self.server.themeName
|
||||
iconFilename = mediaStr
|
||||
if not path.endswith('.png'):
|
||||
self._404()
|
||||
return
|
||||
mediaStr = path.split('/icons/')[1]
|
||||
if '/' not in mediaStr:
|
||||
if not self.server.themeName:
|
||||
theme = 'default'
|
||||
else:
|
||||
theme = mediaStr.split('/')[0]
|
||||
iconFilename = mediaStr.split('/')[1]
|
||||
mediaFilename = \
|
||||
baseDir + '/theme/' + theme + '/icons/' + iconFilename
|
||||
if self._etag_exists(mediaFilename):
|
||||
# The file has not changed
|
||||
self._304()
|
||||
return
|
||||
if self.server.iconsCache.get(mediaStr):
|
||||
mediaBinary = self.server.iconsCache[mediaStr]
|
||||
mimeTypeStr = mediaFileMimeType(mediaFilename)
|
||||
self._set_headers_etag(mediaFilename,
|
||||
mimeTypeStr,
|
||||
mediaBinary, None,
|
||||
self.server.domainFull,
|
||||
False, None)
|
||||
self._write(mediaBinary)
|
||||
theme = self.server.themeName
|
||||
iconFilename = mediaStr
|
||||
else:
|
||||
theme = mediaStr.split('/')[0]
|
||||
iconFilename = mediaStr.split('/')[1]
|
||||
mediaFilename = \
|
||||
baseDir + '/theme/' + theme + '/icons/' + iconFilename
|
||||
if self._etag_exists(mediaFilename):
|
||||
# The file has not changed
|
||||
self._304()
|
||||
return
|
||||
if self.server.iconsCache.get(mediaStr):
|
||||
mediaBinary = self.server.iconsCache[mediaStr]
|
||||
mimeTypeStr = mediaFileMimeType(mediaFilename)
|
||||
self._set_headers_etag(mediaFilename,
|
||||
mimeTypeStr,
|
||||
mediaBinary, None,
|
||||
self.server.domainFull,
|
||||
False, None)
|
||||
self._write(mediaBinary)
|
||||
fitnessPerformance(GETstartTime, self.server.fitness,
|
||||
'_GET', '_showIcon', self.server.debug)
|
||||
return
|
||||
else:
|
||||
if os.path.isfile(mediaFilename):
|
||||
mediaBinary = None
|
||||
try:
|
||||
with open(mediaFilename, 'rb') as avFile:
|
||||
mediaBinary = avFile.read()
|
||||
except OSError:
|
||||
print('EX: unable to read icon image ' + mediaFilename)
|
||||
if mediaBinary:
|
||||
mimeType = mediaFileMimeType(mediaFilename)
|
||||
self._set_headers_etag(mediaFilename,
|
||||
mimeType,
|
||||
mediaBinary, None,
|
||||
self.server.domainFull,
|
||||
False, None)
|
||||
self._write(mediaBinary)
|
||||
self.server.iconsCache[mediaStr] = mediaBinary
|
||||
fitnessPerformance(GETstartTime, self.server.fitness,
|
||||
'_GET', '_showIcon', self.server.debug)
|
||||
return
|
||||
else:
|
||||
if os.path.isfile(mediaFilename):
|
||||
mediaBinary = None
|
||||
try:
|
||||
with open(mediaFilename, 'rb') as avFile:
|
||||
mediaBinary = avFile.read()
|
||||
except OSError:
|
||||
print('EX: unable to read icon image ' + mediaFilename)
|
||||
if mediaBinary:
|
||||
mimeType = mediaFileMimeType(mediaFilename)
|
||||
self._set_headers_etag(mediaFilename,
|
||||
mimeType,
|
||||
mediaBinary, None,
|
||||
self.server.domainFull,
|
||||
False, None)
|
||||
self._write(mediaBinary)
|
||||
self.server.iconsCache[mediaStr] = mediaBinary
|
||||
fitnessPerformance(GETstartTime, self.server.fitness,
|
||||
'_GET', '_showIcon', self.server.debug)
|
||||
return
|
||||
self._404()
|
||||
|
||||
def _showHelpScreenImage(self, callingDomain: str, path: str,
|
||||
|
|
12
theme.py
12
theme.py
|
@ -513,8 +513,6 @@ def resetThemeDesignerSettings(baseDir: str, themeName: str, domain: str,
|
|||
os.remove(customVariablesFile)
|
||||
except OSError:
|
||||
print('EX: unable to remove theme designer settings on reset')
|
||||
setTheme(baseDir, themeName, domain,
|
||||
allowLocalNetworkAccess, systemLanguage)
|
||||
|
||||
|
||||
def _readVariablesFile(baseDir: str, themeName: str,
|
||||
|
@ -826,13 +824,9 @@ def setTheme(baseDir: str, name: str, domain: str,
|
|||
|
||||
# if the theme has changed then remove any custom settings
|
||||
if prevThemeName != name:
|
||||
customVariablesFile = baseDir + '/accounts/theme.json'
|
||||
if os.path.isfile(customVariablesFile):
|
||||
print('Removing theme designer settings')
|
||||
try:
|
||||
os.remove(customVariablesFile)
|
||||
except OSError:
|
||||
print('EX: removing theme designer settings')
|
||||
resetThemeDesignerSettings(baseDir, name, domain,
|
||||
allowLocalNetworkAccess,
|
||||
systemLanguage)
|
||||
|
||||
_removeTheme(baseDir)
|
||||
|
||||
|
|
2
utils.py
2
utils.py
|
@ -595,6 +595,8 @@ def removeIdEnding(idStr: str) -> str:
|
|||
idStr = idStr[:-len('/event')]
|
||||
elif idStr.endswith('/replies'):
|
||||
idStr = idStr[:-len('/replies')]
|
||||
if idStr.endswith('#Create'):
|
||||
idStr = idStr.split('#Create')[0]
|
||||
return idStr
|
||||
|
||||
|
||||
|
|
|
@ -390,7 +390,11 @@ def _getReplyIconHtml(baseDir: str, nickname: str, domain: str,
|
|||
return replyStr
|
||||
|
||||
# reply is permitted - create reply icon
|
||||
replyToLink = removeIdEnding(postJsonObject['object']['id'])
|
||||
if '#' not in postJsonObject['object']['id']:
|
||||
replyToLink = removeIdEnding(postJsonObject['object']['id'])
|
||||
else:
|
||||
replyToLink = \
|
||||
removeIdEnding(postJsonObject['object']['id'].split('#')[0])
|
||||
|
||||
# see Mike MacGirvin's replyTo suggestion
|
||||
if postJsonObject['object'].get('replyTo'):
|
||||
|
@ -571,7 +575,11 @@ def _getAnnounceIconHtml(isAnnounced: bool,
|
|||
unannounceLinkStr = '?unannounce=' + \
|
||||
removeIdEnding(announceJsonObject['id'])
|
||||
|
||||
announcePostId = removeIdEnding(postJsonObject['object']['id'])
|
||||
if '#' not in postJsonObject['object']['id']:
|
||||
announcePostId = removeIdEnding(postJsonObject['object']['id'])
|
||||
else:
|
||||
announcePostId = \
|
||||
removeIdEnding(postJsonObject['object']['id'].split('#')[0])
|
||||
announceLinkStr = '?' + \
|
||||
announceLink + '=' + announcePostId + pageNumberParam
|
||||
announceStr = \
|
||||
|
@ -639,7 +647,10 @@ def _getLikeIconHtml(nickname: str, domainFull: str,
|
|||
likeStr += '<label class="likesCount">'
|
||||
likeStr += likeCountStr.replace('(', '').replace(')', '').strip()
|
||||
likeStr += '</label>\n'
|
||||
likePostId = removeIdEnding(postJsonObject['id'])
|
||||
if '#' not in postJsonObject['id']:
|
||||
likePostId = removeIdEnding(postJsonObject['id'])
|
||||
else:
|
||||
likePostId = removeIdEnding(postJsonObject['id'].split('#')[0])
|
||||
likeStr += \
|
||||
' <a class="imageAnchor" href="/users/' + nickname + '?' + \
|
||||
likeLink + '=' + likePostId + \
|
||||
|
@ -685,7 +696,11 @@ def _getBookmarkIconHtml(nickname: str, domainFull: str,
|
|||
if translate.get(bookmarkTitle):
|
||||
bookmarkTitle = translate[bookmarkTitle]
|
||||
_logPostTiming(enableTimingLog, postStartTime, '12.6')
|
||||
bookmarkPostId = removeIdEnding(postJsonObject['object']['id'])
|
||||
if '#' not in postJsonObject['object']['id']:
|
||||
bookmarkPostId = removeIdEnding(postJsonObject['object']['id'])
|
||||
else:
|
||||
bookmarkPostId = \
|
||||
removeIdEnding(postJsonObject['object']['id'].split('#')[0])
|
||||
bookmarkStr = \
|
||||
' <a class="imageAnchor" href="/users/' + nickname + '?' + \
|
||||
bookmarkLink + '=' + bookmarkPostId + \
|
||||
|
@ -722,7 +737,11 @@ def _getReactionIconHtml(nickname: str, domainFull: str,
|
|||
if translate.get(reactionTitle):
|
||||
reactionTitle = translate[reactionTitle]
|
||||
_logPostTiming(enableTimingLog, postStartTime, '12.65')
|
||||
reactionPostId = removeIdEnding(postJsonObject['object']['id'])
|
||||
if '#' not in postJsonObject['object']['id']:
|
||||
reactionPostId = removeIdEnding(postJsonObject['object']['id'])
|
||||
else:
|
||||
reactionPostId = \
|
||||
removeIdEnding(postJsonObject['object']['id'].split('#')[0])
|
||||
reactionStr = \
|
||||
' <a class="imageAnchor" href="/users/' + nickname + \
|
||||
'?selreact=' + reactionPostId + pageNumberParam + \
|
||||
|
@ -1364,7 +1383,10 @@ def individualPostAsHtml(signingPrivateKeyPem: str,
|
|||
avatarPosition = ''
|
||||
messageId = ''
|
||||
if postJsonObject.get('id'):
|
||||
messageId = removeIdEnding(postJsonObject['id'])
|
||||
if '#' not in postJsonObject['id']:
|
||||
messageId = removeIdEnding(postJsonObject['id'])
|
||||
else:
|
||||
messageId = removeIdEnding(postJsonObject['id'].split('#')[0])
|
||||
|
||||
_logPostTiming(enableTimingLog, postStartTime, '2')
|
||||
|
||||
|
|
Loading…
Reference in New Issue