privoxy: Use new setup mechanism

This commit is contained in:
Sunil Mohan Adapa 2016-02-12 14:06:43 +05:30
parent 45a1bff51d
commit b112c82889
No known key found for this signature in database
GPG Key ID: 36C361440C9BC971
3 changed files with 35 additions and 37 deletions

View File

@ -25,23 +25,50 @@ from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import service as service_module
from plinth.utils import format_lazy
version = 1
is_essential = False
depends = ['apps']
title = _('Web Proxy (Privoxy)')
description = [
_('Privoxy is a non-caching web proxy with advanced filtering '
'capabilities for enhancing privacy, modifying web page data and '
'HTTP headers, controlling access, and removing ads and other '
'obnoxious Internet junk. '),
format_lazy(
_('You can use Privoxy by modifying your browser proxy settings to '
'your {box_name} hostname (or IP address) with port 8118. '
'While using Privoxy, you can see its configuration details and '
'documentation at '
'<a href="http://config.privoxy.org">http://config.privoxy.org/</a> '
'or <a href="http://p.p">http://p.p</a>.'), box_name=_(cfg.box_name))
]
service = None
def init():
"""Intialize the module."""
menu = cfg.main_menu.get('apps:index')
menu.add_urlname(_('Web Proxy (Privoxy)'), 'glyphicon-cloud-upload',
'privoxy:index', 1000)
menu.add_urlname(title, 'glyphicon-cloud-upload', 'privoxy:index', 1000)
global service
service = service_module.Service(
'privoxy', _('Privoxy Web Proxy'),
is_external=False, enabled=is_enabled())
'privoxy', title, is_external=False, enabled=is_enabled())
def setup(helper, old_version=None):
"""Install and configure the module."""
helper.install(['privoxy'])
helper.call('post', actions.superuser_run, 'privoxy', ['setup'])
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,29 +21,7 @@
{% load bootstrap %}
{% load i18n %}
{% block content %}
<h2>{% trans "Web Proxy (Privoxy)" %}</h2>
<p>
{% blocktrans trimmed %}
Privoxy is a non-caching web proxy with advanced filtering
capabilities for enhancing privacy, modifying web page data and
HTTP headers, controlling access, and removing ads and other
obnoxious Internet junk.
{% endblocktrans %}
</p>
<p>
{% blocktrans trimmed %}
You can use Privoxy by modifying your browser proxy settings to
your {{ box_name }} hostname (or IP address) with port 8118.
While using Privoxy, you can see its configuration details and
documentation at
<a href="http://config.privoxy.org">http://config.privoxy.org/</a>
or <a href="http://p.p">http://p.p</a>.
{% endblocktrans %}
</p>
{% block configuration %}
<h3>{% trans "Status" %}</h3>

View File

@ -26,19 +26,11 @@ import logging
from .forms import PrivoxyForm
from plinth import actions
from plinth import package
from plinth.modules import privoxy
logger = logging.getLogger(__name__)
def on_install():
"""Notify that the service is now enabled."""
actions.superuser_run('privoxy', ['setup'])
privoxy.service.notify_enabled(None, True)
@package.required(['privoxy'], on_install=on_install)
def index(request):
"""Serve configuration page."""
status = get_status()
@ -56,7 +48,8 @@ def index(request):
form = PrivoxyForm(initial=status, prefix='privoxy')
return TemplateResponse(request, 'privoxy.html',
{'title': _('Web Proxy (Privoxy)'),
{'title': privoxy.title,
'description': privoxy.description,
'status': status,
'form': form})