diff --git a/LICENSES b/LICENSES index dc86c91c7..9888fd05b 100644 --- a/LICENSES +++ b/LICENSES @@ -65,3 +65,6 @@ otherwise. - static/themes/default/icons/ttrss.png :: [[https://tt-rss.org/gitlab/fox/tt-rss][GPL]] - static/themes/default/img/f-droid.png :: [[https://commons.wikimedia.org/wiki/File%3AGet_it_on_F-Droid_(material_design).svg][GPLv3]] - static/themes/default/img/google-play.png :: [[https://upload.wikimedia.org/wikipedia/commons/c/cd/Get_it_on_Google_play.svg][Public Domain]] +- static/themes/default/img/debian.png :: [[https://commons.wikimedia.org/wiki/File:Debian_logo-black.png][GPL3+/CC-BY-SA]] +- static/themes/default/img/apple.png :: [[https://thenounproject.com/icon/1203053/download/color/000000/png][CC BY 3.0 US]] +- static/themes/default/img/windows.png :: [[https://thenounproject.com/icon/1206946/download/color/000000/png][CC BY 3.0 US]] diff --git a/data/etc/plinth/modules-enabled/api b/data/etc/plinth/modules-enabled/api new file mode 100644 index 000000000..9bf760b6d --- /dev/null +++ b/data/etc/plinth/modules-enabled/api @@ -0,0 +1 @@ +plinth.modules.api \ No newline at end of file diff --git a/plinth/modules/api/urls.py b/plinth/modules/api/urls.py index d1bfbb0f8..f070276d3 100644 --- a/plinth/modules/api/urls.py +++ b/plinth/modules/api/urls.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ URLs for the plinth api for android app. """ @@ -22,9 +21,9 @@ URLs for the plinth api for android app. from django.conf.urls import url from stronghold.decorators import public -from plinth.modules.api.views import get_apps, get_access_info +from plinth.modules.api.views import get_access_info, get_services urlpatterns = [ - url(r'^api/(?P[0-9]+)/services/?$', public(get_apps)), - url(r'^api/(?P[0-9]+)/access-info/?$', public(get_access_info)) -] \ No newline at end of file + url(r'^api/(?P[0-9]+)/services/?$', public(get_services)), + url(r'^api/(?P[0-9]+)/access-info/?$', public(get_access_info)), +] diff --git a/plinth/modules/api/views.py b/plinth/modules/api/views.py index 007dcd0ae..58166c5e1 100644 --- a/plinth/modules/api/views.py +++ b/plinth/modules/api/views.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Plinth module for api for android app. """ @@ -28,32 +27,42 @@ from plinth import module_loader import json -def get_apps(request, **kwargs): - shortcuts = frontpage.get_shortcuts() - - response = {'services': list(map(get_app_data, shortcuts)) } - return HttpResponse(json.dumps(response, cls=DjangoJSONEncoder), - content_type="application/json") - - -def get_app_data(item): - item_id = item['id'].split('_')[0] - shortcut_module = module_loader.loaded_modules[item_id] - - def get_icon_url(icon): - return 'static/theme/icons/{}.svg'.format(icon) if icon else None - - return {key: value for key, value in dict(name=shortcut_module.name, - short_description=getattr(shortcut_module, - 'short_description', None), - icon_url=get_icon_url(getattr(shortcut_module, 'icon', None)), - description=getattr(shortcut_module, 'description', None), - usage=getattr(shortcut_module, 'usage', None), - manual_url=getattr(shortcut_module, 'manual_url', None), - clients=getattr(shortcut_module, 'clients', None)).items() if value } - - def get_access_info(request, **kwargs): - response = {domain_type: get_domain(domain_type) for domain_type in - get_domain_types()} + response = { + domain_type: get_domain(domain_type) + for domain_type in get_domain_types() + } return HttpResponse(json.dumps(response), content_type="application/json") + + +def get_services(request, **kwargs): + services = [shortcut['id'].split('_')[0] + for shortcut in frontpage.get_shortcuts()] + response = {'services': list(map(_get_service_data, services))} + return HttpResponse( + json.dumps(response, cls=DjangoJSONEncoder), + content_type="application/json") + + +def _get_service_data(service): + module = module_loader.loaded_modules[service] + + def _getattr(attr, not_found=None): + """A closure to get the enclosed module's attributes""" + return getattr(module, attr, not_found) + + return { + key: value + for key, value in dict( + name=module.name, + short_description=_getattr('short_description'), + icon_url=_get_icon_url(_getattr('icon')), + description=_getattr('description'), + usage=_getattr('usage'), + manual_url=_getattr('manual_url'), + clients=_getattr('clients')).items() + } + + +def _get_icon_url(icon): + return 'static/theme/icons/{}.svg'.format(icon) if icon else None diff --git a/plinth/modules/matrixsynapse/__init__.py b/plinth/modules/matrixsynapse/__init__.py index f4e96fdaf..163936e1d 100644 --- a/plinth/modules/matrixsynapse/__init__.py +++ b/plinth/modules/matrixsynapse/__init__.py @@ -30,7 +30,6 @@ from plinth import action_utils from plinth import actions from plinth import frontpage from plinth import service as service_module -from plinth.client import desktop_client, web_client, mobile_client from plinth.menu import main_menu from .manifest import clients @@ -59,20 +58,6 @@ description = [ 'client is recommended.') ] -web_clients = [web_client(name='Riot', url='https://riot.im/app/#/home')] - -desktop_clients = [desktop_client(name='Riot', - url='https://riot.im/desktop.html'), - desktop_client(name='WeeChat CLI', - url='https://weechat.org/')] - -mobile_clients = [mobile_client(name='Riot', - fully_qualified_name='im.vector.alpha', - play_store_url='https://play.google.com/store/apps/' - 'details?id=im.vector.alpha', - fdroid_url='https://f-droid.org/packages/' - 'im.vector.alpha/')] - service = None logger = logging.getLogger(__name__) diff --git a/plinth/modules/matrixsynapse/manifest.py b/plinth/modules/matrixsynapse/manifest.py index 5964826ea..1edac0cd6 100644 --- a/plinth/modules/matrixsynapse/manifest.py +++ b/plinth/modules/matrixsynapse/manifest.py @@ -24,7 +24,7 @@ clients = [ { 'type': 'store', 'os': 'Android', - 'store_type': 'google_play_store', + 'store_name': 'google_play_store', 'fully_qualified_name': 'im.vector.alpha', 'url': 'https://play.google.com/store/apps/details?id=im' '.vector.alpha ' @@ -33,7 +33,7 @@ clients = [ 'type': 'store', 'os': 'Android', 'os_version': '>=6.0', - 'store_type': 'fdroid_store', + 'store_name': 'fdroid_store', 'fully_qualified_name': 'im.vector.alpha', 'url': 'https://f-droid.org/packages/im.vector.alpha/' }, @@ -41,30 +41,21 @@ clients = [ 'type': 'web', 'url': 'https://riot.im/app/#/home' }, + { + 'type': 'download', + 'os': 'Debian', + 'url': 'https://riot.im/desktop.html' + }, { 'type': 'download', 'os': 'macOS', - 'url': 'https://riot.im/download/desktop/install/macos' - '/Riot-0.12.4.dmg' + 'url': 'https://riot.im/desktop.html' }, { 'type': 'download', - 'os': 'Windows(32 bit)', + 'os': 'Windows', 'os_version': '>=7', - 'url': 'https://riot.im/download/desktop/install/win32/ia32/' - 'Riot%20Setup%200.12.4-ia32.exe' + 'url': 'https://riot.im/desktop.html' }, - { - 'type': 'download', - 'os': 'Windows(64 bit)', - 'os_version': '>=7', - 'url': 'https://riot.im/download/desktop/install/win32/x64/Riot' - '%20Setup%200.12.4.exe' - }, - { - 'type': 'download', - 'os': 'Debian/Ubuntu', - 'url': 'https://riot.im/packages/debian/' - } ] }] diff --git a/plinth/modules/syncthing/__init__.py b/plinth/modules/syncthing/__init__.py index a905e6ab6..da667460e 100644 --- a/plinth/modules/syncthing/__init__.py +++ b/plinth/modules/syncthing/__init__.py @@ -28,7 +28,6 @@ from plinth import frontpage from plinth import service as service_module from plinth.menu import main_menu from plinth.utils import format_lazy -from plinth.client import desktop_client, mobile_client, web_client from .manifest import clients @@ -62,17 +61,6 @@ description = [ clients = clients -web_clients = [web_client(name='Syncthing', url='/syncthing')] - -desktop_clients = [desktop_client(name='Syncthing', - url='https://syncthing.net/')] - -mobile_clients = [mobile_client( - name='Syncthing', fully_qualified_name='com.nutomic.syncthingandroid', - fdroid_url='https://f-droid.org/packages/com.nutomic.syncthingandroid/', - play_store_url='https://play.google.com/store/apps/details?id=com.nutomic' - '.syncthingandroid')] - service = None diff --git a/plinth/modules/syncthing/manifest.py b/plinth/modules/syncthing/manifest.py index c85537dc5..15ba3d943 100644 --- a/plinth/modules/syncthing/manifest.py +++ b/plinth/modules/syncthing/manifest.py @@ -21,31 +21,25 @@ clients = [ { 'name': _('Syncthing'), 'platforms': [ - { - 'type': 'apt', - 'os': 'Debian/Ubuntu', - 'usage': _('For more usage information refer to Syncthing'), - 'package_name': 'syncthing' - }, { 'type': 'download', - 'os': 'Windows(64-bit)', - 'url': 'https://github.com/syncthing/syncthing/releases' - '/download/v0.14.38/syncthing-windows-amd64-v0.14.38' - '.zip ' + 'os': 'Debian', + 'url': 'https://apt.syncthing.net/', }, { 'type': 'download', 'os': 'macOS', 'url': 'https://github.com/syncthing/syncthing/releases' - '/download/v0.14.38/syncthing-macosx-amd64-v0.14.38' - '.tar.gz ' + }, + { + 'type': 'download', + 'os': 'Windows', + 'url': 'https://github.com/syncthing/syncthing/releases' }, { 'type': 'store', 'os': 'Android', - 'store_type': 'google_play_store', + 'store_name': 'google_play_store', 'fully_qualified_name': 'com.nutomic.syncthingandroid', 'url': 'https://play.google.com/store/apps/details?id=com' '.nutomic.syncthingandroid ' diff --git a/plinth/modules/transmission/__init__.py b/plinth/modules/transmission/__init__.py index 9a5b623d6..a571f03fb 100644 --- a/plinth/modules/transmission/__init__.py +++ b/plinth/modules/transmission/__init__.py @@ -23,9 +23,15 @@ import json from django.utils.translation import ugettext_lazy as _ from plinth import service as service_module +<<<<<<< HEAD from plinth import action_utils, actions, frontpage from plinth.menu import main_menu from plinth.modules.users import add_group +======= +from plinth.client import web_client +from plinth.menu import main_menu +from .manifest import clients +>>>>>>> Add client information for Matrix Synapse and Syncthing from .manifest import clients @@ -48,6 +54,11 @@ description = [ clients = clients +<<<<<<< HEAD +======= +web_clients = [web_client(name='Transmission', url='/transmission')] + +>>>>>>> Add client information for Matrix Synapse and Syncthing reserved_usernames = ['debian-transmission'] service = None diff --git a/plinth/templates/clients.html b/plinth/templates/clients.html index aedc9d952..879f3bda0 100644 --- a/plinth/templates/clients.html +++ b/plinth/templates/clients.html @@ -19,59 +19,80 @@ {% load i18n %} -{% if module.web_clients %} +{% if module.clients %} {% trans "Web Clients" %}: - {% for client in module.web_clients %} - - {{ client.name}} - + {% for client in module.clients %} + {% for platform in client.platforms %} + {% if platform.type == 'web' %} + + {{ client.name}} + + {% endif %} + {% endfor %} {% endfor %} -{% endif %} -{% if module.desktop_clients %} + {% load static %} {% trans "Desktop Clients" %}: - {% for client in module.desktop_clients %} - + {% for client in module.clients %} + - {{ client.name }} + {{ client.name }} + + {% for platform in client.platforms %} + {% if platform.type == 'download' %} + + + {% if platform.os == 'Windows' %} + + {% elif platform.os == 'macOS' %} + + {% elif platform.os == 'Debian' %} + + {% endif %} + + + {% endif %} + {% endfor %} {% endfor %} -{% endif %} -{% if module.mobile_clients %} {% load static %} {% trans "Mobile Clients" %}: - {% for client in module.mobile_clients %} - {{ client.name }} - - {% if client.fdroid_url %} - - - - + {% for client in module.clients %} + {{ client.name }} + + {% for platform in client.platforms %} + {% if platform.type == 'store' and platform.os == 'Android' %} + {% if platform.store_name == 'fdroid_store' %} + + + + + + {% endif %} + {% if platform.store_name == 'google_play_store' %} + + + + + + {% endif %} + {% endif %} + {% endfor %} - {% endif %} - {% if client.play_store_url %} - - - - - - {% endif %} - {% endfor %} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/static/themes/default/css/plinth.css b/static/themes/default/css/plinth.css index 3bc8ea4dc..5b3c49958 100644 --- a/static/themes/default/css/plinth.css +++ b/static/themes/default/css/plinth.css @@ -136,9 +136,15 @@ footer license-info p{ } .store-icon { - display:block; + display: block; width: 100%; - height: auto + height: auto; +} + +.os-icon { + display: block; + width: 100%; + height: auto; } .shortcut-label { diff --git a/static/themes/default/img/apple.png b/static/themes/default/img/apple.png new file mode 100644 index 000000000..6f2bdb6e2 Binary files /dev/null and b/static/themes/default/img/apple.png differ diff --git a/static/themes/default/img/debian.png b/static/themes/default/img/debian.png new file mode 100644 index 000000000..78db4dbfc Binary files /dev/null and b/static/themes/default/img/debian.png differ diff --git a/static/themes/default/img/f-Droid.png b/static/themes/default/img/f-droid.png similarity index 100% rename from static/themes/default/img/f-Droid.png rename to static/themes/default/img/f-droid.png diff --git a/static/themes/default/img/windows.png b/static/themes/default/img/windows.png new file mode 100644 index 000000000..f7849b582 Binary files /dev/null and b/static/themes/default/img/windows.png differ
{% trans "Web Clients" %}:
{% trans "Desktop Clients" %}:
{% trans "Mobile Clients" %}: