From 5c782ddb7d24cfe10b2133e1d786cd2e243c79eb Mon Sep 17 00:00:00 2001 From: CasperVerswijvelt Date: Wed, 21 Apr 2021 17:33:23 +0200 Subject: [PATCH] Use flag icons instead of emoji's --- Pipfile | 1 - Pipfile.lock | 10 +--------- package-lock.json | 5 +++++ package.json | 1 + shynet/dashboard/templates/base.html | 1 + .../templates/dashboard/includes/session_list.html | 2 +- .../dashboard/templates/dashboard/pages/service.html | 2 +- .../templates/dashboard/pages/service_session.html | 2 +- shynet/dashboard/templatetags/helpers.py | 11 +++++------ shynet/shynet/settings.py | 1 + 10 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Pipfile b/Pipfile index d35023e..00711bf 100644 --- a/Pipfile +++ b/Pipfile @@ -13,7 +13,6 @@ django-ipware = "~=2.1.0" pyyaml = "~=5.4" ua-parser = "~=0.10.0" user-agents = "~=2.1" -emoji-country-flag = "~=1.2.1" rules = "~=2.2" gunicorn = "~=20.0.4" psycopg2-binary = "~=2.8.5" diff --git a/Pipfile.lock b/Pipfile.lock index aa683c9..70b6e97 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "f8c76565a776f1bd36364077a86d6c16fccc522d9d2024bb9b51be5cb9f8b4b5" + "sha256": "c51ea0205c9ffe753b9ef5249cd49c2338bb50768ae104113bfb7b97b5f9d70c" }, "pipfile-spec": 6, "requires": {}, @@ -116,14 +116,6 @@ "index": "pypi", "version": "==3.0.0" }, - "emoji-country-flag": { - "hashes": [ - "sha256:338f5e374119dcde093cfeaa8ca3af372d4b8d984d89a7fb2fb0db0011662560", - "sha256:a3a068191294294143d8ef294fdfe9792c5c243753eac130798bf2fa5de38185" - ], - "index": "pypi", - "version": "==1.2.4" - }, "geoip2": { "hashes": [ "sha256:5869e987bc54c0d707264fec4710661332cc38d2dca5a7f9bb5362d0308e2ce0", diff --git a/package-lock.json b/package-lock.json index 85faf46..45e72c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,11 @@ "svg.select.js": "^3.0.1" } }, + "flag-icon-css": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/flag-icon-css/-/flag-icon-css-3.5.0.tgz", + "integrity": "sha512-pgJnJLrtb0tcDgU1fzGaQXmR8h++nXvILJ+r5SmOXaaL/2pocunQo2a8TAXhjQnBpRLPtZ1KCz/TYpqeNuE2ew==" + }, "inter-ui": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/inter-ui/-/inter-ui-3.15.0.tgz", diff --git a/package.json b/package.json index 4637fd3..f7bb6dd 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@fortawesome/fontawesome-free": "^5.15.1", "a17t": "^0.5.1", "apexcharts": "^3.24.0", + "flag-icon-css": "^3.5.0", "inter-ui": "^3.15.0", "litepicker": "^1.5.7" } diff --git a/shynet/dashboard/templates/base.html b/shynet/dashboard/templates/base.html index cff7d83..3a24758 100644 --- a/shynet/dashboard/templates/base.html +++ b/shynet/dashboard/templates/base.html @@ -13,6 +13,7 @@ + {% block extra_head %} {% endblock %} diff --git a/shynet/dashboard/templates/dashboard/includes/session_list.html b/shynet/dashboard/templates/dashboard/includes/session_list.html index 0509aa4..a1c45b5 100644 --- a/shynet/dashboard/templates/dashboard/includes/session_list.html +++ b/shynet/dashboard/templates/dashboard/includes/session_list.html @@ -27,7 +27,7 @@ {% endif %} - {{session.country|flag_emoji}} {{session.asn|default:"Unknown"}} + {{session.asn|default:"Unknown"}} {{session.duration|naturaldelta}} {{session.hit_set.count|intcomma}} diff --git a/shynet/dashboard/templates/dashboard/pages/service.html b/shynet/dashboard/templates/dashboard/pages/service.html index e7bdab6..7a25c62 100644 --- a/shynet/dashboard/templates/dashboard/pages/service.html +++ b/shynet/dashboard/templates/dashboard/pages/service.html @@ -153,7 +153,7 @@ {% for country in stats.countries %} - {{country.country|flag_emoji}} {{country.country|country_name}} + {{country.country|country_name}} {{country.count|intcomma}} {% empty %} diff --git a/shynet/dashboard/templates/dashboard/pages/service_session.html b/shynet/dashboard/templates/dashboard/pages/service_session.html index 5b089cc..ac366ef 100644 --- a/shynet/dashboard/templates/dashboard/pages/service_session.html +++ b/shynet/dashboard/templates/dashboard/pages/service_session.html @@ -45,7 +45,7 @@

Country

-

{{session.country|flag_emoji}} {{session.country|country_name}}

+

{{session.country|country_name}}

Location

diff --git a/shynet/dashboard/templatetags/helpers.py b/shynet/dashboard/templatetags/helpers.py index 4eaa599..9cda09f 100644 --- a/shynet/dashboard/templatetags/helpers.py +++ b/shynet/dashboard/templatetags/helpers.py @@ -2,7 +2,6 @@ from datetime import timedelta from urllib.parse import urlparse import urllib -import flag import pycountry from django import template from django.conf import settings @@ -29,11 +28,11 @@ def naturaldelta(timedelta): @register.filter -def flag_emoji(isocode): - try: - return flag.flag(isocode) - except: - return "" +def flag_class(isocode): + if isocode: + return "mr-1 flag-icon flag-icon-" + isocode.lower() + else: + return "hidden" @register.filter diff --git a/shynet/shynet/settings.py b/shynet/shynet/settings.py index 9bd510e..30332b5 100644 --- a/shynet/shynet/settings.py +++ b/shynet/shynet/settings.py @@ -306,6 +306,7 @@ NPM_FILE_PATTERNS = { "stimulus": [os.path.join("dist", "stimulus.umd.js")], "inter-ui": [os.path.join("Inter (web)", "*")], "@fortawesome": [os.path.join("fontawesome-free", "js", "all.min.js")], + "flag-icon-css": [os.path.join("css", "flag-icon.min.css"), os.path.join("flags", "*")], } # Shynet