From 5165f5a4141c13dbdb4d4984882423566dd85448 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Thu, 16 Nov 2017 12:23:21 +0530 Subject: [PATCH] consistent naming convention for icons Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- .style.yapf | 5 +- plinth/modules/syncthing/manifest.py | 15 +++--- plinth/templates/clients.html | 45 +++++++----------- plinth/templatetags/plinth_extras.py | 22 ++++++++- .../default/icons/{apple.png => mac-os.png} | Bin 5 files changed, 48 insertions(+), 39 deletions(-) rename static/themes/default/icons/{apple.png => mac-os.png} (100%) diff --git a/.style.yapf b/.style.yapf index 03ac89877..841a11856 100644 --- a/.style.yapf +++ b/.style.yapf @@ -1,7 +1,8 @@ [style] based_on_style = pep8 spaces_before_comment = 2 -split_before_logical_operator = true +split_before_logical_operator = false each_dict_entry_on_separate_line = true coalesce_brackets = false -indent_dictionary_value = true \ No newline at end of file +indent_dictionary_value = true +split_before_named_assigns = false \ No newline at end of file diff --git a/plinth/modules/syncthing/manifest.py b/plinth/modules/syncthing/manifest.py index da00f1545..837cad950 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 = { 'syncthing': { @@ -45,21 +46,21 @@ clients = [{ .format(metadata['syncthing']['version']) }, { 'type': 'download', - 'os': 'GNU/Linux', + 'os': Desktop_OS.GNU_LINUX.value, 'arch': 'amd64', 'url': 'https://github.com/syncthing/syncthing/releases/' 'download/v{0}/syncthing-linux-amd64-v{0}.tar.gz' .format(metadata['syncthing']['version']), }, { 'type': 'download', - 'os': 'macOS', + 'os': Desktop_OS.MAC_OS.value, 'arch': 'amd64', 'url': 'https://github.com/syncthing/syncthing/releases/' 'download/v{0}/syncthing-macosx-amd64-v{0}.tar.gz' .format(metadata['syncthing']['version']), }, { 'type': 'download', - 'os': 'Windows', + 'os': Desktop_OS.WINDOWS.value, 'arch': 'amd64', 'url': 'https://github.com/syncthing/syncthing/releases/' 'download/v{0}/syncthing-windows-amd64-v{0}.zip' @@ -68,9 +69,9 @@ clients = [{ 'type': 'store', 'os': - 'Android', + Mobile_OS.ANDROID.value, 'store_name': - 'google_play_store', + Store.GOOGLE_PLAY.value, 'fully_qualified_name': 'com.nutomic.syncthingandroid', 'url': @@ -80,9 +81,9 @@ clients = [{ 'type': 'store', 'os': - 'Android', + Mobile_OS.ANDROID.value, 'store_name': - 'fdroid_store', + Store.F_DROID.value, 'fully_qualified_name': 'com.nutomic.syncthingandroid', 'url': diff --git a/plinth/templates/clients.html b/plinth/templates/clients.html index 778a729b0..ad54c01e1 100644 --- a/plinth/templates/clients.html +++ b/plinth/templates/clients.html @@ -60,50 +60,39 @@ {% for platform in client.platforms %} {% if platform.type == 'download' %} - {% endif %} + {% endif %} {% endfor %} {% endif %} - {% endfor %} + {% endfor %} {% endif %} {% if clients|has_mobile_clients %}
- {% load static %} -

{% trans "Mobile Clients" %}:

+ {% load static %} +

{% trans "Mobile Clients" %}:

    - {% for client in clients %} - {% if client|has_mobile_clients %} + {% for client in clients %} + {% if client|has_mobile_clients %}
  • {{ client.name }}
  • - {% for platform in client.platforms %} - {% if platform.type == 'store' and platform.os == 'Android' %} - {% if platform.store_name == 'fdroid_store' %} + {% for platform in client.platforms %} + {% if platform.type == 'store' and platform.os == 'android' %} - {% endif %} - {% if platform.store_name == 'google_play_store' %} -
    - - - -
    - {% endif %} {% endif %} {% endfor %}
    diff --git a/plinth/templatetags/plinth_extras.py b/plinth/templatetags/plinth_extras.py index 14bafd2b4..906c75597 100644 --- a/plinth/templatetags/plinth_extras.py +++ b/plinth/templatetags/plinth_extras.py @@ -17,10 +17,27 @@ import os from django import template +from enum import Enum register = template.Library() +class Desktop_OS(Enum): + WINDOWS = 'windows' + MAC_OS = 'mac-os' + GNU_LINUX = 'gnu-linux' + + +class Mobile_OS(Enum): + ANDROID = 'android' + IOS = 'ios' + + +class Store(Enum): + GOOGLE_PLAY = 'google-play' + F_DROID = 'f-droid' + + def mark_active_menuitem(menu, path): """Mark the best-matching menu item with 'active' @@ -76,7 +93,8 @@ def has_web_clients(clients): @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', '') == 'Android') + return __check(clients, + lambda x: x.get('os', '') == Mobile_OS.ANDROID.value) @register.filter(name='has_desktop_clients') @@ -84,4 +102,4 @@ def has_desktop_clients(clients): """Filter to find out whether an application has desktop clients""" return __check( clients, - lambda x: x.get('os', '') in ['Windows', 'macOS', 'GNU/Linux']) + lambda x: x.get('os', '') in [x.value for x in list(Desktop_OS)]) diff --git a/static/themes/default/icons/apple.png b/static/themes/default/icons/mac-os.png similarity index 100% rename from static/themes/default/icons/apple.png rename to static/themes/default/icons/mac-os.png