Replace https in css

main
Bob Mottram 2019-12-10 14:48:08 +00:00
parent fbc8ff9437
commit 27276b332b
3 changed files with 47 additions and 13 deletions

View File

@ -2314,7 +2314,8 @@ class PubServer(BaseHTTPRequestHandler):
msg=htmlEditProfile(self.server.translate, \ msg=htmlEditProfile(self.server.translate, \
self.server.baseDir, \ self.server.baseDir, \
self.path,self.server.domain, \ self.path,self.server.domain, \
self.server.port).encode() self.server.port, \
self.server.httpPrefix).encode()
self._set_headers('text/html',len(msg),cookie) self._set_headers('text/html',len(msg),cookie)
self._write(msg) self._write(msg)
self.server.GETbusy=False self.server.GETbusy=False
@ -4456,7 +4457,8 @@ class PubServer(BaseHTTPRequestHandler):
moderationText.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip() moderationText.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip()
elif moderationStr.startswith('submitInfo'): elif moderationStr.startswith('submitInfo'):
msg=htmlModerationInfo(self.server.translate, \ msg=htmlModerationInfo(self.server.translate, \
self.server.baseDir).encode('utf-8') self.server.baseDir, \
self.server.httpPrefix).encode('utf-8')
self._login_headers('text/html',len(msg)) self._login_headers('text/html',len(msg))
self._write(msg) self._write(msg)
self.server.POSTbusy=False self.server.POSTbusy=False
@ -4654,7 +4656,9 @@ class PubServer(BaseHTTPRequestHandler):
searchStr=searchStr.replace('*','').strip() searchStr=searchStr.replace('*','').strip()
skillStr= \ skillStr= \
htmlSkillsSearch(self.server.translate, \ htmlSkillsSearch(self.server.translate, \
self.server.baseDir,searchStr, \ self.server.baseDir, \
self.server.httpPrefix, \
searchStr, \
self.server.instanceOnlySkillsSearch, \ self.server.instanceOnlySkillsSearch, \
64) 64)
if skillStr: if skillStr:
@ -4703,7 +4707,9 @@ class PubServer(BaseHTTPRequestHandler):
# emoji search # emoji search
emojiStr= \ emojiStr= \
htmlSearchEmoji(self.server.translate, \ htmlSearchEmoji(self.server.translate, \
self.server.baseDir,searchStr) self.server.baseDir, \
self.server.httpPrefix, \
searchStr)
if emojiStr: if emojiStr:
msg=emojiStr.encode('utf-8') msg=emojiStr.encode('utf-8')
self._login_headers('text/html',len(msg)) self._login_headers('text/html',len(msg))

View File

@ -1493,7 +1493,7 @@ if not registration:
if setTheme(baseDir,themeName): if setTheme(baseDir,themeName):
print('Theme set to '+themeName) print('Theme set to '+themeName)
runDaemon(args.mediainstance,args.maxRecentPosts, \ runDaemon(args.mediainstance,args.maxRecentPosts, \
not args.nosharedinbox, \ not args.nosharedinbox, \
registration,args.language,__version__, \ registration,args.language,__version__, \

View File

@ -144,7 +144,7 @@ def getPersonAvatarUrl(baseDir: str,personUrl: str,personCache: {}) -> str:
return personJson['icon']['url'] return personJson['icon']['url']
return None return None
def htmlSearchEmoji(translate: {},baseDir: str,searchStr: str) -> str: def htmlSearchEmoji(translate: {},baseDir: str,httpPrefix: str,searchStr: str) -> str:
"""Search results for emoji """Search results for emoji
""" """
@ -159,6 +159,8 @@ def htmlSearchEmoji(translate: {},baseDir: str,searchStr: str) -> str:
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
emojiCSS=cssFile.read() emojiCSS=cssFile.read()
if httpPrefix!='https':
emojiCSS=emojiCSS.replace('https://',httpPrefix+'://')
emojiLookupFilename=baseDir+'/emoji/emoji.json' emojiLookupFilename=baseDir+'/emoji/emoji.json'
# create header # create header
@ -219,9 +221,12 @@ def htmlSearchSharedItems(translate: {}, \
searchStrLowerList=searchStrLower.split('+') searchStrLowerList=searchStrLower.split('+')
cssFilename=baseDir+'/epicyon-profile.css' cssFilename=baseDir+'/epicyon-profile.css'
if os.path.isfile(baseDir+'/epicyon.css'): if os.path.isfile(baseDir+'/epicyon.css'):
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
sharedItemsCSS=cssFile.read() sharedItemsCSS=cssFile.read()
if httpPrefix!='https':
sharedItemsCSS=sharedItemsCSS.replace('https://',httpPrefix+'://')
sharedItemsForm=htmlHeader(cssFilename,sharedItemsCSS) sharedItemsForm=htmlHeader(cssFilename,sharedItemsCSS)
sharedItemsForm+='<center><h1>'+translate['Shared Items Search']+'</h1></center>' sharedItemsForm+='<center><h1>'+translate['Shared Items Search']+'</h1></center>'
resultsExist=False resultsExist=False
@ -299,13 +304,15 @@ def htmlSearchSharedItems(translate: {}, \
sharedItemsForm+=htmlFooter() sharedItemsForm+=htmlFooter()
return sharedItemsForm return sharedItemsForm
def htmlModerationInfo(translate: {},baseDir: str) -> str: def htmlModerationInfo(translate: {},baseDir: str,httpPrefix: str) -> str:
infoForm='' infoForm=''
cssFilename=baseDir+'/epicyon-profile.css' cssFilename=baseDir+'/epicyon-profile.css'
if os.path.isfile(baseDir+'/epicyon.css'): if os.path.isfile(baseDir+'/epicyon.css'):
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
infoCSS=cssFile.read() infoCSS=cssFile.read()
if httpPrefix!='https':
infoCSS=infoCSS.replace('https://',httpPrefix+'://')
infoForm=htmlHeader(cssFilename,infoCSS) infoForm=htmlHeader(cssFilename,infoCSS)
infoForm+='<center><h1>'+translate['Moderation Information']+'</h1></center>' infoForm+='<center><h1>'+translate['Moderation Information']+'</h1></center>'
@ -359,6 +366,8 @@ def htmlHashtagSearch(recentPostsCache: {},maxRecentPosts: int, \
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
hashtagSearchCSS = cssFile.read() hashtagSearchCSS = cssFile.read()
if httpPrefix!='https':
hashtagSearchCSS=hashtagSearchCSS.replace('https://',httpPrefix+'://')
startIndex=len(lines)-1-int(pageNumber*postsPerPage) startIndex=len(lines)-1-int(pageNumber*postsPerPage)
if startIndex<0: if startIndex<0:
@ -409,6 +418,7 @@ def htmlHashtagSearch(recentPostsCache: {},maxRecentPosts: int, \
return hashtagSearchForm return hashtagSearchForm
def htmlSkillsSearch(translate: {},baseDir: str, \ def htmlSkillsSearch(translate: {},baseDir: str, \
httpPrefix: str, \
skillsearch: str,instanceOnly: bool, \ skillsearch: str,instanceOnly: bool, \
postsPerPage: int) -> str: postsPerPage: int) -> str:
"""Show a page containing search results for a skill """Show a page containing search results for a skill
@ -486,7 +496,8 @@ def htmlSkillsSearch(translate: {},baseDir: str, \
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
skillSearchCSS = cssFile.read() skillSearchCSS = cssFile.read()
if httpPrefix!='https':
skillSearchCSS=skillSearchCSS.replace('https://',httpPrefix+'://')
skillSearchForm=htmlHeader(cssFilename,skillSearchCSS) skillSearchForm=htmlHeader(cssFilename,skillSearchCSS)
skillSearchForm+='<center><h1>'+translate['Skills search']+': '+skillsearch+'</h1></center>' skillSearchForm+='<center><h1>'+translate['Skills search']+': '+skillsearch+'</h1></center>'
@ -510,7 +521,7 @@ def htmlSkillsSearch(translate: {},baseDir: str, \
skillSearchForm+=htmlFooter() skillSearchForm+=htmlFooter()
return skillSearchForm return skillSearchForm
def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int) -> str: def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,httpPrefix: str) -> str:
"""Shows the edit profile screen """Shows the edit profile screen
""" """
imageFormats='.png, .jpg, .jpeg, .gif, .webp' imageFormats='.png, .jpg, .jpeg, .gif, .webp'
@ -599,6 +610,8 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int)
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
editProfileCSS = cssFile.read() editProfileCSS = cssFile.read()
if httpPrefix!='https':
editProfileCSS=editProfileCSS.replace('https://',httpPrefix+'://')
instanceStr='' instanceStr=''
moderatorsStr='' moderatorsStr=''
@ -840,6 +853,8 @@ def htmlTermsOfService(baseDir: str,httpPrefix: str,domainFull: str) -> str:
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
termsCSS = cssFile.read() termsCSS = cssFile.read()
if httpPrefix!='https':
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>'
@ -870,7 +885,9 @@ def htmlAbout(baseDir: str,httpPrefix: str,domainFull: str) -> str:
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
termsCSS = cssFile.read() termsCSS = cssFile.read()
if httpPrefix!='http':
termsCSS=termsCSS.replace('https://',httpPrefix+'://')
aboutForm=htmlHeader(cssFilename,termsCSS) aboutForm=htmlHeader(cssFilename,termsCSS)
aboutForm+='<div class="container">'+aboutText+'</div>' aboutForm+='<div class="container">'+aboutText+'</div>'
if adminNickname: if adminNickname:
@ -957,6 +974,8 @@ def htmlNewPost(mediaInstance: bool,translate: {},baseDir: str, \
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
newPostCSS = cssFile.read() newPostCSS = cssFile.read()
if httpPrefix!='https':
newPostCSS=newPostCSS.replace('https://',httpPrefix+'://')
if '?' in path: if '?' in path:
path=path.split('?')[0] path=path.split('?')[0]
@ -2646,10 +2665,12 @@ def htmlTimeline(defaultTimeline: str, \
if not os.path.isfile(bannerFilename): if not os.path.isfile(bannerFilename):
bannerFile='banner.webp' bannerFile='banner.webp'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
profileStyle = \ profileStyle = \
cssFile.read().replace('banner.png', \ cssFile.read().replace('banner.png', \
'/users/'+nickname+'/'+bannerFile) '/users/'+nickname+'/'+bannerFile)
if httpPrefix!='https':
profileStyle=profileStyle.replace('https://',httpPrefix+'://')
moderator=isModerator(baseDir,nickname) moderator=isModerator(baseDir,nickname)
@ -3025,6 +3046,8 @@ def htmlIndividualPost(recentPostsCache: {},maxRecentPosts: int, \
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
postsCSS=cssFile.read() postsCSS=cssFile.read()
if httpPrefix!='https':
postsCSS=postsCSS.replace('https://',httpPrefix+'://')
return htmlHeader(cssFilename,postsCSS)+postStr+htmlFooter() return htmlHeader(cssFilename,postsCSS)+postStr+htmlFooter()
def htmlPostReplies(recentPostsCache: {},maxRecentPosts: int, \ def htmlPostReplies(recentPostsCache: {},maxRecentPosts: int, \
@ -3051,6 +3074,8 @@ def htmlPostReplies(recentPostsCache: {},maxRecentPosts: int, \
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
postsCSS=cssFile.read() postsCSS=cssFile.read()
if httpPrefix!='https':
postsCSS=postsCSS.replace('https://',httpPrefix+'://')
return htmlHeader(cssFilename,postsCSS)+repliesStr+htmlFooter() return htmlHeader(cssFilename,postsCSS)+repliesStr+htmlFooter()
def htmlRemoveSharedItem(translate: {},baseDir: str,actor: str,shareName: str) -> str: def htmlRemoveSharedItem(translate: {},baseDir: str,actor: str,shareName: str) -> str:
@ -3136,6 +3161,8 @@ def htmlDeletePost(recentPostsCache: {},maxRecentPosts: int, \
cssFilename=baseDir+'/epicyon.css' cssFilename=baseDir+'/epicyon.css'
with open(cssFilename, 'r') as cssFile: with open(cssFilename, 'r') as cssFile:
profileStyle = cssFile.read() profileStyle = cssFile.read()
if httpPrefix!='https':
profileStyle=profileStyle.replace('https://',httpPrefix+'://')
deletePostStr=htmlHeader(cssFilename,profileStyle) deletePostStr=htmlHeader(cssFilename,profileStyle)
deletePostStr+='<script>'+contentWarningScript()+'</script>' deletePostStr+='<script>'+contentWarningScript()+'</script>'
deletePostStr+= \ deletePostStr+= \
@ -3814,7 +3841,8 @@ def htmlProfileAfterSearch(recentPostsCache: {},maxRecentPosts: int, \
profileBackgroundImage=profileJson['image']['url'] profileBackgroundImage=profileJson['image']['url']
profileStyle = cssFile.read().replace('image.png',profileBackgroundImage) profileStyle = cssFile.read().replace('image.png',profileBackgroundImage)
if httpPrefix!='https':
profileStyle=profileStyle.replace('https://',httpPrefix+'://')
# url to return to # url to return to
backUrl=path backUrl=path
if not backUrl.endswith('/inbox'): if not backUrl.endswith('/inbox'):