diff --git a/plinth/modules/i2p/templates/i2p.html b/plinth/modules/i2p/templates/i2p.html index 4f47d0a5b..f26901881 100644 --- a/plinth/modules/i2p/templates/i2p.html +++ b/plinth/modules/i2p/templates/i2p.html @@ -7,16 +7,31 @@ {% load i18n %} {% block configuration %} + {{ block.super }} -

{% trans "Configuration" %}

+

{% trans "I2P Proxies and Tunnels" %}

+ {% for line in proxies_description %} +

{{ line|safe }}

+ {% endfor %} -
- {% csrf_token %} +

+ + {% trans "Launch" %} + +

- {{ form|bootstrap }} - - -
+

{% trans "Anonymous Torrents" %}

+ {% for line in torrents_description %} +

{{ line|safe }}

+ {% endfor %} +

+ + {% trans "Launch" %} + +

{% endblock %} diff --git a/plinth/modules/i2p/templates/i2p_service.html b/plinth/modules/i2p/templates/i2p_service.html deleted file mode 100644 index 468a063d5..000000000 --- a/plinth/modules/i2p/templates/i2p_service.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "app.html" %} -{% comment %} -# SPDX-License-Identifier: AGPL-3.0-or-later -{% endcomment %} - -{% 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 fd3b7167d..cab9dcb84 100644 --- a/plinth/modules/i2p/urls.py +++ b/plinth/modules/i2p/urls.py @@ -4,12 +4,6 @@ URLs for the I2P module. """ from django.conf.urls import url - from plinth.modules.i2p import views -urlpatterns = [ - url(r'^apps/i2p/$', views.I2PAppView.as_view(), name='index'), - url(r'^apps/i2p/tunnels/?$', views.TunnelsView.as_view(), name='tunnels'), - url(r'^apps/i2p/torrents/?$', views.TorrentsView.as_view(), - name='torrents'), -] +urlpatterns = [url(r'^apps/i2p/$', views.I2PAppView.as_view(), name='index')] diff --git a/plinth/modules/i2p/views.py b/plinth/modules/i2p/views.py index a809f113d..c5b3bfb56 100644 --- a/plinth/modules/i2p/views.py +++ b/plinth/modules/i2p/views.py @@ -3,66 +3,16 @@ 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.modules import i2p from plinth.views import AppView -subsubmenu = [{ - 'url': reverse_lazy('i2p:index'), - 'text': ugettext_lazy('Configure') -}, { - 'url': reverse_lazy('i2p:tunnels'), - 'text': ugettext_lazy('Proxies') -}, { - 'url': reverse_lazy('i2p:torrents'), - 'text': ugettext_lazy('Anonymous torrents') -}] - class I2PAppView(AppView): """Serve configuration page.""" app_id = 'i2p' 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['title'] = i2p.app.info.name - context['app_info'] = i2p.app.info - context['subsubmenu'] = subsubmenu - context['port_forwarding_info'] = i2p.port_forwarding_info - return context - - -class ServiceBaseView(TemplateView): - """View to describe and launch a service.""" - service_description = None - service_title = None - service_path = None - - def get_context_data(self, **kwargs): - """Add context data for template.""" - context = super().get_context_data(**kwargs) - context['title'] = i2p.app.info.name - context['app_info'] = i2p.app.info - context['subsubmenu'] = subsubmenu - context['is_enabled'] = i2p.app.is_enabled() - context['service_title'] = self.service_title - context['service_path'] = self.service_path - context['service_description'] = self.service_description - return context - - -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 = [ + proxies_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.'), @@ -70,15 +20,17 @@ class TunnelsView(ServiceBaseView): 'proxies and tunnels may be configured using the tunnel ' 'configuration interface.'), ] - - -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 = [ + torrents_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.'), ] + + def get_context_data(self, **kwargs): + """Return the context data for rendering the template view.""" + context = super().get_context_data(**kwargs) + context['port_forwarding_info'] = i2p.port_forwarding_info + context['proxies_description'] = self.proxies_description + context['torrents_description'] = self.torrents_description + + return context