diaspora: Drop app that was never finished.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[sunil: Add to configuration file removal in Debian package]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Joseph Nuthalapati 2021-12-20 14:17:17 -08:00 committed by Sunil Mohan Adapa
parent ce5274d9ee
commit 621cb67527
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
14 changed files with 2 additions and 642 deletions

View File

@ -1,146 +0,0 @@
#!/usr/bin/python3
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Configuration helper for diaspora* pod.
"""
import argparse
import subprocess
import augeas
from plinth import action_utils
from plinth.modules import diaspora
DIASPORA_YAML = "/etc/diaspora/diaspora.yml"
def parse_arguments():
"""Return parsed command line arguments as dictionary."""
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
subparsers.add_parser(
'pre-install',
help='Preseed debconf values before packages are installed.')
subparsers.add_parser(
'enable-user-registrations',
help='Allow users to sign up to this diaspora* pod without an '
'invitation.')
subparsers.add_parser(
'disable-user-registrations',
help='Allow only users with an invitation to register to this '
'diaspora* pod')
subparsers.add_parser('start-diaspora', help='Start diaspora* service')
subparsers.add_parser(
'disable-ssl', help="Disable SSL on the diaspora* application server")
setup = subparsers.add_parser('setup',
help='Set Domain name for diaspora*')
setup.add_argument('--domain-name',
help='The domain name that will be used by diaspora*')
return parser.parse_args()
def subcommand_setup(arguments):
"""Set the domain_name in diaspora configuration files"""
domain_name = arguments.domain_name
with open('/etc/diaspora/domain_name', 'w') as dnf:
dnf.write(domain_name)
set_domain_name(domain_name)
uncomment_user_registrations()
def set_domain_name(domain_name):
"""Write a new domain name to diaspora configuration files"""
# This did not set the domain_name
# action_utils.dpkg_reconfigure('diaspora-common',
# {'url': domain_name})
# Manually changing the domain name in the conf files.
conf_file = '/etc/diaspora.conf'
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
# lens for shell-script config file
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
aug.set('/augeas/load/Shellvars/incl[last() + 1]', conf_file)
aug.load()
aug.set('/files/etc/diaspora.conf/SERVERNAME', '"{}"'.format(domain_name))
aug.set('/files/etc/diaspora.conf/ENVIRONMENT_URL',
'http://{}:3000'.format(domain_name))
aug.save()
diaspora.generate_apache_configuration(
'/etc/apache2/conf-available/diaspora-plinth.conf', domain_name)
action_utils.service_enable('diaspora')
action_utils.service_start('diaspora')
def subcommand_disable_ssl(_):
"""
Disable ssl in the diaspora configuration
as the apache server takes care of ssl
"""
# Using sed because ruamel.yaml has a bug for this kind of files
subprocess.call([
"sed", "-i", "s/#require_ssl: true/require_ssl: false/g", DIASPORA_YAML
])
def uncomment_user_registrations():
"""Uncomment the enable_registrations line which is commented by default"""
subprocess.call([
"sed", "-i", "s/#enable_registrations/enable_registrations/g",
DIASPORA_YAML
])
def subcommand_enable_user_registrations(_):
"""Enable new user registrations on the diaspora* pod """
subprocess.call([
"sed", "-i",
"s/enable_registrations: false/enable_registrations: true/g",
DIASPORA_YAML
])
def subcommand_disable_user_registrations(_):
"""Disable new user registrations on the diaspora* pod """
subprocess.call([
"sed", "-i",
"s/enable_registrations: true/enable_registrations: false/g",
DIASPORA_YAML
])
def subcommand_pre_install(_):
"""Pre installation configuration for diaspora"""
presets = [
'diaspora-common diaspora-common/url string dummy_domain_name',
'diaspora-common diaspora-common/dbpass note ',
'diaspora-common diaspora-common/enablessl boolean false',
'diaspora-common diaspora-common/useletsencrypt string false',
'diaspora-common diaspora-common/services multiselect ',
'diaspora-common diaspora-common/ssl boolean false',
'diaspora-common diaspora-common/pgsql/authmethod-admin string ident',
'diaspora-common diaspora-common/letsencrypt boolean false',
'diaspora-common diaspora-common/remote/host string localhost',
'diaspora-common diaspora-common/database-type string pgsql',
'diaspora-common diaspora-common/dbconfig-install boolean true'
]
action_utils.debconf_set_selections(presets)
def main():
"""Parse arguments and perform all duties."""
arguments = parse_arguments()
subcommand = arguments.subcommand.replace('-', '_')
subcommand_method = globals()['subcommand_' + subcommand]
subcommand_method(arguments)
if __name__ == '__main__':
main()

4
debian/copyright vendored
View File

@ -60,9 +60,7 @@ Copyright: 2007 Andrew Wedderburn
Comment: https://commons.wikimedia.org/wiki/File:Deluge-Logo.svg
License: GPL-2+
Files: static/themes/default/icons/diaspora.png
static/themes/default/icons/diaspora.svg
static/themes/default/icons/ejabberd.png
Files: static/themes/default/icons/ejabberd.png
static/themes/default/icons/ejabberd.svg
static/themes/default/icons/matrixsynapse.svg
static/themes/default/icons/privoxy.png

View File

@ -13,4 +13,5 @@ rm_conffile /etc/apt/preferences.d/50freedombox3.pref 20.5~
rm_conffile /etc/plinth/plinth.config 20.12~
rm_conffile /etc/plinth/custom-shortcuts.json 20.12~
rm_conffile /etc/plinth/modules-enabled/coquelicot 20.14~
rm_conffile /etc/plinth/modules-enabled/diaspora 21.16~
rm_conffile /etc/plinth/modules-enabled/monkeysphere 21.16~

View File

@ -1,194 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
import os
import augeas
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module
from plinth import frontpage, menu
from plinth.daemon import Daemon
from plinth.errors import DomainNotRegisteredError
from plinth.modules.apache.components import Webserver, diagnose_url
from plinth.modules.firewall.components import Firewall
from plinth.package import Packages
from plinth.utils import format_lazy
domain_name_file = "/etc/diaspora/domain_name"
lazy_domain_name = None # To avoid repeatedly reading from file
def is_setup():
return os.path.exists(domain_name_file)
def get_configured_domain_name():
global lazy_domain_name
if lazy_domain_name:
return lazy_domain_name
if not is_setup():
raise DomainNotRegisteredError()
with open(domain_name_file) as dnf:
lazy_domain_name = dnf.read().rstrip()
return lazy_domain_name
_description = [
_('diaspora* is a decentralized social network where you can store '
'and control your own data.'),
format_lazy(
'When enabled, the diaspora* pod will be available from '
'<a href="https://diaspora.{host}">diaspora.{host}</a> path on the '
'web server.'.format(host=get_configured_domain_name()) if is_setup()
else 'Please register a domain name for your FreedomBox to be able to'
' federate with other diaspora* pods.')
]
app = None
class DiasporaApp(app_module.App):
"""FreedomBox app for Diaspora."""
app_id = 'diaspora'
_version = 1
def __init__(self):
"""Create components for the app."""
super().__init__()
from . import manifest
info = app_module.Info(app_id=self.app_id, version=self._version,
name=_('diaspora*'), icon_filename='diaspora',
short_description=_('Federated Social Network'),
description=_description,
clients=manifest.clients)
self.add(info)
menu_item = menu.Menu('menu-diaspora', info.name,
info.short_description, info.icon_filename,
'diaspora:index', parent_url_name='apps')
self.add(menu_item)
shortcut = Shortcut('shortcut-diaspora', info.name,
short_description=info.short_description,
icon=info.icon_filename, url=None,
clients=info.clients, login_required=True)
self.add(shortcut)
packages = Packages('packages-diaspora', ['diaspora'])
self.add(packages)
firewall = Firewall('firewall-diaspora', info.name,
ports=['http', 'https'], is_external=True)
self.add(firewall)
webserver = Webserver('webserver-diaspora', 'diaspora-plinth')
self.add(webserver)
daemon = Daemon('daemon-diaspora', 'diaspora')
self.add(daemon)
def diagnose(self):
"""Run diagnostics and return the results."""
results = super().diagnose()
results.append(
diagnose_url('http://diaspora.localhost', kind='4',
check_certificate=False))
results.append(
diagnose_url('http://diaspora.localhost', kind='6',
check_certificate=False))
results.append(
diagnose_url(
'http://diaspora.{}'.format(get_configured_domain_name()),
kind='4', check_certificate=False))
return results
class Shortcut(frontpage.Shortcut):
"""Frontpage shortcut to use configured domain name for URL."""
def enable(self):
"""Set the proper shortcut URL when enabled."""
super().enable()
self.url = 'https://diaspora.{}'.format(get_configured_domain_name())
def setup(helper, old_version=None):
"""Install and configure the module."""
helper.call('pre', actions.superuser_run, 'diaspora', ['pre-install'])
app.setup(old_version)
helper.call('custom_config', actions.superuser_run, 'diaspora',
['disable-ssl'])
def setup_domain_name(domain_name):
actions.superuser_run('diaspora', ['setup', '--domain-name', domain_name])
app.enable()
def is_user_registrations_enabled():
"""Return whether user registrations are enabled"""
with open('/etc/diaspora/diaspora.yml') as f:
for line in f.readlines():
if "enable_registrations" in line:
return line.split(":")[1].strip() == "true"
def enable_user_registrations():
"""Allow users to register without invitation"""
actions.superuser_run('diaspora', ['enable-user-registrations'])
def disable_user_registrations():
"""Disallow users from registering without invitation"""
actions.superuser_run('diaspora', ['disable-user-registrations'])
def generate_apache_configuration(conf_file, domain_name):
"""Generate Diaspora's apache configuration with the given domain name"""
open(conf_file, 'w').close()
diaspora_domain_name = ".".join(["diaspora", domain_name])
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
aug.set('/augeas/load/Httpd/lens', 'Httpd.lns')
aug.set('/augeas/load/Httpd/incl[last() + 1]', conf_file)
aug.load()
aug.defvar('conf', '/files' + conf_file)
aug.set('$conf/VirtualHost', None)
aug.defvar('vh', '$conf/VirtualHost')
aug.set('$vh/arg', diaspora_domain_name)
aug.set('$vh/directive[1]', 'ServerName')
aug.set('$vh/directive[1]/arg', diaspora_domain_name)
aug.set('$vh/directive[2]', 'DocumentRoot')
aug.set('$vh/directive[2]/arg', '"/var/lib/diaspora/public/"')
aug.set('$vh/Location', None)
aug.set('$vh/Location/arg', '"/"')
aug.set('$vh/Location/directive[1]', 'ProxyPass')
aug.set('$vh/Location/directive[1]/arg',
'"unix:/var/run/diaspora/diaspora.sock|http://localhost/"')
aug.set('$vh/Location[last() + 1]', None)
aug.set('$vh/Location[last()]/arg', '"/assets"')
aug.set('$vh/Location[last()]/directive[1]', 'ProxyPass')
aug.set('$vh/Location[last()]/directive[1]/arg', '!')
aug.set('$vh/Directory', None)
aug.set('$vh/Directory/arg', '/var/lib/diaspora/public/')
aug.set('$vh/Directory/directive[1]', 'Require')
aug.set('$vh/Directory/directive[1]/arg[1]', 'all')
aug.set('$vh/Directory/directive[1]/arg[2]', 'granted')
aug.save()

