Merged Sunil's stub cleanup.

This commit is contained in:
Nick Daly 2014-06-18 22:39:24 -05:00
commit 4d0fa9c4f9
109 changed files with 435 additions and 800 deletions

View File

@ -45,29 +45,22 @@ specified and linked otherwise.
- doc/scripts.mdwn :: -
- doc/security.mdwn :: -
- doc/themes.mdwn :: -
- modules/installed/first_boot.py :: -
- modules/installed/apps/apps.py :: -
- modules/installed/apps/owncloud.py :: -
- modules/installed/help/help.py :: -
- modules/installed/lib/auth_page.py :: -
- modules/installed/lib/auth.py :: Derived from [[http://tools.cherrypy.org/wiki/AuthenticationAndAccessRestrictions][Arnar Birisson's CherryPy wiki code]].
- modules/installed/lib/forms.py :: [[file:modules/installed/lib/forms.py::Copyright%202011-2013%20James%20Vasile][Copyright James Vasile]]
- modules/installed/lib/user_store.py :: -
- modules/installed/privacy/privacy.py :: -
- modules/installed/router/info.py :: -
- modules/installed/router/router.py :: -
- modules/installed/santiago/santiago.py :: -
- modules/installed/services/services.py :: -
- modules/installed/services/xmpp.py :: -
- modules/installed/sharing/file_explorer.py :: -
- modules/installed/sharing/sharing.py :: -
- modules/installed/system/config.py :: -
- modules/installed/system/diagnostics.py :: -
- modules/installed/system/expert_mode.py :: -
- modules/installed/system/system.py :: -
- modules/installed/system/time_zones :: -
- modules/installed/system/users.py :: -
- modules/installed/system/wan.py :: -
- modules/apps/apps.py :: -
- modules/config/config.py :: -
- modules/diagnostics/diagnostics.py :: -
- modules/expert_mode/expert_mode.py :: -
- modules/first_boot/first_boot.py :: -
- modules/help/help.py :: -
- modules/lib/auth_page.py :: -
- modules/lib/auth.py :: Derived from [[http://tools.cherrypy.org/wiki/AuthenticationAndAccessRestrictions][Arnar Birisson's CherryPy wiki code]].
- modules/lib/user_store.py :: -
- modules/owncloud/owncloud.py :: -
- modules/packages/packages.py :: -
- modules/santiago/santiago.py :: -
- modules/system/system.py :: -
- modules/tor/tor.py :: -
- modules/users/users.py :: -
- modules/xmpp/xmpp.py :: -
- setup/86_plinth :: -
- share/apache2/plinth.conf :: -
- share/apache2/plinth-ssl.conf :: -

View File

@ -1 +0,0 @@
installed/apps/apps.py

View File

@ -1,5 +1,3 @@
{% extends "login_nav.html" %}
{% comment %}
#
# This file is part of Plinth.
#
@ -16,14 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% block main_block %}
"""
Plinth module for apps section page
"""
<p class='lead'>One Login for Every Site</p>
from . import apps
<p>Your {{ cfg.box_name }} is also an OpenID machine. It can generate
credentials that allow you to log in to many websites without the need
to remember or enter a separate username and password at each one.</p>
{% endblock %}
__all__ = ['apps']

View File

@ -1,6 +1,5 @@
import cherrypy
from gettext import gettext as _
from modules.auth import require
from plugin_mount import PagePlugin
import cfg
import util
@ -12,15 +11,8 @@ class Apps(PagePlugin):
self.register_page("apps")
self.menu = cfg.main_menu.add_item("Apps", "icon-download-alt", "/apps", 80)
self.menu.add_item("Chat", "icon-comment", "/../jwchat", 30)
self.menu.add_item("Photo Gallery", "icon-picture", "/apps/photos", 35)
@cherrypy.expose
def index(self):
return util.render_template(template='apps',
title=_('User Applications'))
@cherrypy.expose
@require()
def photos(self):
return util.render_template(template='photos',
title=_('Photo Gallery'))

View File

@ -1 +0,0 @@
installed/lib/auth.py

View File

@ -1 +0,0 @@
installed/lib/auth_page.py

View File

@ -1 +0,0 @@
installed/system/config.py

View File

@ -1,5 +1,3 @@
{% extends "login_nav.html" %}
{% comment %}
#
# This file is part of Plinth.
#
@ -16,22 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% block main_block %}
"""
Plinth module for basic system configuration
"""
<p>TODO: Setup and install SAMBA</p>
<p>TODO: Setup and install CUPS</p>
from . import config
{% endblock %}
{% block sidebar_right_block %}
<div class="well sidebar-nav">
<h3>Share Your Printer</h3>
<p> The {{ cfg.box_name }} can share your printer via Samba and
CUPS.</p>
</div>
{% endblock %}
__all__ = ['config']

View File

@ -28,7 +28,7 @@ import socket
import actions
import cfg
from modules.auth import require
from ..lib.auth import require
from plugin_mount import PagePlugin
import util

View File

@ -1 +0,0 @@
installed/system/diagnostics.py

View File

@ -1,5 +1,3 @@
{% extends 'login_nav.html' %}
{% comment %}
#
# This file is part of Plinth.
#
@ -16,14 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% block main_block %}
"""
Plinth module to system diagnostics
"""
<p>Your photos might well be the most valuable digital property you
have, so why trust it to companies that have no investment in the
sentimental value of your family snaps? Keep those photos local,
backed up, easily accessed and free from the whims of some other
websites business model.</p>
from . import diagnostics
{% endblock %}
__all__ = ['diagnostics']

View File

@ -21,7 +21,7 @@ Plinth module for running diagnostics
import cherrypy
from gettext import gettext as _
from auth import require
from ..lib.auth import require
from plugin_mount import PagePlugin
import actions
import cfg

1
modules/enabled/apps Symbolic link
View File

@ -0,0 +1 @@
../apps/

1
modules/enabled/config Symbolic link
View File

@ -0,0 +1 @@
../config/

1
modules/enabled/diagnostics Symbolic link
View File

@ -0,0 +1 @@
../diagnostics/

1
modules/enabled/expert_mode Symbolic link
View File

@ -0,0 +1 @@
../expert_mode/

1
modules/enabled/firewall Symbolic link
View File

@ -0,0 +1 @@
../firewall/

1
modules/enabled/first_boot Symbolic link
View File

@ -0,0 +1 @@
../first_boot/

1
modules/enabled/help Symbolic link
View File

@ -0,0 +1 @@
../help/

1
modules/enabled/lib Symbolic link
View File

@ -0,0 +1 @@
../lib/

1
modules/enabled/owncloud Symbolic link
View File

@ -0,0 +1 @@
../owncloud/

1
modules/enabled/packages Symbolic link
View File

@ -0,0 +1 @@
../packages/

1
modules/enabled/pagekite Symbolic link
View File

@ -0,0 +1 @@
../pagekite/

1
modules/enabled/system Symbolic link
View File

@ -0,0 +1 @@
../system/

1
modules/enabled/tor Symbolic link
View File

@ -0,0 +1 @@
../tor/

1
modules/enabled/users Symbolic link
View File

@ -0,0 +1 @@
../users/

1
modules/enabled/xmpp Symbolic link
View File

@ -0,0 +1 @@
../xmpp/

View File

@ -1 +0,0 @@
installed/system/expert_mode.py

View File

@ -1,5 +1,3 @@
{% extends "login_nav.html" %}
{% comment %}
#
# This file is part of Plinth.
#
@ -16,18 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% block sidebar_right_block %}
"""
Plinth module for expert mode configuration
"""
<div class="well sidebar-nav">
<h3>Freedom NAS</h3>
from . import expert_mode
<p> The {{ cfg.box_name }} can make your spare hard drives
accessible to your local network, thus acting as a NAS server. We
currently support sharing files via NFS and SMB.</p>
<p>TODO: this is not true. We currently support no sharing.</p>
</div>
{% endblock %}
__all__ = ['expert_mode']

View File

@ -1,7 +1,7 @@
import cherrypy
from django import forms
from gettext import gettext as _
from modules.auth import require
from ..lib.auth import require
from plugin_mount import PagePlugin
import cfg
import util
@ -24,10 +24,10 @@ class Experts(PagePlugin):
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page('sys.config.expert')
self.register_page('sys.expert')
cfg.html_root.sys.config.menu.add_item(_('Expert mode'), 'icon-cog',
'/sys/config/expert', 10)
cfg.html_root.sys.menu.add_item(_('Expert Mode'), 'icon-cog',
'/sys/expert', 10)
@cherrypy.expose
@require()

View File

@ -1 +0,0 @@
installed/sharing/file_explorer.py

View File

@ -1 +0,0 @@
installed/system/firewall.py

View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module to configure a firewall
"""
from . import firewall
__all__ = ['firewall']

View File

@ -24,7 +24,7 @@ from gettext import gettext as _
import actions
import cfg
from modules.auth import require
from ..lib.auth import require
from plugin_mount import PagePlugin
import service as service_module
import util

View File

@ -1 +0,0 @@
installed/first_boot.py

View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module for first boot wizard
"""
from . import first_boot
__all__ = ['first_boot']

View File

@ -23,10 +23,10 @@ from django import forms
from django.core import validators
from gettext import gettext as _
from plugin_mount import PagePlugin
from modules.auth import add_user
from ..lib.auth import add_user
from ..config import config
from withsqlite.withsqlite import sqlite_db
import cfg
import config
import util
@ -100,8 +100,12 @@ class FirstBoot(PagePlugin):
message is an optional string that we can display to the
user. It's a good place to put error messages.
"""
try:
if FirstBoot._read_state() >= 5:
raise cherrypy.HTTPRedirect(cfg.server_dir, 302)
except KeyError:
pass
# FIXME: reject connection attempt if db["state"] >= 5.
## Until LDAP is in place, we'll put the box key in the cfg.store_file
status = self.get_state0()
@ -117,11 +121,8 @@ class FirstBoot(PagePlugin):
if success:
# Everything is good, permanently mark and move to page 2
with sqlite_db(cfg.store_file, table="firstboot",
autocommit=True) as database:
database['state'] = 1
raise cherrypy.InternalRedirect('state1')
FirstBoot._write_state(1)
raise cherrypy.HTTPRedirect('state1', 302)
else:
form = State0Form(initial=status, prefix='firstboot')
@ -176,9 +177,21 @@ class FirstBoot(PagePlugin):
"""
# TODO complete first_boot handling
# Make sure the user is not stuck on a dead end for now.
with sqlite_db(cfg.store_file, table='firstboot', autocommit=True) as \
database:
database['state'] = 5
FirstBoot._write_state(5)
return util.render_template(template='firstboot_state1',
title=_('Installing the Certificate'))
@staticmethod
def _read_state():
"""Read the current state from database"""
with sqlite_db(cfg.store_file, table='firstboot',
autocommit=True) as database:
return database['state']
@staticmethod
def _write_state(state):
"""Write state to database"""
with sqlite_db(cfg.store_file, table='firstboot',
autocommit=True) as database:
database['state'] = state

View File

@ -23,7 +23,7 @@
{% block main_block %}
<p>Welcome screen not completely implemented yet. Press <a
href="{{basehref }}/router">continue</a> to see the rest of the
href="{{basehref }}/apps">continue</a> to see the rest of the
web interface.</p>
<ul>

View File

@ -1 +0,0 @@
installed/lib/forms.py

View File

@ -1 +0,0 @@
installed/help/help.py

25
modules/help/__init__.py Normal file
View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module for help pages
"""
from . import help # pylint: disable-msg=W0622
__all__ = ['help']

View File

@ -1 +0,0 @@
installed/router/info.py

View File

@ -1,28 +0,0 @@
import cherrypy
from gettext import gettext as _
from plugin_mount import PagePlugin
from modules.auth import require
import cfg
import util
class Privacy(PagePlugin):
order = 20 # order of running init in PagePlugins
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page("privacy")
self.menu = cfg.main_menu.add_item("Privacy", "icon-eye-open", "/privacy", 12)
self.menu.add_item("General Config", "icon-asterisk", "/privacy/config", 10)
self.menu.add_item("Ad Blocking", "icon-ban-circle", "/privacy/adblock", 20)
self.menu.add_item("HTTPS Everywhere", "icon-lock", "/privacy/https_everywhere", 30)
@cherrypy.expose
def index(self):
#raise cherrypy.InternalRedirect('/privacy/config')
return self.config()
@cherrypy.expose
@require()
def config(self):
return util.render_template(template='privacy_config',
title=_('Privacy Control Panel'))

View File

@ -1,46 +0,0 @@
{% extends "login_nav.html" %}
{% comment %}
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% block main_block %}
<p>Privacy controls are not yet implemented. This page is a
placeholder and a promise: privacy is important enough that it is a
founding consideration, not an afterthought.</p>
{% endblock %}
{% block sidebar_right_block %}
<div class="well sidebar-nav">
<h3>Statement of Principles</h3>
<p>When we say your privacy is important, it's not just an empty
pleasantry. We really mean it. Your privacy control panel should
give you fine-grained control over exactly who can access your {{
cfg.product_name }} and the information on it.</p>
<p>Your personal information should not leave this box without your
knowledge and direction. And if companies or government wants this
information, they have to ask <strong>you</strong> for it. This
gives you a chance to refuse and also tells you who wants your
data.</p>
</div>
{% endblock %}

View File

@ -1,21 +0,0 @@
import cherrypy
from plugin_mount import PagePlugin
from modules.auth import require
import util
class Info(PagePlugin):
title = 'Info'
order = 10
url = 'info'
def __init__(self, *args, **kwargs):
self.register_page("router.info")
@cherrypy.expose
@require()
def index(self):
return util.render_template(title="Router Information", main="""
<p>Eventually we will display a bunch of info, graphs and logs about
the routing functions here.</p>
""")

View File

@ -1,150 +0,0 @@
import cherrypy
from django import forms
from gettext import gettext as _
from plugin_mount import PagePlugin
from modules.auth import require
import cfg
import util
class Router(PagePlugin):
"""Router page"""
order = 9 # order of running init in PagePlugins
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, args, kwargs)
self.register_page('router')
self.menu = cfg.main_menu.add_item('Router', 'icon-retweet', '/router',
10)
self.menu.add_item('Wireless', 'icon-signal', '/router/wireless', 12)
self.menu.add_item('Firewall', 'icon-fire', '/router/firewall', 18)
self.menu.add_item('Hotspot and Mesh', 'icon-map-marker',
'/router/hotspot')
self.menu.add_item('Info', 'icon-list-alt', '/router/info', 100)
@staticmethod
@cherrypy.expose
def index():
"""This isn't an internal redirect, because we need the url to
reflect that we've moved down into the submenu hierarchy.
Otherwise, it's hard to know which menu portion to make active
or expand or contract."""
raise cherrypy.HTTPRedirect(cfg.server_dir + '/router/setup')
@staticmethod
@cherrypy.expose
@require()
def wireless():
"""Serve the wireless page"""
return util.render_template(title="Wireless",
main="<p>wireless setup: essid, etc.</p>")
@staticmethod
@cherrypy.expose
@require()
def firewall():
"""Serve the firewall page"""
return util.render_template(title="Firewall",
main="<p>Iptables twiddling.</p>")
@staticmethod
@cherrypy.expose
@require()
def hotspot():
"""Serve the hotspot page"""
return util.render_template(title="Hotspot and Mesh",
main="<p>connection sharing setup.</p>")
class WANForm(forms.Form): # pylint: disable-msg=W0232
"""WAN setup form"""
connection_type = forms.ChoiceField(
label=_('Connection Type'),
choices=[('dhcp', _('DHCP')), ('static_ip', _('Static IP'))])
wan_ip = forms.IPAddressField(label=_('WAN IP Address'), required=False)
subnet_mask = forms.IPAddressField(label=_('Subnet Mask'), required=False)
dns_1 = forms.IPAddressField(label=_('Static DNS 1'), required=False)
dns_2 = forms.IPAddressField(label=_('Static DNS 2'), required=False)
dns_3 = forms.IPAddressField(label=_('Static DNS 3'), required=False)
class Setup(PagePlugin):
"""Router setup page"""
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, args, kwargs)
self.register_page('router.setup')
self.menu = cfg.html_root.router.menu.add_item(
'General Setup', 'icon-cog', '/router/setup', 10)
self.menu.add_item('Dynamic DNS', 'icon-flag', '/router/setup/ddns',
20)
self.menu.add_item('MAC Address Clone', 'icon-barcode',
'/router/setup/mac_address', 30)
@cherrypy.expose
@require()
def index(self, **kwargs):
"""Return the setup page"""
status = self.get_status()
form = None
messages = []
if kwargs:
form = WANForm(kwargs, prefix='router')
# pylint: disable-msg=E1101
if form.is_valid():
self._apply_changes(status, form.cleaned_data, messages)
status = self.get_status()
form = WANForm(initial=status, prefix='router')
else:
form = WANForm(initial=status, prefix='router')
return util.render_template(template='router_setup',
title=_('General Router Setup'),
form=form, messages=messages)
@staticmethod
@cherrypy.expose
@require()
def ddns():
"""Return the DDNS page"""
return util.render_template(title="Dynamic DNS",
main="<p>Masquerade setup</p>")
@staticmethod
@cherrypy.expose
@require()
def mac_address():
"""Return the MAC address page"""
return util.render_template(
title="MAC Address Cloning",
main="<p>Your router can pretend to have a different MAC address \
on any interface.</p>")
@staticmethod
def get_status():
"""Return the current status"""
store = util.filedict_con(cfg.store_file, 'router')
return {'connection_type': store.get('connection_type', 'dhcp')}
@staticmethod
def _apply_changes(old_status, new_status, messages):
"""Apply the changes"""
print 'Apply changes - %s, %s', old_status, new_status
if old_status['connection_type'] == new_status['connection_type']:
return
store = util.filedict_con(cfg.store_file, 'router')
store['connection_type'] = new_status['connection_type']
messages.append(('success', _('Connection type set')))
messages.append(('info', _('IP address settings unimplemented')))

View File

@ -1,117 +0,0 @@
{% extends "login_nav.html" %}
{% comment %}
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% block main_block %}
{% if cfg.users.expert %}
<h3>WAN Connection</h3>
{% include 'messages.html' %}
<form class="form" method="post">
{% csrf_token %}
{% include 'bootstrapform/field.html' with field=form.connection_type %}
<div id="static_ip_form"
style='display:
{% if form.connection_type.value = 'static_ip' %} block
{% else %} none {% endif %};'>
{% include 'bootstrapform/field.html' with field=form.wan_ip %}
{% include 'bootstrapform/field.html' with field=form.subnet_mask %}
{% include 'bootstrapform/field.html' with field=form.dns_1 %}
{% include 'bootstrapform/field.html' with field=form.dns_2 %}
{% include 'bootstrapform/field.html' with field=form.dns_3 %}
</div>
<input type="submit" class="btn-primary" value="Set WAN"/>
</form>
{% else %}
<p>In basic mode, you don't need to do any router setup before you
can go online. Just plug your {{ cfg.product_name }} in to your
cable or DSL modem and the router will try to get you on the
internet using DHCP.</p>
<p>If that fails, you might need to resort to the expert options.
Enable expert mode in the "{{ cfg.product_name }} / System /
Configure" menu.</p>
{% endif %}
{% endblock %}
{% block sidebar_right_block %}
<div class="well sidebar-nav">
<h3>Introduction</h3>
<p>Your {{ cfg.box_name }} is a replacement for your wireless
router. By default, it should do everything your usual router
does. With the addition of some extra modules, its abilities
can rival those of high-end routers costing hundreds of
dollars.</p>
{% if cfg.users.expert %}
<h3>WAN Connection Type</h3>
<h3>DHCP</h3>
<p>DHCP allows your router to automatically connect with the
upstream network. If you are unsure what option to choose,
stick with DHCP. It is usually correct.</p>
<h3>Static IP</h3>
<p>If you want to setup your connection manually, you can enter
static IP information. This option is for those who know what
they're doing. As such, it is only available in expert
mode.</p>
{% endif %}
</div>
{% endblock %}
{% block js_block %}
{{ js|safe }}
<script type="text/javascript">
(function($) {
function hideshow_static() {
var value = $('#id_router-connection_type').val();
var show_or_hide = (value == 'static_ip');
$('#static_ip_form').toggle(show_or_hide);
}
$(document).ready(function() {
$('#id_router-connection_type').change(hideshow_static);
hideshow_static();
});
})(jQuery);
</script>
{% endblock %}

View File

@ -1,23 +0,0 @@
import cherrypy
from modules.auth import require
from plugin_mount import PagePlugin
import cfg
import util
class Services(PagePlugin):
order = 9 # order of running init in PagePlugins
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page("services")
self.menu = cfg.main_menu.add_item("Services", "icon-list", "/services", 90)
self.menu.add_item("Open ID", "icon-user", "/services/openid", 35)
@cherrypy.expose
def index(self):
return self.openid()
@cherrypy.expose
@require()
def openid(self):
return util.render_template(template='openid', title="Open ID")

View File

@ -1,19 +0,0 @@
import cherrypy
from gettext import gettext as _
from modules.auth import require
from plugin_mount import PagePlugin
import cfg
import util
class FileExplorer(PagePlugin):
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page("sharing.explorer")
cfg.html_root.sharing.menu.add_item("File Explorer", "icon-folder-open", "/sharing/explorer", 30)
@cherrypy.expose
@require()
def index(self):
return util.render_template(template='file_explorer',
title=_('File Explorer'))

View File

@ -1,44 +0,0 @@
import cherrypy
from gettext import gettext as _
from modules.auth import require
from plugin_mount import PagePlugin
import cfg
import util
class Sharing(PagePlugin):
order = 9 # order of running init in PagePlugins
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page("sharing")
self.menu = cfg.main_menu.add_item("Sharing", "icon-share-alt", "/sharing", 35)
self.menu.add_item("File Server", "icon-inbox", "/sharing/files", 10)
@cherrypy.expose
def index(self):
"""This isn't an internal redirect, because we need the url to
reflect that we've moved down into the submenu hierarchy.
Otherwise, it's hard to know which menu portion to make active
or expand or contract."""
raise cherrypy.HTTPRedirect(cfg.server_dir + '/sharing/files')
@cherrypy.expose
@require()
def files(self):
return util.render_template(template='sharing',
title=_('File Server'))
#TODO: move PrinterSharing to another file, as it should be an optional module (most people don't care about printer sharing)
class PrinterSharing(PagePlugin):
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page("sharing.printer")
cfg.html_root.sharing.menu.add_item("Printer Sharing", "icon-print", "/sharing/printer", 35)
@cherrypy.expose
@require()
def index(self):
return util.render_template(template='sharing_printer',
title=_('Printer Sharing'))

View File

@ -1,42 +0,0 @@
{% extends 'login_nav.html' %}
{% comment %}
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% block main_block %}
<p>File explorer for users that also have shell accounts.</p> <p>Until
that is written (and it will be a while), we should
install <a href="http://www.mollify.org/demo.php">mollify</a>
or <a href="http://www.ajaxplorer.info/wordpress/demo/">ajaxplorer</a>,
but of which seem to have some support for playing media files in the
browser (as opposed to forcing users to download and play them
locally). The downsides to third-party explorers are: they're don't
fit within our theme system, they require separate login, and they're
written in php, which will make integrating them hard.</p>
<p>There are, of course, many other options for php-based file
explorers. These were the ones I saw that might do built-in media
players.</p>
<p>For python-friendly options, check out <a
href="http://blogfreakz.com/jquery/web-based-filemanager/">FileManager</a>.
It appears to be mostly javascript with some bindings to make it
python-friendly.</p>
{% endblock %}

View File

@ -1,52 +0,0 @@
{% extends "login_nav.html" %}
{% comment %}
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% load bootstrap %}
{% block main_block %}
{% if cfg.users.expert %}
{% include 'messages.html' %}
<p>For security reasons, neither WAN Administration nor WAN SSH is
available to the `admin` user account.</p>
<p>TODO: in expert mode, tell user they can ssh in to enable admin
from WAN, do their business, then disable it. It would be good to
enable the option and autodisable it when the ssh connection
dies.</p>
<form class="form" method="post">
{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" class="btn-primary" value="Submit"/>
</form>
{% else %}
<p>This page is available only in expert mode.</p>
{% endif %}
{% endblock %}

View File

@ -1,85 +0,0 @@
import cherrypy
from django import forms
from gettext import gettext as _
from modules.auth import require
from plugin_mount import PagePlugin
import cfg
import util
class WanForm(forms.Form): # pylint: disable-msg=W0232
"""Form to configure wan settings"""
wan_admin = forms.BooleanField(
label=_('Allow access to Plinth from WAN'),
required=False,
help_text=_('If you check this box, this front end will be reachable \
from the WAN. If your {{ box_name }} connects you to the internet, that \
means you\'ll be able to log in to the front end from the internet. This \
might be convenient, but it is also <strong>dangerous</strong>, since it can \
enable attackers to gain access to your {{ box_name }} from the outside \
world. All they\'ll need is your username and passphrase, which they might \
guess or they might simply try every posible combination of letters and \
numbers until they get in. If you enable the WAN administration option, you \
<strong>must</strong> use long and complex passphrases.').format(
box_name=cfg.box_name))
lan_ssh = forms.BooleanField(
label=_('Allow SSH access from LAN'),
required=False)
wan_ssh = forms.BooleanField(
label=_('Allow SSH access from WAN'),
required=False)
# XXX: Only present due to issue with submitting empty form
dummy = forms.CharField(label='Dummy', initial='dummy',
widget=forms.HiddenInput())
class Wan(PagePlugin):
order = 60
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page('sys.config.wan')
cfg.html_root.sys.config.menu.add_item(_('WAN'), 'icon-cog',
'/sys/config/wan', 20)
@cherrypy.expose
@require()
def index(self, **kwargs):
"""Serve the configuration form"""
status = self.get_status()
form = None
messages = []
if kwargs and cfg.users.expert():
form = WanForm(kwargs, prefix='wan')
# pylint: disable-msg=E1101
if form.is_valid():
self._apply_changes(form.cleaned_data, messages)
status = self.get_status()
form = WanForm(initial=status, prefix='wan')
else:
form = WanForm(initial=status, prefix='wan')
title = _('Accessing the {box_name}').format(box_name=cfg.box_name)
return util.render_template(template='wan', title=title, form=form,
messages=messages)
@staticmethod
def get_status():
"""Return the current status"""
return util.filedict_con(cfg.store_file, 'sys')
@staticmethod
def _apply_changes(new_status, messages):
"""Apply the changes after form submission"""
store = util.filedict_con(cfg.store_file, 'sys')
for field in ['wan_admin', 'wan_ssh', 'lan_ssh']:
store[field] = new_status[field]
messages.append(('success', _('Setting updated')))

29
modules/lib/__init__.py Normal file
View File

@ -0,0 +1,29 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth library modules
"""
from . import auth
from . import auth_page
from . import user_store
__all__ = ['auth',
'auth_page',
'user_store']

View File

@ -1 +0,0 @@
installed/apps/owncloud.py

View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module to configure ownCloud
"""
from . import owncloud
__all__ = ['owncloud']

View File

@ -1,7 +1,7 @@
import cherrypy
from django import forms
from gettext import gettext as _
from modules.auth import require
from ..lib.auth import require
from plugin_mount import PagePlugin
import actions
import cfg

View File

@ -1 +0,0 @@
installed/system/packages.py

View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module to manage packages
"""
from . import packages
__all__ = ['packages']

View File

@ -1,7 +1,7 @@
import cherrypy
from django import forms
from gettext import gettext as _
from auth import require
from ..lib.auth import require
from plugin_mount import PagePlugin
import actions
import cfg

View File

@ -1 +0,0 @@
installed/router/pagekite.py

View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module to configure PageKite
"""
from . import pagekite
__all__ = ['pagekite']

View File

@ -26,7 +26,7 @@ from gettext import gettext as _
import actions
import cfg
from modules.auth import require
from ..lib.auth import require
from plugin_mount import PagePlugin
import util
@ -38,10 +38,10 @@ class PageKite(PagePlugin):
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page("router.setup.pagekite")
cfg.html_root.router.setup.menu.add_item(
self.register_page("apps.pagekite")
cfg.html_root.apps.menu.add_item(
_("Public Visibility (PageKite)"), "icon-flag",
"/router/setup/pagekite", 50)
"/apps/pagekite", 50)
@staticmethod
@cherrypy.expose
@ -51,7 +51,7 @@ class PageKite(PagePlugin):
del kwargs # Unused
menu = {'title': _('PageKite'),
'items': [{'url': '/router/setup/pagekite/configure',
'items': [{'url': '/apps/pagekite/configure',
'text': _('Configure PageKite')}]}
sidebar_right = util.render_template(template='menu_block', menu=menu)
@ -112,7 +112,7 @@ class Configure(PagePlugin): # pylint: disable-msg=C0103
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page("router.setup.pagekite.configure")
self.register_page("apps.pagekite.configure")
@cherrypy.expose
@require()

View File

@ -49,7 +49,7 @@ there. In future, it might be possible to use your buddy's
<p>
<a class='btn btn-primary btn-lg'
href="{{ basehref }}/router/setup/pagekite/configure">Configure
href="{{ basehref }}/apps/pagekite/configure">Configure
PageKite</a>
</p>

View File

@ -1 +0,0 @@
installed/privacy/privacy.py

View File

@ -1 +0,0 @@
installed/router/router.py

View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module to configure santiago port
"""
from . import santiago
__all__ = ['santiago']

