Merge branch 'main' of gitlab.com:bashrc2/epicyon

main
Bob Mottram 2021-12-06 11:51:58 +00:00
commit b011c90d0f
4 changed files with 83 additions and 60 deletions

View File

@ -2157,6 +2157,8 @@ class PubServer(BaseHTTPRequestHandler):
resetThemeDesignerSettings(baseDir, themeName, domain, resetThemeDesignerSettings(baseDir, themeName, domain,
allowLocalNetworkAccess, allowLocalNetworkAccess,
systemLanguage) systemLanguage)
setTheme(baseDir, themeName, domain,
allowLocalNetworkAccess, systemLanguage)
if callingDomain.endswith('.onion') and onionDomain: if callingDomain.endswith('.onion') and onionDomain:
originPathStr = \ originPathStr = \
@ -2204,6 +2206,7 @@ class PubServer(BaseHTTPRequestHandler):
allowLocalNetworkAccess, allowLocalNetworkAccess,
systemLanguage) systemLanguage)
# set boolean values
if 'rss-icon-at-top' in themeDesignerParams: if 'rss-icon-at-top' in themeDesignerParams:
if themeDesignerParams['rss-icon-at-top'].lower() == 'true': if themeDesignerParams['rss-icon-at-top'].lower() == 'true':
self.server.rssIconAtTop = True self.server.rssIconAtTop = True
@ -7298,7 +7301,9 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, GETstartTime) -> None: baseDir: str, GETstartTime) -> None:
"""Shows an icon """Shows an icon
""" """
if path.endswith('.png'): if not path.endswith('.png'):
self._404()
return
mediaStr = path.split('/icons/')[1] mediaStr = path.split('/icons/')[1]
if '/' not in mediaStr: if '/' not in mediaStr:
if not self.server.themeName: if not self.server.themeName:

View File

