[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:
parent
7f5857296e
commit
f3784723ae
|
@ -3,6 +3,7 @@ default_language_version:
|
||||||
exclude: >
|
exclude: >
|
||||||
(?x)^(
|
(?x)^(
|
||||||
deluge/ui/web/docs/template/.*|
|
deluge/ui/web/docs/template/.*|
|
||||||
|
deluge/tests/data/.*svg|
|
||||||
)$
|
)$
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/ambv/black
|
- repo: https://github.com/ambv/black
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
|
@ -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 |
|
@ -6,11 +6,9 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from twisted.trial.unittest import SkipTest
|
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.ui.tracker_icons
|
import deluge.ui.tracker_icons
|
||||||
from deluge.common import windows_check
|
|
||||||
from deluge.ui.tracker_icons import TrackerIcon, TrackerIcons
|
from deluge.ui.tracker_icons import TrackerIcon, TrackerIcons
|
||||||
|
|
||||||
from . import common
|
from . import common
|
||||||
|
@ -23,10 +21,6 @@ common.disable_new_release_check()
|
||||||
|
|
||||||
@pytest.mark.internet
|
@pytest.mark.internet
|
||||||
class TrackerIconsTestCase(BaseTestCase):
|
class TrackerIconsTestCase(BaseTestCase):
|
||||||
|
|
||||||
if windows_check():
|
|
||||||
skip = 'cannot use os.path.samefile to compair on windows(unix only)'
|
|
||||||
|
|
||||||
def set_up(self):
|
def set_up(self):
|
||||||
# Disable resizing with Pillow for consistency.
|
# Disable resizing with Pillow for consistency.
|
||||||
self.patch(deluge.ui.tracker_icons, 'Image', None)
|
self.patch(deluge.ui.tracker_icons, 'Image', None)
|
||||||
|
@ -60,10 +54,9 @@ class TrackerIconsTestCase(BaseTestCase):
|
||||||
d.addCallback(self.assertEqual, icon)
|
d.addCallback(self.assertEqual, icon)
|
||||||
return d
|
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
|
# seo using certificates with SNI support only
|
||||||
raise SkipTest('Site certificate expired')
|
icon = TrackerIcon(common.get_test_data_file('seo.svg'))
|
||||||
icon = TrackerIcon(common.get_test_data_file('seo.ico'))
|
|
||||||
d = self.icons.fetch('www.seo.com')
|
d = self.icons.fetch('www.seo.com')
|
||||||
d.addCallback(self.assertNotIdentical, None)
|
d.addCallback(self.assertNotIdentical, None)
|
||||||
d.addCallback(self.assertEqual, icon)
|
d.addCallback(self.assertEqual, icon)
|
||||||
|
|
|
@ -609,11 +609,13 @@ MIME_MAP = {
|
||||||
'image/png': 'png',
|
'image/png': 'png',
|
||||||
'image/vnd.microsoft.icon': 'ico',
|
'image/vnd.microsoft.icon': 'ico',
|
||||||
'image/x-icon': 'ico',
|
'image/x-icon': 'ico',
|
||||||
|
'image/svg+xml': 'svg',
|
||||||
'gif': 'image/gif',
|
'gif': 'image/gif',
|
||||||
'jpg': 'image/jpeg',
|
'jpg': 'image/jpeg',
|
||||||
'jpeg': 'image/jpeg',
|
'jpeg': 'image/jpeg',
|
||||||
'png': 'image/png',
|
'png': 'image/png',
|
||||||
'ico': 'image/vnd.microsoft.icon',
|
'ico': 'image/vnd.microsoft.icon',
|
||||||
|
'svg': 'image/svg+xml',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue