jsxc: Add setup

Fix routes.
This commit is contained in:
Swapnil Gupta 2017-01-08 03:44:01 +05:30 committed by James Valleroy
parent 7a9554cbf7
commit bb70c43923
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
9 changed files with 21 additions and 16 deletions

View File

@ -0,0 +1 @@
plinth.modules.xmpp

View File

@ -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')
]

View File

@ -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 '
'<a href=\'http://xmpp.org/xmpp-software/clients/\' target=\'_blank\''
'>XMPP client</a>.'),
]
@ -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')

View File

@ -28,7 +28,7 @@
<p>
<a href='{% url "xmpp:jsxc" %}' target='_blank' class='btn btn-primary'>
<a href='{% url "jsxc:jsxc" %}' target='_blank' class='btn btn-primary'>
{% trans "Launch web client" %}</a>
</p>
{% endblock %}

View File

@ -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')
]

View File

@ -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)

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB