forked from indymedia/epicyon
Support for custom fonts
parent
774cf26c47
commit
6203345e8e
41
daemon.py
41
daemon.py
|
@ -1738,6 +1738,46 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings, 21)
|
self._benchmarkGETtimings(GETstartTime, GETtimings, 21)
|
||||||
|
|
||||||
|
# get fonts
|
||||||
|
if self.path.startswith('/fonts/'):
|
||||||
|
if self.path.endswith('.ttf') or \
|
||||||
|
self.path.endswith('.woff') or \
|
||||||
|
self.path.endswith('.woff2'):
|
||||||
|
if self.path.endswith('.ttf'):
|
||||||
|
fontType = 'application/x-font-ttf'
|
||||||
|
elif self.path.endswith('.woff'):
|
||||||
|
fontType = 'application/font-woff'
|
||||||
|
else:
|
||||||
|
fontType = 'application/font-woff2'
|
||||||
|
fontStr = self.path.split('/fonts/')[1]
|
||||||
|
fontFilename = \
|
||||||
|
self.server.baseDir + '/fonts/' + fontStr
|
||||||
|
if self._etag_exists(fontFilename):
|
||||||
|
# The file has not changed
|
||||||
|
self._304()
|
||||||
|
return
|
||||||
|
if self.server.fontsCache.get(fontStr):
|
||||||
|
fontBinary = self.server.fontsCache[fontStr]
|
||||||
|
self._set_headers_etag(fontFilename,
|
||||||
|
fontType,
|
||||||
|
fontBinary, cookie,
|
||||||
|
callingDomain)
|
||||||
|
self._write(fontBinary)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
if os.path.isfile(fontFilename):
|
||||||
|
with open(fontFilename, 'rb') as avFile:
|
||||||
|
fontBinary = avFile.read()
|
||||||
|
self._set_headers_etag(fontFilename,
|
||||||
|
fontType,
|
||||||
|
fontBinary, cookie,
|
||||||
|
callingDomain)
|
||||||
|
self._write(fontBinary)
|
||||||
|
self.server.fontsCache[fontStr] = fontBinary
|
||||||
|
return
|
||||||
|
self._404()
|
||||||
|
return
|
||||||
|
|
||||||
# icon images
|
# icon images
|
||||||
# Note that this comes before the busy flag to avoid conflicts
|
# Note that this comes before the busy flag to avoid conflicts
|
||||||
if self.path.startswith('/icons/'):
|
if self.path.startswith('/icons/'):
|
||||||
|
@ -7428,6 +7468,7 @@ def runDaemon(blogsInstance: bool, mediaInstance: bool,
|
||||||
httpd.recentPostsCache = {}
|
httpd.recentPostsCache = {}
|
||||||
httpd.maxRecentPosts = maxRecentPosts
|
httpd.maxRecentPosts = maxRecentPosts
|
||||||
httpd.iconsCache = {}
|
httpd.iconsCache = {}
|
||||||
|
httpd.fontsCache = {}
|
||||||
|
|
||||||
print('Creating inbox queue')
|
print('Creating inbox queue')
|
||||||
httpd.thrInboxQueue = \
|
httpd.thrInboxQueue = \
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Add any fonts that you may want to use within themes to this directory. They can be in ttf, woff or woff2 format.
|
Loading…
Reference in New Issue