summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-01-25 15:42:57 +0000
committerMika Havela <mika.havela@gmail.com>2008-01-25 15:42:57 +0000
commit64ed4dd6998ab8cbfe5b4042e9c91fe86a49c551 (patch)
tree239bb21388fe731f1991d483812053fe94fc58ac
parent1bf6e76a2d62e1f2746a6a4187dbd0d7a82e79f8 (diff)
downloadacf-alpine-conf-64ed4dd6998ab8cbfe5b4042e9c91fe86a49c551.tar.bz2
acf-alpine-conf-64ed4dd6998ab8cbfe5b4042e9c91fe86a49c551.tar.xz
Added a expert-tab like in other acf-modules
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@654 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--Makefile1
-rw-r--r--lbu-controller.lua14
-rw-r--r--lbu-expert-html.lsp45
-rw-r--r--lbu-model.lua17
4 files changed, 77 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index d95ca90..dbe34a6 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ APP_DIST=\
lbu-commit-html.lsp \
lbu-config-html.lsp \
lbu-controller.lua \
+ lbu-expert-html.lua \
lbu-model.lua \
lbu-status-html.lsp \
diff --git a/lbu-controller.lua b/lbu-controller.lua
index dbe910f..04b729a 100644
--- a/lbu-controller.lua
+++ b/lbu-controller.lua
@@ -92,4 +92,18 @@ function commit(self)
clientdata = self.clientdata,
url = url, } )
end
+expert = function (self)
+ local modifications = self.clientdata.modifications or ""
+ if ( self.clientdata.cmdsave) then
+ modifications = self.model:update_filecontent(modifications)
+ end
+
+ local status = self.model.getstatus()
+ local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
+
+ return { file = self.model:get_filedetails(),
+ status = status,
+ clientdata = self.clientdata,
+ url = url, }
+end
diff --git a/lbu-expert-html.lsp b/lbu-expert-html.lsp
new file mode 100644
index 0000000..29c3bdd
--- /dev/null
+++ b/lbu-expert-html.lsp
@@ -0,0 +1,45 @@
+<? local view = ... ?>
+
+<h1>SYSTEM INFO</h1>
+
+<DL>
+ <dt>Program status</dt>
+ <dd><?= view.status.status or "" ?></dd>
+
+ <dt>Program version</dt>
+ <dd><?= view.status.version ?></dd>
+</DL>
+
+<h1>CONFIGURATION</h1>
+<H2>Expert config</H2>
+<h3>File details</h3>
+
+<DL>
+ <dt>File name</dt>
+ <dd><?= view.file.details.path ?></dd>
+
+ <dt>File size</dt>
+ <dd><?= view.file.details.size ?></dd>
+
+ <dt>Last modified</dt>
+ <dd><?= view.file.details.mtime ?></dd>
+</DL>
+
+<h3>File content</h3>
+
+<form name="myform" action="" method="POST">
+<input name="name" type=hidden value="">
+<textarea name="modifications"><?= view.file.content ?></textarea>
+
+<H2>Save and apply above settings</H2>
+<DL>
+ <DT>Apply settings</DT>
+ <DD><input class="submit" type="submit" name="cmdsave" value="Apply"/></DD>
+</DL>
+
+<?
+--[[ DEBUG INFORMATION
+require("debugs")
+io.write(debugs.variables(view))
+--]]
+?>
diff --git a/lbu-model.lua b/lbu-model.lua
index 9ff31a4..f38d34d 100644
--- a/lbu-model.lua
+++ b/lbu-model.lua
@@ -3,6 +3,7 @@ module (..., package.seeall)
require("fs")
require("format")
require("getopts")
+require("daemoncontrol")
local configfile = "/etc/lbu/lbu.conf"
@@ -200,4 +201,20 @@ function editconfig (self,variable,value)
fs.write_file(path,table.concat(cmdoutput,"\n"))
return cmdoutput
end
+function get_filedetails()
+ local filedetails = {}
+ local path = configfile
+ filedetails.details = {path=path, size="0",mtime=""}
+ filedetails.content = ""
+ if (fs.is_file(path)) then
+ filedetails.details = fs.stat(path)
+ filedetails.content = fs.read_file(path)
+ end
+ return filedetails
+end
+function update_filecontent (self, modifications)
+ local path = configfile
+ local file_result,err = fs.write_file(path, format.dostounix(modifications))
+ return file_result, err
+end