From 2c373166485f4dd8bdaa7281ebc721d4e6dc6a95 Mon Sep 17 00:00:00 2001
From: James Valleroy
Date: Mon, 9 Jan 2017 16:52:43 -0500
Subject: [PATCH] ejabberd, jsxc: Fix few remaining issues from module split
---
CHANGELOG.md | 1 +
data/etc/plinth/modules-enabled/ejabberd | 2 +-
data/etc/plinth/modules-enabled/jsxc | 2 +-
plinth/modules/ejabberd/__init__.py | 4 +--
.../modules/ejabberd/templates/ejabberd.html | 2 +-
plinth/modules/jsxc/__init__.py | 29 ++++++++++---------
plinth/modules/jsxc/templates/jsxc.html | 3 ++
plinth/modules/jsxc/urls.py | 4 +--
plinth/modules/jsxc/views.py | 8 ++---
9 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 02231e178..82c5b5800 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- Prevent anonymous users from accessing setup pages.
- Firstboot, KVStore: merge old firstboot state fields.
- tor: Use Plinth-specific instance instead of default.
+- xmpp: Split into ejabberd and jsxc modules.
## [0.12.0] - 2016-12-08
### Added
diff --git a/data/etc/plinth/modules-enabled/ejabberd b/data/etc/plinth/modules-enabled/ejabberd
index 89238446c..078b9f990 100644
--- a/data/etc/plinth/modules-enabled/ejabberd
+++ b/data/etc/plinth/modules-enabled/ejabberd
@@ -1 +1 @@
-plinth.modules.xmpp
+plinth.modules.ejabberd
diff --git a/data/etc/plinth/modules-enabled/jsxc b/data/etc/plinth/modules-enabled/jsxc
index 89238446c..29add6543 100644
--- a/data/etc/plinth/modules-enabled/jsxc
+++ b/data/etc/plinth/modules-enabled/jsxc
@@ -1 +1 @@
-plinth.modules.xmpp
+plinth.modules.jsxc
diff --git a/plinth/modules/ejabberd/__init__.py b/plinth/modules/ejabberd/__init__.py
index 96b87cb61..b2c1ffe02 100644
--- a/plinth/modules/ejabberd/__init__.py
+++ b/plinth/modules/ejabberd/__init__.py
@@ -33,7 +33,7 @@ from plinth.signals import pre_hostname_change, post_hostname_change
from plinth.signals import domainname_change
-version = 2
+version = 1
depends = ['apps']
@@ -106,7 +106,7 @@ def add_shortcut():
def is_enabled():
"""Return whether the module is enabled."""
- return (action_utils.service_is_enabled('ejabberd'))
+ return action_utils.service_is_enabled('ejabberd')
def get_domainname():
diff --git a/plinth/modules/ejabberd/templates/ejabberd.html b/plinth/modules/ejabberd/templates/ejabberd.html
index 4e546c455..79e525503 100644
--- a/plinth/modules/ejabberd/templates/ejabberd.html
+++ b/plinth/modules/ejabberd/templates/ejabberd.html
@@ -42,7 +42,7 @@
-
+
{% trans "Launch web client" %}
{% endblock %}
diff --git a/plinth/modules/jsxc/__init__.py b/plinth/modules/jsxc/__init__.py
index 2a9013c1a..a1e3065e0 100644
--- a/plinth/modules/jsxc/__init__.py
+++ b/plinth/modules/jsxc/__init__.py
@@ -24,14 +24,12 @@ from django.utils.translation import ugettext_lazy as _
import logging
import socket
-from plinth import actions
-from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
-version = 2
+version = 1
depends = ['apps']
@@ -41,9 +39,8 @@ title = _('Chat Client \n (JSXC)')
description = [
- _('JSXC is a web client for XMPP. Typically it is used with an XMPP server running locally '
- 'XMPP client.'),
+ _('JSXC is a web client for XMPP. Typically it is used with an XMPP '
+ 'server running locally.'),
]
service = None
@@ -59,32 +56,36 @@ def init():
global service
setup_helper = globals()['setup_helper']
if setup_helper.get_state() != 'needs-setup':
- service = service = service_module.Service(
+ service = service_module.Service(
'jsxc', title, ports=['http', 'https'], is_external=True,
is_enabled=is_enabled, enable=enable, disable=disable)
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(
+
+ global service
+ if not 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'),
+ url=reverse_lazy('jsxc:jsxc'),
login_required=True)
def is_enabled():
"""Return whether the module is enabled."""
- 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)
+ setup_helper = globals()['setup_helper']
+ return setup_helper.get_state() != 'needs-setup'
def get_domainname():
diff --git a/plinth/modules/jsxc/templates/jsxc.html b/plinth/modules/jsxc/templates/jsxc.html
index c480affec..0332e0920 100644
--- a/plinth/modules/jsxc/templates/jsxc.html
+++ b/plinth/modules/jsxc/templates/jsxc.html
@@ -32,3 +32,6 @@
{% trans "Launch web client" %}
{% endblock %}
+
+{% block configuration %}
+{% endblock %}
diff --git a/plinth/modules/jsxc/urls.py b/plinth/modules/jsxc/urls.py
index 25e48a129..70e2fd254 100644
--- a/plinth/modules/jsxc/urls.py
+++ b/plinth/modules/jsxc/urls.py
@@ -25,6 +25,6 @@ from .views import JSXCServiceView, JsxcView
urlpatterns = [
- url(r'^apps/jsxc', JSXCServiceView(), name='index'),
- url(r'^apps/jsxc/jsxc', JsxcView(), name='jsxc')
+ url(r'^apps/jsxc$', JSXCServiceView.as_view(), name='index'),
+ url(r'^apps/jsxc/jsxc$', JsxcView.as_view(), name='jsxc')
]
diff --git a/plinth/modules/jsxc/views.py b/plinth/modules/jsxc/views.py
index cdc63b163..9a886ff48 100644
--- a/plinth/modules/jsxc/views.py
+++ b/plinth/modules/jsxc/views.py
@@ -32,16 +32,12 @@ class JSXCServiceView(ServiceView):
service_id = 'jsxc'
template_name = 'jsxc.html'
description = jsxc.description
-
- def get_context_data(self, *args, **kwargs):
- context = super().get_context_data(*args, **kwargs)
- context['domainname'] = jsxc.get_domainname()
- return context
+ show_status_block = False
class JsxcView(TemplateView):
"""A simple page to embed Javascript XMPP Client library."""
- template_name = 'jsxc.html'
+ template_name = 'jsxc_launch.html'
@method_decorator(public)
def dispatch(self, *args, **kwargs):