Line endings

main
Bob Mottram 2020-07-28 11:06:05 +01:00
parent da2025a140
commit 5b25712427
1 changed files with 89 additions and 81 deletions

View File

@ -1703,14 +1703,15 @@ def htmlTermsOfService(baseDir: str, httpPrefix: str, domainFull: str) -> str:
termsCSS = termsCSS.replace('https://', httpPrefix+'://') termsCSS = termsCSS.replace('https://', httpPrefix+'://')
TOSForm = htmlHeader(cssFilename, termsCSS) TOSForm = htmlHeader(cssFilename, termsCSS)
TOSForm += '<div class="container">' + TOSText + '</div>' TOSForm += '<div class="container">' + TOSText + '</div>\n'
if adminNickname: if adminNickname:
adminActor = httpPrefix + '://' + domainFull + \ adminActor = httpPrefix + '://' + domainFull + \
'/users/' + adminNickname '/users/' + adminNickname
TOSForm += \ TOSForm += \
'<div class="container"><center>' + \ '<div class="container"><center>\n' + \
'<p class="administeredby">Administered by <a href="' + \ '<p class="administeredby">Administered by <a href="' + \
adminActor + '">' + adminNickname + '</a></p></center></div>' adminActor + '">' + adminNickname + '</a></p>\n' + \
'</center></div>\n'
TOSForm += htmlFooter() TOSForm += htmlFooter()
return TOSForm return TOSForm
@ -1748,14 +1749,16 @@ def htmlAbout(baseDir: str, httpPrefix: str,
aboutForm += '<div class="container">' + aboutText + '</div>' aboutForm += '<div class="container">' + aboutText + '</div>'
if onionDomain: if onionDomain:
aboutForm += \ aboutForm += \
'<div class="container"><center><p class="administeredby">' + \ '<div class="container"><center>\n' + \
'http://' + onionDomain + '</p></center></div>' '<p class="administeredby">' + \
'http://' + onionDomain + '</p>\n</center></div>\n'
if adminNickname: if adminNickname:
adminActor = '/users/' + adminNickname adminActor = '/users/' + adminNickname
aboutForm += \ aboutForm += \
'<div class="container"><center>' + \ '<div class="container"><center>\n' + \
'<p class="administeredby">Administered by <a href="' + \ '<p class="administeredby">Administered by <a href="' + \
adminActor + '">' + adminNickname + '</a></p></center></div>' adminActor + '">' + adminNickname + '</a></p>\n' + \
'</center></div>\n'
aboutForm += htmlFooter() aboutForm += htmlFooter()
return aboutForm return aboutForm
@ -1770,11 +1773,11 @@ def htmlHashtagBlocked(baseDir: str) -> str:
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
blockedHashtagCSS = cssFile.read() blockedHashtagCSS = cssFile.read()
blockedHashtagForm = htmlHeader(cssFilename, blockedHashtagCSS) blockedHashtagForm = htmlHeader(cssFilename, blockedHashtagCSS)
blockedHashtagForm += '<div><center>' blockedHashtagForm += '<div><center>\n'
blockedHashtagForm += ' <p class="screentitle">Hashtag Blocked</p>' blockedHashtagForm += ' <p class="screentitle">Hashtag Blocked</p>\n'
blockedHashtagForm += \ blockedHashtagForm += \
' <p>See <a href="/terms">Terms of Service</a></p>' ' <p>See <a href="/terms">Terms of Service</a></p>\n'
blockedHashtagForm += '</center></div>' blockedHashtagForm += '</center></div>\n'
blockedHashtagForm += htmlFooter() blockedHashtagForm += htmlFooter()
return blockedHashtagForm return blockedHashtagForm
@ -1789,10 +1792,10 @@ def htmlSuspended(baseDir: str) -> str:
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
suspendedCSS = cssFile.read() suspendedCSS = cssFile.read()
suspendedForm = htmlHeader(cssFilename, suspendedCSS) suspendedForm = htmlHeader(cssFilename, suspendedCSS)
suspendedForm += '<div><center>' suspendedForm += '<div><center>\n'
suspendedForm += ' <p class="screentitle">Account Suspended</p>' suspendedForm += ' <p class="screentitle">Account Suspended</p>\n'
suspendedForm += ' <p>See <a href="/terms">Terms of Service</a></p>' suspendedForm += ' <p>See <a href="/terms">Terms of Service</a></p>\n'
suspendedForm += '</center></div>' suspendedForm += '</center></div>\n'
suspendedForm += htmlFooter() suspendedForm += htmlFooter()
return suspendedForm return suspendedForm
@ -1815,13 +1818,13 @@ def htmlNewPost(mediaInstance: bool, translate: {},
if not path.endswith('/newreport'): if not path.endswith('/newreport'):
if not inReplyTo or path.endswith('/newreminder'): if not inReplyTo or path.endswith('/newreminder'):
newPostText = '<p class="new-post-text">' + \ newPostText = '<p class="new-post-text">' + \
translate['Write your post text below.'] + '</p>' translate['Write your post text below.'] + '</p>\n'
else: else:
newPostText = \ newPostText = \
'<p class="new-post-text">' + \ '<p class="new-post-text">' + \
translate['Write your reply to'] + \ translate['Write your reply to'] + \
' <a href="' + inReplyTo + '">' + \ ' <a href="' + inReplyTo + '">' + \
translate['this post'] + '</a></p>' translate['this post'] + '</a></p>\n'
replyStr = '<input type="hidden" ' + \ replyStr = '<input type="hidden" ' + \
'name="replyTo" value="' + inReplyTo + '">' 'name="replyTo" value="' + inReplyTo + '">'
@ -1840,7 +1843,7 @@ def htmlNewPost(mediaInstance: bool, translate: {},
else: else:
newPostText = \ newPostText = \
'<p class="new-post-text">' + \ '<p class="new-post-text">' + \
translate['Write your report below.'] + '</p>' translate['Write your report below.'] + '</p>\n'
# custom report header with any additional instructions # custom report header with any additional instructions
if os.path.isfile(baseDir + '/accounts/report.txt'): if os.path.isfile(baseDir + '/accounts/report.txt'):
@ -1849,7 +1852,7 @@ def htmlNewPost(mediaInstance: bool, translate: {},
if '</p>' not in customReportText: if '</p>' not in customReportText:
customReportText = \ customReportText = \
'<p class="login-subtext">' + \ '<p class="login-subtext">' + \
customReportText + '</p>' customReportText + '</p>\n'
repStr = '<p class="login-subtext">' repStr = '<p class="login-subtext">'
customReportText = \ customReportText = \
customReportText.replace('<p>', repStr) customReportText.replace('<p>', repStr)
@ -1858,24 +1861,26 @@ def htmlNewPost(mediaInstance: bool, translate: {},
idx = 'This message only goes to moderators, even if it ' + \ idx = 'This message only goes to moderators, even if it ' + \
'mentions other fediverse addresses.' 'mentions other fediverse addresses.'
newPostText += \ newPostText += \
'<p class="new-post-subtext">' + translate[idx] + \ '<p class="new-post-subtext">' + translate[idx] + '</p>\n' + \
'</p><p class="new-post-subtext">' + translate['Also see'] + \ '<p class="new-post-subtext">' + translate['Also see'] + \
' <a href="/terms">' + \ ' <a href="/terms">' + \
translate['Terms of Service'] + '</a></p>' translate['Terms of Service'] + '</a></p>\n'
else: else:
newPostText = \ newPostText = \
'<p class="new-post-text">' + \ '<p class="new-post-text">' + \
translate['Enter the details for your shared item below.'] + '</p>' translate['Enter the details for your shared item below.'] + \
'</p>\n'
if path.endswith('/newquestion'): if path.endswith('/newquestion'):
newPostText = \ newPostText = \
'<p class="new-post-text">' + \ '<p class="new-post-text">' + \
translate['Enter the choices for your question below.'] + '</p>' translate['Enter the choices for your question below.'] + \
'</p>\n'
if os.path.isfile(baseDir + '/accounts/newpost.txt'): if os.path.isfile(baseDir + '/accounts/newpost.txt'):
with open(baseDir + '/accounts/newpost.txt', 'r') as file: with open(baseDir + '/accounts/newpost.txt', 'r') as file:
newPostText = \ newPostText = \
'<p class="new-post-text">' + file.read() + '</p>' '<p class="new-post-text">' + file.read() + '</p>\n'
cssFilename = baseDir + '/epicyon-profile.css' cssFilename = baseDir + '/epicyon-profile.css'
if os.path.isfile(baseDir + '/epicyon.css'): if os.path.isfile(baseDir + '/epicyon.css'):
@ -1897,14 +1902,15 @@ def htmlNewPost(mediaInstance: bool, translate: {},
newPostImageSection = ' <div class="container">' newPostImageSection = ' <div class="container">'
newPostImageSection += \ newPostImageSection += \
' <label class="labels">' + translate['Image description'] + \ ' <label class="labels">' + translate['Image description'] + \
'</label>' '</label>\n'
newPostImageSection += ' <input type="text" name="imageDescription">' newPostImageSection += \
' <input type="text" name="imageDescription">\n'
newPostImageSection += \ newPostImageSection += \
' <input type="file" id="attachpic" name="attachpic"' ' <input type="file" id="attachpic" name="attachpic"'
newPostImageSection += \ newPostImageSection += \
' accept=".png, .jpg, .jpeg, .gif, .webp, .mp4, ' + \ ' accept=".png, .jpg, .jpeg, .gif, .webp, .mp4, ' + \
'.webm, .ogv, .mp3, .ogg">' '.webm, .ogv, .mp3, .ogg">\n'
newPostImageSection += ' </div>' newPostImageSection += ' </div>\n'
scopeIcon = 'scope_public.png' scopeIcon = 'scope_public.png'
scopeDescription = translate['Public'] scopeDescription = translate['Public']
@ -1948,19 +1954,19 @@ def htmlNewPost(mediaInstance: bool, translate: {},
scopeDescription = translate['Question'] scopeDescription = translate['Question']
placeholderMessage = translate['Enter your question'] + '...' placeholderMessage = translate['Enter your question'] + '...'
endpoint = 'newquestion' endpoint = 'newquestion'
extraFields = '<div class="container">' extraFields = '<div class="container">\n'
extraFields += ' <label class="labels">' + \ extraFields += ' <label class="labels">' + \
translate['Possible answers'] + ':</label><br>' translate['Possible answers'] + ':</label><br>\n'
for questionCtr in range(8): for questionCtr in range(8):
extraFields += \ extraFields += \
' <input type="text" class="questionOption" placeholder="' + \ ' <input type="text" class="questionOption" placeholder="' + \
str(questionCtr + 1) + \ str(questionCtr + 1) + \
'" name="questionOption' + str(questionCtr) + '"><br>' '" name="questionOption' + str(questionCtr) + '"><br>\n'
extraFields += \ extraFields += \
' <label class="labels">' + \ ' <label class="labels">' + \
translate['Duration of listing in days'] + \ translate['Duration of listing in days'] + \
':</label> <input type="number" name="duration" ' + \ ':</label> <input type="number" name="duration" ' + \
'min="1" max="365" step="1" value="14"><br>' 'min="1" max="365" step="1" value="14"><br>\n'
extraFields += '</div>' extraFields += '</div>'
elif path.endswith('/newshare'): elif path.endswith('/newshare'):
scopeIcon = 'scope_share.png' scopeIcon = 'scope_share.png'
@ -1969,27 +1975,29 @@ def htmlNewPost(mediaInstance: bool, translate: {},
placeholderMessage = \ placeholderMessage = \
translate['Description of the item being shared'] + '...' translate['Description of the item being shared'] + '...'
endpoint = 'newshare' endpoint = 'newshare'
extraFields = '<div class="container">' extraFields = '<div class="container">\n'
extraFields += \ extraFields += \
' <label class="labels">' + \ ' <label class="labels">' + \
translate['Type of shared item. eg. hat'] + ':</label>' translate['Type of shared item. eg. hat'] + ':</label>\n'
extraFields += ' <input type="text" class="itemType" name="itemType">' extraFields += \
' <input type="text" class="itemType" name="itemType">\n'
extraFields += \ extraFields += \
' <br><label class="labels">' + \ ' <br><label class="labels">' + \
translate['Category of shared item. eg. clothing'] + ':</label>' translate['Category of shared item. eg. clothing'] + ':</label>\n'
extraFields += ' <input type="text" class="category" name="category">' extraFields += \
' <input type="text" class="category" name="category">\n'
extraFields += \ extraFields += \
' <br><label class="labels">' + \ ' <br><label class="labels">' + \
translate['Duration of listing in days'] + ':</label>' translate['Duration of listing in days'] + ':</label>\n'
extraFields += ' <input type="number" name="duration" ' + \ extraFields += ' <input type="number" name="duration" ' + \
'min="1" max="365" step="1" value="14">' 'min="1" max="365" step="1" value="14">\n'
extraFields += '</div>' extraFields += '</div>\n'
extraFields += '<div class="container">' extraFields += '<div class="container">\n'
extraFields += \ extraFields += \
'<label class="labels">' + \ '<label class="labels">' + \
translate['City or location of the shared item'] + ':</label>' translate['City or location of the shared item'] + ':</label>\n'
extraFields += '<input type="text" name="location">' extraFields += '<input type="text" name="location">\n'
extraFields += '</div>' extraFields += '</div>\n'
dateAndLocation = '' dateAndLocation = ''
if endpoint != 'newshare' and \ if endpoint != 'newshare' and \
@ -2001,24 +2009,24 @@ def htmlNewPost(mediaInstance: bool, translate: {},
dateAndLocation += \ dateAndLocation += \
'<p><input type="checkbox" class="profilecheckbox" ' + \ '<p><input type="checkbox" class="profilecheckbox" ' + \
'name="schedulePost"><label class="labels"> ' + \ 'name="schedulePost"><label class="labels"> ' + \
translate['This is a scheduled post.'] + '</label></p>' translate['This is a scheduled post.'] + '</label></p>\n'
dateAndLocation += \ dateAndLocation += \
'<p><img loading="lazy" alt="" title="" ' + \ '<p><img loading="lazy" alt="" title="" ' + \
'class="emojicalendar" src="/' + \ 'class="emojicalendar" src="/' + \
iconsDir + '/calendar.png"/>' iconsDir + '/calendar.png"/>\n'
dateAndLocation += '<label class="labels">' + \ dateAndLocation += '<label class="labels">' + \
translate['Date'] + ': </label>' translate['Date'] + ': </label>\n'
dateAndLocation += '<input type="date" name="eventDate">' dateAndLocation += '<input type="date" name="eventDate">\n'
dateAndLocation += '<label class="labelsright">' + \ dateAndLocation += '<label class="labelsright">' + \
translate['Time'] + ':' translate['Time'] + ':'
dateAndLocation += '<input type="time" name="eventTime"></label></p>' dateAndLocation += '<input type="time" name="eventTime"></label></p>\n'
dateAndLocation += '</div>' dateAndLocation += '</div>\n'
dateAndLocation += '<div class="container">' dateAndLocation += '<div class="container">\n'
dateAndLocation += '<br><label class="labels">' + \ dateAndLocation += '<br><label class="labels">' + \
translate['Location'] + ': </label>' translate['Location'] + ': </label>\n'
dateAndLocation += '<input type="text" name="location">' dateAndLocation += '<input type="text" name="location">\n'
dateAndLocation += '</div>' dateAndLocation += '</div>\n'
newPostForm = htmlHeader(cssFilename, newPostCSS) newPostForm = htmlHeader(cssFilename, newPostCSS)
@ -2343,12 +2351,12 @@ def htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
if authorized and pageNumber > 1: if authorized and pageNumber > 1:
# page up arrow # page up arrow
profileStr += \ profileStr += \
'<center><a href="' + actor + '/' + feedName + \ '<center>\n<a href="' + actor + '/' + feedName + \
'?page=' + str(pageNumber - 1) + \ '?page=' + str(pageNumber - 1) + \
'"><img loading="lazy" class="pageicon" src="/' + \ '"><img loading="lazy" class="pageicon" src="/' + \
iconsDir + '/pageup.png" title="' + \ iconsDir + '/pageup.png" title="' + \
translate['Page up'] + '" alt="' + \ translate['Page up'] + '" alt="' + \
translate['Page up'] + '"></a></center>' translate['Page up'] + '"></a>\n</center>\n'
for item in followingJson['orderedItems']: for item in followingJson['orderedItems']:
profileStr += \ profileStr += \
@ -2361,12 +2369,12 @@ def htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
if len(followingJson['orderedItems']) >= maxItemsPerPage: if len(followingJson['orderedItems']) >= maxItemsPerPage:
# page down arrow # page down arrow
profileStr += \ profileStr += \
'<center><a href="' + actor + '/' + feedName + \ '<center>\n<a href="' + actor + '/' + feedName + \
'?page=' + str(pageNumber + 1) + \ '?page=' + str(pageNumber + 1) + \
'"><img loading="lazy" class="pageicon" src="/' + \ '"><img loading="lazy" class="pageicon" src="/' + \
iconsDir + '/pagedown.png" title="' + \ iconsDir + '/pagedown.png" title="' + \
translate['Page down'] + '" alt="' + \ translate['Page down'] + '" alt="' + \
translate['Page down'] + '"></a></center>' translate['Page down'] + '"></a>\n</center>\n'
return profileStr return profileStr
@ -2377,16 +2385,16 @@ def htmlProfileRoles(translate: {}, nickname: str, domain: str,
profileStr = '' profileStr = ''
for project, rolesList in rolesJson.items(): for project, rolesList in rolesJson.items():
profileStr += \ profileStr += \
'<div class="roles"><h2>' + project + \ '<div class="roles">\n<h2>' + project + \
'</h2><div class="roles-inner">' '</h2>\n<div class="roles-inner">\n'
for role in rolesList: for role in rolesList:
profileStr += '<h3>' + role + '</h3>' profileStr += '<h3>' + role + '</h3>\n'
profileStr += '</div></div>' profileStr += '</div></div>\n'
if len(profileStr) == 0: if len(profileStr) == 0:
profileStr += \ profileStr += \
'<p>@' + nickname + '@' + domain + ' has no roles assigned</p>' '<p>@' + nickname + '@' + domain + ' has no roles assigned</p>\n'
else: else:
profileStr = '<div>' + profileStr + '</div>' profileStr = '<div>' + profileStr + '</div>\n'
return profileStr return profileStr
@ -2399,10 +2407,10 @@ def htmlProfileSkills(translate: {}, nickname: str, domain: str,
profileStr += \ profileStr += \
'<div>' + skill + \ '<div>' + skill + \
'<br><div id="myProgress"><div id="myBar" style="width:' + \ '<br><div id="myProgress"><div id="myBar" style="width:' + \
str(level) + '%"></div></div></div><br>' str(level) + '%"></div></div></div>\n<br>\n'
if len(profileStr) > 0: if len(profileStr) > 0:
profileStr = '<center><div class="skill-title">' + \ profileStr = '<center><div class="skill-title">' + \
profileStr + '</div></center>' profileStr + '</div></center>\n'
return profileStr return profileStr
@ -2410,33 +2418,33 @@ def htmlIndividualShare(actor: str, item: {}, translate: {},
showContact: bool, removeButton: bool) -> str: showContact: bool, removeButton: bool) -> str:
"""Returns an individual shared item as html """Returns an individual shared item as html
""" """
profileStr = '<div class="container">' profileStr = '<div class="container">\n'
profileStr += '<p class="share-title">' + item['displayName'] + '</p>' profileStr += '<p class="share-title">' + item['displayName'] + '</p>\n'
if item.get('imageUrl'): if item.get('imageUrl'):
profileStr += '<a href="' + item['imageUrl'] + '">' profileStr += '<a href="' + item['imageUrl'] + '">\n'
profileStr += \ profileStr += \
'<img loading="lazy" src="' + item['imageUrl'] + \ '<img loading="lazy" src="' + item['imageUrl'] + \
'" alt="' + translate['Item image'] + '"></a>' '" alt="' + translate['Item image'] + '">\n</a>\n'
profileStr += '<p>' + item['summary'] + '</p>' profileStr += '<p>' + item['summary'] + '</p>\n'
profileStr += \ profileStr += \
'<p><b>' + translate['Type'] + ':</b> ' + item['itemType'] + ' ' '<p><b>' + translate['Type'] + ':</b> ' + item['itemType'] + ' '
profileStr += \ profileStr += \
'<b>' + translate['Category'] + ':</b> ' + item['category'] + ' ' '<b>' + translate['Category'] + ':</b> ' + item['category'] + ' '
profileStr += \ profileStr += \
'<b>' + translate['Location'] + ':</b> ' + item['location'] + '</p>' '<b>' + translate['Location'] + ':</b> ' + item['location'] + '</p>\n'
if showContact: if showContact:
contactActor = item['actor'] contactActor = item['actor']
profileStr += \ profileStr += \
'<p><a href="' + actor + \ '<p><a href="' + actor + \
'?replydm=sharedesc:' + item['displayName'] + \ '?replydm=sharedesc:' + item['displayName'] + \
'?mention=' + contactActor + '"><button class="button">' + \ '?mention=' + contactActor + '"><button class="button">' + \
translate['Contact'] + '</button></a>' translate['Contact'] + '</button></a>\n'
if removeButton: if removeButton:
profileStr += \ profileStr += \
' <a href="' + actor + '?rmshare=' + item['displayName'] + \ ' <a href="' + actor + '?rmshare=' + item['displayName'] + \
'"><button class="button">' + \ '"><button class="button">' + \
translate['Remove'] + '</button></a>' translate['Remove'] + '</button></a>\n'
profileStr += '</div>' profileStr += '</div>\n'
return profileStr return profileStr
@ -2448,7 +2456,7 @@ def htmlProfileShares(actor: str, translate: {},
for item in sharesJson['orderedItems']: for item in sharesJson['orderedItems']:
profileStr += htmlIndividualShare(actor, item, translate, False, False) profileStr += htmlIndividualShare(actor, item, translate, False, False)
if len(profileStr) > 0: if len(profileStr) > 0:
profileStr = '<div class="share-title">' + profileStr + '</div>' profileStr = '<div class="share-title">' + profileStr + '</div>\n'
return profileStr return profileStr
@ -2523,11 +2531,11 @@ def htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int,
if pageNumber > 1: if pageNumber > 1:
iconsDir = getIconsDir(baseDir) iconsDir = getIconsDir(baseDir)
timelineStr += \ timelineStr += \
'<center><a href="' + actor + '/tlshares?page=' + \ '<center>\n<a href="' + actor + '/tlshares?page=' + \
str(pageNumber - 1) + \ str(pageNumber - 1) + \
'"><img loading="lazy" class="pageicon" src="/' + \ '"><img loading="lazy" class="pageicon" src="/' + \
iconsDir + '/pageup.png" title="' + translate['Page up'] + \ iconsDir + '/pageup.png" title="' + translate['Page up'] + \
'" alt="' + translate['Page up'] + '"></a></center>' '" alt="' + translate['Page up'] + '"></a>\n</center>\n'
for published, item in sharesJson.items(): for published, item in sharesJson.items():
showContactButton = False showContactButton = False
@ -2543,11 +2551,11 @@ def htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int,
if not lastPage: if not lastPage:
iconsDir = getIconsDir(baseDir) iconsDir = getIconsDir(baseDir)
timelineStr += \ timelineStr += \
'<center><a href="' + actor + '/tlshares?page=' + \ '<center>\n<a href="' + actor + '/tlshares?page=' + \
str(pageNumber + 1) + \ str(pageNumber + 1) + \
'"><img loading="lazy" class="pageicon" src="/' + \ '"><img loading="lazy" class="pageicon" src="/' + \
iconsDir + '/pagedown.png" title="' + translate['Page down'] + \ iconsDir + '/pagedown.png" title="' + translate['Page down'] + \
'" alt="' + translate['Page down'] + '"></a></center>' '" alt="' + translate['Page down'] + '"></a>\n</center>\n'
return timelineStr return timelineStr