View File

@ -1,13 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Forms for configuring diaspora*
"""
from django import forms
from django.utils.translation import gettext_lazy as _
class DiasporaAppForm(forms.Form):
"""Service Form with additional fields for diaspora*"""
is_user_registrations_enabled = forms.BooleanField(
label=_('Enable new user registrations'), required=False)

View File

@ -1,33 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import gettext_lazy as _
from plinth.clients import store_url
from plinth.modules import diaspora
from plinth.utils import format_lazy
clients = [{
'name':
_('dandelion*'),
'description':
_('It is an unofficial webview based client for the '
'community-run, distributed social network diaspora*'),
'platforms': [{
'type': 'store',
'os': 'android',
'store_name': 'f-droid',
'url': store_url('f-droid', 'com.github.dfa.diaspora_android'),
}]
}, {
'name':
_('diaspora*'),
'platforms': [{
'type':
'web',
'url':
format_lazy(
'https://diaspora.{host}',
host=diaspora.get_configured_domain_name()
if diaspora.is_setup() else "<please-setup-domain-name>")
}]
}]

View File

@ -1,24 +0,0 @@
{% extends "app.html" %}
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block description %}
{% for paragraph in description %}
<p>{{ paragraph|safe }}</p>
{% endfor %}
<p>
{% url 'config:index' as index_url %}
{% blocktrans trimmed with domain_name=domain_name %}
The diaspora* pod domain is set to <b>{{ domain_name }}</b>. User
IDs will look like <i>username@diaspora.{{ domain_name }}</i><br/>
If the FreedomBox domain name is changed, all data of the users
registered with the previous podname wouldn't be accessible. <br/>
You can access the diaspora* pod at <a href="https://diaspora.{{domain_name}}"> diaspora.{{domain_name}} </a>
{% endblocktrans %}
</p>
{% endblock %}

View File

@ -1,47 +0,0 @@
{% extends "base.html" %}
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
{% block content %}
{% block pagetitle %}
<h2>{{ title }}</h2>
{% endblock %}
{% block description %}
{% for paragraph in description %}
<p>{{ paragraph|safe }}</p>
{% endfor %}
{% endblock %}
<p>
{% url 'config:index' as index_url %}
{% if domain_names|length == 0 %}
No domain(s) are set. You can setup your domain on the system at
<a href="{{ index_url }}">Configure</a> page.
{% endif %}
</p>
{% block status %}
{% endblock %}
{% block diagnostics %}
{% endblock %}
{% block configuration %}
{% if domain_names|length > 0 %}
<h3>{% trans "Configuration" %}</h3>
<form class="form" method="post">
{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary"
value="{% trans "Update setup" %}"/>
</form>
{% endif %}
{% endblock %}
{% endblock %}

View File

@ -1 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -1,25 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Test Apache configuration generation for diaspora*
"""
import os
import tempfile
from plinth.modules import diaspora
def test_generate_apache_configuration():
"""Test that Apache configuration is created properly."""
with tempfile.NamedTemporaryFile() as conf_file:
diaspora.generate_apache_configuration(conf_file.name,
'freedombox.rocks')
assert os.stat(conf_file.name).st_size != 0
with open(conf_file.name) as file_handle:
contents = file_handle.read()
assert all(
word in contents
for word in ['VirtualHost', 'Location', 'Directory', 'assets'])

