From 57c44f32e6ff62ca4d5daaa283c1099d16fe19a2 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Sat, 18 Nov 2017 08:18:46 +0530 Subject: [PATCH] Add support for iOS AppStore - iSorted Python imports in all the manifest files - Some refactoring in plinth_extras Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- plinth/modules/diaspora/manifest.py | 5 ++-- plinth/modules/ejabberd/manifest.py | 4 +-- plinth/modules/infinoted/manifest.py | 2 +- plinth/modules/matrixsynapse/manifest.py | 1 + plinth/modules/minetest/manifest.py | 1 + plinth/modules/mumble/manifest.py | 9 +++--- plinth/modules/quassel/manifest.py | 1 + plinth/modules/radicale/manifest.py | 1 + plinth/modules/repro/manifest.py | 5 ++-- plinth/modules/syncthing/manifest.py | 1 + plinth/modules/tor/manifest.py | 1 + plinth/modules/ttrss/manifest.py | 1 + plinth/templates/clients.html | 2 +- plinth/templatetags/plinth_extras.py | 35 ++++++++++++++---------- 14 files changed, 42 insertions(+), 27 deletions(-) diff --git a/plinth/modules/diaspora/manifest.py b/plinth/modules/diaspora/manifest.py index 9641fe8bf..0ec1578c8 100644 --- a/plinth/modules/diaspora/manifest.py +++ b/plinth/modules/diaspora/manifest.py @@ -17,9 +17,10 @@ from django.utils.translation import ugettext_lazy as _ -from plinth.utils import format_lazy -from . import get_configured_domain_name from plinth.templatetags.plinth_extras import Mobile_OS, Store +from plinth.utils import format_lazy + +from . import get_configured_domain_name clients = [{ 'name': diff --git a/plinth/modules/ejabberd/manifest.py b/plinth/modules/ejabberd/manifest.py index 8cb992adf..c35fa1767 100644 --- a/plinth/modules/ejabberd/manifest.py +++ b/plinth/modules/ejabberd/manifest.py @@ -58,8 +58,8 @@ clients = [{ 'extra security.'), 'platforms': [{ 'type': 'store', - 'os': 'iOS', - 'store_name': 'apple_store', + 'os': Mobile_OS.IOS.value, + 'store_name': Store.APP_STORE.value, 'url': 'https://itunes.apple.com/us/app/chatsecure' '/id464200063 ' }] diff --git a/plinth/modules/infinoted/manifest.py b/plinth/modules/infinoted/manifest.py index 9d86bb49a..72f6db676 100644 --- a/plinth/modules/infinoted/manifest.py +++ b/plinth/modules/infinoted/manifest.py @@ -17,9 +17,9 @@ from django.utils.translation import ugettext_lazy as _ +from plinth import cfg from plinth.templatetags.plinth_extras import Desktop_OS from plinth.utils import format_lazy -from plinth import cfg clients = [{ 'name': diff --git a/plinth/modules/matrixsynapse/manifest.py b/plinth/modules/matrixsynapse/manifest.py index 7839358cb..0a981ce0e 100644 --- a/plinth/modules/matrixsynapse/manifest.py +++ b/plinth/modules/matrixsynapse/manifest.py @@ -16,6 +16,7 @@ # from django.utils.translation import ugettext_lazy as _ + from plinth.templatetags.plinth_extras import Desktop_OS, Mobile_OS, Store clients = [{ diff --git a/plinth/modules/minetest/manifest.py b/plinth/modules/minetest/manifest.py index 341537561..db556ba63 100644 --- a/plinth/modules/minetest/manifest.py +++ b/plinth/modules/minetest/manifest.py @@ -16,6 +16,7 @@ # from django.utils.translation import ugettext_lazy as _ + from plinth.templatetags.plinth_extras import Desktop_OS, Mobile_OS, Store clients = [{ diff --git a/plinth/modules/mumble/manifest.py b/plinth/modules/mumble/manifest.py index f025f5cd7..f9aaf7b30 100644 --- a/plinth/modules/mumble/manifest.py +++ b/plinth/modules/mumble/manifest.py @@ -16,6 +16,7 @@ # from django.utils.translation import ugettext_lazy as _ + from plinth.templatetags.plinth_extras import Desktop_OS, Mobile_OS, Store clients = [{ @@ -38,9 +39,9 @@ clients = [{ 'name': 'mumble' }, { 'type': 'store', - 'os': 'iOS', + 'os': Mobile_OS.IOS.value, 'os_version': '>=8.0', - 'store_name': 'apple_store', + 'store_name': Store.APP_STORE.value, 'url': 'https://itunes.apple.com/us/app/mumble/id443472808' }] }, { @@ -66,9 +67,9 @@ clients = [{ _('Mumblefly'), 'platforms': [{ 'type': 'store', - 'os': 'iOS', + 'os': Mobile_OS.IOS.value, 'os_version': '>=7.0', - 'store_name': 'apple_store', + 'store_name': Store.APP_STORE.value, 'url': 'https://itunes.apple.com/dk/app/mumblefy/id858752232' }] }] diff --git a/plinth/modules/quassel/manifest.py b/plinth/modules/quassel/manifest.py index 3e02707e8..f886cd440 100644 --- a/plinth/modules/quassel/manifest.py +++ b/plinth/modules/quassel/manifest.py @@ -16,6 +16,7 @@ # from django.utils.translation import ugettext_lazy as _ + from plinth.templatetags.plinth_extras import Desktop_OS, Mobile_OS, Store clients = [{ diff --git a/plinth/modules/radicale/manifest.py b/plinth/modules/radicale/manifest.py index f0ce6a18c..3addbf01b 100644 --- a/plinth/modules/radicale/manifest.py +++ b/plinth/modules/radicale/manifest.py @@ -16,6 +16,7 @@ # from django.utils.translation import ugettext_lazy as _ + from plinth.templatetags.plinth_extras import Mobile_OS, Store clients = [{ diff --git a/plinth/modules/repro/manifest.py b/plinth/modules/repro/manifest.py index 3eee0e36b..b3b036368 100644 --- a/plinth/modules/repro/manifest.py +++ b/plinth/modules/repro/manifest.py @@ -16,6 +16,7 @@ # from django.utils.translation import ugettext_lazy as _ + from plinth.templatetags.plinth_extras import Desktop_OS, Mobile_OS, Store clients = [{ @@ -39,8 +40,8 @@ clients = [{ '.jitsi.meet ' }, { 'type': 'store', - 'os': 'iOS', - 'store_name': 'apple_store', + 'os': Mobile_OS.IOS.value, + 'store_name': Store.APP_STORE.value, 'url': 'https://itunes.apple.com/in/app/jitsi-meet/id1165103905' }, { 'type': 'download', diff --git a/plinth/modules/syncthing/manifest.py b/plinth/modules/syncthing/manifest.py index 7b94ca2b8..3ec6de5fc 100644 --- a/plinth/modules/syncthing/manifest.py +++ b/plinth/modules/syncthing/manifest.py @@ -16,6 +16,7 @@ # from django.utils.translation import ugettext_lazy as _ + from plinth.templatetags.plinth_extras import Desktop_OS, Mobile_OS, Store metadata = { diff --git a/plinth/modules/tor/manifest.py b/plinth/modules/tor/manifest.py index 295ae73cd..2216dc72c 100644 --- a/plinth/modules/tor/manifest.py +++ b/plinth/modules/tor/manifest.py @@ -16,6 +16,7 @@ # from django.utils.translation import ugettext_lazy as _ + from plinth.templatetags.plinth_extras import Desktop_OS, Mobile_OS, Store version = '7.0.6' diff --git a/plinth/modules/ttrss/manifest.py b/plinth/modules/ttrss/manifest.py index 50326d872..92cbbab5b 100644 --- a/plinth/modules/ttrss/manifest.py +++ b/plinth/modules/ttrss/manifest.py @@ -16,6 +16,7 @@ # from django.utils.translation import ugettext_lazy as _ + from plinth.templatetags.plinth_extras import Mobile_OS, Store clients = [{ diff --git a/plinth/templates/clients.html b/plinth/templates/clients.html index 5f13afba3..7d86d0bcc 100644 --- a/plinth/templates/clients.html +++ b/plinth/templates/clients.html @@ -85,7 +85,7 @@
{% for platform in client.platforms %} - {% if platform.type == 'store' and platform.os == 'android' %} + {% if platform.type == 'store' and platform.os == 'android' or platform.os == 'ios' %}
{% with 'theme/icons/'|add:platform.store_name|add:'.png' as icon %} diff --git a/plinth/templatetags/plinth_extras.py b/plinth/templatetags/plinth_extras.py index 906c75597..70a5180c9 100644 --- a/plinth/templatetags/plinth_extras.py +++ b/plinth/templatetags/plinth_extras.py @@ -16,16 +16,17 @@ # import os -from django import template from enum import Enum +from django import template + register = template.Library() class Desktop_OS(Enum): - WINDOWS = 'windows' - MAC_OS = 'mac-os' GNU_LINUX = 'gnu-linux' + MAC_OS = 'mac-os' + WINDOWS = 'windows' class Mobile_OS(Enum): @@ -34,8 +35,13 @@ class Mobile_OS(Enum): class Store(Enum): - GOOGLE_PLAY = 'google-play' + APP_STORE = 'app-store' F_DROID = 'f-droid' + GOOGLE_PLAY = 'google-play' + + +def string_values(enum): + return [x.value for x in list(enum)] def mark_active_menuitem(menu, path): @@ -84,22 +90,21 @@ def __check(clients, cond): if cond(pf)) -@register.filter(name='has_web_clients') -def has_web_clients(clients): - """Filter to find out whether an application has web clients""" - return __check(clients, lambda x: x['type'] == 'web') +@register.filter(name='has_desktop_clients') +def has_desktop_clients(clients): + """Filter to find out whether an application has desktop clients""" + return __check(clients, + lambda x: x.get('os', '') in string_values(Desktop_OS)) @register.filter(name='has_mobile_clients') def has_mobile_clients(clients): """Filter to find out whether an application has mobile clients""" return __check(clients, - lambda x: x.get('os', '') == Mobile_OS.ANDROID.value) + lambda x: x.get('os', '') in string_values(Mobile_OS)) -@register.filter(name='has_desktop_clients') -def has_desktop_clients(clients): - """Filter to find out whether an application has desktop clients""" - return __check( - clients, - lambda x: x.get('os', '') in [x.value for x in list(Desktop_OS)]) +@register.filter(name='has_web_clients') +def has_web_clients(clients): + """Filter to find out whether an application has web clients""" + return __check(clients, lambda x: x['type'] == 'web')