diff --git a/README.md b/README.md index 1563eb9b..629eac07 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,11 @@ If you want to use a particular font then copy it into the *fonts* directory, re systemctl restart epicyon ``` +## Custom Favicon + +If you want to use your own favicon then copy your `favicon.ico` file to the base directory where you installed Epicyon. + + ## Adding Themes If you want to add a new theme then open `theme.py` and add the theme name to the list within `getThemesList`. Add a function with the name `setTheme[YourThemeName]`. Have a look at the other themes to get an idea of how to set the colors and fonts. diff --git a/daemon.py b/daemon.py index 4a497e9e..6107ce06 100644 --- a/daemon.py +++ b/daemon.py @@ -1815,6 +1815,41 @@ class PubServer(BaseHTTPRequestHandler): self._404() return + # favicon image + if '/favicon.ico' in self.path: + # custom favicon + mediaFilename = \ + self.server.baseDir + '/favicon.ico' + if not os.path.isfile(mediaFilename): + # default favicon + mediaFilename = \ + self.server.baseDir + '/img/icons/favicon.ico' + if self._etag_exists(mediaFilename): + # The file has not changed + self._304() + return + if self.server.iconsCache.get(mediaStr): + mediaBinary = self.server.iconsCache[mediaStr] + self._set_headers_etag(mediaFilename, + 'image/png', + mediaBinary, cookie, + callingDomain) + self._write(mediaBinary) + return + else: + if os.path.isfile(mediaFilename): + with open(mediaFilename, 'rb') as avFile: + mediaBinary = avFile.read() + self._set_headers_etag(mediaFilename, + 'image/png', + mediaBinary, cookie, + callingDomain) + self._write(mediaBinary) + self.server.iconsCache[mediaStr] = mediaBinary + return + self._404() + return + self._benchmarkGETtimings(GETstartTime, GETtimings, 22) # cached avatar images diff --git a/img/icons/favicon.ico b/img/icons/favicon.ico new file mode 100644 index 00000000..c7cb1bbb Binary files /dev/null and b/img/icons/favicon.ico differ