diff options
author | DjLegolas <djlegolas@protonmail.com> | 2021-12-29 20:13:59 +0200 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2021-12-29 21:38:55 +0000 |
commit | f3784723ae54b9394dd3db219457071ab9b48ecb (patch) | |
tree | 062e5ea4d13fabd0e57a5cfc012e0cd955002b5f | |
parent | 7f5857296e5f21eea6c8dec9b56a51e352e8bfbb (diff) | |
download | deluge-f3784723ae54b9394dd3db219457071ab9b48ecb.tar.gz deluge-f3784723ae54b9394dd3db219457071ab9b48ecb.tar.bz2 deluge-f3784723ae54b9394dd3db219457071ab9b48ecb.zip |
[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.
-rw-r--r-- | .pre-commit-config.yaml | 1 | ||||
-rw-r--r-- | deluge/tests/data/seo.ico | bin | 1150 -> 0 bytes | |||
-rw-r--r-- | deluge/tests/data/seo.svg | 1 | ||||
-rw-r--r-- | deluge/tests/test_tracker_icons.py | 11 | ||||
-rw-r--r-- | deluge/ui/tracker_icons.py | 2 |
5 files changed, 6 insertions, 9 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 133d536dd..8f00d42fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/deluge/tests/data/seo.ico b/deluge/tests/data/seo.ico Binary files differdeleted file mode 100644 index 841e52871..000000000 --- a/deluge/tests/data/seo.ico +++ /dev/null diff --git a/deluge/tests/data/seo.svg b/deluge/tests/data/seo.svg new file mode 100644 index 000000000..fc96f74d4 --- /dev/null +++ b/deluge/tests/data/seo.svg @@ -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>
\ No newline at end of file diff --git a/deluge/tests/test_tracker_icons.py b/deluge/tests/test_tracker_icons.py index 8f6dda900..0f7a66c61 100644 --- a/deluge/tests/test_tracker_icons.py +++ b/deluge/tests/test_tracker_icons.py @@ -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) diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index 3f3ca4dbe..a1bcd78b5 100644 --- a/deluge/ui/tracker_icons.py +++ b/deluge/ui/tracker_icons.py @@ -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', } |