Merge pull request #31 from petterreinholdtsen/app-owncloud

Add support for owncloud in the apps menu
This commit is contained in:
Nick Daly committed 2013-09-28 10:48:39 -07:00
commit d722ca950f
12 files changed
+148 -65

No files matched your search

+48
View File
@@ -1,6 +1,9 @@
import cherrypy
from gettext import gettext as _
from modules.auth import require
from plugin_mount import PagePlugin
from forms import Form
from privilegedactions import privilegedaction_run
import cfg
class Apps(PagePlugin):
@@ -9,6 +12,7 @@ class Apps(PagePlugin):
self.register_page("apps")
self.menu = cfg.main_menu.add_item("Apps", "icon-download-alt", "/apps", 80)
self.menu.add_item("Photo Gallery", "icon-picture", "/apps/photos", 35)
self.menu.add_item("Owncloud", "icon-picture", "/apps/owncloud", 35)
@cherrypy.expose
def index(self):
@@ -33,3 +37,47 @@ 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>
""")
@cherrypy.expose
@require()
def owncloud(self, submitted=False, **kwargs):
checkedinfo = {
'enable' : False,
}
if submitted:
opts = []
for k in kwargs.keys():
if 'on' == kwargs[k]:
shortk = k.split("owncloud_").pop()
checkedinfo[shortk] = True
for key in checkedinfo.keys():
if checkedinfo[key]:
opts.append(key)
else:
opts.append('no'+key)
privilegedaction_run("owncloud-setup", opts)
output, error = privilegedaction_run("owncloud-setup", ['status'])
if error:
raise Exception("something is wrong: " + error)
for option in output.split():
checkedinfo[option] = True
main="""
"""
form = Form(title="Configuration",
action="/apps/owncloud",
name="configure_owncloud",
message='')
form.checkbox(_("Enable Owncloud"), name="owncloud_enable", id="owncloud_enable", checked=checkedinfo['enable'])
form.hidden(name="submitted", value="True")
form.html(_("<p>When enabled, the owncloud installation will be available from /owncloud/ on the web server.</p>"))
form.submit(_("Update setup"))
main += form.render()
sidebar_right="""
<strong>Owncloud</strong><p>gives you universal access to your files through a web interface or WebDAV. It also provides a platform to easily view & sync your contacts, calendars and bookmarks across all your devices and enables basic editing right on the web. Installation has minimal server requirements, doesn’t need special permissions and is quick. ownCloud is extendable via a simple but powerful API for applications and plugins.
</p>
"""
return self.fill_template(title="Owncloud", main=main, sidebar_right=sidebar_right)
+7 -12
View File
@@ -9,6 +9,7 @@ from gettext import gettext as _
from filedict import FileDict
from modules.auth import require
from plugin_mount import PagePlugin, FormPlugin
from privilegedactions import privilegedaction_run
import cfg
from forms import Form
from model import User
@@ -48,20 +49,14 @@ def get_hostname():
def set_hostname(hostname):
"Sets machine hostname to hostname"
cfg.log.info("Writing '%s' to /etc/hostname with exmachina" % hostname)
cfg.log.info("Changing hostname to '%s'" % hostname)
try:
cfg.exmachina.augeas.set("/files/etc/hostname/*", hostname)
cfg.exmachina.augeas.save()
privilegedaction_run("hostname-change", [hostname])
# don't persist/cache change unless it was saved successfuly
sys_store = filedict_con(cfg.store_file, 'sys')
sys_store['hostname'] = hostname
if platform.linux_distribution()[0]=="Ubuntu" :
cfg.exmachina.service.start("hostname")
else:
cfg.exmachina.initd.start("hostname.sh") # is hostname.sh debian-only?
except OSError, e:
raise cherrypy.HTTPError(500, "Hostname restart failed: %s" % e)
raise cherrypy.HTTPError(500, "Updating hostname failed: %s" % e)
class general(FormPlugin, PagePlugin):
url = ["/sys/config"]
@@ -79,7 +74,7 @@ class general(FormPlugin, PagePlugin):
return '<p>' + _('Only members of the expert group are allowed to see and modify the system setup.') + '</p>'
sys_store = filedict_con(cfg.store_file, 'sys')
hostname = cfg.exmachina.augeas.get("/files/etc/hostname/*")
hostname = get_hostname()
# this layer of persisting configuration in sys_store could/should be
# removed -BLN
defaults = {'time_zone': "slurp('/etc/timezone').rstrip()",
@@ -139,10 +134,10 @@ class general(FormPlugin, PagePlugin):
raise
else:
message += msg
time_zone = time_zone.strip()
if time_zone != sys_store['time_zone']:
src = os.path.join("/usr/share/zoneinfo", time_zone)
cfg.log.info("Setting timezone to %s" % time_zone)
cfg.exmachina.misc.set_timezone(time_zone)
privilegedaction_run("timezone-change", [time_zone])
sys_store['time_zone'] = time_zone
return message or "Settings updated."