@ -513,8 +513,6 @@ def resetThemeDesignerSettings(baseDir: str, themeName: str, domain: str,
os.remove(customVariablesFile) os.remove(customVariablesFile)
except OSError: except OSError:
print('EX: unable to remove theme designer settings on reset') print('EX: unable to remove theme designer settings on reset')
setTheme(baseDir, themeName, domain,
allowLocalNetworkAccess, systemLanguage)
def _readVariablesFile(baseDir: str, themeName: str, 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 the theme has changed then remove any custom settings
if prevThemeName != name: if prevThemeName != name:
customVariablesFile = baseDir + '/accounts/theme.json' resetThemeDesignerSettings(baseDir, name, domain,
if os.path.isfile(customVariablesFile): allowLocalNetworkAccess,
print('Removing theme designer settings') systemLanguage)
try:
os.remove(customVariablesFile)
except OSError:
print('EX: removing theme designer settings')
_removeTheme(baseDir) _removeTheme(baseDir)

View File

@ -595,6 +595,8 @@ def removeIdEnding(idStr: str) -> str:
idStr = idStr[:-len('/event')] idStr = idStr[:-len('/event')]
elif idStr.endswith('/replies'): elif idStr.endswith('/replies'):
idStr = idStr[:-len('/replies')] idStr = idStr[:-len('/replies')]
if idStr.endswith('#Create'):
idStr = idStr.split('#Create')[0]
return idStr return idStr

View File

@ -390,7 +390,11 @@ def _getReplyIconHtml(baseDir: str, nickname: str, domain: str,
return replyStr return replyStr
# reply is permitted - create reply icon # reply is permitted - create reply icon
if '#' not in postJsonObject['object']['id']:
replyToLink = removeIdEnding(postJsonObject['object']['id']) replyToLink = removeIdEnding(postJsonObject['object']['id'])
else:
replyToLink = \
removeIdEnding(postJsonObject['object']['id'].split('#')[0])
# see Mike MacGirvin's replyTo suggestion # see Mike MacGirvin's replyTo suggestion
if postJsonObject['object'].get('replyTo'): if postJsonObject['object'].get('replyTo'):
@ -571,7 +575,11 @@ def _getAnnounceIconHtml(isAnnounced: bool,
unannounceLinkStr = '?unannounce=' + \ unannounceLinkStr = '?unannounce=' + \
removeIdEnding(announceJsonObject['id']) removeIdEnding(announceJsonObject['id'])
if '#' not in postJsonObject['object']['id']:
announcePostId = removeIdEnding(postJsonObject['object']['id']) announcePostId = removeIdEnding(postJsonObject['object']['id'])
else:
announcePostId = \
removeIdEnding(postJsonObject['object']['id'].split('#')[0])
announceLinkStr = '?' + \ announceLinkStr = '?' + \
announceLink + '=' + announcePostId + pageNumberParam announceLink + '=' + announcePostId + pageNumberParam
announceStr = \ announceStr = \
@ -639,7 +647,10 @@ def _getLikeIconHtml(nickname: str, domainFull: str,
likeStr += '<label class="likesCount">' likeStr += '<label class="likesCount">'
likeStr += likeCountStr.replace('(', '').replace(')', '').strip() likeStr += likeCountStr.replace('(', '').replace(')', '').strip()
likeStr += '</label>\n' likeStr += '</label>\n'
if '#' not in postJsonObject['id']:
likePostId = removeIdEnding(postJsonObject['id']) likePostId = removeIdEnding(postJsonObject['id'])
else:
likePostId = removeIdEnding(postJsonObject['id'].split('#')[0])
likeStr += \ likeStr += \
' <a class="imageAnchor" href="/users/' + nickname + '?' + \ ' <a class="imageAnchor" href="/users/' + nickname + '?' + \
likeLink + '=' + likePostId + \ likeLink + '=' + likePostId + \
@ -685,7 +696,11 @@ def _getBookmarkIconHtml(nickname: str, domainFull: str,
if translate.get(bookmarkTitle): if translate.get(bookmarkTitle):
bookmarkTitle = translate[bookmarkTitle] bookmarkTitle = translate[bookmarkTitle]
_logPostTiming(enableTimingLog, postStartTime, '12.6') _logPostTiming(enableTimingLog, postStartTime, '12.6')
if '#' not in postJsonObject['object']['id']:
bookmarkPostId = removeIdEnding(postJsonObject['object']['id']) bookmarkPostId = removeIdEnding(postJsonObject['object']['id'])
else:
bookmarkPostId = \
removeIdEnding(postJsonObject['object']['id'].split('#')[0])
bookmarkStr = \ bookmarkStr = \
' <a class="imageAnchor" href="/users/' + nickname + '?' + \ ' <a class="imageAnchor" href="/users/' + nickname + '?' + \
bookmarkLink + '=' + bookmarkPostId + \ bookmarkLink + '=' + bookmarkPostId + \
@ -722,7 +737,11 @@ def _getReactionIconHtml(nickname: str, domainFull: str,
if translate.get(reactionTitle): if translate.get(reactionTitle):
reactionTitle = translate[reactionTitle] reactionTitle = translate[reactionTitle]
_logPostTiming(enableTimingLog, postStartTime, '12.65') _logPostTiming(enableTimingLog, postStartTime, '12.65')
if '#' not in postJsonObject['object']['id']:
reactionPostId = removeIdEnding(postJsonObject['object']['id']) reactionPostId = removeIdEnding(postJsonObject['object']['id'])
else:
reactionPostId = \
removeIdEnding(postJsonObject['object']['id'].split('#')[0])
reactionStr = \ reactionStr = \
' <a class="imageAnchor" href="/users/' + nickname + \ ' <a class="imageAnchor" href="/users/' + nickname + \
'?selreact=' + reactionPostId + pageNumberParam + \ '?selreact=' + reactionPostId + pageNumberParam + \
@ -1364,7 +1383,10 @@ def individualPostAsHtml(signingPrivateKeyPem: str,
avatarPosition = '' avatarPosition = ''
messageId = '' messageId = ''
if postJsonObject.get('id'): if postJsonObject.get('id'):
if '#' not in postJsonObject['id']:
messageId = removeIdEnding(postJsonObject['id']) messageId = removeIdEnding(postJsonObject['id'])
else:
messageId = removeIdEnding(postJsonObject['id'].split('#')[0])
_logPostTiming(enableTimingLog, postStartTime, '2') _logPostTiming(enableTimingLog, postStartTime, '2')