From 95709518eb1fe3855388f1fbc832a41a7180e989 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalpati Date: Mon, 18 Nov 2019 19:19:30 +0530 Subject: [PATCH] clients: Improve code readability - Break up long lines multiple short lines - Fix indentation and formatting Signed-off-by: Joseph Nuthalapati --- plinth/templates/app.html | 23 ++-- plinth/templates/clients.html | 214 +++++++++++++++++----------------- 2 files changed, 119 insertions(+), 118 deletions(-) diff --git a/plinth/templates/app.html b/plinth/templates/app.html index 11e65af65..ba9532806 100644 --- a/plinth/templates/app.html +++ b/plinth/templates/app.html @@ -45,19 +45,20 @@

{% endif %} - {% if clients|length == 1 and clients|first|lookup:'platforms'|length == 1 and clients|first|lookup:'platforms'|first|lookup:'type' == 'web' %} - - {% block launch_button %} -

- - {% trans "Launch web client" %} -

- {% endblock %} - + {% if clients|length == 1 %} + {% with clients|first|lookup:'platforms' as platforms %} + {% if platforms|length == 1 and platforms|first|lookup:'type' == 'web' %} + {% block launch_button %} +

+ + {% trans "Launch web client" %} +

+ {% endblock %} + {% endif %} + {% endwith %} {% else %} - {% include "clients.html" with clients=clients enabled=is_enabled %} - {% endif %} {% block subsubmenu %} diff --git a/plinth/templates/clients.html b/plinth/templates/clients.html index 1192f4027..bd84a01c0 100644 --- a/plinth/templates/clients.html +++ b/plinth/templates/clients.html @@ -31,122 +31,122 @@

- +
- {% with clients|clients_of_type:'web' as web_clients %} - {% for client in web_clients %} - - {% if forloop.counter == 1 %} - - {% endif %} - {% for platform in client.platforms %} - {% if platform.type == 'web' %} - - + {% with clients|clients_of_type:'web' as web_clients %} + {% for client in web_clients %} + + {% if forloop.counter == 1 %} + {% endif %} - {% endfor %} - - {% endfor %} - {% endwith %} - - {% with clients|clients_of_type:'desktop' as desktop_clients %} - {% for client in desktop_clients %} - - {% if forloop.counter == 1 %} - - {% endif %} - - + {% endif %} {% endfor %} - - - {% endfor %} - {% endwith %} + + {% endfor %} + {% endwith %} - {% with clients|clients_of_type:'mobile' as mobile_clients %} - {% for client in mobile_clients %} - - {% if forloop.counter == 1 %} - - {% endif %} - - - - {% endfor %} - {% endwith %} + {% with clients|clients_of_type:'desktop' as desktop_clients %} + {% for client in desktop_clients %} + + {% if forloop.counter == 1 %} + + {% endif %} + + + + {% endfor %} + {% endwith %} - {% with clients|clients_of_type:'package' as package_clients %} - {% for client in package_clients %} - - {% if forloop.counter == 1 %} - - {% endif %} - - + {% if forloop.counter == 1 %} + + {% endif %} + + - - {% endfor %} - {% endwith %} + {% endfor %} + + + {% endfor %} + {% endwith %} -
{% trans "Web" %}{{ client.name }} - - {% trans "Launch" %} - - -
{% trans "Web" %}
{% trans "Desktop" %}{{ client.name }} {% for platform in client.platforms %} - {% if platform.type == 'download' %} - - - {% with 'theme/icons/'|add:platform.os|add:'.png' as icon %} - - {% if platform.os == 'gnu-linux' %} - {% trans 'GNU/Linux' %} - {% elif platform.os == 'windows' %} - {% trans 'Windows' %} - {% elif platform.os == 'macos' %} - {% trans 'macOS' %} - {% endif %} - {% endwith %} - - + {% if platform.type == 'web' %} + {{ client.name }} + + {% trans "Launch" %} + + +
{% trans "Mobile" %}{{ client.name }} - {% for platform in client.platforms %} - {% if platform.type == 'store' and platform.os == 'android' or platform.os == 'ios' %} - - - {% with 'theme/icons/'|add:platform.store_name|add:'.png' as icon %} - - {% if platform.store_name == 'google-play' %} - {% trans 'Play Store' %} - {% elif platform.store_name == 'f-droid' %} - {% trans 'F-Droid' %} - {% elif platform.store_name == 'app-store' %} - {% trans 'App Store' %} - {% endif %} - {% endwith %} - - - {% endif %} - {% endfor %} -
{% trans "Desktop" %}{{ client.name }} + {% for platform in client.platforms %} + {% if platform.type == 'download' %} + + + {% with 'theme/icons/'|add:platform.os|add:'.png' as icon %} + + {% if platform.os == 'gnu-linux' %} + {% trans 'GNU/Linux' %} + {% elif platform.os == 'windows' %} + {% trans 'Windows' %} + {% elif platform.os == 'macos' %} + {% trans 'macOS' %} + {% endif %} + {% endwith %} + + + {% endif %} + {% endfor %} +
{% trans "Package" %}{{ client.name }} - {% for platform in client.platforms %} - {% if platform.type == 'package' %} - {% if platform.format == 'deb' %} -
{% trans "Debian:" %} {{ platform.name }}
+ {% with clients|clients_of_type:'mobile' as mobile_clients %} + {% for client in mobile_clients %} +
{% trans "Mobile" %}{{ client.name }} + {% for platform in client.platforms %} + {% if platform.type == 'store' and platform.os == 'android' or platform.os == 'ios' %} + + + {% with 'theme/icons/'|add:platform.store_name|add:'.png' as icon %} + + {% if platform.store_name == 'google-play' %} + {% trans 'Play Store' %} + {% elif platform.store_name == 'f-droid' %} + {% trans 'F-Droid' %} + {% elif platform.store_name == 'app-store' %} + {% trans 'App Store' %} + {% endif %} + {% endwith %} + + {% endif %} - {% if platform.format == 'brew' %} -
{% trans "Homebrew:" %} {{ platform.name }}
- {% endif %} - {% if platform.format == 'rpm' %} -

{% trans "RPM:" %} {{ platform.name }}

- {% endif %} - {% endif %} - {% endfor %} -
+ {% with clients|clients_of_type:'package' as package_clients %} + {% for client in package_clients %} + + {% if forloop.counter == 1 %} + {% trans "Package" %} + {% endif %} + {{ client.name }} + + {% for platform in client.platforms %} + {% if platform.type == 'package' %} + {% if platform.format == 'deb' %} +
{% trans "Debian:" %} {{ platform.name }}
+ {% endif %} + {% if platform.format == 'brew' %} +
{% trans "Homebrew:" %} {{ platform.name }}
+ {% endif %} + {% if platform.format == 'rpm' %} +

{% trans "RPM:" %} {{ platform.name }}

+ {% endif %} + {% endif %} + {% endfor %} + + + {% endfor %} + {% endwith %} + +
{% endif %}