mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-11 08:23:49 +00:00
i2p: New style app page layout
Get rid of tabs in the app page. Tests performed: - enable/disable app - check that links to the external site work - check that links to the external site are disabled if app is disabled - i2p functional tests pass Signed-off-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
2238352e45
commit
296f6dbe85
@ -7,16 +7,31 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block configuration %}
|
||||
{{ block.super }}
|
||||
|
||||
<h3>{% trans "Configuration" %}</h3>
|
||||
<h3>{% trans "I2P Proxies and Tunnels" %}</h3>
|
||||
{% for line in proxies_description %}
|
||||
<p>{{ line|safe }}</p>
|
||||
{% endfor %}
|
||||
|
||||
<form class="form form-configuration" method="post">
|
||||
{% csrf_token %}
|
||||
<p>
|
||||
<a class="btn btn-primary" target="_blank" role="button"
|
||||
href="/i2p/i2ptunnel/"
|
||||
{{ is_enabled|yesno:',disabled="disabled"' }}>
|
||||
{% trans "Launch" %}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
{{ form|bootstrap }}
|
||||
|
||||
<input type="submit" class="btn btn-primary"
|
||||
value="{% trans "Update setup" %}"/>
|
||||
</form>
|
||||
<h3>{% trans "Anonymous Torrents" %}</h3>
|
||||
{% for line in torrents_description %}
|
||||
<p>{{ line|safe }}</p>
|
||||
{% endfor %}
|
||||
|
||||
<p>
|
||||
<a class="btn btn-primary" target="_blank" role="button"
|
||||
href="/i2p/i2psnark/"
|
||||
{{ is_enabled|yesno:',disabled="disabled"' }}>
|
||||
{% trans "Launch" %}
|
||||
</a>
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
||||
@ -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 %}
|
||||
<p>{{ line|safe }}</p>
|
||||
{% endfor %}
|
||||
|
||||
<p>
|
||||
<a class="btn btn-primary" target="_blank" role="button"
|
||||
href="{{ service_path }}">
|
||||
{% trans "Launch" %}
|
||||
</a>
|
||||
</p>
|
||||
{% endblock %}
|
||||
@ -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')]
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user