diff --git a/daemon.py b/daemon.py index ff9f6fef..0936d82e 100644 --- a/daemon.py +++ b/daemon.py @@ -2314,7 +2314,8 @@ class PubServer(BaseHTTPRequestHandler): msg=htmlEditProfile(self.server.translate, \ self.server.baseDir, \ 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._write(msg) self.server.GETbusy=False @@ -4456,7 +4457,8 @@ class PubServer(BaseHTTPRequestHandler): moderationText.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip() elif moderationStr.startswith('submitInfo'): 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._write(msg) self.server.POSTbusy=False @@ -4654,7 +4656,9 @@ class PubServer(BaseHTTPRequestHandler): searchStr=searchStr.replace('*','').strip() skillStr= \ htmlSkillsSearch(self.server.translate, \ - self.server.baseDir,searchStr, \ + self.server.baseDir, \ + self.server.httpPrefix, \ + searchStr, \ self.server.instanceOnlySkillsSearch, \ 64) if skillStr: @@ -4703,7 +4707,9 @@ class PubServer(BaseHTTPRequestHandler): # emoji search emojiStr= \ htmlSearchEmoji(self.server.translate, \ - self.server.baseDir,searchStr) + self.server.baseDir, \ + self.server.httpPrefix, \ + searchStr) if emojiStr: msg=emojiStr.encode('utf-8') self._login_headers('text/html',len(msg)) diff --git a/epicyon.py b/epicyon.py index e7f8529a..92e9d302 100644 --- a/epicyon.py +++ b/epicyon.py @@ -1493,7 +1493,7 @@ if not registration: if setTheme(baseDir,themeName): print('Theme set to '+themeName) - + runDaemon(args.mediainstance,args.maxRecentPosts, \ not args.nosharedinbox, \ registration,args.language,__version__, \ diff --git a/webinterface.py b/webinterface.py index 826f7803..c86467cd 100644 --- a/webinterface.py +++ b/webinterface.py @@ -144,7 +144,7 @@ def getPersonAvatarUrl(baseDir: str,personUrl: str,personCache: {}) -> str: return personJson['icon']['url'] return None -def htmlSearchEmoji(translate: {},baseDir: str,searchStr: str) -> str: +def htmlSearchEmoji(translate: {},baseDir: str,httpPrefix: str,searchStr: str) -> str: """Search results for emoji """ @@ -159,6 +159,8 @@ def htmlSearchEmoji(translate: {},baseDir: str,searchStr: str) -> str: cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: emojiCSS=cssFile.read() + if httpPrefix!='https': + emojiCSS=emojiCSS.replace('https://',httpPrefix+'://') emojiLookupFilename=baseDir+'/emoji/emoji.json' # create header @@ -219,9 +221,12 @@ def htmlSearchSharedItems(translate: {}, \ searchStrLowerList=searchStrLower.split('+') cssFilename=baseDir+'/epicyon-profile.css' if os.path.isfile(baseDir+'/epicyon.css'): - cssFilename=baseDir+'/epicyon.css' + cssFilename=baseDir+'/epicyon.css' + with open(cssFilename, 'r') as cssFile: sharedItemsCSS=cssFile.read() + if httpPrefix!='https': + sharedItemsCSS=sharedItemsCSS.replace('https://',httpPrefix+'://') sharedItemsForm=htmlHeader(cssFilename,sharedItemsCSS) sharedItemsForm+='

'+translate['Shared Items Search']+'

' resultsExist=False @@ -299,13 +304,15 @@ def htmlSearchSharedItems(translate: {}, \ sharedItemsForm+=htmlFooter() return sharedItemsForm -def htmlModerationInfo(translate: {},baseDir: str) -> str: +def htmlModerationInfo(translate: {},baseDir: str,httpPrefix: str) -> str: infoForm='' cssFilename=baseDir+'/epicyon-profile.css' if os.path.isfile(baseDir+'/epicyon.css'): cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: infoCSS=cssFile.read() + if httpPrefix!='https': + infoCSS=infoCSS.replace('https://',httpPrefix+'://') infoForm=htmlHeader(cssFilename,infoCSS) infoForm+='

'+translate['Moderation Information']+'

' @@ -359,6 +366,8 @@ def htmlHashtagSearch(recentPostsCache: {},maxRecentPosts: int, \ cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: hashtagSearchCSS = cssFile.read() + if httpPrefix!='https': + hashtagSearchCSS=hashtagSearchCSS.replace('https://',httpPrefix+'://') startIndex=len(lines)-1-int(pageNumber*postsPerPage) if startIndex<0: @@ -409,6 +418,7 @@ def htmlHashtagSearch(recentPostsCache: {},maxRecentPosts: int, \ return hashtagSearchForm def htmlSkillsSearch(translate: {},baseDir: str, \ + httpPrefix: str, \ skillsearch: str,instanceOnly: bool, \ postsPerPage: int) -> str: """Show a page containing search results for a skill @@ -486,7 +496,8 @@ def htmlSkillsSearch(translate: {},baseDir: str, \ cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: skillSearchCSS = cssFile.read() - + if httpPrefix!='https': + skillSearchCSS=skillSearchCSS.replace('https://',httpPrefix+'://') skillSearchForm=htmlHeader(cssFilename,skillSearchCSS) skillSearchForm+='

'+translate['Skills search']+': '+skillsearch+'

' @@ -510,7 +521,7 @@ def htmlSkillsSearch(translate: {},baseDir: str, \ skillSearchForm+=htmlFooter() 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 """ 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' with open(cssFilename, 'r') as cssFile: editProfileCSS = cssFile.read() + if httpPrefix!='https': + editProfileCSS=editProfileCSS.replace('https://',httpPrefix+'://') instanceStr='' moderatorsStr='' @@ -840,6 +853,8 @@ def htmlTermsOfService(baseDir: str,httpPrefix: str,domainFull: str) -> str: cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: termsCSS = cssFile.read() + if httpPrefix!='https': + termsCSS=termsCSS.replace('https://',httpPrefix+'://') TOSForm=htmlHeader(cssFilename,termsCSS) TOSForm+='
'+TOSText+'
' @@ -870,7 +885,9 @@ def htmlAbout(baseDir: str,httpPrefix: str,domainFull: str) -> str: cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: termsCSS = cssFile.read() - + if httpPrefix!='http': + termsCSS=termsCSS.replace('https://',httpPrefix+'://') + aboutForm=htmlHeader(cssFilename,termsCSS) aboutForm+='
'+aboutText+'
' if adminNickname: @@ -957,6 +974,8 @@ def htmlNewPost(mediaInstance: bool,translate: {},baseDir: str, \ cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: newPostCSS = cssFile.read() + if httpPrefix!='https': + newPostCSS=newPostCSS.replace('https://',httpPrefix+'://') if '?' in path: path=path.split('?')[0] @@ -2646,10 +2665,12 @@ def htmlTimeline(defaultTimeline: str, \ if not os.path.isfile(bannerFilename): bannerFile='banner.webp' - with open(cssFilename, 'r') as cssFile: + with open(cssFilename, 'r') as cssFile: profileStyle = \ cssFile.read().replace('banner.png', \ '/users/'+nickname+'/'+bannerFile) + if httpPrefix!='https': + profileStyle=profileStyle.replace('https://',httpPrefix+'://') moderator=isModerator(baseDir,nickname) @@ -3025,6 +3046,8 @@ def htmlIndividualPost(recentPostsCache: {},maxRecentPosts: int, \ cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: postsCSS=cssFile.read() + if httpPrefix!='https': + postsCSS=postsCSS.replace('https://',httpPrefix+'://') return htmlHeader(cssFilename,postsCSS)+postStr+htmlFooter() def htmlPostReplies(recentPostsCache: {},maxRecentPosts: int, \ @@ -3051,6 +3074,8 @@ def htmlPostReplies(recentPostsCache: {},maxRecentPosts: int, \ cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: postsCSS=cssFile.read() + if httpPrefix!='https': + postsCSS=postsCSS.replace('https://',httpPrefix+'://') return htmlHeader(cssFilename,postsCSS)+repliesStr+htmlFooter() def htmlRemoveSharedItem(translate: {},baseDir: str,actor: str,shareName: str) -> str: @@ -3136,6 +3161,8 @@ def htmlDeletePost(recentPostsCache: {},maxRecentPosts: int, \ cssFilename=baseDir+'/epicyon.css' with open(cssFilename, 'r') as cssFile: profileStyle = cssFile.read() + if httpPrefix!='https': + profileStyle=profileStyle.replace('https://',httpPrefix+'://') deletePostStr=htmlHeader(cssFilename,profileStyle) deletePostStr+='' deletePostStr+= \ @@ -3814,7 +3841,8 @@ def htmlProfileAfterSearch(recentPostsCache: {},maxRecentPosts: int, \ profileBackgroundImage=profileJson['image']['url'] profileStyle = cssFile.read().replace('image.png',profileBackgroundImage) - + if httpPrefix!='https': + profileStyle=profileStyle.replace('https://',httpPrefix+'://') # url to return to backUrl=path if not backUrl.endswith('/inbox'):