From b112c828897a3d062632bd8bcea6ce5cf59cae39 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 12 Feb 2016 14:06:43 +0530 Subject: [PATCH] privoxy: Use new setup mechanism --- plinth/modules/privoxy/__init__.py | 35 ++++++++++++++++--- plinth/modules/privoxy/templates/privoxy.html | 26 ++------------ plinth/modules/privoxy/views.py | 11 ++---- 3 files changed, 35 insertions(+), 37 deletions(-) diff --git a/plinth/modules/privoxy/__init__.py b/plinth/modules/privoxy/__init__.py index 4c3e07627..eaf0d20d1 100644 --- a/plinth/modules/privoxy/__init__.py +++ b/plinth/modules/privoxy/__init__.py @@ -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 ' + 'http://config.privoxy.org/ ' + 'or http://p.p.'), 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(): diff --git a/plinth/modules/privoxy/templates/privoxy.html b/plinth/modules/privoxy/templates/privoxy.html index 4a4f82c00..d80099eb4 100644 --- a/plinth/modules/privoxy/templates/privoxy.html +++ b/plinth/modules/privoxy/templates/privoxy.html @@ -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 %} - -

{% trans "Web Proxy (Privoxy)" %}

- -

- {% 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 %} -

- -

- {% 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 - http://config.privoxy.org/ - or http://p.p. - {% endblocktrans %} -

+{% block configuration %}

{% trans "Status" %}

diff --git a/plinth/modules/privoxy/views.py b/plinth/modules/privoxy/views.py index 47bb844c7..853f8709f 100644 --- a/plinth/modules/privoxy/views.py +++ b/plinth/modules/privoxy/views.py @@ -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})