Add package names (Debian and Homebrew) as a client entry

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2017-11-20 17:53:02 +05:30 committed by James Valleroy
parent 9ac7ff10ce
commit 0b1b8157e4
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
7 changed files with 197 additions and 144 deletions

View File

@ -86,8 +86,8 @@ _clients = [{
_('Gajim'),
'platforms': [{
'type': 'package',
'os': 'Debian',
'package_name': 'gajim'
'format': 'deb',
'name': 'gajim'
}, {
'type': 'download',
'os': Desktop_OS.WINDOWS.value,

View File

@ -37,7 +37,7 @@ clients = [{
'url': 'http://releases.0x539.de/gobby/gobby-stable.exe'
}, {
'type': 'package',
'os': 'Debian',
'package_name': 'gobby'
'format': 'deb',
'name': 'gobby'
}]
}]

View File

@ -22,8 +22,8 @@ clients = [{
_('JSXC'),
'platforms': [{
'type': 'package',
'os': 'Debian',
'package_name': 'libjs-jsxc'
'format': 'deb',
'name': 'libjs-jsxc'
}, {
'type': 'web',
'url': '/jsxc'

View File

@ -32,8 +32,8 @@ clients = [{
'url': quassel_download_url,
}, {
'type': 'package',
'os': 'Debian',
'package_name': 'quassel-client',
'format': 'deb',
'name': 'quassel-client',
}]
}, {
'name':

View File

@ -41,8 +41,8 @@ clients = [{
_('GNOME Calendar'),
'platforms': [{
'type': 'package',
'os': 'Debian',
'package-name': 'gnome-calendar'
'format': 'deb',
'name': 'gnome-calendar'
}]
}, {
'name':
@ -59,7 +59,7 @@ clients = [{
'calendars and address books.'),
'platforms': [{
'type': 'package',
'os': 'Debian',
'package-name': 'gnome-calendar'
'format': 'deb',
'name': 'evolution'
}]
}]

View File

@ -22,141 +22,187 @@
{% load static %}
{% if clients %}
<p>
<button id="collapsible-button" type="button" class="btn btn-default collapsed"
data-toggle="collapse" data-target="#clients">
Client Apps
</button>
</p>
<p>
<button id="collapsible-button" type="button" class="btn btn-default collapsed"
data-toggle="collapse" data-target="#clients">
Client Apps
</button>
</p>
<table id="clients" class="table table-hover collapse">
<table id="clients" class="table table-hover collapse">
{% if clients|has_web_clients %}
{% with clients|of_type:'web' as web_clients %}
<tr>
<th rowspan=" {{ web_clients|length }}"> Web </th>
{% with web_clients|first as client %}
{% for platform in client.platforms %}
{% if platform.type == 'web' %}
<td> {{ client.name }} </td>
<td>
<a href="{{ platform.url }}">
<button type="button" class="btn btn-success">Launch</button>
</a>
</td>
{% endif %}
{% endfor %}
{% endwith %}
</tr>
{% for client in web_clients|slice:"1:" %}
{% for platform in client.platforms %}
{% if platform.type == 'web' %}
<tr>
<td> {{ client.name }} </td>
<td>
<a href="{{ platform.url }}">
<button type="button" class="btn btn-success">Launch</button>
</a>
</td>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
{% endwith %}
{% endif %}
{% if clients|has_web_clients %}
{% with clients|of_type:'web' as web_clients %}
<tr>
<th rowspan=" {{ web_clients|length }}"> Web </th>
{% with web_clients|first as client %}
{% for platform in client.platforms %}
{% if platform.type == 'web' %}
<td> {{ client.name }} </td>
<td>
<a href="{{ platform.url }}">
<button type="button" class="btn btn-success">Launch</button>
</a>
</td>
{% endif %}
{% endfor %}
{% endwith %}
</tr>
{% for client in web_clients|slice:"1:" %}
{% for platform in client.platforms %}
{% if platform.type == 'web' %}
<tr>
<td> {{ client.name }} </td>
<td>
<a href="{{ platform.url }}">
<button type="button" class="btn btn-success">Launch</button>
</a>
</td>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
{% endwith %}
{% endif %}
{% if clients|has_desktop_clients %}
{% with clients|of_type:'desktop' as desktop_clients %}
<tr>
<th rowspan="{{ desktop_clients|length }}"> Desktop </th>
{% with desktop_clients|first as client %}
<td> {{ client.name }} </td>
<td>
<div class ="row">
{% for platform in client.platforms %}
{% if platform.type == 'download' %}
<div class="col-md-2 col-xs-4">
<a href="{{ platform.url }}">
{% with 'theme/icons/'|add:platform.os|add:'.png' as icon %}
<img class="os-icon" src="{% static icon %}" />
{% endwith %}
</a>
</div>
{% endif %}
{% endfor %}
</div>
</td>
{% endwith %}
</tr>
{% for client in desktop_clients|slice:"1:" %}
<tr>
<td> {{ client.name }} </td>
<td>
<div class ="row">
{% for platform in client.platforms %}
{% if platform.type == 'download' %}
<div class="col-md-2 col-xs-4">
<a href="{{ platform.url }}">
{% with 'theme/icons/'|add:platform.os|add:'.png' as icon %}
<img class="os-icon" src="{% static icon %}" />
{% endwith %}
</a>
</div>
{% endif %}
{% endfor %}
</div>
</td>
</tr>
{% endfor %}
{% endwith %}
{% endif %}
{% if clients|has_desktop_clients %}
{% with clients|of_type:'desktop' as desktop_clients %}
<tr>
<th rowspan="{{ desktop_clients|length }}"> Desktop </th>
{% with desktop_clients|first as client %}
<td> {{ client.name }} </td>
<td>
<div class ="row">
{% for platform in client.platforms %}
{% if platform.type == 'download' %}
<div class="col-md-2 col-xs-4">
<a href="{{ platform.url }}">
{% with 'theme/icons/'|add:platform.os|add:'.png' as icon %}
<img class="os-icon" src="{% static icon %}" />
{% endwith %}
</a>
</div>
{% endif %}
{% endfor %}
</div>
</td>
{% endwith %}
</tr>
{% for client in desktop_clients|slice:"1:" %}
<tr>
<td> {{ client.name }} </td>
<td>
<div class ="row">
{% for platform in client.platforms %}
{% if platform.type == 'download' %}
<div class="col-md-2 col-xs-4">
<a href="{{ platform.url }}">
{% with 'theme/icons/'|add:platform.os|add:'.png' as icon %}
<img class="os-icon" src="{% static icon %}" />
{% endwith %}
</a>
</div>
{% endif %}
{% endfor %}
</div>
</td>
</tr>
{% endfor %}
{% endwith %}
{% endif %}
{% if clients|has_mobile_clients %}
{% with clients|of_type:'mobile' as mobile_clients %}
<tr>
<th rowspan="{{ mobile_clients|length }}"> Mobile </th>
{% with mobile_clients|first as client %}
<td> {{ client.name }} </td>
<td>
<div class="row">
{% for platform in client.platforms %}
{% if platform.type == 'store' and platform.os == 'android' or platform.os == 'ios' %}
<div class="col-md-2 col-xs-4">
<a href="{{ platform.url }}">
{% with 'theme/icons/'|add:platform.store_name|add:'.png' as icon %}
<img class="store-icon" src="{% static icon %}" />
{% endwith %}
</a>
</div>
{% endif %}
{% endfor %}
</div>
</td>
{% endwith %}
</tr>
{% for client in mobile_clients|slice:"1:" %}
<tr>
<td> {{ client.name }} </td>
<td>
<div class="row">
{% for platform in client.platforms %}
{% if platform.type == 'store' and platform.os == 'android' or platform.os == 'ios' %}
<div class="col-md-2 col-xs-4">
<a href="{{ platform.url }}">
{% with 'theme/icons/'|add:platform.store_name|add:'.png' as icon %}
<img class="store-icon" src="{% static icon %}" />
{% endwith %}
</a>
</div>
{% endif %}
{% endfor %}
</div>
</td>
</tr>
{% endfor %}
{% endwith %}
{% endif %}
{% if clients|has_mobile_clients %}
{% with clients|of_type:'mobile' as mobile_clients %}
<tr>
<th rowspan="{{ mobile_clients|length }}"> Mobile </th>
{% with mobile_clients|first as client %}
<td> {{ client.name }} </td>
<td>
<div class="row">
{% for platform in client.platforms %}
{% if platform.type == 'store' and platform.os == 'android' or platform.os == 'ios' %}
<div class="col-md-2 col-xs-4">
<a href="{{ platform.url }}">
{% with 'theme/icons/'|add:platform.store_name|add:'.png' as icon %}
<img class="store-icon" src="{% static icon %}" />
{% endwith %}
</a>
</div>
{% endif %}
{% endfor %}
</div>
</td>
{% endwith %}
</tr>
{% for client in mobile_clients|slice:"1:" %}
<tr>
<td> {{ client.name }} </td>
<td>
<div class="row">
{% for platform in client.platforms %}
{% if platform.type == 'store' and platform.os == 'android' or platform.os == 'ios' %}
<div class="col-md-2 col-xs-4">
<a href="{{ platform.url }}">
{% with 'theme/icons/'|add:platform.store_name|add:'.png' as icon %}
<img class="store-icon" src="{% static icon %}" />
{% endwith %}
</a>
</div>
{% endif %}
{% endfor %}
</div>
</td>
</tr>
{% endfor %}
{% endwith %}
{% endif %}
</table>
{% if clients|has_package_clients %}
{% with clients|of_type:'package' as package_clients %}
<tr>
<th rowspan="{{ package_clients|length }}"> Package </th>
{% with package_clients|first as client %}
<td> {{ client.name }} </td>
<td>
<div class="row">
<ul>
{% for platform in client.platforms %}
{% if platform.type == 'package' and platform.format == 'deb' %}
<li> <strong> Debian: </strong> {{ platform.name }} </li>
{% endif %}
{% if platform.type == 'package' and platform.format == 'homebrew' %}
<li> <strong> HomeBrew: </strong> {{ platform.name }} </li>
{% endif %}
{% endfor %}
</ul>
</div>
</td>
{% endwith %}
</tr>
{% for client in package_clients|slice:"1:" %}
<tr>
<td> {{ client.name }} </td>
<td>
<div class="row">
<ul>
{% for platform in client.platforms %}
{% if platform.type == 'package' %}
{% if platform.type == 'package' and platform.format == 'deb' %}
<li> <strong> Debian: </strong> {{ platform.name }} </li>
{% endif %}
{% if platform.type == 'package' and platform.format == 'homebrew' %}
<li> <strong> HomeBrew: </strong> {{ platform.name }} </li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
</div>
</td>
</tr>
{% endfor %}
{% endwith %}
{% endif %}
</table>
{% endif %}

View File

@ -110,12 +110,19 @@ def has_web_clients(clients):
return __check(clients, lambda x: x['type'] == 'web')
@register.filter(name='has_package_clients')
def has_package_clients(clients):
"""Filter to find out whether an application has web clients"""
return __check(clients, lambda x: x['type'] == 'package')
@register.filter(name='of_type')
def of_type(clients, typ):
"""Filter and get clients of a particular type"""
filters = {
'mobile': has_mobile_clients,
'desktop': has_desktop_clients,
'web': has_web_clients
'web': has_web_clients,
'package': has_package_clients,
}
return list(filter(filters.get(typ, lambda x: x), clients))