From bb70c439230c5c4747ac059d02d0281456df7c39 Mon Sep 17 00:00:00 2001 From: Swapnil Gupta <500swapnil@github.com> Date: Sun, 8 Jan 2017 03:44:01 +0530 Subject: [PATCH] jsxc: Add setup Fix routes. --- actions/{xmpp => ejabberd} | 0 .../plinth/modules-enabled/{xmpp => ejabberd} | 0 data/etc/plinth/modules-enabled/jsxc | 1 + plinth/modules/ejabberd/urls.py | 2 +- plinth/modules/jsxc/__init__.py | 26 ++++++++++-------- plinth/modules/jsxc/templates/jsxc.html | 2 +- plinth/modules/jsxc/urls.py | 3 +- plinth/modules/jsxc/views.py | 3 +- .../default/icons/{xmpp.png => ejabberd.png} | Bin 9 files changed, 21 insertions(+), 16 deletions(-) rename actions/{xmpp => ejabberd} (100%) rename data/etc/plinth/modules-enabled/{xmpp => ejabberd} (100%) create mode 100644 data/etc/plinth/modules-enabled/jsxc rename static/themes/default/icons/{xmpp.png => ejabberd.png} (100%) diff --git a/actions/xmpp b/actions/ejabberd similarity index 100% rename from actions/xmpp rename to actions/ejabberd diff --git a/data/etc/plinth/modules-enabled/xmpp b/data/etc/plinth/modules-enabled/ejabberd similarity index 100% rename from data/etc/plinth/modules-enabled/xmpp rename to data/etc/plinth/modules-enabled/ejabberd diff --git a/data/etc/plinth/modules-enabled/jsxc b/data/etc/plinth/modules-enabled/jsxc new file mode 100644 index 000000000..89238446c --- /dev/null +++ b/data/etc/plinth/modules-enabled/jsxc @@ -0,0 +1 @@ +plinth.modules.xmpp diff --git a/plinth/modules/ejabberd/urls.py b/plinth/modules/ejabberd/urls.py index 433feb691..025e69b76 100644 --- a/plinth/modules/ejabberd/urls.py +++ b/plinth/modules/ejabberd/urls.py @@ -25,5 +25,5 @@ from .views import EjabberdServiceView urlpatterns = [ - url(r'^apps/xmpp/ejabberd/$', EjabberdServiceView.as_view(), name='index') + url(r'^apps/ejabberd/$', EjabberdServiceView.as_view(), name='index') ] diff --git a/plinth/modules/jsxc/__init__.py b/plinth/modules/jsxc/__init__.py index f8ee7a865..2a9013c1a 100644 --- a/plinth/modules/jsxc/__init__.py +++ b/plinth/modules/jsxc/__init__.py @@ -29,8 +29,6 @@ from plinth import action_utils from plinth import cfg from plinth import frontpage from plinth import service as service_module -from plinth.signals import pre_hostname_change, post_hostname_change -from plinth.signals import domainname_change version = 2 @@ -39,11 +37,11 @@ depends = ['apps'] managed_packages = ['libjs-jsxc'] -title = _('JSXC') +title = _('Chat Client \n (JSXC)') description = [ - _('To actually communicate, you can use the web client or any other ' + _('JSXC is a web client for XMPP. Typically it is used with an XMPP server running locally ' 'XMPP client.'), ] @@ -54,7 +52,7 @@ logger = logging.getLogger(__name__) def init(): - """Initialize the XMPP module""" + """Initialize the JSXC module""" menu = cfg.main_menu.get('apps:index') menu.add_urlname(title, 'glyphicon-comment', 'jsxc:index') @@ -67,7 +65,14 @@ def init(): if is_enabled(): add_shortcut() - +def setup(helper, old_version=None): + """Install and configure the module.""" + helper.install(managed_packages) + if setup_helper.get_state() != 'needs-setup': + service = service = service_module.Service( + 'jsxc', title, ports=['http', 'https'], is_external=True, + is_enabled=is_enabled, enable=enable, disable=disable) + helper.call('post', add_shortcut) def add_shortcut(): frontpage.add_shortcut('jsxc', _('Chat Client \n (jsxc)'), url=reverse_lazy('xmpp:jsxc'), @@ -76,7 +81,10 @@ def add_shortcut(): def is_enabled(): """Return whether the module is enabled.""" - return action_utils.webserver_is_enabled('jwchat-plinth')) + if setup_helper.get_state() != 'needs-setup': + service = service = service_module.Service( + 'jsxc', title, ports=['http', 'https'], is_external=True, + is_enabled=is_enabled, enable=enable, disable=disable) def get_domainname(): @@ -86,12 +94,8 @@ def get_domainname(): def enable(): - """Enable the module.""" - actions.superuser_run('jsxc', ['enable']) add_shortcut() def disable(): - """Enable the module.""" - actions.superuser_run('jsxc', ['disable']) frontpage.remove_shortcut('jsxc') diff --git a/plinth/modules/jsxc/templates/jsxc.html b/plinth/modules/jsxc/templates/jsxc.html index 5a21188dc..c480affec 100644 --- a/plinth/modules/jsxc/templates/jsxc.html +++ b/plinth/modules/jsxc/templates/jsxc.html @@ -28,7 +28,7 @@
{% endblock %} diff --git a/plinth/modules/jsxc/urls.py b/plinth/modules/jsxc/urls.py index 59d714e50..25e48a129 100644 --- a/plinth/modules/jsxc/urls.py +++ b/plinth/modules/jsxc/urls.py @@ -25,5 +25,6 @@ from .views import JSXCServiceView, JsxcView urlpatterns = [ - url(r'^apps/jsxc/$', JsxcView.as_view(), name='jsxc'), + url(r'^apps/jsxc', JSXCServiceView(), name='index'), + url(r'^apps/jsxc/jsxc', JsxcView(), name='jsxc') ] diff --git a/plinth/modules/jsxc/views.py b/plinth/modules/jsxc/views.py index deda837f3..cdc63b163 100644 --- a/plinth/modules/jsxc/views.py +++ b/plinth/modules/jsxc/views.py @@ -29,10 +29,9 @@ from plinth.views import ServiceView class JSXCServiceView(ServiceView): """Show ejabberd as a service.""" - service_id = jsxc.managed_services[0] + service_id = 'jsxc' template_name = 'jsxc.html' description = jsxc.description - diagnostics_module_name = 'jsxc' def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) diff --git a/static/themes/default/icons/xmpp.png b/static/themes/default/icons/ejabberd.png similarity index 100% rename from static/themes/default/icons/xmpp.png rename to static/themes/default/icons/ejabberd.png