2020-11-09 15:22:59 +00:00
|
|
|
__filename__ = "webapp.py"
|
2020-04-05 09:17:19 +00:00
|
|
|
__author__ = "Bob Mottram"
|
|
|
|
__license__ = "AGPL3+"
|
|
|
|
__version__ = "1.1.0"
|
|
|
|
__maintainer__ = "Bob Mottram"
|
|
|
|
__email__ = "bob@freedombone.net"
|
|
|
|
__status__ = "Production"
|
|
|
|
|
2019-07-24 22:38:42 +00:00
|
|
|
import os
|
|
|
|
from shutil import copyfile
|
2020-10-29 12:48:58 +00:00
|
|
|
from utils import getCSS
|
2019-07-21 12:41:31 +00:00
|
|
|
from utils import getNicknameFromActor
|
|
|
|
from utils import getDomainFromActor
|
2019-08-02 18:57:06 +00:00
|
|
|
from utils import locatePost
|
2019-10-22 11:55:06 +00:00
|
|
|
from utils import loadJson
|
2019-11-03 09:48:01 +00:00
|
|
|
from shares import getValidSharedItemID
|
2020-11-09 15:22:59 +00:00
|
|
|
from webapp_utils import getAltPath
|
|
|
|
from webapp_utils import getIconsDir
|
2020-11-09 19:41:01 +00:00
|
|
|
from webapp_utils import htmlHeader
|
|
|
|
from webapp_utils import htmlFooter
|
|
|
|
from webapp_post import individualPostAsHtml
|
2019-08-18 13:30:40 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
|
2020-10-29 12:48:58 +00:00
|
|
|
def htmlFollowingList(cssCache: {}, baseDir: str,
|
|
|
|
followingFilename: str) -> str:
|
2020-06-28 21:54:49 +00:00
|
|
|
"""Returns a list of handles being followed
|
|
|
|
"""
|
|
|
|
with open(followingFilename, 'r') as followingFile:
|
|
|
|
msg = followingFile.read()
|
|
|
|
followingList = msg.split('\n')
|
|
|
|
followingList.sort()
|
|
|
|
if followingList:
|
|
|
|
cssFilename = baseDir + '/epicyon-profile.css'
|
|
|
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
|
|
|
cssFilename = baseDir + '/epicyon.css'
|
2020-10-29 12:48:58 +00:00
|
|
|
|
|
|
|
profileCSS = getCSS(baseDir, cssFilename, cssCache)
|
|
|
|
if profileCSS:
|
2020-06-28 21:54:49 +00:00
|
|
|
followingListHtml = htmlHeader(cssFilename, profileCSS)
|
|
|
|
for followingAddress in followingList:
|
|
|
|
if followingAddress:
|
|
|
|
followingListHtml += \
|
2020-06-28 22:02:45 +00:00
|
|
|
'<h3>@' + followingAddress + '</h3>'
|
2020-06-28 21:54:49 +00:00
|
|
|
followingListHtml += htmlFooter()
|
|
|
|
msg = followingListHtml
|
|
|
|
return msg
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
2020-10-29 12:48:58 +00:00
|
|
|
def htmlHashtagBlocked(cssCache: {}, baseDir: str, translate: {}) -> str:
|
2019-08-14 10:32:15 +00:00
|
|
|
"""Show the screen for a blocked hashtag
|
|
|
|
"""
|
2020-04-05 09:17:19 +00:00
|
|
|
blockedHashtagForm = ''
|
|
|
|
cssFilename = baseDir + '/epicyon-suspended.css'
|
|
|
|
if os.path.isfile(baseDir + '/suspended.css'):
|
|
|
|
cssFilename = baseDir + '/suspended.css'
|
2020-10-29 12:48:58 +00:00
|
|
|
|
|
|
|
blockedHashtagCSS = getCSS(baseDir, cssFilename, cssCache)
|
|
|
|
if blockedHashtagCSS:
|
2020-06-19 09:13:41 +00:00
|
|
|
blockedHashtagForm = htmlHeader(cssFilename, blockedHashtagCSS)
|
2020-07-28 10:06:05 +00:00
|
|
|
blockedHashtagForm += '<div><center>\n'
|
2020-09-28 10:54:41 +00:00
|
|
|
blockedHashtagForm += \
|
|
|
|
' <p class="screentitle">' + \
|
|
|
|
translate['Hashtag Blocked'] + '</p>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
blockedHashtagForm += \
|
2020-09-28 11:08:40 +00:00
|
|
|
' <p>See <a href="/terms">' + \
|
|
|
|
translate['Terms of Service'] + '</a></p>\n'
|
2020-07-28 10:06:05 +00:00
|
|
|
blockedHashtagForm += '</center></div>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
blockedHashtagForm += htmlFooter()
|
2019-08-14 10:32:15 +00:00
|
|
|
return blockedHashtagForm
|
2020-03-22 21:16:02 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
|
2020-10-29 12:48:58 +00:00
|
|
|
def htmlRemoveSharedItem(cssCache: {}, translate: {}, baseDir: str,
|
2020-07-11 20:31:25 +00:00
|
|
|
actor: str, shareName: str,
|
|
|
|
callingDomain: str) -> str:
|
2019-08-26 09:13:26 +00:00
|
|
|
"""Shows a screen asking to confirm the removal of a shared item
|
|
|
|
"""
|
2020-04-05 09:17:19 +00:00
|
|
|
itemID = getValidSharedItemID(shareName)
|
|
|
|
nickname = getNicknameFromActor(actor)
|
|
|
|
domain, port = getDomainFromActor(actor)
|
2020-07-11 20:31:25 +00:00
|
|
|
domainFull = domain
|
|
|
|
if port:
|
|
|
|
if port != 80 and port != 443:
|
|
|
|
domainFull = domain + ':' + str(port)
|
2020-04-05 09:17:19 +00:00
|
|
|
sharesFile = baseDir + '/accounts/' + \
|
|
|
|
nickname + '@' + domain + '/shares.json'
|
2019-08-26 09:13:26 +00:00
|
|
|
if not os.path.isfile(sharesFile):
|
2020-04-05 09:17:19 +00:00
|
|
|
print('ERROR: no shares file ' + sharesFile)
|
2019-08-26 09:13:26 +00:00
|
|
|
return None
|
2020-04-05 09:17:19 +00:00
|
|
|
sharesJson = loadJson(sharesFile)
|
2019-08-26 09:13:26 +00:00
|
|
|
if not sharesJson:
|
2019-11-03 09:36:04 +00:00
|
|
|
print('ERROR: unable to load shares.json')
|
2019-08-26 09:13:26 +00:00
|
|
|
return None
|
2019-11-03 09:48:01 +00:00
|
|
|
if not sharesJson.get(itemID):
|
2020-04-05 09:17:19 +00:00
|
|
|
print('ERROR: share named "' + itemID + '" is not in ' + sharesFile)
|
2019-08-26 09:13:26 +00:00
|
|
|
return None
|
2020-04-05 09:17:19 +00:00
|
|
|
sharedItemDisplayName = sharesJson[itemID]['displayName']
|
|
|
|
sharedItemImageUrl = None
|
2019-11-03 09:48:01 +00:00
|
|
|
if sharesJson[itemID].get('imageUrl'):
|
2020-04-05 09:17:19 +00:00
|
|
|
sharedItemImageUrl = sharesJson[itemID]['imageUrl']
|
2019-08-26 09:13:26 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
if os.path.isfile(baseDir + '/img/shares-background.png'):
|
|
|
|
if not os.path.isfile(baseDir + '/accounts/shares-background.png'):
|
|
|
|
copyfile(baseDir + '/img/shares-background.png',
|
|
|
|
baseDir + '/accounts/shares-background.png')
|
2019-08-26 09:13:26 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
cssFilename = baseDir + '/epicyon-follow.css'
|
|
|
|
if os.path.isfile(baseDir + '/follow.css'):
|
|
|
|
cssFilename = baseDir + '/follow.css'
|
2020-10-29 12:48:58 +00:00
|
|
|
|
|
|
|
profileStyle = getCSS(baseDir, cssFilename, cssCache)
|
2020-04-05 09:17:19 +00:00
|
|
|
sharesStr = htmlHeader(cssFilename, profileStyle)
|
2020-07-28 10:31:36 +00:00
|
|
|
sharesStr += '<div class="follow">\n'
|
|
|
|
sharesStr += ' <div class="followAvatar">\n'
|
|
|
|
sharesStr += ' <center>\n'
|
2019-08-26 09:13:26 +00:00
|
|
|
if sharedItemImageUrl:
|
2020-04-05 09:17:19 +00:00
|
|
|
sharesStr += ' <img loading="lazy" src="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
sharedItemImageUrl + '"/>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
sharesStr += \
|
|
|
|
' <p class="followText">' + translate['Remove'] + \
|
2020-07-28 10:31:36 +00:00
|
|
|
' ' + sharedItemDisplayName + ' ?</p>\n'
|
2020-07-11 20:44:20 +00:00
|
|
|
postActor = getAltPath(actor, domainFull, callingDomain)
|
2020-07-28 10:31:36 +00:00
|
|
|
sharesStr += ' <form method="POST" action="' + postActor + '/rmshare">\n'
|
|
|
|
sharesStr += \
|
|
|
|
' <input type="hidden" name="actor" value="' + actor + '">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
sharesStr += ' <input type="hidden" name="shareName" value="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
shareName + '">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
sharesStr += \
|
|
|
|
' <button type="submit" class="button" name="submitYes">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['Yes'] + '</button>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
sharesStr += \
|
|
|
|
' <a href="' + actor + '/inbox' + '"><button class="button">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['No'] + '</button></a>\n'
|
|
|
|
sharesStr += ' </form>\n'
|
|
|
|
sharesStr += ' </center>\n'
|
|
|
|
sharesStr += ' </div>\n'
|
|
|
|
sharesStr += '</div>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
sharesStr += htmlFooter()
|
2019-08-26 09:13:26 +00:00
|
|
|
return sharesStr
|
2019-08-27 12:47:11 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
|
2020-10-29 12:48:58 +00:00
|
|
|
def htmlDeletePost(cssCache: {},
|
|
|
|
recentPostsCache: {}, maxRecentPosts: int,
|
2020-04-05 09:17:19 +00:00
|
|
|
translate, pageNumber: int,
|
|
|
|
session, baseDir: str, messageId: str,
|
|
|
|
httpPrefix: str, projectVersion: str,
|
2020-07-11 16:57:00 +00:00
|
|
|
wfRequest: {}, personCache: {},
|
2020-08-02 09:51:20 +00:00
|
|
|
callingDomain: str,
|
2020-10-11 18:50:13 +00:00
|
|
|
YTReplacementDomain: str,
|
|
|
|
showPublishedDateOnly: bool) -> str:
|
2019-08-27 12:47:11 +00:00
|
|
|
"""Shows a screen asking to confirm the deletion of a post
|
|
|
|
"""
|
|
|
|
if '/statuses/' not in messageId:
|
|
|
|
return None
|
2020-04-05 09:17:19 +00:00
|
|
|
iconsDir = getIconsDir(baseDir)
|
|
|
|
actor = messageId.split('/statuses/')[0]
|
|
|
|
nickname = getNicknameFromActor(actor)
|
|
|
|
domain, port = getDomainFromActor(actor)
|
2020-07-11 16:57:00 +00:00
|
|
|
domainFull = domain
|
|
|
|
if port:
|
|
|
|
if port != 80 and port != 443:
|
|
|
|
domainFull = domain + ':' + str(port)
|
2019-08-27 12:47:11 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
postFilename = locatePost(baseDir, nickname, domain, messageId)
|
2019-08-27 12:47:11 +00:00
|
|
|
if not postFilename:
|
|
|
|
return None
|
2019-09-17 12:14:36 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
postJsonObject = loadJson(postFilename)
|
2019-09-17 12:14:36 +00:00
|
|
|
if not postJsonObject:
|
|
|
|
return None
|
2019-08-27 12:47:11 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
if os.path.isfile(baseDir + '/img/delete-background.png'):
|
|
|
|
if not os.path.isfile(baseDir + '/accounts/delete-background.png'):
|
|
|
|
copyfile(baseDir + '/img/delete-background.png',
|
|
|
|
baseDir + '/accounts/delete-background.png')
|
2019-08-27 12:47:11 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
deletePostStr = None
|
|
|
|
cssFilename = baseDir + '/epicyon-profile.css'
|
|
|
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
|
|
|
cssFilename = baseDir + '/epicyon.css'
|
2020-10-29 12:48:58 +00:00
|
|
|
|
|
|
|
profileStyle = getCSS(baseDir, cssFilename, cssCache)
|
|
|
|
if profileStyle:
|
2020-04-05 09:17:19 +00:00
|
|
|
if httpPrefix != 'https':
|
|
|
|
profileStyle = profileStyle.replace('https://',
|
|
|
|
httpPrefix + '://')
|
|
|
|
deletePostStr = htmlHeader(cssFilename, profileStyle)
|
|
|
|
deletePostStr += \
|
2020-08-29 09:30:23 +00:00
|
|
|
individualPostAsHtml(True, recentPostsCache, maxRecentPosts,
|
2020-04-05 09:17:19 +00:00
|
|
|
iconsDir, translate, pageNumber,
|
|
|
|
baseDir, session, wfRequest, personCache,
|
|
|
|
nickname, domain, port, postJsonObject,
|
|
|
|
None, True, False,
|
|
|
|
httpPrefix, projectVersion, 'outbox',
|
2020-08-02 09:51:20 +00:00
|
|
|
YTReplacementDomain,
|
2020-10-11 18:50:13 +00:00
|
|
|
showPublishedDateOnly,
|
2020-04-05 09:17:19 +00:00
|
|
|
False, False, False, False, False)
|
|
|
|
deletePostStr += '<center>'
|
|
|
|
deletePostStr += \
|
|
|
|
' <p class="followText">' + \
|
|
|
|
translate['Delete this post?'] + '</p>'
|
2020-07-11 16:57:00 +00:00
|
|
|
|
2020-07-11 20:44:20 +00:00
|
|
|
postActor = getAltPath(actor, domainFull, callingDomain)
|
2020-07-11 16:57:00 +00:00
|
|
|
deletePostStr += \
|
2020-07-28 10:31:36 +00:00
|
|
|
' <form method="POST" action="' + postActor + '/rmpost">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
deletePostStr += \
|
|
|
|
' <input type="hidden" name="pageNumber" value="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
str(pageNumber) + '">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
deletePostStr += \
|
|
|
|
' <input type="hidden" name="messageId" value="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
messageId + '">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
deletePostStr += \
|
|
|
|
' <button type="submit" class="button" name="submitYes">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['Yes'] + '</button>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
deletePostStr += \
|
|
|
|
' <a href="' + actor + '/inbox"><button class="button">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['No'] + '</button></a>\n'
|
|
|
|
deletePostStr += ' </form>\n'
|
|
|
|
deletePostStr += '</center>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
deletePostStr += htmlFooter()
|
2019-08-27 12:47:11 +00:00
|
|
|
return deletePostStr
|
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
|
2020-10-29 12:48:58 +00:00
|
|
|
def htmlFollowConfirm(cssCache: {}, translate: {}, baseDir: str,
|
2020-04-05 09:17:19 +00:00
|
|
|
originPathStr: str,
|
|
|
|
followActor: str,
|
2019-09-07 08:57:52 +00:00
|
|
|
followProfileUrl: str) -> str:
|
2019-07-29 09:49:46 +00:00
|
|
|
"""Asks to confirm a follow
|
|
|
|
"""
|
2020-04-05 09:17:19 +00:00
|
|
|
followDomain, port = getDomainFromActor(followActor)
|
2020-03-22 21:16:02 +00:00
|
|
|
|
2020-07-25 19:07:06 +00:00
|
|
|
if os.path.isfile(baseDir + '/accounts/follow-background-custom.jpg'):
|
|
|
|
if not os.path.isfile(baseDir + '/accounts/follow-background.jpg'):
|
|
|
|
copyfile(baseDir + '/accounts/follow-background-custom.jpg',
|
|
|
|
baseDir + '/accounts/follow-background.jpg')
|
2019-07-29 09:49:46 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
cssFilename = baseDir + '/epicyon-follow.css'
|
|
|
|
if os.path.isfile(baseDir + '/follow.css'):
|
|
|
|
cssFilename = baseDir + '/follow.css'
|
2020-10-29 12:48:58 +00:00
|
|
|
|
|
|
|
profileStyle = getCSS(baseDir, cssFilename, cssCache)
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr = htmlHeader(cssFilename, profileStyle)
|
2020-07-28 10:31:36 +00:00
|
|
|
followStr += '<div class="follow">\n'
|
|
|
|
followStr += ' <div class="followAvatar">\n'
|
|
|
|
followStr += ' <center>\n'
|
|
|
|
followStr += ' <a href="' + followActor + '">\n'
|
|
|
|
followStr += ' <img loading="lazy" src="' + followProfileUrl + '"/></a>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += \
|
|
|
|
' <p class="followText">' + translate['Follow'] + ' ' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
getNicknameFromActor(followActor) + '@' + followDomain + ' ?</p>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += ' <form method="POST" action="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
originPathStr + '/followconfirm">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += ' <input type="hidden" name="actor" value="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
followActor + '">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += \
|
|
|
|
' <button type="submit" class="button" name="submitYes">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['Yes'] + '</button>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += \
|
|
|
|
' <a href="' + originPathStr + '"><button class="button">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['No'] + '</button></a>\n'
|
|
|
|
followStr += ' </form>\n'
|
|
|
|
followStr += '</center>\n'
|
|
|
|
followStr += '</div>\n'
|
|
|
|
followStr += '</div>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += htmlFooter()
|
2019-07-29 09:49:46 +00:00
|
|
|
return followStr
|
2019-07-29 20:36:26 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
|
2020-10-29 12:48:58 +00:00
|
|
|
def htmlUnfollowConfirm(cssCache: {}, translate: {}, baseDir: str,
|
2020-04-05 09:17:19 +00:00
|
|
|
originPathStr: str,
|
|
|
|
followActor: str,
|
2019-09-07 08:57:52 +00:00
|
|
|
followProfileUrl: str) -> str:
|
2019-07-29 20:36:26 +00:00
|
|
|
"""Asks to confirm unfollowing an actor
|
|
|
|
"""
|
2020-04-05 09:17:19 +00:00
|
|
|
followDomain, port = getDomainFromActor(followActor)
|
2020-03-22 21:16:02 +00:00
|
|
|
|
2020-07-25 19:07:06 +00:00
|
|
|
if os.path.isfile(baseDir + '/accounts/follow-background-custom.jpg'):
|
|
|
|
if not os.path.isfile(baseDir + '/accounts/follow-background.jpg'):
|
|
|
|
copyfile(baseDir + '/accounts/follow-background-custom.jpg',
|
|
|
|
baseDir + '/accounts/follow-background.jpg')
|
2019-07-29 20:36:26 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
cssFilename = baseDir + '/epicyon-follow.css'
|
|
|
|
if os.path.isfile(baseDir + '/follow.css'):
|
|
|
|
cssFilename = baseDir + '/follow.css'
|
2020-10-29 12:48:58 +00:00
|
|
|
|
|
|
|
profileStyle = getCSS(baseDir, cssFilename, cssCache)
|
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr = htmlHeader(cssFilename, profileStyle)
|
2020-07-28 10:31:36 +00:00
|
|
|
followStr += '<div class="follow">\n'
|
|
|
|
followStr += ' <div class="followAvatar">\n'
|
|
|
|
followStr += ' <center>\n'
|
|
|
|
followStr += ' <a href="' + followActor + '">\n'
|
|
|
|
followStr += ' <img loading="lazy" src="' + followProfileUrl + '"/></a>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += \
|
|
|
|
' <p class="followText">' + translate['Stop following'] + \
|
2020-07-28 10:31:36 +00:00
|
|
|
' ' + getNicknameFromActor(followActor) + \
|
|
|
|
'@' + followDomain + ' ?</p>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += ' <form method="POST" action="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
originPathStr + '/unfollowconfirm">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += ' <input type="hidden" name="actor" value="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
followActor + '">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += \
|
|
|
|
' <button type="submit" class="button" name="submitYes">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['Yes'] + '</button>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += \
|
|
|
|
' <a href="' + originPathStr + '"><button class="button">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['No'] + '</button></a>\n'
|
|
|
|
followStr += ' </form>\n'
|
|
|
|
followStr += '</center>\n'
|
|
|
|
followStr += '</div>\n'
|
|
|
|
followStr += '</div>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
followStr += htmlFooter()
|
2019-07-29 20:36:26 +00:00
|
|
|
return followStr
|
2019-07-30 22:34:04 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
|
2020-10-29 12:48:58 +00:00
|
|
|
def htmlUnblockConfirm(cssCache: {}, translate: {}, baseDir: str,
|
2020-04-05 09:17:19 +00:00
|
|
|
originPathStr: str,
|
|
|
|
blockActor: str,
|
2019-09-07 08:57:52 +00:00
|
|
|
blockProfileUrl: str) -> str:
|
2019-08-02 14:36:03 +00:00
|
|
|
"""Asks to confirm unblocking an actor
|
|
|
|
"""
|
2020-04-05 09:17:19 +00:00
|
|
|
blockDomain, port = getDomainFromActor(blockActor)
|
2020-03-22 21:16:02 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
if os.path.isfile(baseDir + '/img/block-background.png'):
|
|
|
|
if not os.path.isfile(baseDir + '/accounts/block-background.png'):
|
|
|
|
copyfile(baseDir + '/img/block-background.png',
|
|
|
|
baseDir + '/accounts/block-background.png')
|
2019-08-02 14:36:03 +00:00
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
cssFilename = baseDir + '/epicyon-follow.css'
|
|
|
|
if os.path.isfile(baseDir + '/follow.css'):
|
|
|
|
cssFilename = baseDir + '/follow.css'
|
2020-10-29 12:48:58 +00:00
|
|
|
|
|
|
|
profileStyle = getCSS(baseDir, cssFilename, cssCache)
|
|
|
|
|
2020-04-05 09:17:19 +00:00
|
|
|
blockStr = htmlHeader(cssFilename, profileStyle)
|
2020-07-28 10:31:36 +00:00
|
|
|
blockStr += '<div class="block">\n'
|
|
|
|
blockStr += ' <div class="blockAvatar">\n'
|
|
|
|
blockStr += ' <center>\n'
|
|
|
|
blockStr += ' <a href="' + blockActor + '">\n'
|
|
|
|
blockStr += ' <img loading="lazy" src="' + blockProfileUrl + '"/></a>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
blockStr += \
|
|
|
|
' <p class="blockText">' + translate['Stop blocking'] + ' ' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
getNicknameFromActor(blockActor) + '@' + blockDomain + ' ?</p>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
blockStr += ' <form method="POST" action="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
originPathStr + '/unblockconfirm">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
blockStr += ' <input type="hidden" name="actor" value="' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
blockActor + '">\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
blockStr += \
|
|
|
|
' <button type="submit" class="button" name="submitYes">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['Yes'] + '</button>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
blockStr += \
|
|
|
|
' <a href="' + originPathStr + '"><button class="button">' + \
|
2020-07-28 10:31:36 +00:00
|
|
|
translate['No'] + '</button></a>\n'
|
|
|
|
blockStr += ' </form>\n'
|
|
|
|
blockStr += '</center>\n'
|
|
|
|
blockStr += '</div>\n'
|
|
|
|
blockStr += '</div>\n'
|
2020-04-05 09:17:19 +00:00
|
|
|
blockStr += htmlFooter()
|
2019-08-02 14:36:03 +00:00
|
|
|
return blockStr
|