diff --git a/webapp_column_left.py b/webapp_column_left.py index 9a7216ebd..5f9aa19c6 100644 --- a/webapp_column_left.py +++ b/webapp_column_left.py @@ -9,7 +9,6 @@ __status__ = "Production" import os from shutil import copyfile from utils import getConfigParam -from utils import getCSS from utils import getNicknameFromActor from posts import isEditor from webapp_utils import htmlPostSeparator @@ -201,13 +200,6 @@ def htmlLinksMobile(cssCache: {}, baseDir: str, if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' - profileStyle = getCSS(baseDir, cssFilename, cssCache) - if profileStyle: - # replace any https within the css with whatever prefix is needed - if httpPrefix != 'https': - profileStyle = \ - profileStyle.replace('https://', httpPrefix + '://') - iconsDir = getIconsDir(baseDir) # is the user a site editor? @@ -220,7 +212,7 @@ def htmlLinksMobile(cssCache: {}, baseDir: str, if ':' in domain: domain = domain.split(':')[0] - htmlStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle) + htmlStr = htmlHeaderWithExternalStyle(cssFilename) bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain) htmlStr += \ '' + \ @@ -263,16 +255,10 @@ def htmlEditLinks(cssCache: {}, translate: {}, baseDir: str, path: str, if os.path.isfile(baseDir + '/links.css'): cssFilename = baseDir + '/links.css' - editCSS = getCSS(baseDir, cssFilename, cssCache) - if editCSS: - if httpPrefix != 'https': - editCSS = \ - editCSS.replace('https://', httpPrefix + '://') - # filename of the banner shown at the top bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain) - editLinksForm = htmlHeaderWithExternalStyle(cssFilename, editCSS) + editLinksForm = htmlHeaderWithExternalStyle(cssFilename) # top banner editLinksForm += \ diff --git a/webapp_column_right.py b/webapp_column_right.py index 46529a8a7..b2ab6af11 100644 --- a/webapp_column_right.py +++ b/webapp_column_right.py @@ -12,7 +12,6 @@ from shutil import copyfile from content import removeLongWords from utils import locatePost from utils import loadJson -from utils import getCSS from utils import getConfigParam from utils import votesOnNewswireItem from utils import getNicknameFromActor @@ -305,16 +304,9 @@ def htmlCitations(baseDir: str, nickname: str, domain: str, if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' - profileStyle = getCSS(baseDir, cssFilename, cssCache) - if profileStyle: - # replace any https within the css with whatever prefix is needed - if httpPrefix != 'https': - profileStyle = \ - profileStyle.replace('https://', httpPrefix + '://') - # iconsDir = getIconsDir(baseDir) - htmlStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle) + htmlStr = htmlHeaderWithExternalStyle(cssFilename) # top banner bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain) @@ -402,14 +394,6 @@ def htmlNewswireMobile(cssCache: {}, baseDir: str, nickname: str, if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' - profileStyle = getCSS(baseDir, cssFilename, cssCache) - if profileStyle: - # replace any https within the css with whatever prefix is needed - if httpPrefix != 'https': - profileStyle = \ - profileStyle.replace('https://', - httpPrefix + '://') - iconsDir = getIconsDir(baseDir) if nickname == 'news': @@ -424,7 +408,7 @@ def htmlNewswireMobile(cssCache: {}, baseDir: str, nickname: str, showPublishButton = editor - htmlStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle) + htmlStr = htmlHeaderWithExternalStyle(cssFilename) bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain) htmlStr += \ @@ -470,16 +454,10 @@ def htmlEditNewswire(cssCache: {}, translate: {}, baseDir: str, path: str, if os.path.isfile(baseDir + '/links.css'): cssFilename = baseDir + '/links.css' - editCSS = getCSS(baseDir, cssFilename, cssCache) - if editCSS: - if httpPrefix != 'https': - editCSS = \ - editCSS.replace('https://', httpPrefix + '://') - # filename of the banner shown at the top bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain) - editNewswireForm = htmlHeaderWithExternalStyle(cssFilename, editCSS) + editNewswireForm = htmlHeaderWithExternalStyle(cssFilename) # top banner editNewswireForm += \ @@ -598,13 +576,7 @@ def htmlEditNewsPost(cssCache: {}, translate: {}, baseDir: str, path: str, if os.path.isfile(baseDir + '/links.css'): cssFilename = baseDir + '/links.css' - editCSS = getCSS(baseDir, cssFilename, cssCache) - if editCSS: - if httpPrefix != 'https': - editCSS = \ - editCSS.replace('https://', httpPrefix + '://') - - editNewsPostForm = htmlHeaderWithExternalStyle(cssFilename, editCSS) + editNewsPostForm = htmlHeaderWithExternalStyle(cssFilename) editNewsPostForm += \ '
\n' diff --git a/webapp_create_post.py b/webapp_create_post.py index 49f7e2cf8..2e4f1633c 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -8,7 +8,6 @@ __status__ = "Production" import os from utils import isPublicPostFromUrl -from utils import getCSS from utils import getNicknameFromActor from utils import getDomainFromActor from webapp_utils import getIconsDir @@ -253,12 +252,6 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' - newPostCSS = getCSS(baseDir, cssFilename, cssCache) - if newPostCSS: - if httpPrefix != 'https': - newPostCSS = newPostCSS.replace('https://', - httpPrefix + '://') - if '?' in path: path = path.split('?')[0] pathBase = path.replace('/newreport', '').replace('/newpost', '') @@ -558,7 +551,7 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, dateAndLocation += '\n' dateAndLocation += '\n' - newPostForm = htmlHeaderWithExternalStyle(cssFilename, newPostCSS) + newPostForm = htmlHeaderWithExternalStyle(cssFilename) newPostForm += \ '' - emojiForm += '' + # create header + emojiForm = htmlHeaderWithExternalStyle(cssFilename) + emojiForm += '

' + \ + translate['Emoji Search'] + \ + '

' + # does the lookup file exist? + if not os.path.isfile(emojiLookupFilename): + emojiForm += '
' + \ + translate['No results'] + '
' emojiForm += htmlFooter() + return emojiForm + + emojiJson = loadJson(emojiLookupFilename) + if emojiJson: + results = {} + for emojiName, filename in emojiJson.items(): + if searchStr in emojiName: + results[emojiName] = filename + '.png' + for emojiName, filename in emojiJson.items(): + if emojiName in searchStr: + results[emojiName] = filename + '.png' + headingShown = False + emojiForm += '
' + msgStr1 = translate['Copy the text then paste it into your post'] + msgStr2 = ':' + emojiForm += '
' + + emojiForm += htmlFooter() return emojiForm @@ -114,155 +111,153 @@ def htmlSearchSharedItems(cssCache: {}, translate: {}, if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' - sharedItemsCSS = getCSS(baseDir, cssFilename, cssCache) - if sharedItemsCSS: - sharedItemsForm = \ - htmlHeaderWithExternalStyle(cssFilename, sharedItemsCSS) - sharedItemsForm += \ - '

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

' - resultsExist = False - for subdir, dirs, files in os.walk(baseDir + '/accounts'): - for handle in dirs: - if '@' not in handle: - continue - contactNickname = handle.split('@')[0] - sharesFilename = baseDir + '/accounts/' + handle + \ - '/shares.json' - if not os.path.isfile(sharesFilename): - continue + sharedItemsForm = \ + htmlHeaderWithExternalStyle(cssFilename) + sharedItemsForm += \ + '

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

' + resultsExist = False + for subdir, dirs, files in os.walk(baseDir + '/accounts'): + for handle in dirs: + if '@' not in handle: + continue + contactNickname = handle.split('@')[0] + sharesFilename = baseDir + '/accounts/' + handle + \ + '/shares.json' + if not os.path.isfile(sharesFilename): + continue - sharesJson = loadJson(sharesFilename) - if not sharesJson: - continue + sharesJson = loadJson(sharesFilename) + if not sharesJson: + continue - for name, sharedItem in sharesJson.items(): - matched = True - for searchSubstr in searchStrLowerList: - subStrMatched = False - searchSubstr = searchSubstr.strip() - if searchSubstr in sharedItem['location'].lower(): - subStrMatched = True - elif searchSubstr in sharedItem['summary'].lower(): - subStrMatched = True - elif searchSubstr in sharedItem['displayName'].lower(): - subStrMatched = True - elif searchSubstr in sharedItem['category'].lower(): - subStrMatched = True - if not subStrMatched: - matched = False + for name, sharedItem in sharesJson.items(): + matched = True + for searchSubstr in searchStrLowerList: + subStrMatched = False + searchSubstr = searchSubstr.strip() + if searchSubstr in sharedItem['location'].lower(): + subStrMatched = True + elif searchSubstr in sharedItem['summary'].lower(): + subStrMatched = True + elif searchSubstr in sharedItem['displayName'].lower(): + subStrMatched = True + elif searchSubstr in sharedItem['category'].lower(): + subStrMatched = True + if not subStrMatched: + matched = False + break + if matched: + if currPage == pageNumber: + sharedItemsForm += '
\n' + sharedItemsForm += \ + '\n' + if sharedItem.get('imageUrl'): + sharedItemsForm += \ + '\n' + sharedItemsForm += \ + 'Item image\n' + sharedItemsForm += \ + '

' + sharedItem['summary'] + '

\n' + sharedItemsForm += \ + '

' + translate['Type'] + \ + ': ' + sharedItem['itemType'] + ' ' + sharedItemsForm += \ + '' + translate['Category'] + \ + ': ' + sharedItem['category'] + ' ' + sharedItemsForm += \ + '' + translate['Location'] + \ + ': ' + sharedItem['location'] + '

\n' + contactActor = \ + httpPrefix + '://' + domainFull + \ + '/users/' + contactNickname + sharedItemsForm += \ + '

\n' + if actor.endswith('/users/' + contactNickname): + sharedItemsForm += \ + ' \n' + sharedItemsForm += '

\n' + if not resultsExist and currPage > 1: + postActor = \ + getAltPath(actor, domainFull, + callingDomain) + # previous page link, needs to be a POST + sharedItemsForm += \ + '\n' + sharedItemsForm += \ + ' \n' + sharedItemsForm += \ + '
\n' + sharedItemsForm += \ + '
\n' + \ + ' \n' + sharedItemsForm += \ + ' ' + translate['Page up'] + \
+                                '\n' + sharedItemsForm += '
\n' + sharedItemsForm += '
\n' + resultsExist = True + ctr += 1 + if ctr >= resultsPerPage: + currPage += 1 + if currPage > pageNumber: + postActor = \ + getAltPath(actor, domainFull, + callingDomain) + # next page link, needs to be a POST + sharedItemsForm += \ + '
\n' + sharedItemsForm += \ + ' \n' + sharedItemsForm += \ + '
\n' + sharedItemsForm += \ + '
\n' + \ + ' \n' + sharedItemsForm += \ + ' ' + translate['Page down'] + \
+                                '\n' + sharedItemsForm += '
\n' + sharedItemsForm += '
\n' break - if matched: - if currPage == pageNumber: - sharedItemsForm += '
\n' - sharedItemsForm += \ - '

' + \ - sharedItem['displayName'] + '

\n' - if sharedItem.get('imageUrl'): - sharedItemsForm += \ - '\n' - sharedItemsForm += \ - 'Item image\n' - sharedItemsForm += \ - '

' + sharedItem['summary'] + '

\n' - sharedItemsForm += \ - '

' + translate['Type'] + \ - ': ' + sharedItem['itemType'] + ' ' - sharedItemsForm += \ - '' + translate['Category'] + \ - ': ' + sharedItem['category'] + ' ' - sharedItemsForm += \ - '' + translate['Location'] + \ - ': ' + sharedItem['location'] + '

\n' - contactActor = \ - httpPrefix + '://' + domainFull + \ - '/users/' + contactNickname - sharedItemsForm += \ - '

\n' - if actor.endswith('/users/' + contactNickname): - sharedItemsForm += \ - ' \n' - sharedItemsForm += '

\n' - if not resultsExist and currPage > 1: - postActor = \ - getAltPath(actor, domainFull, - callingDomain) - # previous page link, needs to be a POST - sharedItemsForm += \ - '
\n' - sharedItemsForm += \ - ' \n' - sharedItemsForm += \ - '
\n' - sharedItemsForm += \ - '
\n' + \ - ' \n' - sharedItemsForm += \ - ' ' + translate['Page up'] + \
-                                    '\n' - sharedItemsForm += '
\n' - sharedItemsForm += '
\n' - resultsExist = True - ctr += 1 - if ctr >= resultsPerPage: - currPage += 1 - if currPage > pageNumber: - postActor = \ - getAltPath(actor, domainFull, - callingDomain) - # next page link, needs to be a POST - sharedItemsForm += \ - '
\n' - sharedItemsForm += \ - ' \n' - sharedItemsForm += \ - '
\n' - sharedItemsForm += \ - '
\n' + \ - ' \n' - sharedItemsForm += \ - ' ' + translate['Page down'] + \
-                                    '\n' - sharedItemsForm += '
\n' - sharedItemsForm += '
\n' - break - ctr = 0 - if not resultsExist: - sharedItemsForm += \ - '
' + translate['No results'] + '
\n' - sharedItemsForm += htmlFooter() + ctr = 0 + if not resultsExist: + sharedItemsForm += \ + '
' + translate['No results'] + '
\n' + sharedItemsForm += htmlFooter() return sharedItemsForm @@ -288,9 +283,7 @@ def htmlSearchEmojiTextEntry(cssCache: {}, translate: {}, if os.path.isfile(baseDir + '/follow.css'): cssFilename = baseDir + '/follow.css' - profileStyle = getCSS(baseDir, cssFilename, cssCache) - - emojiStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle) + emojiStr = htmlHeaderWithExternalStyle(cssFilename) emojiStr += '
\n' emojiStr += '
\n' emojiStr += '
\n' @@ -330,9 +323,7 @@ def htmlSearch(cssCache: {}, translate: {}, if os.path.isfile(baseDir + '/search.css'): cssFilename = baseDir + '/search.css' - profileStyle = getCSS(baseDir, cssFilename, cssCache) - - followStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle) + followStr = htmlHeaderWithExternalStyle(cssFilename) # show a banner above the search box searchBannerFile, searchBannerFilename = \ @@ -506,8 +497,6 @@ def htmlHashtagSearch(cssCache: {}, if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' - hashtagSearchCSS = getCSS(baseDir, cssFilename, cssCache) - # ensure that the page number is in bounds if not pageNumber: pageNumber = 1 @@ -523,7 +512,7 @@ def htmlHashtagSearch(cssCache: {}, # add the page title hashtagSearchForm = \ - htmlHeaderWithExternalStyle(cssFilename, hashtagSearchCSS) + htmlHeaderWithExternalStyle(cssFilename) if nickname: hashtagSearchForm += '
\n' + \ '

#' + \ @@ -813,9 +802,7 @@ def htmlSkillsSearch(cssCache: {}, translate: {}, baseDir: str, if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' - skillSearchCSS = getCSS(baseDir, cssFilename, cssCache) - - skillSearchForm = htmlHeaderWithExternalStyle(cssFilename, skillSearchCSS) + skillSearchForm = htmlHeaderWithExternalStyle(cssFilename) skillSearchForm += \ '

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

' @@ -878,9 +865,8 @@ def htmlHistorySearch(cssCache: {}, translate: {}, baseDir: str, if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' - historySearchCSS = getCSS(baseDir, cssFilename, cssCache) historySearchForm = \ - htmlHeaderWithExternalStyle(cssFilename, historySearchCSS) + htmlHeaderWithExternalStyle(cssFilename) # add the page title historySearchForm += \ diff --git a/webapp_timeline.py b/webapp_timeline.py index 9e65b3d64..8ec1d8325 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -9,7 +9,6 @@ __status__ = "Production" import os from datetime import datetime import time -from utils import getCSS from utils import removeIdEnding from follow import followerApprovalActive from person import isPersonSnoozed @@ -121,17 +120,6 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, if timeDiff > 100: print('TIMELINE TIMING ' + boxName + ' 1 = ' + str(timeDiff)) - profileStyle = getCSS(baseDir, cssFilename, cssCache) - if not profileStyle: - print('ERROR: css file not found ' + cssFilename) - return None - - # replace any https within the css with whatever prefix is needed - if httpPrefix != 'https': - profileStyle = \ - profileStyle.replace('https://', - httpPrefix + '://') - # is the user a moderator? if not moderator: moderator = isModerator(baseDir, nickname) @@ -263,7 +251,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, eventsButton + '">' + translate['Events'] + \ '
' - tlStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle) + tlStr = htmlHeaderWithExternalStyle(cssFilename) # benchmark 4 timeDiff = int((time.time() - timelineStartTime) * 1000) diff --git a/webapp_utils.py b/webapp_utils.py index 8e5894fe1..cea77cbdf 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -437,15 +437,11 @@ def htmlHeader(cssFilename: str, css: str, lang='en') -> str: return htmlStr -def htmlHeaderWithExternalStyle(cssFilename: str, css: str, lang='en') -> str: +def htmlHeaderWithExternalStyle(cssFilename: str, lang='en') -> str: htmlStr = '\n' htmlStr += '\n' htmlStr += ' \n' htmlStr += ' \n' - fontName, fontFormat = getFontFromCss(css) - if fontName: - htmlStr += ' \n' cssFile = cssFilename.split('/')[-1] htmlStr += ' \n' htmlStr += ' \n'