summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Vasile <james@jamesvasile.com>2013-02-08 10:15:42 -0500
committerJames Vasile <james@jamesvasile.com>2013-02-08 11:31:07 -0500
commit3c7aa32c5bf7fe791d6e64bdc971b55594a82070 (patch)
tree2af710f61d318356c8b82e1b1cbeca11d56a9600
parent2e1240ad18ac0e5bcd7116816b812454af726cbf (diff)
Yay for first boot screens
* import withsqlite into plinth.py and start detecting first boot * new url page and start on forms * update license intro and (c) statement
-rw-r--r--COPYING8
l---------modules/first_boot.py1
-rw-r--r--modules/installed/first_boot.py67
-rw-r--r--modules/installed/lib/forms.py11
-rwxr-xr-xplinth.py5
5 files changed, 84 insertions, 8 deletions
diff --git a/COPYING b/COPYING
index 9f218c2..694d454 100644
--- a/COPYING
+++ b/COPYING
@@ -1,9 +1,9 @@
-# License to Copy the Plinth front end to the Freedom Plug
+# License to Copy Plinth
-Plinth is Copyright 2011 James Vasile (<james@hackervisions.org>). It
+Plinth is Copyright 2011-2013 James Vasile (<james@hackervisions.org>). It
is distributed under the GNU Affero General Public License, Version 3
-or later. A copy of GPLv3 is available [from the Free Software
-Foundation](http://www.gnu.org/licenses/gpl.html).
+or later. A copy of AGPLv3 is available [from the Free Software
+Foundation](http://www.gnu.org/licenses/agpl.html).
In addition, the documentation to this software is distributed under a
Creative Commons Attribution-ShareAlike 3.0 Unported, Version 3
diff --git a/modules/first_boot.py b/modules/first_boot.py
new file mode 120000
index 0000000..ae5c554
--- /dev/null
+++ b/modules/first_boot.py
@@ -0,0 +1 @@
+installed/first_boot.py \ No newline at end of file
diff --git a/modules/installed/first_boot.py b/modules/installed/first_boot.py
new file mode 100644
index 0000000..8706689
--- /dev/null
+++ b/modules/installed/first_boot.py
@@ -0,0 +1,67 @@
+from urlparse import urlparse
+import os, cherrypy
+from gettext import gettext as _
+from plugin_mount import PagePlugin, PluginMount, FormPlugin
+from modules.auth import require
+from forms import Form
+from util import *
+import cfg
+
+class FirstBoot(PagePlugin):
+ order = 0 # order of running init in PagePlugins
+ def __init__(self, *args, **kwargs):
+ PagePlugin.__init__(self, *args, **kwargs)
+ self.register_page("firstboot") # this is the url this page will hang off of (/firstboot)
+ #self.menu = cfg.main_menu.add_item("First Boot", "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("TOR", "icon-eye-close", "/privacy/TOR", 30)
+ #self.menu.add_item("HTTPS Everywhere", "icon-lock", "/privacy/https_everywhere", 30)
+
+ @cherrypy.expose
+ def index(self, *args, **kwargs):
+ return self.state0(*args, **kwargs)
+
+ @cherrypy.expose
+ @require()
+ def state0(self, message=None, box_name=None, box_key=""):
+ """
+ All the parameters are form inputs. They get passed in when
+ the form is submitted. This method checks the inputs and if
+ they validate, uses them to take action. If they do not
+ validate, it displays the form to give the user a chance to
+ input correct values. It might display an error message (in
+ the message parameter).
+
+ message is an optional string that we can display to the
+ user. It's a good place to put error messages.
+ """
+
+
+
+ form = Form(title="Welcome to Your FreedomBox!",
+ action="/firstboot",
+ name="whats_my_name",
+ message=message)
+ if not box_name:
+ box_name = cfg.box_name
+ form.html("<p>For convenience, your FreedomBox needs a name. It should be something short that doesn't contain spaces or punctuation. 'Willard' would be a good name. 'Freestyle McFreedomBox!!!' would not.</p>")
+ form.text_input('Name your FreedomBox', id="box_name", value=box_name)
+ form.html("<p>%(box_name)s uses cryptographic keys so it can prove its identity when talking to you. %(box_name)s can make a key for you, but if you already have one (from a prior FreedomBox, maybe), you can paste it below. This key should not be the same as your key because you are not your FreedomBox!</p>" % {'box_name':cfg.box_name})
+ form.text_box("If you want, paste your box's key here.", id="box_key", value=box_key)
+ form.submit("Box it up!")
+
+ main=form.render()
+ return main
+ return self.fill_template(title=_("Privacy Control Panel"), main=main,
+sidebar_right=_("""<strong>Statement of Principles</strong><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 %s 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
+change to refuse and also tells you who wants your data.</p>
+""") % cfg.product_name)
diff --git a/modules/installed/lib/forms.py b/modules/installed/lib/forms.py
index 00ad43f..a45e26c 100644
--- a/modules/installed/lib/forms.py
+++ b/modules/installed/lib/forms.py
@@ -23,7 +23,10 @@ class Form():
"""Note that there appears to be a bug in cherrypy whereby
forms submitted via post don't have their fields included in
kwargs for the default index method. So we use get by
- default, though it's not as neat."""
+ default, though it's not as neat.
+
+ TODO: file bug on this w/ CherryPy project
+ """
action = self.get_form_attrib_text('action', action)
onsubmit = self.get_form_attrib_text('onsubmit', onsubmit)
@@ -85,13 +88,13 @@ class Form():
<span>%s</span>
<input type="%s" class="inputtext" name="%s" id="%s" value="%s" size="%s"/>
</label>""" % (label, type, name, id, value, size)
- def text_box(self, label='', name=None, id=None):
+ def text_box(self, label='', name=None, id=None, value=""):
name, id = self.name_or_id(name, id)
self.text += """
<label>
<span>%s</span>
- <textarea class="textbox" name="%s" id="%s"></textarea>
- </label>""" % (label, name, id)
+ <textarea class="textbox" name="%s" id="%s">%s</textarea>
+ </label>""" % (label, name, id, value)
def submit(self, label='', name=None, id=None):
name, id = self.name_or_id(name, id)
self.text += """
diff --git a/plinth.py b/plinth.py
index 9f0f5e1..4f88310 100755
--- a/plinth.py
+++ b/plinth.py
@@ -16,6 +16,8 @@ from util import *
from logger import Logger
#from modules.auth import AuthController, require, member_of, name_is
+import withsqlite
+from withsqlite.withsqlite import sqlite_db
import exmachina
from exmachina.exmachina import ExMachinaClient
import socket
@@ -52,6 +54,9 @@ def error_page_500(status, message, traceback, version):
class Root(plugin_mount.PagePlugin):
@cherrypy.expose
def index(self):
+ with sqlite_db(cfg.store_file, table="firstboot") as db:
+ if not 'state' in db:
+ raise cherrypy.InternalRedirect('/firstboot')
if cherrypy.session.get(cfg.session_key, None):
raise cherrypy.InternalRedirect('/router')
else: