minetest: Use new setup mechanism

This commit is contained in:
Sunil Mohan Adapa 2016-02-26 15:20:05 +05:30
parent 363e071bff
commit 6c67a50e11
No known key found for this signature in database
GPG Key ID: 36C361440C9BC971
3 changed files with 29 additions and 28 deletions

View File

@ -24,22 +24,41 @@ from django.utils.translation import ugettext_lazy as _
from plinth import action_utils
from plinth import cfg
from plinth import service as service_module
from plinth.utils import format_lazy
depends = ['plinth.modules.apps']
version = 1
depends = ['apps']
title = _('Block Sandbox (Minetest)')
description = [
format_lazy(
_('Minetest is a multiplayer infinite-world block sandbox. This '
'module enables the Minetest server to be run on this '
'{box_name}, on the default port (30000). To connect to the server, '
'a <a href="http://www.minetest.net/downloads/">Minetest client</a> '
'is needed.'), box_name=_(cfg.box_name)),
]
service = None
def init():
"""Initialize the minetest module."""
"""Initialize the module."""
menu = cfg.main_menu.get('apps:index')
menu.add_urlname(_('Block Sandbox (Minetest)'), 'glyphicon-th-large',
'minetest:index', 325)
menu.add_urlname(title, 'glyphicon-th-large', 'minetest:index', 325)
global service
service = service_module.Service(
'minetest-plinth', _('Minetest Server'),
is_external=True, enabled=is_enabled())
'minetest-plinth', title, is_external=True, enabled=is_enabled())
def setup(helper, old_version=None):
"""Install and configure the module."""
helper.install(['minetest-server'])
helper.call('post', service.notify_enabled, None, True)
def is_enabled():

View File

@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "app.html" %}
{% comment %}
#
# This file is part of Plinth.
@ -21,19 +21,7 @@
{% load bootstrap %}
{% load i18n %}
{% block content %}
<h2>{% trans "Block Sandbox (Minetest)" %}</h2>
<p>
{% blocktrans trimmed %}
Minetest is a multiplayer infinite-world block sandbox. This module
enables the Minetest server to be run on this {{ box_name }}, on the
default port (30000). To connect to the server, a
<a href="http://www.minetest.net/downloads/">Minetest client</a>
is needed.
{% endblocktrans %}
</p>
{% block configuration %}
<h3>{% trans "Status" %}</h3>

View File

@ -25,16 +25,9 @@ from django.utils.translation import ugettext as _
from .forms import MinetestForm
from plinth import actions
from plinth import package
from plinth.modules import minetest
def on_install():
"""Notify that the service is now enabled."""
minetest.service.notify_enabled(None, True)
@package.required(['minetest-server'], on_install=on_install)
def index(request):
"""Serve configuration page."""
status = get_status()
@ -51,7 +44,8 @@ def index(request):
form = MinetestForm(initial=status, prefix='minetest')
return TemplateResponse(request, 'minetest.html',
{'title': _('Block Sandbox (Minetest)'),
{'title': minetest.title,
'description': minetest.description,
'status': status,
'form': form})