View File

@ -1,14 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
URLs for the diaspora module
"""
from django.urls import re_path
from .views import DiasporaAppView, DiasporaSetupView
urlpatterns = [
re_path(r'^apps/diaspora/setup$', DiasporaSetupView.as_view(),
name='setup'),
re_path(r'^apps/diaspora/$', DiasporaAppView.as_view(), name='index')
]

View File

@ -1,80 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Views for the diaspora module
"""
from django.contrib import messages
from django.shortcuts import redirect
from django.urls import reverse_lazy
from django.utils.translation import gettext as _
from django.views.generic import FormView
from plinth.forms import DomainSelectionForm
from plinth.modules import diaspora, names
from plinth.views import AppView
from .forms import DiasporaAppForm
class DiasporaSetupView(FormView):
"""Show diaspora setup page."""
template_name = 'diaspora-pre-setup.html'
form_class = DomainSelectionForm
description = diaspora.app.info.description
title = diaspora.app.info.name
success_url = reverse_lazy('diaspora:index')
def form_valid(self, form):
domain_name = form.cleaned_data['domain_name']
diaspora.setup_domain_name(domain_name)
return super().form_valid(form)
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
context['description'] = self.description
context['title'] = self.title
context['domain_names'] = names.components.DomainName.list_names(
'https')
return context
class DiasporaAppView(AppView):
"""Show diaspora service page."""
form_class = DiasporaAppForm
app_id = 'diaspora'
template_name = 'diaspora-post-setup.html'
def dispatch(self, request, *args, **kwargs):
if not diaspora.is_setup():
return redirect('diaspora:setup')
return super().dispatch(request, *args, **kwargs)
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
context['domain_name'] = diaspora.get_configured_domain_name()
return context
def get_initial(self):
"""Return the status of the service to fill in the form."""
status = super().get_initial()
status['is_user_registrations_enabled'] = \
diaspora.is_user_registrations_enabled()
return status
def form_valid(self, form):
"""Enable/disable user registrations"""
old_registration = form.initial['is_user_registrations_enabled']
new_registration = form.cleaned_data['is_user_registrations_enabled']
if old_registration != new_registration:
if new_registration:
diaspora.enable_user_registrations()
messages.success(self.request, _('User registrations enabled'))
else:
diaspora.disable_user_registrations()
messages.success(self.request,
_('User registrations disabled'))
return super().form_valid(form)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View File

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="svg91922"
width="512"
height="512"
viewBox="0 0 512 511.99999"
sodipodi:docname="diaspora.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<metadata
id="metadata91928">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs91926" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1893"
inkscape:window-height="1255"
id="namedview91924"
showgrid="false"
inkscape:zoom="0.60263472"
inkscape:cx="503.01426"
inkscape:cy="305.95062"
inkscape:window-x="443"
inkscape:window-y="322"
inkscape:window-maximized="0"
inkscape:current-layer="svg91922"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<path
style="display:inline;fill:#3e4142;fill-opacity:1;stroke-width:1.0020926"
d="M 235.0754,511.23874 C 202.70619,508.75883 175.71816,501.19465 144.27837,485.79023 66.126352,447.49846 15.584928,378.40771 2.3391325,291.75759 -0.76329202,271.46243 -0.78195948,239.28991 2.2970695,219.26357 10.739845,164.35086 36.136619,113.83908 74.58731,75.485123 114.95109,35.222893 165.00102,10.614245 224.65535,1.6993829 c 15.24386,-2.27806523 48.06637,-2.26318055 63.95014,0.02899 65.7282,9.4852571 126.22277,43.0230521 166.48101,92.2959991 27.97253,34.236188 48.31237,81.913388 55.13871,129.246818 2.36308,16.38538 2.36698,48.69175 0.008,65.12437 -5.25766,36.62302 -18.63217,73.74466 -37.18075,103.19708 -14.37753,22.82966 -36.89247,48.24595 -56.65706,63.95829 -51.41162,40.8709 -115.95976,60.69524 -181.31974,55.68781 z M 199.31649,408.37471 c 2.67052,-3.16854 9.22838,-11.62219 14.57303,-18.78587 5.34467,-7.16369 16.27391,-21.81666 24.28723,-32.56218 8.01331,-10.74553 15.48802,-20.35429 16.61047,-21.35281 2.00843,-1.7867 2.14372,-1.68336 8.52631,6.51244 3.56701,4.58037 12.94186,17.11971 20.83299,27.86524 20.43834,27.83135 32.81614,43.08227 34.96598,43.08227 5.38392,0 64.20767,-44.69328 64.20767,-48.7839 0,-1.9354 -3.70947,-7.43639 -28.58485,-42.39021 -20.38523,-28.64447 -28.04487,-39.93361 -27.44683,-40.45242 0.22305,-0.19354 12.35769,-4.3138 26.9658,-9.15619 31.26989,-10.36552 54.04401,-18.4765 62.38477,-22.21827 l 5.99104,-2.68766 -0.577,-4.20811 c -1.35763,-9.90143 -22.14488,-69.02786 -25.14273,-71.51496 -1.78977,-1.48485 -10.06051,0.61828 -39.66529,10.08634 -12.39429,3.96388 -29.97696,9.58343 -39.07257,12.4879 l -16.53748,5.28085 -0.73593,-2.68072 c -0.75816,-2.76178 -2.75151,-66.27863 -2.76464,-88.09383 l -0.007,-12.273434 h -41.46899 -41.46899 l -0.62644,3.13098 c -0.34454,1.722024 -0.63637,14.909724 -0.64846,29.305964 -0.0259,30.8903 -1.59083,67.76363 -2.93265,69.10497 -1.2785,1.27803 -5.41358,0.0511 -53.47134,-15.8631 -22.48994,-7.44758 -41.53159,-13.54106 -42.31478,-13.54106 -0.98259,0 -4.526,9.5495 -11.43185,30.80884 -5.504338,16.94486 -10.92989,34.17852 -12.056788,38.29702 -1.968596,7.19469 -1.978603,7.55847 -0.255292,9.28119 3.128644,3.12752 16.31643,8.20734 55.39154,21.33629 20.91501,7.0273 38.0273,13.28419 38.0273,13.90422 0,1.48445 -1.57784,3.79588 -27.07632,39.66519 -11.94769,16.80709 -23.4457,33.16588 -25.55113,36.35284 l -3.82806,5.7945 3.42153,3.58069 c 10.0496,10.51708 57.61711,46.44799 61.49068,46.44799 0.62369,0 3.31891,-2.59244 5.98942,-5.761 z"
id="path92475"
inkscape:connector-curvature="0" />
</svg>

Before

Width:  |  Height:  |  Size: 4.1 KiB