alt-html-css
Bob Mottram 2020-12-16 11:19:16 +00:00
parent 6ec956e312
commit 825fb76066
11 changed files with 36 additions and 109 deletions

View File

@ -11,6 +11,7 @@ from webfinger import webfingerHandle
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from utils import getFullDomain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import loadJson from utils import loadJson
@ -259,12 +260,7 @@ def sendRoleViaServer(baseDir: str, session,
print('WARN: No session for sendRoleViaServer') print('WARN: No session for sendRoleViaServer')
return 6 return 6
delegatorDomainFull = delegatorDomain delegatorDomainFull = getFullDomain(delegatorDomain, delegatorPort)
if delegatorPort:
if delegatorPort != 80 and delegatorPort != 443:
if ':' not in delegatorDomain:
delegatorDomainFull = \
delegatorDomain + ':' + str(delegatorPort)
toUrl = \ toUrl = \
httpPrefix + '://' + delegatorDomainFull + '/users/' + nickname httpPrefix + '://' + delegatorDomainFull + '/users/' + nickname

View File

@ -13,6 +13,7 @@ from auth import createBasicAuthHeader
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from session import postImage from session import postImage
from utils import getFullDomain
from utils import validNickname from utils import validNickname
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
@ -115,11 +116,7 @@ def addShare(baseDir: str,
imageFilename = sharesImageFilename + '.' + ext imageFilename = sharesImageFilename + '.' + ext
moveImage = True moveImage = True
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
# copy or move the image for the shared item to its destination # copy or move the image for the shared item to its destination
if imageFilename: if imageFilename:
@ -247,10 +244,7 @@ def getSharesFeedForPerson(baseDir: str,
if not validNickname(domain, nickname): if not validNickname(domain, nickname):
return None return None
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
handleDomain = domain handleDomain = domain
if ':' in handleDomain: if ':' in handleDomain:
@ -331,11 +325,7 @@ def sendShareViaServer(baseDir, session,
print('WARN: No session for sendShareViaServer') print('WARN: No session for sendShareViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomainFull + \ ccUrl = httpPrefix + '://' + fromDomainFull + \
@ -439,11 +429,7 @@ def sendUndoShareViaServer(baseDir: str, session,
print('WARN: No session for sendUndoShareViaServer') print('WARN: No session for sendUndoShareViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomainFull + \ ccUrl = httpPrefix + '://' + fromDomainFull + \

View File

@ -11,6 +11,7 @@ from webfinger import webfingerHandle
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from utils import getFullDomain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import loadJson from utils import loadJson
@ -108,11 +109,7 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
print('WARN: No session for sendSkillViaServer') print('WARN: No session for sendSkillViaServer')
return 6 return 6
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
actor = httpPrefix + '://' + domainFull + '/users/' + nickname actor = httpPrefix + '://' + domainFull + '/users/' + nickname
toUrl = actor toUrl = actor

View File

@ -33,6 +33,7 @@ from follow import clearFollows
from follow import clearFollowers from follow import clearFollowers
from follow import sendFollowRequestViaServer from follow import sendFollowRequestViaServer
from follow import sendUnfollowRequestViaServer from follow import sendUnfollowRequestViaServer
from utils import getFullDomain
from utils import validNickname from utils import validNickname
from utils import firstParagraphFromString from utils import firstParagraphFromString
from utils import removeIdEnding from utils import removeIdEnding
@ -127,11 +128,7 @@ def testHttpsigBase(withDigest):
} }
messageBodyJsonStr = json.dumps(messageBodyJson) messageBodyJsonStr = json.dumps(messageBodyJson)
headersDomain = domain headersDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
headersDomain = domain + ':' + str(port)
dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()) dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime())
boxpath = '/inbox' boxpath = '/inbox'

View File

@ -8,6 +8,7 @@ __status__ = "Production"
import os import os
from shutil import copyfile from shutil import copyfile
from utils import getFullDomain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import locatePost from utils import locatePost
@ -35,10 +36,7 @@ def htmlConfirmDelete(cssCache: {},
actor = messageId.split('/statuses/')[0] actor = messageId.split('/statuses/')[0]
nickname = getNicknameFromActor(actor) nickname = getNicknameFromActor(actor)
domain, port = getDomainFromActor(actor) domain, port = getDomainFromActor(actor)
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
postFilename = locatePost(baseDir, nickname, domain, messageId) postFilename = locatePost(baseDir, nickname, domain, messageId)
if not postFilename: if not postFilename:
@ -103,10 +101,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, baseDir: str,
itemID = getValidSharedItemID(shareName) itemID = getValidSharedItemID(shareName)
nickname = getNicknameFromActor(actor) nickname = getNicknameFromActor(actor)
domain, port = getDomainFromActor(actor) domain, port = getDomainFromActor(actor)
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
sharesFile = baseDir + '/accounts/' + \ sharesFile = baseDir + '/accounts/' + \
nickname + '@' + domain + '/shares.json' nickname + '@' + domain + '/shares.json'
if not os.path.isfile(sharesFile): if not os.path.isfile(sharesFile):

View File

@ -11,6 +11,7 @@ from shutil import copyfile
from petnames import getPetName from petnames import getPetName
from person import isPersonSnoozed from person import isPersonSnoozed
from posts import isModerator from posts import isModerator
from utils import getFullDomain
from utils import isDormant from utils import isDormant
from utils import removeHtml from utils import removeHtml
from utils import getDomainFromActor from utils import getDomainFromActor
@ -45,10 +46,7 @@ def htmlPersonOptions(defaultTimeline: str,
"""Show options for a person: view/follow/block/report """Show options for a person: view/follow/block/report
""" """
optionsDomain, optionsPort = getDomainFromActor(optionsActor) optionsDomain, optionsPort = getDomainFromActor(optionsActor)
optionsDomainFull = optionsDomain optionsDomainFull = getFullDomain(optionsDomain, optionsPort)
if optionsPort:
if optionsPort != 80 and optionsPort != 443:
optionsDomainFull = optionsDomain + ':' + str(optionsPort)
if os.path.isfile(baseDir + '/accounts/options-background-custom.jpg'): if os.path.isfile(baseDir + '/accounts/options-background-custom.jpg'):
if not os.path.isfile(baseDir + '/accounts/options-background.jpg'): if not os.path.isfile(baseDir + '/accounts/options-background.jpg'):
@ -74,10 +72,7 @@ def htmlPersonOptions(defaultTimeline: str,
dormantMonths) dormantMonths)
optionsNickname = getNicknameFromActor(optionsActor) optionsNickname = getNicknameFromActor(optionsActor)
optionsDomainFull = optionsDomain optionsDomainFull = getFullDomain(optionsDomain, optionsPort)
if optionsPort:
if optionsPort != 80 and optionsPort != 443:
optionsDomainFull = optionsDomain + ':' + str(optionsPort)
if isBlocked(baseDir, nickname, domain, if isBlocked(baseDir, nickname, domain,
optionsNickname, optionsDomainFull): optionsNickname, optionsDomainFull):
blockStr = 'Block' blockStr = 'Block'

View File

@ -22,6 +22,7 @@ from posts import getPersonBox
from posts import isDM from posts import isDM
from posts import downloadAnnounce from posts import downloadAnnounce
from posts import populateRepliesJson from posts import populateRepliesJson
from utils import getFullDomain
from utils import isEditor from utils import isEditor
from utils import locatePost from utils import locatePost
from utils import loadJson from utils import loadJson
@ -1135,11 +1136,7 @@ def individualPostAsHtml(allowDownloads: bool,
if messageId: if messageId:
messageIdStr = ';' + messageId messageIdStr = ';' + messageId
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
pageNumberParam = '' pageNumberParam = ''
if pageNumber: if pageNumber:
@ -1604,19 +1601,14 @@ def htmlIndividualPost(cssCache: {},
if likedBy: if likedBy:
likedByNickname = getNicknameFromActor(likedBy) likedByNickname = getNicknameFromActor(likedBy)
likedByDomain, likedByPort = getDomainFromActor(likedBy) likedByDomain, likedByPort = getDomainFromActor(likedBy)
if likedByPort: likedByDomain = getFullDomain(likedByDomain, likedByPort)
if likedByPort != 80 and likedByPort != 443:
likedByDomain += ':' + str(likedByPort)
likedByHandle = likedByNickname + '@' + likedByDomain likedByHandle = likedByNickname + '@' + likedByDomain
postStr += \ postStr += \
'<p>' + translate['Liked by'] + \ '<p>' + translate['Liked by'] + \
' <a href="' + likedBy + '">@' + \ ' <a href="' + likedBy + '">@' + \
likedByHandle + '</a>\n' likedByHandle + '</a>\n'
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
actor = '/users/' + nickname actor = '/users/' + nickname
followStr = ' <form method="POST" ' + \ followStr = ' <form method="POST" ' + \
'accept-charset="UTF-8" action="' + actor + '/searchhandle">\n' 'accept-charset="UTF-8" action="' + actor + '/searchhandle">\n'

View File

@ -8,6 +8,7 @@ __status__ = "Production"
import os import os
from pprint import pprint from pprint import pprint
from utils import getFullDomain
from utils import isDormant from utils import isDormant
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
@ -97,11 +98,7 @@ def htmlProfileAfterSearch(cssCache: {},
print('DEBUG: No domain found in ' + profileHandle) print('DEBUG: No domain found in ' + profileHandle)
return None return None
searchDomainFull = searchDomain searchDomainFull = getFullDomain(searchDomain, searchPort)
if searchPort:
if searchPort != 80 and searchPort != 443:
if ':' not in searchDomain:
searchDomainFull = searchDomain + ':' + str(searchPort)
profileStr = '' profileStr = ''
cssFilename = baseDir + '/epicyon-profile.css' cssFilename = baseDir + '/epicyon-profile.css'
@ -225,10 +222,7 @@ def htmlProfileAfterSearch(cssCache: {},
profileDescriptionShort, profileDescriptionShort,
avatarUrl, imageUrl) avatarUrl, imageUrl)
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
followIsPermitted = True followIsPermitted = True
if searchNickname == 'news' and searchDomainFull == domainFull: if searchNickname == 'news' and searchDomainFull == domainFull:
@ -834,11 +828,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
nickname = getNicknameFromActor(path) nickname = getNicknameFromActor(path)
if not nickname: if not nickname:
return '' return ''
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
actorFilename = \ actorFilename = \
baseDir + '/accounts/' + nickname + '@' + domain + '.json' baseDir + '/accounts/' + nickname + '@' + domain + '.json'

View File

@ -10,6 +10,7 @@ import os
from shutil import copyfile from shutil import copyfile
import urllib.parse import urllib.parse
from datetime import datetime from datetime import datetime
from utils import getFullDomain
from utils import isEditor from utils import isEditor
from utils import loadJson from utils import loadJson
from utils import getDomainFromActor from utils import getDomainFromActor
@ -544,10 +545,7 @@ def htmlHistorySearch(cssCache: {}, translate: {}, baseDir: str,
htmlHeaderWithExternalStyle(cssFilename) htmlHeaderWithExternalStyle(cssFilename)
# add the page title # add the page title
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
actor = httpPrefix + '://' + domainFull + '/users/' + nickname actor = httpPrefix + '://' + domainFull + '/users/' + nickname
historySearchForm += \ historySearchForm += \
'<center><h1><a href="' + actor + '/search">' + \ '<center><h1><a href="' + actor + '/search">' + \
@ -823,10 +821,7 @@ def rssHashtagSearch(nickname: str, domain: str, port: int,
if not lines: if not lines:
return None return None
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
maxFeedLength = 10 maxFeedLength = 10
hashtagFeed = \ hashtagFeed = \

View File

@ -8,6 +8,7 @@ __status__ = "Production"
import os import os
import time import time
from utils import getFullDomain
from utils import isEditor from utils import isEditor
from utils import removeIdEnding from utils import removeIdEnding
from follow import followerApprovalActive from follow import followerApprovalActive
@ -191,10 +192,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
eventsButton = 'buttonselected' eventsButton = 'buttonselected'
# get the full domain, including any port number # get the full domain, including any port number
fullDomain = domain fullDomain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
usersPath = '/users/' + nickname usersPath = '/users/' + nickname
actor = httpPrefix + '://' + fullDomain + usersPath actor = httpPrefix + '://' + fullDomain + usersPath
@ -399,10 +397,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
tlStr += ' <tbody>\n' tlStr += ' <tbody>\n'
tlStr += ' <tr>\n' tlStr += ' <tr>\n'
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
# left column # left column
leftColumnStr = \ leftColumnStr = \
@ -655,10 +650,7 @@ def htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int,
sharesJson, lastPage = \ sharesJson, lastPage = \
sharesTimelineJson(actor, pageNumber, itemsPerPage, sharesTimelineJson(actor, pageNumber, itemsPerPage,
baseDir, maxSharesPerAccount) baseDir, maxSharesPerAccount)
domainFull = domain domainFull = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
actor = httpPrefix + '://' + domainFull + '/users/' + nickname actor = httpPrefix + '://' + domainFull + '/users/' + nickname
timelineStr = '' timelineStr = ''

View File

@ -18,6 +18,7 @@ import urllib.parse
from session import getJson from session import getJson
from cache import storeWebfingerInCache from cache import storeWebfingerInCache
from cache import getWebfingerFromCache from cache import getWebfingerFromCache
from utils import getFullDomain
from utils import loadJson from utils import loadJson
from utils import loadJsonOnionify from utils import loadJsonOnionify
from utils import saveJson from utils import saveJson
@ -113,10 +114,7 @@ def storeWebfingerEndpoint(nickname: str, domain: str, port: int,
"""Stores webfinger endpoint for a user to a file """Stores webfinger endpoint for a user to a file
""" """
originalDomain = domain originalDomain = domain
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
handle = nickname + '@' + domain handle = nickname + '@' + domain
wfSubdir = '/wfendpoints' wfSubdir = '/wfendpoints'
if not os.path.isdir(baseDir + wfSubdir): if not os.path.isdir(baseDir + wfSubdir):
@ -135,10 +133,7 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int,
"""Creates a webfinger endpoint for a user """Creates a webfinger endpoint for a user
""" """
originalDomain = domain originalDomain = domain
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
personName = nickname personName = nickname
personId = httpPrefix + "://" + domain + "/users/" + personName personId = httpPrefix + "://" + domain + "/users/" + personName
@ -245,10 +240,7 @@ def webfingerLookup(path: str, baseDir: str,
if debug: if debug:
print('DEBUG: WEBFINGER no @ in handle ' + handle) print('DEBUG: WEBFINGER no @ in handle ' + handle)
return None return None
if port: handle = getFullDomain(handle, port)
if port != 80 and port != 443:
if ':' not in handle:
handle = handle + ':' + str(port)
# convert @domain@domain to inbox@domain # convert @domain@domain to inbox@domain
if '@' in handle: if '@' in handle:
handleDomain = handle.split('@')[1] handleDomain = handle.split('@')[1]