mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-10 11:00:22 +00:00
deluge: Rename from bittorrent to deluge
- There could be multiple applications for the same functions. Although in the interface we should we show generic names like 'BitTorrent', we could use specific names in the backend. - There is already a bittorrent client: Transmission.
This commit is contained in:
parent
55a8b445ad
commit
51e6aa3df6
@ -29,6 +29,12 @@ import subprocess
|
||||
SITE_CONF = '/etc/apache2/conf-available/deluge-web.conf'
|
||||
SITE_ENABLED = '/etc/apache2/conf-enabled/deluge-web.conf'
|
||||
|
||||
APACHE_CONF = '''
|
||||
<Location /deluge>
|
||||
ProxyPass http://localhost:8112
|
||||
</Location>
|
||||
'''
|
||||
|
||||
|
||||
def parse_arguments():
|
||||
"""Return parsed command line arguments as dictionary."""
|
||||
@ -70,6 +76,7 @@ def subcommand_enable(_):
|
||||
"""Enable deluge-web site and start deluge-web."""
|
||||
if not os.path.isfile(SITE_CONF):
|
||||
setup()
|
||||
|
||||
subprocess.check_call(['a2enconf', 'deluge-web'])
|
||||
subprocess.check_call(['service', 'apache2', 'reload'])
|
||||
|
||||
@ -98,7 +105,7 @@ def subcommand_start(_):
|
||||
'--name', 'deluge-web',
|
||||
'--exec', '/usr/bin/deluge-web',
|
||||
'--chuid', 'debian-deluged',
|
||||
'--', '--base=bittorrent'])
|
||||
'--', '--base=deluge'])
|
||||
|
||||
|
||||
def subcommand_stop(_):
|
||||
@ -109,11 +116,7 @@ def subcommand_stop(_):
|
||||
def setup():
|
||||
"""Perform initial setup for deluge-web site."""
|
||||
with open(SITE_CONF, 'w') as conffile:
|
||||
conffile.writelines([
|
||||
'<Location /bittorrent>\n',
|
||||
' ProxyPass http://localhost:8112\n',
|
||||
'</Location>\n',
|
||||
])
|
||||
conffile.write(APACHE_CONF)
|
||||
|
||||
|
||||
def main():
|
||||
@ -1 +0,0 @@
|
||||
plinth.modules.bittorrent
|
||||
1
data/etc/plinth/modules-enabled/deluge
Normal file
1
data/etc/plinth/modules-enabled/deluge
Normal file
@ -0,0 +1 @@
|
||||
plinth.modules.deluge
|
||||
@ -16,7 +16,7 @@
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module to configure a BitTorrent web client (deluge-web)
|
||||
Plinth module to configure a Deluge web client
|
||||
"""
|
||||
|
||||
from gettext import gettext as _
|
||||
@ -31,4 +31,4 @@ def init():
|
||||
"""Initialize the BitTorrent module."""
|
||||
menu = cfg.main_menu.get('apps:index')
|
||||
menu.add_urlname(_('BitTorrent (Deluge)'), 'glyphicon-magnet',
|
||||
'bittorrent:index', 60)
|
||||
'deluge:index', 60)
|
||||
@ -16,15 +16,15 @@
|
||||
#
|
||||
|
||||
"""
|
||||
Forms for configuring BitTorrent web client
|
||||
Forms for configuring Deluge web client.
|
||||
"""
|
||||
|
||||
from django import forms
|
||||
from gettext import gettext as _
|
||||
|
||||
|
||||
class BitTorrentForm(forms.Form):
|
||||
"""BitTorrent configuration form."""
|
||||
class DelugeForm(forms.Form):
|
||||
"""Deluge configuration form."""
|
||||
enabled = forms.BooleanField(
|
||||
label=_('Enable BitTorrent web client'),
|
||||
label=_('Enable Deluge web client'),
|
||||
required=False)
|
||||
@ -27,7 +27,7 @@
|
||||
<p>Deluge is a BitTorrent client that features a Web UI.</p>
|
||||
|
||||
<p>When enabled, the Deluge web client will be available from
|
||||
<a href="/bittorrent">/bittorrent</a> path on the web server. The default
|
||||
<a href="/deluge">/deluge</a> path on the web server. The default
|
||||
password is 'deluge', but you should log in and change it immediately after
|
||||
enabling this service.</p>
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
<p>
|
||||
{% if status.is_running %}
|
||||
<span class="running-status active"></span> deluge-web is running
|
||||
<form class="form" method="post" action="{% url 'bittorrent:stop' %}">
|
||||
<form class="form" method="post" action="{% url 'deluge:stop' %}">
|
||||
{% csrf_token %}
|
||||
<input type="submit" class="btn btn-primary"
|
||||
value="Stop deluge-web »"/>
|
||||
@ -58,7 +58,7 @@
|
||||
|
||||
{% else %}
|
||||
<span class="running-status inactive"></span> deluge-web is not running
|
||||
<form class="form" method="post" action="{% url 'bittorrent:start' %}">
|
||||
<form class="form" method="post" action="{% url 'deluge:start' %}">
|
||||
{% csrf_token %}
|
||||
<input type="submit" class="btn btn-primary"
|
||||
value="Start deluge-web »"/>
|
||||
@ -16,15 +16,15 @@
|
||||
#
|
||||
|
||||
"""
|
||||
URLs for the BitTorrent module
|
||||
URLs for the Deluge module.
|
||||
"""
|
||||
|
||||
from django.conf.urls import patterns, url
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'plinth.modules.bittorrent.views',
|
||||
url(r'^apps/bittorrent/$', 'index', name='index'),
|
||||
url(r'^apps/bittorrent/start/$', 'start', name='start'),
|
||||
url(r'^apps/bittorrent/stop/$', 'stop', name='stop'),
|
||||
'plinth.modules.deluge.views',
|
||||
url(r'^apps/deluge/$', 'index', name='index'),
|
||||
url(r'^apps/deluge/start/$', 'start', name='start'),
|
||||
url(r'^apps/deluge/stop/$', 'stop', name='stop'),
|
||||
)
|
||||
@ -16,7 +16,7 @@
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module to configure a BitTorrent web client (deluge-web)
|
||||
Plinth module to configure a Deluge web client.
|
||||
"""
|
||||
|
||||
from django.contrib import messages
|
||||
@ -27,7 +27,7 @@ from django.template.response import TemplateResponse
|
||||
from django.views.decorators.http import require_POST
|
||||
from gettext import gettext as _
|
||||
|
||||
from .forms import BitTorrentForm
|
||||
from .forms import DelugeForm
|
||||
from plinth import actions
|
||||
from plinth import package
|
||||
|
||||
@ -41,16 +41,16 @@ def index(request):
|
||||
form = None
|
||||
|
||||
if request.method == 'POST':
|
||||
form = BitTorrentForm(request.POST, prefix='bittorrent')
|
||||
form = DelugeForm(request.POST, prefix='deluge')
|
||||
# pylint: disable=E1101
|
||||
if form.is_valid():
|
||||
_apply_changes(request, status, form.cleaned_data)
|
||||
status = get_status()
|
||||
form = BitTorrentForm(initial=status, prefix='bittorrent')
|
||||
form = DelugeForm(initial=status, prefix='deluge')
|
||||
else:
|
||||
form = BitTorrentForm(initial=status, prefix='bittorrent')
|
||||
form = DelugeForm(initial=status, prefix='deluge')
|
||||
|
||||
return TemplateResponse(request, 'bittorrent.html',
|
||||
return TemplateResponse(request, 'deluge.html',
|
||||
{'title': _('BitTorrent (Deluge)'),
|
||||
'status': status,
|
||||
'form': form})
|
||||
@ -60,24 +60,24 @@ def index(request):
|
||||
@require_POST
|
||||
def start(request):
|
||||
"""Start deluge-web."""
|
||||
actions.run('bittorrent', ['start'])
|
||||
return redirect(reverse_lazy('bittorrent:index'))
|
||||
actions.run('deluge', ['start'])
|
||||
return redirect(reverse_lazy('deluge:index'))
|
||||
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def stop(request):
|
||||
"""Stop deluge-web."""
|
||||
actions.run('bittorrent', ['stop'])
|
||||
return redirect(reverse_lazy('bittorrent:index'))
|
||||
actions.run('deluge', ['stop'])
|
||||
return redirect(reverse_lazy('deluge:index'))
|
||||
|
||||
|
||||
def get_status():
|
||||
"""Get the current settings."""
|
||||
output = actions.run('bittorrent', ['get-enabled'])
|
||||
output = actions.run('deluge', ['get-enabled'])
|
||||
enabled = (output.strip() == 'yes')
|
||||
|
||||
output = actions.run('bittorrent', ['is-running'])
|
||||
output = actions.run('deluge', ['is-running'])
|
||||
is_running = ('yes' in output.strip())
|
||||
|
||||
status = {'enabled': enabled,
|
||||
@ -92,7 +92,7 @@ def _apply_changes(request, old_status, new_status):
|
||||
|
||||
if old_status['enabled'] != new_status['enabled']:
|
||||
sub_command = 'enable' if new_status['enabled'] else 'disable'
|
||||
actions.superuser_run('bittorrent', [sub_command])
|
||||
actions.superuser_run('deluge', [sub_command])
|
||||
modified = True
|
||||
|
||||
if modified:
|
||||
Loading…
x
Reference in New Issue
Block a user