forked from indymedia/epicyon
Remove double load of css, second time from the browser
parent
b987fae6e7
commit
a7bbe4a7d9
|
@ -9,7 +9,6 @@ __status__ = "Production"
|
||||||
import os
|
import os
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import getCSS
|
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from posts import isEditor
|
from posts import isEditor
|
||||||
from webapp_utils import htmlPostSeparator
|
from webapp_utils import htmlPostSeparator
|
||||||
|
@ -201,13 +200,6 @@ def htmlLinksMobile(cssCache: {}, baseDir: str,
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = 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)
|
iconsDir = getIconsDir(baseDir)
|
||||||
|
|
||||||
# is the user a site editor?
|
# is the user a site editor?
|
||||||
|
@ -220,7 +212,7 @@ def htmlLinksMobile(cssCache: {}, baseDir: str,
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
domain = domain.split(':')[0]
|
domain = domain.split(':')[0]
|
||||||
|
|
||||||
htmlStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle)
|
htmlStr = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
||||||
htmlStr += \
|
htmlStr += \
|
||||||
'<a href="/users/' + nickname + '/' + defaultTimeline + '">' + \
|
'<a href="/users/' + nickname + '/' + defaultTimeline + '">' + \
|
||||||
|
@ -263,16 +255,10 @@ def htmlEditLinks(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
if os.path.isfile(baseDir + '/links.css'):
|
if os.path.isfile(baseDir + '/links.css'):
|
||||||
cssFilename = 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
|
# filename of the banner shown at the top
|
||||||
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
||||||
|
|
||||||
editLinksForm = htmlHeaderWithExternalStyle(cssFilename, editCSS)
|
editLinksForm = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
# top banner
|
# top banner
|
||||||
editLinksForm += \
|
editLinksForm += \
|
||||||
|
|
|
@ -12,7 +12,6 @@ from shutil import copyfile
|
||||||
from content import removeLongWords
|
from content import removeLongWords
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getCSS
|
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import votesOnNewswireItem
|
from utils import votesOnNewswireItem
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
|
@ -305,16 +304,9 @@ def htmlCitations(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = 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)
|
# iconsDir = getIconsDir(baseDir)
|
||||||
|
|
||||||
htmlStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle)
|
htmlStr = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
# top banner
|
# top banner
|
||||||
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
||||||
|
@ -402,14 +394,6 @@ def htmlNewswireMobile(cssCache: {}, baseDir: str, nickname: str,
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = 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)
|
iconsDir = getIconsDir(baseDir)
|
||||||
|
|
||||||
if nickname == 'news':
|
if nickname == 'news':
|
||||||
|
@ -424,7 +408,7 @@ def htmlNewswireMobile(cssCache: {}, baseDir: str, nickname: str,
|
||||||
|
|
||||||
showPublishButton = editor
|
showPublishButton = editor
|
||||||
|
|
||||||
htmlStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle)
|
htmlStr = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
||||||
htmlStr += \
|
htmlStr += \
|
||||||
|
@ -470,16 +454,10 @@ def htmlEditNewswire(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
if os.path.isfile(baseDir + '/links.css'):
|
if os.path.isfile(baseDir + '/links.css'):
|
||||||
cssFilename = 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
|
# filename of the banner shown at the top
|
||||||
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
||||||
|
|
||||||
editNewswireForm = htmlHeaderWithExternalStyle(cssFilename, editCSS)
|
editNewswireForm = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
# top banner
|
# top banner
|
||||||
editNewswireForm += \
|
editNewswireForm += \
|
||||||
|
@ -598,13 +576,7 @@ def htmlEditNewsPost(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
if os.path.isfile(baseDir + '/links.css'):
|
if os.path.isfile(baseDir + '/links.css'):
|
||||||
cssFilename = baseDir + '/links.css'
|
cssFilename = baseDir + '/links.css'
|
||||||
|
|
||||||
editCSS = getCSS(baseDir, cssFilename, cssCache)
|
editNewsPostForm = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
if editCSS:
|
|
||||||
if httpPrefix != 'https':
|
|
||||||
editCSS = \
|
|
||||||
editCSS.replace('https://', httpPrefix + '://')
|
|
||||||
|
|
||||||
editNewsPostForm = htmlHeaderWithExternalStyle(cssFilename, editCSS)
|
|
||||||
editNewsPostForm += \
|
editNewsPostForm += \
|
||||||
'<form enctype="multipart/form-data" method="POST" ' + \
|
'<form enctype="multipart/form-data" method="POST" ' + \
|
||||||
'accept-charset="UTF-8" action="' + path + '/newseditdata">\n'
|
'accept-charset="UTF-8" action="' + path + '/newseditdata">\n'
|
||||||
|
|
|
@ -8,7 +8,6 @@ __status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import isPublicPostFromUrl
|
from utils import isPublicPostFromUrl
|
||||||
from utils import getCSS
|
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from webapp_utils import getIconsDir
|
from webapp_utils import getIconsDir
|
||||||
|
@ -253,12 +252,6 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = 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:
|
if '?' in path:
|
||||||
path = path.split('?')[0]
|
path = path.split('?')[0]
|
||||||
pathBase = path.replace('/newreport', '').replace('/newpost', '')
|
pathBase = path.replace('/newreport', '').replace('/newpost', '')
|
||||||
|
@ -558,7 +551,7 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
|
||||||
dateAndLocation += '<input type="text" name="category">\n'
|
dateAndLocation += '<input type="text" name="category">\n'
|
||||||
dateAndLocation += '</div>\n'
|
dateAndLocation += '</div>\n'
|
||||||
|
|
||||||
newPostForm = htmlHeaderWithExternalStyle(cssFilename, newPostCSS)
|
newPostForm = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
newPostForm += \
|
newPostForm += \
|
||||||
'<a href="/users/' + nickname + '/' + defaultTimeline + '" title="' + \
|
'<a href="/users/' + nickname + '/' + defaultTimeline + '" title="' + \
|
||||||
|
|
|
@ -10,7 +10,6 @@ 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 getCSS
|
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
|
@ -48,12 +47,10 @@ def htmlSearchEmoji(cssCache: {}, translate: {},
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = baseDir + '/epicyon.css'
|
cssFilename = baseDir + '/epicyon.css'
|
||||||
|
|
||||||
emojiCSS = getCSS(baseDir, cssFilename, cssCache)
|
|
||||||
if emojiCSS:
|
|
||||||
emojiLookupFilename = baseDir + '/emoji/emoji.json'
|
emojiLookupFilename = baseDir + '/emoji/emoji.json'
|
||||||
|
|
||||||
# create header
|
# create header
|
||||||
emojiForm = htmlHeaderWithExternalStyle(cssFilename, emojiCSS)
|
emojiForm = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
emojiForm += '<center><h1>' + \
|
emojiForm += '<center><h1>' + \
|
||||||
translate['Emoji Search'] + \
|
translate['Emoji Search'] + \
|
||||||
'</h1></center>'
|
'</h1></center>'
|
||||||
|
@ -114,10 +111,8 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = baseDir + '/epicyon.css'
|
cssFilename = baseDir + '/epicyon.css'
|
||||||
|
|
||||||
sharedItemsCSS = getCSS(baseDir, cssFilename, cssCache)
|
|
||||||
if sharedItemsCSS:
|
|
||||||
sharedItemsForm = \
|
sharedItemsForm = \
|
||||||
htmlHeaderWithExternalStyle(cssFilename, sharedItemsCSS)
|
htmlHeaderWithExternalStyle(cssFilename)
|
||||||
sharedItemsForm += \
|
sharedItemsForm += \
|
||||||
'<center><h1>' + translate['Shared Items Search'] + \
|
'<center><h1>' + translate['Shared Items Search'] + \
|
||||||
'</h1></center>'
|
'</h1></center>'
|
||||||
|
@ -288,9 +283,7 @@ def htmlSearchEmojiTextEntry(cssCache: {}, translate: {},
|
||||||
if os.path.isfile(baseDir + '/follow.css'):
|
if os.path.isfile(baseDir + '/follow.css'):
|
||||||
cssFilename = baseDir + '/follow.css'
|
cssFilename = baseDir + '/follow.css'
|
||||||
|
|
||||||
profileStyle = getCSS(baseDir, cssFilename, cssCache)
|
emojiStr = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
emojiStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle)
|
|
||||||
emojiStr += '<div class="follow">\n'
|
emojiStr += '<div class="follow">\n'
|
||||||
emojiStr += ' <div class="followAvatar">\n'
|
emojiStr += ' <div class="followAvatar">\n'
|
||||||
emojiStr += ' <center>\n'
|
emojiStr += ' <center>\n'
|
||||||
|
@ -330,9 +323,7 @@ def htmlSearch(cssCache: {}, translate: {},
|
||||||
if os.path.isfile(baseDir + '/search.css'):
|
if os.path.isfile(baseDir + '/search.css'):
|
||||||
cssFilename = baseDir + '/search.css'
|
cssFilename = baseDir + '/search.css'
|
||||||
|
|
||||||
profileStyle = getCSS(baseDir, cssFilename, cssCache)
|
followStr = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
followStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle)
|
|
||||||
|
|
||||||
# show a banner above the search box
|
# show a banner above the search box
|
||||||
searchBannerFile, searchBannerFilename = \
|
searchBannerFile, searchBannerFilename = \
|
||||||
|
@ -506,8 +497,6 @@ def htmlHashtagSearch(cssCache: {},
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = baseDir + '/epicyon.css'
|
cssFilename = baseDir + '/epicyon.css'
|
||||||
|
|
||||||
hashtagSearchCSS = getCSS(baseDir, cssFilename, cssCache)
|
|
||||||
|
|
||||||
# ensure that the page number is in bounds
|
# ensure that the page number is in bounds
|
||||||
if not pageNumber:
|
if not pageNumber:
|
||||||
pageNumber = 1
|
pageNumber = 1
|
||||||
|
@ -523,7 +512,7 @@ def htmlHashtagSearch(cssCache: {},
|
||||||
|
|
||||||
# add the page title
|
# add the page title
|
||||||
hashtagSearchForm = \
|
hashtagSearchForm = \
|
||||||
htmlHeaderWithExternalStyle(cssFilename, hashtagSearchCSS)
|
htmlHeaderWithExternalStyle(cssFilename)
|
||||||
if nickname:
|
if nickname:
|
||||||
hashtagSearchForm += '<center>\n' + \
|
hashtagSearchForm += '<center>\n' + \
|
||||||
'<h1><a href="/users/' + nickname + '/search">#' + \
|
'<h1><a href="/users/' + nickname + '/search">#' + \
|
||||||
|
@ -813,9 +802,7 @@ def htmlSkillsSearch(cssCache: {}, translate: {}, baseDir: str,
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = baseDir + '/epicyon.css'
|
cssFilename = baseDir + '/epicyon.css'
|
||||||
|
|
||||||
skillSearchCSS = getCSS(baseDir, cssFilename, cssCache)
|
skillSearchForm = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
skillSearchForm = htmlHeaderWithExternalStyle(cssFilename, skillSearchCSS)
|
|
||||||
skillSearchForm += \
|
skillSearchForm += \
|
||||||
'<center><h1>' + translate['Skills search'] + ': ' + \
|
'<center><h1>' + translate['Skills search'] + ': ' + \
|
||||||
skillsearch + '</h1></center>'
|
skillsearch + '</h1></center>'
|
||||||
|
@ -878,9 +865,8 @@ def htmlHistorySearch(cssCache: {}, translate: {}, baseDir: str,
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = baseDir + '/epicyon.css'
|
cssFilename = baseDir + '/epicyon.css'
|
||||||
|
|
||||||
historySearchCSS = getCSS(baseDir, cssFilename, cssCache)
|
|
||||||
historySearchForm = \
|
historySearchForm = \
|
||||||
htmlHeaderWithExternalStyle(cssFilename, historySearchCSS)
|
htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
# add the page title
|
# add the page title
|
||||||
historySearchForm += \
|
historySearchForm += \
|
||||||
|
|
|
@ -9,7 +9,6 @@ __status__ = "Production"
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import time
|
import time
|
||||||
from utils import getCSS
|
|
||||||
from utils import removeIdEnding
|
from utils import removeIdEnding
|
||||||
from follow import followerApprovalActive
|
from follow import followerApprovalActive
|
||||||
from person import isPersonSnoozed
|
from person import isPersonSnoozed
|
||||||
|
@ -121,17 +120,6 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if timeDiff > 100:
|
if timeDiff > 100:
|
||||||
print('TIMELINE TIMING ' + boxName + ' 1 = ' + str(timeDiff))
|
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?
|
# is the user a moderator?
|
||||||
if not moderator:
|
if not moderator:
|
||||||
moderator = isModerator(baseDir, nickname)
|
moderator = isModerator(baseDir, nickname)
|
||||||
|
@ -263,7 +251,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
eventsButton + '"><span>' + translate['Events'] + \
|
eventsButton + '"><span>' + translate['Events'] + \
|
||||||
'</span></button></a>'
|
'</span></button></a>'
|
||||||
|
|
||||||
tlStr = htmlHeaderWithExternalStyle(cssFilename, profileStyle)
|
tlStr = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
# benchmark 4
|
# benchmark 4
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
||||||
|
|
|
@ -437,15 +437,11 @@ def htmlHeader(cssFilename: str, css: str, lang='en') -> str:
|
||||||
return htmlStr
|
return htmlStr
|
||||||
|
|
||||||
|
|
||||||
def htmlHeaderWithExternalStyle(cssFilename: str, css: str, lang='en') -> str:
|
def htmlHeaderWithExternalStyle(cssFilename: str, lang='en') -> str:
|
||||||
htmlStr = '<!DOCTYPE html>\n'
|
htmlStr = '<!DOCTYPE html>\n'
|
||||||
htmlStr += '<html lang="' + lang + '">\n'
|
htmlStr += '<html lang="' + lang + '">\n'
|
||||||
htmlStr += ' <head>\n'
|
htmlStr += ' <head>\n'
|
||||||
htmlStr += ' <meta charset="utf-8">\n'
|
htmlStr += ' <meta charset="utf-8">\n'
|
||||||
fontName, fontFormat = getFontFromCss(css)
|
|
||||||
if fontName:
|
|
||||||
htmlStr += ' <link rel="preload" as="font" type="' + \
|
|
||||||
fontFormat + '" href="' + fontName + '" crossorigin>\n'
|
|
||||||
cssFile = cssFilename.split('/')[-1]
|
cssFile = cssFilename.split('/')[-1]
|
||||||
htmlStr += ' <link rel="stylesheet" href="' + cssFile + '">\n'
|
htmlStr += ' <link rel="stylesheet" href="' + cssFile + '">\n'
|
||||||
htmlStr += ' <link rel="manifest" href="/manifest.json">\n'
|
htmlStr += ' <link rel="manifest" href="/manifest.json">\n'
|
||||||
|
|
Loading…
Reference in New Issue