From a3ed814e9f2734670cd2c5efab784ae436c7e0c3 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 7 Jan 2021 10:38:33 +0000 Subject: [PATCH] Default favicon for newswire, if site favicon is not available --- daemon.py | 23 +++++++++++++----- theme/blue/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/debian/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/default/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/hacker/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/henge/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/indymediaclassic/icons/favicon.ico | Bin 1150 -> 766 bytes .../icons/newswire_favicon.ico | Bin 0 -> 766 bytes theme/indymediamodern/icons/favicon.ico | Bin 1150 -> 766 bytes .../icons/newswire_favicon.ico | Bin 0 -> 766 bytes theme/lcd/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/light/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/night/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/purple/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/rc3/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/solidaric/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/starlight/icons/newswire_favicon.ico | Bin 0 -> 1150 bytes theme/zen/icons/newswire_favicon.ico | Bin 0 -> 198 bytes webapp_column_right.py | 4 +-- 19 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 theme/blue/icons/newswire_favicon.ico create mode 100644 theme/debian/icons/newswire_favicon.ico create mode 100644 theme/default/icons/newswire_favicon.ico create mode 100644 theme/hacker/icons/newswire_favicon.ico create mode 100644 theme/henge/icons/newswire_favicon.ico create mode 100644 theme/indymediaclassic/icons/newswire_favicon.ico create mode 100644 theme/indymediamodern/icons/newswire_favicon.ico create mode 100644 theme/lcd/icons/newswire_favicon.ico create mode 100644 theme/light/icons/newswire_favicon.ico create mode 100644 theme/night/icons/newswire_favicon.ico create mode 100644 theme/purple/icons/newswire_favicon.ico create mode 100644 theme/rc3/icons/newswire_favicon.ico create mode 100644 theme/solidaric/icons/newswire_favicon.ico create mode 100644 theme/starlight/icons/newswire_favicon.ico create mode 100644 theme/zen/icons/newswire_favicon.ico diff --git a/daemon.py b/daemon.py index 4eb105fbd..4bd818d5b 100644 --- a/daemon.py +++ b/daemon.py @@ -1127,6 +1127,7 @@ class PubServer(BaseHTTPRequestHandler): if self.path.startswith('/icons/') or \ self.path.startswith('/avatars/') or \ self.path.startswith('/favicon.ico') or \ + self.path.startswith('/newswire_favicon.ico') or \ self.path.startswith('/categories.xml') or \ self.path.startswith('/newswire.xml'): return False @@ -4835,18 +4836,19 @@ class PubServer(BaseHTTPRequestHandler): 'show logout', 'send manifest') def _getFavicon(self, callingDomain: str, - baseDir: str, debug: bool) -> None: - """Return the favicon + baseDir: str, debug: bool, + favFile='favicon.ico') -> None: + """Return the site favicon or default newswire favicon """ favType = 'image/x-icon' - favFilename = 'favicon.ico' + favFilename = favFile if self._hasAccept(callingDomain): if 'image/webp' in self.headers['Accept']: favType = 'image/webp' - favFilename = 'favicon.webp' + favFilename = favFile.split('.')[0] + '.webp' if 'image/avif' in self.headers['Accept']: favType = 'image/avif' - favFilename = 'favicon.avif' + favFilename = favFile.split('.')[0] + '.avif' if not self.server.themeName: self.themeName = getConfigParam(baseDir, 'theme') if not self.server.themeName: @@ -9731,7 +9733,16 @@ class PubServer(BaseHTTPRequestHandler): # favicon image if 'favicon.ico' in self.path: self._getFavicon(callingDomain, self.server.baseDir, - self.server.debug) + self.server.debug, + 'favicon.ico') + return + + # default newswire favicon, for links to sites which + # have no favicon + if 'newswire_favicon.ico' in self.path: + self._getFavicon(callingDomain, self.server.baseDir, + self.server.debug, + 'newswire_favicon.ico') return # check authorization diff --git a/theme/blue/icons/newswire_favicon.ico b/theme/blue/icons/newswire_favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c7cb1bbbe0ff1c57a5974ddeb09fc6dc8e31d96f GIT binary patch literal 1150 zcmd6iF$%&!6hud`RbpdnN^griEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7riEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7riEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7me`&;0Q`o-a4t*=gzM7=oK>Nf6wQ~`OUs>G9IP6vt{$7Mk$XM zRkwMWXGJ4q8hLHrjK7vXFO#jMb+J9$`_zm3WJCGbeYAgUu5&}akS2eK+kW*SZ%nfp zU&nkgU3qcL*QNiG?b=tfim&>h0uIE6C?3GR1a?w8Xc(3 literal 0 HcmV?d00001 diff --git a/theme/henge/icons/newswire_favicon.ico b/theme/henge/icons/newswire_favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..10bdfcfe5f1931d42190b0f432a91a6f2c74d6ff GIT binary patch literal 1150 zcmd5%I|{-;6db`;iH)r(y@f~c2)4F1g4!q+9>b$(=RrJzAQ7T*78!Yww~@uhgxPs- z-pqc07XK^**BsL}&<8LiC{cOoq@-^(-&6rfA!Gjc{BpLq+V}Okom_XeY@SprAz%~_SLN9tKKMqBe5p-ci?aXb{AlK28t7XW8g6%20%3;n0*2=p1i97 literal 0 HcmV?d00001 diff --git a/theme/indymediaclassic/icons/favicon.ico b/theme/indymediaclassic/icons/favicon.ico index c7cb1bbbe0ff1c57a5974ddeb09fc6dc8e31d96f..061668e430e42781e50011bfa9f56f877e7015d3 100644 GIT binary patch literal 766 zcmb`FO-{ow6ojXM6i(13%92AM%8_~iP;Ig22;nFV7iexkmu6>GUZluvhHriEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7GUZluvhHGUZluvhHriEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7GUZluvhHriEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7riEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7riEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7riEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7JjWwN!j7~8#_PrbNJ)|U^RN9%{?+SljvY4ZEH=~wUb zhBTXTb;uXel^2J6G5wcpY+cPt-s*!AI1(Eoe*lL&u)6}=3vfHpHwT_eV#I$YBba>w D0!7)g literal 0 HcmV?d00001 diff --git a/theme/solidaric/icons/newswire_favicon.ico b/theme/solidaric/icons/newswire_favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c7cb1bbbe0ff1c57a5974ddeb09fc6dc8e31d96f GIT binary patch literal 1150 zcmd6iF$%&!6hud`RbpdnN^griEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7riEjn+X0&v#!*{v3}tERlq{d;~rpPuafdfiU0f41u1 zOT8G^Ywhb~RFvX<6>IZ8lj>bwbGw$8QhT=J)Jwm~hVrrh(f+Zy&JA%PPkcyyUVVs- zc{bzLF)rpSFO6|2|CelPU(G7s>QfbPW^GvI1327){T0|=fZLJW7fEXl?3zXda50?4^q~Q1u1H%I#ZUEx>e;F9| o|72ij|IEP9{Fs5^$8n%Ke+Gts@jxuk!0_K5h>`Vz*ktGj0Qe9${Qv*} literal 0 HcmV?d00001 diff --git a/webapp_column_right.py b/webapp_column_right.py index d52717fec..32aef9b41 100644 --- a/webapp_column_right.py +++ b/webapp_column_right.py @@ -197,10 +197,10 @@ def _getNewswireFavicon(url: str) -> str: """Returns a favicon url from the given article link """ if '://' not in url: - return None + return '/newswire_favicon.ico' if url.startswith('http://'): if not (url.endswith('.onion') or url.endswith('.i2p')): - return None + return '/newswire_favicon.ico' domain = url.split('://')[1] if '/' not in domain: return url + '/favicon.ico'