View File

@ -1 +0,0 @@
installed/services/services.py

View File

@ -1 +0,0 @@
installed/sharing/sharing.py

View File

@ -1 +0,0 @@
installed/system/system.py

View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module for system section page
"""
from . import system
__all__ = ['system']

View File

@ -1 +0,0 @@
installed/privacy/tor.py

25
modules/tor/__init__.py Normal file
View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module to configure Tor
"""
from . import tor
__all__ = ['tor']

View File

@ -22,18 +22,19 @@ Plinth module for configuring Tor
import cherrypy
from gettext import gettext as _
from plugin_mount import PagePlugin
from modules.auth import require
from ..lib.auth import require
import actions
import cfg
import util
class tor(PagePlugin):
order = 30 # order of running init in PagePlugins
order = 60 # order of running init in PagePlugins
def __init__(self, *args, **kwargs):
PagePlugin.__init__(self, *args, **kwargs)
self.register_page("privacy.tor")
cfg.html_root.privacy.menu.add_item("Tor", "icon-eye-close", "/privacy/tor", 30)
self.register_page("apps.tor")
cfg.html_root.apps.menu.add_item("Tor", "icon-eye-close", "/apps/tor",
30)
@cherrypy.expose
@require()

View File

@ -1 +0,0 @@
installed/lib/user_store.py

View File

@ -1 +0,0 @@
installed/system/users.py

25
modules/users/__init__.py Normal file
View File

@ -0,0 +1,25 @@
#
# This file is part of Plinth.
#
# 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 <http://www.gnu.org/licenses/>.
#
"""
Plinth module to manage users
"""
from . import users
__all__ = ['users']

Some files were not shown because too many files have changed in this diff Show More