Option to not show like button

merge-requests/8/head
Bob Mottram 2020-08-28 14:36:21 +01:00
parent cabdc9c3c5
commit 3200305024
2 changed files with 36 additions and 3 deletions

View File

@ -7116,14 +7116,32 @@ class PubServer(BaseHTTPRequestHandler):
if not removeTwitterActive:
if os.path.isfile(removeTwitterFilename):
os.remove(removeTwitterFilename)
# notify about new Likes
# hide Like button
hideLikeButtonFile = \
self.server.baseDir + '/accounts/' + \
nickname + '@' + self.server.domain + \
'/.hideLikeButton'
notifyLikesFilename = \
self.server.baseDir + '/accounts/' + \
nickname + '@' + self.server.domain + \
'/.notifyLikes'
hideLikeButtonActive = False
if fields.get('hideLikeButton'):
if fields['hideLikeButton'] == 'on':
hideLikeButtonActive = True
with open(hideLikeButtonFile, "w") as rFile:
rFile.write('\n')
# remove notify likes selection
if os.path.isfile(notifyLikesFilename):
os.remove(notifyLikesFilename)
if not hideLikeButtonActive:
if os.path.isfile(hideLikeButtonFile):
os.remove(hideLikeButtonFile)
# notify about new Likes
notifyLikesActive = False
if fields.get('notifyLikes'):
if fields['notifyLikes'] == 'on':
if fields['notifyLikes'] == 'on' and \
not hideLikeButtonActive:
notifyLikesActive = True
with open(notifyLikesFilename, "w") as rFile:
rFile.write('\n')

View File

@ -1084,6 +1084,7 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str,
followDMs = ''
removeTwitter = ''
notifyLikes = ''
hideLikeButton = ''
mediaInstanceStr = ''
displayNickname = nickname
bioStr = ''
@ -1134,6 +1135,9 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str,
if os.path.isfile(baseDir + '/accounts/' +
nickname + '@' + domain + '/.notifyLikes'):
notifyLikes = 'checked'
if os.path.isfile(baseDir + '/accounts/' +
nickname + '@' + domain + '/.hideLikeButton'):
hideLikeButton = 'checked'
mediaInstance = getConfigParam(baseDir, "mediaInstance")
if mediaInstance:
@ -1473,6 +1477,10 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str,
' <input type="checkbox" class="profilecheckbox" ' + \
'name="notifyLikes" ' + notifyLikes + '> ' + \
translate['Notify when posts are liked'] + '<br>\n'
editProfileForm += \
' <input type="checkbox" class="profilecheckbox" ' + \
'name="hideLikeButton" ' + hideLikeButton + '> ' + \
translate["Don't show the Like button"] + '<br>\n'
editProfileForm += \
' <br><b><label class="labels">' + \
@ -4083,8 +4091,15 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int,
'" alt="' + translate['Repeat this post'] + \
' |" src="/' + iconsDir + '/' + announceIcon + '"/></a>\n'
# whether to show a like button
hideLikeButtonFile = \
baseDir + '/accounts/' + nickname + '@' + domain + '/.hideLikeButton'
showLikeButton = True
if os.path.isfile(hideLikeButtonFile):
showLikeButton = False
likeStr = ''
if not isModerationPost:
if not isModerationPost and showLikeButton:
likeIcon = 'like_inactive.png'
likeLink = 'like'
likeTitle = translate['Like this post']