diff --git a/plinth/modules/i2p/__init__.py b/plinth/modules/i2p/__init__.py
index ce8a13fab..33ca296bf 100644
--- a/plinth/modules/i2p/__init__.py
+++ b/plinth/modules/i2p/__init__.py
@@ -29,9 +29,9 @@ from .manifest import backup, clients
version = 1
-servicename = 'i2p'
+service_name = 'i2p'
-managed_services = [servicename]
+managed_services = [service_name]
managed_packages = ['i2p']
@@ -40,14 +40,14 @@ name = _('I2P')
short_description = _('Anonymity Network')
description = [
- _('I2P is an anonymous overlay network - a network within a network. '
- 'It is intended to protect communication from dragnet surveillance '
- 'and monitoring by third parties such as ISPs.'),
- _('When enabled, I2P\'s web interface will be available from '
- '/i2p.'),
- _('The first visit will initiate the configuration process, which can also be skippped'),
- _('You can find more information about I2P one can peruse their '
- 'homepage.')
+ _('The Invisible Internet Project is an anonymous network layer intended '
+ 'to protect communication from censorship and surveillance. I2P '
+ 'provides anonymity by sending encrypted traffic through a '
+ 'volunteer-run network distributed around the world.'),
+ _('Find more information about I2P on their project '
+ 'homepage.'),
+ _('The first visit to the provided web interface will initiate the '
+ 'configuration process.')
]
clients = clients
@@ -91,12 +91,14 @@ def setup(helper, old_version=None):
# Add favorites to the configuration
for fav_name, fav_url in additional_favorites:
- helper.call('post', actions.superuser_run,
- "i2p", ["add-favorite",
- "--name='%s'" % fav_name,
- "--url='%s'" % fav_url,
- ])
- helper.call('post', action_utils.webserver_enable, "proxy_html", kind="module")
+ helper.call('post', actions.superuser_run, 'i2p', [
+ 'add-favorite',
+ '--name',
+ fav_name,
+ '--url',
+ fav_url,
+ ])
+ helper.call('post', enable)
global service
if service is None:
service = service_module.Service(managed_services[0], name, ports=[
diff --git a/plinth/modules/i2p/templates/i2p.html b/plinth/modules/i2p/templates/i2p.html
new file mode 100644
index 000000000..84a154ca3
--- /dev/null
+++ b/plinth/modules/i2p/templates/i2p.html
@@ -0,0 +1,63 @@
+{% extends "service-subsubmenu.html" %}
+{% comment %}
+#
+# This file is part of FreedomBox.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+{% endcomment %}
+
+{% load bootstrap %}
+{% load i18n %}
+
+{% block configuration %}
+ {% block status %}
+ {% if show_status_block %}
+
{% trans "Status" %}
+
+ {% with service_name=service.name %}
+ {% if service.is_running %}
+
+ {% blocktrans trimmed %}
+ Service {{ service_name }} is running.
+ {% endblocktrans %}
+ {% else %}
+
+ {% blocktrans trimmed %}
+ Service {{ service_name }} is not running.
+ {% endblocktrans %}
+ {% endif %}
+ {% endwith %}
+
+ {% endif %}
+ {% endblock %}
+
+ {% block diagnostics %}
+ {% if diagnostics_module_name %}
+ {% include "diagnostics_button.html" with module=diagnostics_module_name enabled=service.is_enabled %}
+ {% endif %}
+ {% endblock %}
+
+ {% trans "Configuration" %}
+
+
+
+{% endblock %}
diff --git a/plinth/modules/i2p/templates/i2p_frame.html b/plinth/modules/i2p/templates/i2p_frame.html
deleted file mode 100644
index 77a556e8b..000000000
--- a/plinth/modules/i2p/templates/i2p_frame.html
+++ /dev/null
@@ -1,27 +0,0 @@
-{% extends "base.html" %}
-{% block page_head %}
-
-{% endblock %}
-{% block content %}
-
-
- {% for line in description %}
-
{{ line|safe }}
- {% endfor %}
-
-
-
-
-
-{% endblock %}
diff --git a/plinth/modules/i2p/templates/i2p_service.html b/plinth/modules/i2p/templates/i2p_service.html
new file mode 100644
index 000000000..364ba0f38
--- /dev/null
+++ b/plinth/modules/i2p/templates/i2p_service.html
@@ -0,0 +1,16 @@
+{% extends "service-subsubmenu.html" %}
+
+{% load i18n %}
+
+{% block configuration %}
+ {% for line in service_description %}
+ {{ line|safe }}
+ {% endfor %}
+
+
+
+ {% trans "Launch" %}
+
+
+{% endblock %}
diff --git a/plinth/modules/i2p/urls.py b/plinth/modules/i2p/urls.py
index fa5f0e8e1..8a62a9f76 100644
--- a/plinth/modules/i2p/urls.py
+++ b/plinth/modules/i2p/urls.py
@@ -24,7 +24,6 @@ from plinth.modules.i2p import views
urlpatterns = [
url(r'^apps/i2p/$', views.I2PServiceView.as_view(), name='index'),
- url(r'^apps/i2p/frame/tunnels/?$', views.i2p_frame_tunnels, name='frame_tunnels'),
- url(r'^apps/i2p/frame/torrent/?$', views.i2p_frame_torrent, name='frame_torrent'),
-
+ url(r'^apps/i2p/tunnels/?$', views.TunnelsView.as_view(), name='tunnels'),
+ url(r'^apps/i2p/torrents/?$', views.TorrentsView.as_view(), name='torrents'),
]
diff --git a/plinth/modules/i2p/views.py b/plinth/modules/i2p/views.py
index 0eb5ec316..ed279a739 100644
--- a/plinth/modules/i2p/views.py
+++ b/plinth/modules/i2p/views.py
@@ -14,10 +14,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
-from django.template.response import TemplateResponse
+"""
+Views for I2P application.
+"""
+
from django.urls import reverse_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
+from django.views.generic import TemplateView
import plinth.modules.i2p as i2p
from plinth.views import ServiceView
@@ -26,70 +30,77 @@ subsubmenu = [{
'url': reverse_lazy('i2p:index'),
'text': ugettext_lazy('Configure')
}, {
- 'url': reverse_lazy('i2p:frame_tunnels'),
+ 'url': reverse_lazy('i2p:tunnels'),
'text': ugettext_lazy('Proxies')
-}, {
- 'url': reverse_lazy('i2p:frame_torrent'),
- 'text': ugettext_lazy('Anonymous torrents')
-}]
+},
+ {
+ 'url': reverse_lazy('i2p:torrents'),
+ 'text': ugettext_lazy('Anonymous torrents')
+ }]
class I2PServiceView(ServiceView):
"""Serve configuration page."""
- service_id = i2p.servicename
+ service_id = i2p.service_name
+ clients = i2p.clients
description = i2p.description
- diagnostics_module_name = i2p.servicename
- show_status_block = False
+ diagnostics_module_name = i2p.service_name
+ show_status_block = True
+ template_name = 'i2p.html'
def get_context_data(self, **kwargs):
"""Return the context data for rendering the template view."""
context = super().get_context_data(**kwargs)
- context['subsubmenu'] = subsubmenu
+ context['title'] = i2p.name
+ context['description'] = i2p.description
context['clients'] = i2p.clients
+ context['manual_page'] = i2p.manual_page
+ context['subsubmenu'] = subsubmenu
return context
-def _create_i2p_frame_view(title, rel_path, description):
- """
- Creates a view with an iframe to the given path
+class ServiceBaseView(TemplateView):
+ """View to describe and launch a service."""
+ service_description = None
+ service_title = None
+ service_path = None
- This is primarily used as a shortcut to pages under /i2p/
-
- :param title: the page title that will have to be i18n
- :type title: basestring
- :param rel_path: the URL path after /i2p/
- :type rel_path: basestring
- :return: a django view
- :rtype: callable
- """
- path = "/i2p/" + rel_path
-
- def i2p_frame_view(request):
- return TemplateResponse(
- request, 'i2p_frame.html', {
- 'title': _(title),
- 'subsubmenu': subsubmenu,
- 'path': path,
- 'description': description
- })
-
- return i2p_frame_view
+ def get_context_data(self, **kwargs):
+ """Add context data for template."""
+ context = super().get_context_data(**kwargs)
+ context['title'] = i2p.name
+ context['description'] = i2p.description
+ context['clients'] = i2p.clients
+ context['manual_page'] = i2p.manual_page
+ context['subsubmenu'] = subsubmenu
+ context['service_title'] = self.service_title
+ context['service_path'] = self.service_path
+ context['service_description'] = self.service_description
+ return context
-i2p_frame_tunnels = _create_i2p_frame_view(
- "I2P Proxies and Tunnels", "i2ptunnel", [
- _('I2P has the concept of tunnels. These enter an exit the network and are configured and (de)activated here.'),
- _('HTTP/S SOCKS5 proxies are entry tunnels, so they are configured here.'),
- _('In order to allow usage by other members of your network, '
- 'select the proxy then the interface you want your proxies to be bound to and save the settings.'
- 'The interface is in the "Reachable by" dropdown list.'),
- _('You can find the IP addresses of your interfaces/connections here'),
+class TunnelsView(ServiceBaseView):
+ """View to describe and launch tunnel configuration."""
+ template_name = 'i2p_service.html'
+ service_title = _('I2P Proxies and Tunnels')
+ service_path = '/i2p/i2ptunnel/'
+ service_description = [
+ _('I2P lets you browse the Internet and hidden services (eepsites) '
+ 'anonymously. For this, your browser, preferably a Tor Browser, '
+ 'needs to be configured for a proxy.'),
+ _('By default HTTP, HTTPS and SOCKS5 proxies are available. Additional '
+ 'proxies and tunnels may be configured using the tunnel '
+ 'configuration interface.'),
]
-)
-i2p_frame_torrent = _create_i2p_frame_view(
- "Anonymous torrents", "i2psnark", [
- _('Track the progress of your anonymous torrent downloads here.'),
- _('You can find a list of trackers on the '
- 'Configuration page'),
+
+
+class TorrentsView(ServiceBaseView):
+ """View to describe and launch I2P torrents application."""
+ template_name = 'i2p_service.html'
+ service_title = _('Anonymous Torrents')
+ service_path = '/i2p/i2psnark/'
+ service_description = [
+ _('I2P provides an application to download files anonymously in a '
+ 'peer-to-peer network. Download files by adding torrents or create a '
+ 'new torrent to share a file.'),
]
-)