[UI] Add SVG support for tracker icons

SVG files are supported by all browsers so need to support it as well,
according to https://www.w3schools.com/html/html_favicon.asp

Also, it appears as SEO.com site, which was dropped because of a cert issue,
has only SVG icon. So enabled it again.

Lastly, from python 3.2, `os.path.samefile` is supported on Windows.
So Windows will now test TrackerIcons as well.
This commit is contained in:
DjLegolas 2021-12-29 20:13:59 +02:00 committed by Calum Lind
parent 7f5857296e
commit f3784723ae
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
5 changed files with 6 additions and 9 deletions

View File

@ -3,6 +3,7 @@ default_language_version:
exclude: >
(?x)^(
deluge/ui/web/docs/template/.*|
deluge/tests/data/.*svg|
)$
repos:
- repo: https://github.com/ambv/black

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 95.63 110.42" width="10cm" height="10cm"><defs><style>.cls-1{fill:#ec5728;}.cls-2{fill:#fff;}</style></defs><title>seocom-target</title><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><polygon class="cls-1" points="95.63 82.81 47.81 110.42 0 82.81 0 27.61 47.81 0 95.63 27.61 95.63 82.81"></polygon><path class="cls-2" d="M47.81,18.64A36.57,36.57,0,1,0,84.38,55.21,36.57,36.57,0,0,0,47.81,18.64Zm0,63.92A27.35,27.35,0,1,1,75.16,55.21,27.35,27.35,0,0,1,47.81,82.56Z"></path><path class="cls-2" d="M47.81,39.46A15.75,15.75,0,1,0,63.56,55.21,15.75,15.75,0,0,0,47.81,39.46Zm0,24.25a8.5,8.5,0,1,1,8.5-8.5A8.51,8.51,0,0,1,47.81,63.71Z"></path></g></g></svg>

After

Width:  |  Height:  |  Size: 770 B

View File

@ -6,11 +6,9 @@
#
import pytest
from twisted.trial.unittest import SkipTest
import deluge.component as component
import deluge.ui.tracker_icons
from deluge.common import windows_check
from deluge.ui.tracker_icons import TrackerIcon, TrackerIcons
from . import common
@ -23,10 +21,6 @@ common.disable_new_release_check()
@pytest.mark.internet
class TrackerIconsTestCase(BaseTestCase):
if windows_check():
skip = 'cannot use os.path.samefile to compair on windows(unix only)'
def set_up(self):
# Disable resizing with Pillow for consistency.
self.patch(deluge.ui.tracker_icons, 'Image', None)
@ -60,10 +54,9 @@ class TrackerIconsTestCase(BaseTestCase):
d.addCallback(self.assertEqual, icon)
return d
def test_get_seo_ico_with_sni(self):
def test_get_seo_svg_with_sni(self):
# seo using certificates with SNI support only
raise SkipTest('Site certificate expired')
icon = TrackerIcon(common.get_test_data_file('seo.ico'))
icon = TrackerIcon(common.get_test_data_file('seo.svg'))
d = self.icons.fetch('www.seo.com')
d.addCallback(self.assertNotIdentical, None)
d.addCallback(self.assertEqual, icon)

View File

@ -609,11 +609,13 @@ MIME_MAP = {
'image/png': 'png',
'image/vnd.microsoft.icon': 'ico',
'image/x-icon': 'ico',
'image/svg+xml': 'svg',
'gif': 'image/gif',
'jpg': 'image/jpeg',
'jpeg': 'image/jpeg',
'png': 'image/png',
'ico': 'image/vnd.microsoft.icon',
'svg': 'image/svg+xml',
}