summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-02-14 15:33:20 +0000
committerMika Havela <mika.havela@gmail.com>2008-02-14 15:33:20 +0000
commit422d93b32eb1c30d9a684146d258ed01ab99a850 (patch)
tree244d6fee9337f1e7e0843b405946d6cf2eb3882d
parent0201f4b56d290494cf5d01756670ae16b2e38936 (diff)
downloadacf-alpine-conf-422d93b32eb1c30d9a684146d258ed01ab99a850.tar.bz2
acf-alpine-conf-422d93b32eb1c30d9a684146d258ed01ab99a850.tar.xz
Rebuilt LBU so it uses cfe instead.v0.2
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@719 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--lbu-commit-html.lsp91
-rw-r--r--lbu-config-html.lsp136
-rw-r--r--lbu-controller.lua114
-rw-r--r--lbu-expert-html.lsp83
-rw-r--r--lbu-model.lua179
-rw-r--r--lbu-status-html.lsp64
6 files changed, 472 insertions, 195 deletions
diff --git a/lbu-commit-html.lsp b/lbu-commit-html.lsp
index f86bef1..a23b907 100644
--- a/lbu-commit-html.lsp
+++ b/lbu-commit-html.lsp
@@ -1,53 +1,72 @@
-<? local view = ... ?>
-
-<h1>SYSTEM INFO</h1>
+<? local form = ... ?>
+<?
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
+--]]
+?>
+<?
+function displayinfo(myform,tags,viewonly)
+ io.write("<DL>")
+ for k,v in pairs(tags) do
+ if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\t<DT")
+ if (#val.errtxt > 0) then
+ val.class = "error"
+ io.write(" class='error'")
+ end
+ io.write(">" .. val.label .. "</DT>\n")
+ if (viewonly) then
+ io.write("\t\t<DD>" .. val.value .. "\n")
+ else
+ io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
+ end
+ if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+ end
+ end
+ io.write("</DL>")
+end
+?>
-<dl>
- <dt>Program status</dt>
- <dd><?= view.status.status or "" ?></dd>
- <dt>Program version</dt>
- <dd><?= view.status.version ?></dd>
-</dl>
+<H1>SYSTEM INFO</H1>
+<?
+local myform = form.status
+local tags = { "status", "version", }
+displayinfo(myform,tags,"viewonly")
+?>
<H2>PROGRAM SPECIFIC OPTIONS/INFORMATION</H2>
-<dl>
- <dt>Archives will be saved to</dt>
- <dd><?= view.status.LBU_MEDIA or "<p class=error>No default - (Needs to be configured)</p>" ?></DD>
- <dt>Archives will be encrypted</dt>
- <dd><? if (view.status.ENCRYPTION) then io.write("yes <I>(Using cipher: " .. view.status.DEFAULT_CIPHER .. ")</I>") else io.write("No") end ?></DD>
-</dl>
+<?
+local myform = form.status
+local tags = { "LBU_MEDIA", "ENCRYPTION", }
+displayinfo(myform,tags,"viewonly")
+?>
<H1>MANAGEMENT</H1>
-
<H2>Save to media</h2>
<form name="cmd" action="" method="POST">
-<dl>
- <dt>Simulate/Test a commit</dt>
- <dd><input type=submit class="submit" name="lbusimulate" value="simulate" ></dd>
- <dt>Actually Commit and save changes</dt>
- <dd><input type=submit class="submit" name="lbucommit" value="commit" ></dd>
-<? if (view.cmderror) and (view.cmderror["-d"]) then ?>
- <dt class=error>Remove existing apk.ovls from media</dt>
- <dd><input type="checkbox" class="checkbox" name="lbucleanmedia" >
-<p>By checking this box, you remove all existing archives from the <?= view.status.LBU_MEDIA ?> when commiting (adding the '-d' flag to the commit action).<br>This needs to be done when you want/dont want to encrypt your archive and there already exists archives on the media.<BR>There can only be one sort of arcive on the media.</p><p>If you dont remove existing apk.ovls from media, your commit will most likely fail.</p></dd>
-<? end ?>
-</dl>
+<?
+local tags = { "lbusimulate", "lbucommit", "lbucleanmedia", }
+displayinfo(myform,tags)
+?>
</form>
-
-
-
-<dl>
-<? if (view.cmdresult) then ?>
+<DL>
+<? if (form.cmdresult) then ?>
<dt>Result of previous action</dt>
- <dd><pre><?= view.cmdresult ?></pre></DD>
+ <dd><pre><?= form.cmdresult ?></pre></DD>
<? end ?>
-</dl>
+</DL>
<?
--[[ DEBUG INFORMATION
-require("debugs")
-io.write(debugs.variables(view))
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
--]]
?>
diff --git a/lbu-config-html.lsp b/lbu-config-html.lsp
index 13e94c3..22c1405 100644
--- a/lbu-config-html.lsp
+++ b/lbu-config-html.lsp
@@ -1,85 +1,85 @@
-<? local view = ... ?>
-
-<h1>SYSTEM INFO</h1>
+<? local form = ... ?>
+<?
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
+--]]
+?>
+<?
+function displayinfo(myform,tags,viewonly)
+ io.write("<DL>")
+ for k,v in pairs(tags) do
+ if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\t<DT")
+ if (#val.errtxt > 0) then
+ val.class = "error"
+ io.write(" class='error'")
+ end
+ io.write(">" .. val.label .. "</DT>\n")
+ if (viewonly) then
+ io.write("\t\t<DD>" .. val.value .. "\n")
+ else
+ io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
+ end
+ if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+ end
+ end
+ io.write("</DL>")
+end
+?>
-<dl>
- <dt>Program status</dt>
- <dd><?= view.status.status or "" ?></dd>
- <dt>Program version</dt>
- <dd><?= view.status.version ?></dd>
-</dl>
+<H1>SYSTEM INFO</H1>
+<?
+local myform = form.status
+local tags = { "status", "version", }
+displayinfo(myform,tags,"viewonly")
+?>
<H1>CONFIG</H1>
<form name="config" action="" method="POST">
<H2>Advanced config</H2>
<H3>Storage media</H3>
-<dl>
- <dt <? if (view.errors) and (view.errors.LBU_MEDIA) then io.write("class='error'") end ?>>Default media for commit</dt>
- <dd><select name="LBU_MEDIA" size="1">
- <? if (view.config.LBU_MEDIA == "") then io.write("<option value='' selected='selected'>No default</option>") end ?>
- <? for i=1, table.maxn(view.config.LBU_MEDIA_LIST) do ?>
- <option value="<?= view.config.LBU_MEDIA_LIST[i]["value"] ?>"
- <? if (string.lower(view.config.LBU_MEDIA_LIST[i]["value"]) == string.lower(view.config.LBU_MEDIA or "")) then io.write("selected='selected'") end?>>
- <?= view.config.LBU_MEDIA_LIST[i]["name"] ?></option>
- <? end ?>
- </select>
- <p class=error><?= view.errors.LBU_MEDIA or "" ?></p></dd>
-</dl>
+<?
+local myform = form.config
+local tags = { "LBU_MEDIA", }
+displayinfo(myform,tags)
+?>
-<H3>Include/exclude list</H3>
-<dl>
- <dt>Included item(s)</dt>
- <dd><select name="lbu_included" size="3">
- <? for i=1, table.maxn(view.config.lbu_included or {}) do ?>
- <option value="<?= view.config.lbu_included[i] ?>"><?= view.config.lbu_included[i] ?></option>
- <? end ?>
- </select></dd>
- <dt>Delete selected include-item</dt>
- <dd><input name="cmd_delete_included" class="submit" type="submit" value="Delete" > (see above)</dd>
- <dt>Add item to inlude list</dt>
- <dd><input type="text" name="item_add_include" class="text" value="">
- <input name="cmd_add_include" class="submit" type="submit" value="Add"></dd>
- <dt>Excluded item(s)</dt>
- <dd><select name="lbu_excluded" size="3">
- <? for i=1, table.maxn(view.config.lbu_excluded or {}) do ?>
- <option value="<?= view.config.lbu_excluded[i] ?>"><?= view.config.lbu_excluded[i] ?></option>
- <? end ?>
- </select></dd>
- <dt>Delete selected exclude-item</dt>
- <dd><input name="cmd_delete_excluded" class="submit" type="submit" value="Delete" > (see above)</dd>
- <dt>Add item to exclude list</dt>
- <dd><input type="text" name="item_add_exclude" class="text" value="">
- <input name="cmd_add_exclude" class="submit" type="submit" value="Add"></dd>
-</dl>
+<H3>Included list</H3>
+<?
+local tags = { "lbu_included","cmd_delete_included", "item_add_included", "cmd_add_included", }
+displayinfo(myform,tags)
+?>
+
+<H3>Excluded list</H3>
+<?
+local tags = { "lbu_excluded","cmd_delete_excluded", "item_add_excluded", "cmd_add_excluded", }
+displayinfo(myform,tags)
+?>
<H3>Security/Encryption</H3>
-<dl>
- <dt>Password protected commits</dt>
- <dd><input type="checkbox" name="ENCRYPTION" <? if (view.config.ENCRYPTION) then io.write("checked=yes") end ?>></dd>
- <dt>Cipher to use at encryption</dt>
- <dd><select name="DEFAULT_CIPHER" size="1">
- <? if (view.config.DEFAULT_CIPHER == "") then io.write("<option value='' selected='selected'>No default</option>") end ?>
- <? for i=1, table.maxn(view.config.DEFAULT_CIPHER_LIST) do ?>
- <option value="<?= view.config.DEFAULT_CIPHER_LIST[i] ?>" <? if (string.lower(view.config.DEFAULT_CIPHER_LIST[i]) == string.lower(view.config.DEFAULT_CIPHER)) then io.write("selected='selected'") end?>><?= view.config.DEFAULT_CIPHER_LIST[i] ?></option>
- <? end ?>
- </select></dd>
- <dt <? if (view.errors) and (view.errors.PASSWORD) then io.write("class='error'") end ?>>Password when encrypting</dt>
- <dd><input type="text" class="text" value="<?= view.config.PASSWORD or "" ?>" name="PASSWORD">
- <p class=error><?= view.errors.PASSWORD or "" ?></p></dd>
-</dl>
+<?
+local tags = { "ENCRYPTION", "DEFAULT_CIPHER", "PASSWORD", }
+displayinfo(myform,tags)
+?>
<H2>Save and apply above settings</H2>
-<DL>
- <DT>Apply settings</DT>
- <DD><input class="submit" name="config_submit" type="submit" value="Apply" /></DD>
-</DL>
+<?
+local tags = { "config_submit" }
+displayinfo(myform,tags)
+?>
+
+
</form>
<?
--[[ DEBUG INFORMATION
-require("debugs")
-io.write(debugs.variables(view))
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
--]]
?>
-
-<? -- vim: set filetype=lua : ?>
diff --git a/lbu-controller.lua b/lbu-controller.lua
index 04b729a..8dbaccb 100644
--- a/lbu-controller.lua
+++ b/lbu-controller.lua
@@ -42,22 +42,84 @@ config = function (self)
cmdresult[var] = self.model:editconfig(var, self.clientdata[var], "change_value")
end
end
- if (self.clientdata.cmd_add_include) and (self.clientdata.item_add_include) then
- cmdresult = self.model:lbuincexcl("include", self.clientdata.item_add_include, "add")
+ if (self.clientdata.cmd_add_included) and (self.clientdata.item_add_included) then
+ cmdresult = self.model:lbuincexcl("include", self.clientdata.item_add_included, "add")
end
- if (self.clientdata.cmd_add_exclude) and (self.clientdata.item_add_exclude) then
- cmdresult = self.model:lbuincexcl("exclude", self.clientdata.item_add_exclude, "add")
+ if (self.clientdata.cmd_add_excluded) and (self.clientdata.item_add_excluded) then
+ cmdresult = self.model:lbuincexcl("exclude", self.clientdata.item_add_excluded, "add")
end
+ local config = self.model:getconfig()
-- This needs to be done /after/ the editing of the config (done earlier in this code)
- local status,errors = self.model:getstatus()
+ local status = self.model:getstatus()
+
+ -- Add submit and other buttons
+ config["cmd_delete_included"] = cfe({
+ name="cmd_delete_included",
+ value="Delete",
+ label="Delete selected included-item",
+ type="submit",
+ descr="Mark a item in '" .. config.lbu_included.label .. "'-list before pressing [Delete]",
+ })
+
+ config["item_add_included"] = cfe({
+ name="item_add_included",
+ label="Item to add to included-list",
+ })
+
+ config["cmd_add_included"] = cfe({
+ name="cmd_add_included",
+ value="Add",
+ label="Add the item into the included-list",
+ type="submit",
+ descr="Enter a value in '" .. config.item_add_included.label .. "'-input before pressing [Add]",
+ })
+
+ config["cmd_delete_excluded"] = cfe({
+ name="cmd_delete_excluded",
+ value="Delete",
+ label="Delete selected excluded-item",
+ type="submit",
+ descr="Mark a item in '" .. config.lbu_excluded.label .. "'-list before pressing [Delete]",
+ })
+
+ config["item_add_excluded"] = cfe({
+ name="item_add_excluded",
+ label="Item to add to excluded-list",
+ })
+
+ config["cmd_add_excluded"] = cfe({
+ name="cmd_add_excluded",
+ value="Add",
+ label="Add the item into the excluded-list",
+ type="submit",
+ descr="Enter a value in '" .. config.item_add_excluded.label .. "'-input before pressing [Add]",
+ })
+
+ config["config_submit"] = cfe({
+ name="config_submit",
+ value="Apply",
+ label="Apply above settings",
+ type="submit",
+ })
+
+ -- Disable buttons/commands that is usable for som reason
+ if (config.lbu_included.option) and (#config.lbu_included.option == 0) then
+ config.cmd_delete_included.disabled= "yes"
+ config.cmd_delete_included.descr= ""
+ end
+ if (config.lbu_excluded.option) and (#config.lbu_excluded.option == 0) then
+ config.cmd_delete_excluded.disabled= "yes"
+ config.cmd_delete_excluded.descr= ""
+ end
+
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
return ( {status = status,
cmdresult = cmdresult,
errors = errors,
clientdata = self.clientdata,
- config = self.model:getconfig(),
+ config = config,
url = url, } )
end
@@ -79,13 +141,37 @@ function commit(self)
end
local status, errors = self.model:getstatus()
- if (errors.last) then
+--[[ if (errors.last) then
self.conf.action = "config"
self.conf.type = "redir"
return config(self)
end
+--]]
+ -- Add buttons
+ status["lbusimulate"] = cfe({
+ name="lbusimulate",
+ value="Simulate",
+ label="Simulate/Test a commit",
+ type="submit",
+ })
+
+ status["lbucommit"] = cfe({
+ name="lbucommit",
+ value="Commit",
+ label="Actually commit and save changes",
+ type="submit",
+ })
+
+ if (cmderror["-d"]) then
+ status["lbucleanmedia"] = cfe({
+ name="lbucleanmedia",
+ value="lbucleanmedia",
+ label="Remove existing apk.ovls from media",
+ type="checkbox",
+ })
+ end
+
return ( {status = status,
- errors = errors,
cmdresult = cmdresult,
cmdflag = cmdflag,
cmderror = cmderror,
@@ -99,9 +185,19 @@ expert = function (self)
end
local status = self.model.getstatus()
+ local file = self.model:get_filedetails()
+ -- Add submit and other buttons
+ file["cmdsave"] = cfe({
+ name="cmdsave",
+ value="Apply",
+ label="Apply settings",
+ type="submit",
+ })
+
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
- return { file = self.model:get_filedetails(),
+ return {
+ file = file,
status = status,
clientdata = self.clientdata,
url = url, }
diff --git a/lbu-expert-html.lsp b/lbu-expert-html.lsp
index 29c3bdd..cea7e4c 100644
--- a/lbu-expert-html.lsp
+++ b/lbu-expert-html.lsp
@@ -1,45 +1,76 @@
-<? local view = ... ?>
+<? local form = ... ?>
+<?
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
+--]]
+?>
-<h1>SYSTEM INFO</h1>
+<?
+function displayinfo(myform,tags,viewonly)
+ io.write("<DL>")
+ for k,v in pairs(tags) do
+ if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\t<DT")
+ if (#val.errtxt > 0) then
+ val.class = "error"
+ io.write(" class='error'")
+ end
+ io.write(">" .. val.label .. "</DT>\n")
+ if (viewonly) then
+ io.write("\t\t<DD>" .. val.value .. "\n")
+ else
+ io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
+ end
+ if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+ end
+ end
+ io.write("</DL>")
+end
+?>
-<DL>
- <dt>Program status</dt>
- <dd><?= view.status.status or "" ?></dd>
+<H1>SYSTEM INFO</H1>
+<?
+local myform = form.status
+local tags = { "status", "version", }
+displayinfo(myform,tags,"viewonly")
+?>
- <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>
+<?
+local myform = form.file
+local tags = { "name", "size", "mtime", }
+displayinfo(myform,tags,"viewonly")
+?>
- <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>
+<?
+local myform = form.file.modifications
+io.write(html.form[myform.type](myform))
+?>
<H2>Save and apply above settings</H2>
-<DL>
- <DT>Apply settings</DT>
- <DD><input class="submit" type="submit" name="cmdsave" value="Apply"/></DD>
-</DL>
+<?
+local myform = form.file
+local tags = { "cmdsave", }
+displayinfo(myform,tags)
+?>
+</form>
<?
--[[ DEBUG INFORMATION
-require("debugs")
-io.write(debugs.variables(view))
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
--]]
?>
diff --git a/lbu-model.lua b/lbu-model.lua
index f38d34d..044d877 100644
--- a/lbu-model.lua
+++ b/lbu-model.lua
@@ -33,6 +33,10 @@ local function getLbuStatus()
return ret
end
+local function availablemedias()
+ return {"floppy","usb"}
+end
+
local function getLbuCommit(flag)
local err = {}
local ret = ""
@@ -84,19 +88,35 @@ end
function getstatus ()
local path = configfile
local status = {}
- local statustxt = nil
+ local statustxt
+ local descrtxt
if (#list() == 0) then
- statustxt = "OK! (There is no uncommited files)"
+ statustxt = "There is no uncommited files"
else
- statustxt = "WARNING! (Until you commit, you will lose your changes at next reboot/shutdown!)"
+ statustxt = "WARNING!"
+ descrtxt = "Until you commit, you will lose your changes at next reboot/shutdown!"
end
- local config, errors = getconfig()
+ local config = getconfig()
+ status["version"] = cfe({
+ name="status",
+ value=get_version(),
+ label="Program version",
+ })
+
+ status["status"] = cfe({
+ name="status",
+ value=statustxt,
+ descr=descrtxt,
+ label="Program status",
+ })
+
status["LBU_MEDIA"] = config["LBU_MEDIA"]
- status["ENCRYPTION"] = config["ENCRYPTION"]
- status["DEFAULT_CIPHER"] = config["DEFAULT_CIPHER"]
- status["version"] = get_version()
- status["status"] = statustxt
- return status, errors
+ if (config["ENCRYPTION"]["checked"]) then
+ status["ENCRYPTION"] = config["ENCRYPTION"]
+ status["ENCRYPTION"]["descr"] = "Using cipher '".. config.DEFAULT_CIPHER.value .. "' for encryption"
+ end
+
+ return status
end
function list(self)
@@ -123,32 +143,84 @@ end
function getconfig ()
local path = configfile
local config = {}
+ local configopts
local errors = {}
- local lbumedias = {}
- table.insert(lbumedias, {name="floppy", value="floppy"})
- table.insert(lbumedias, {name="usb", value="usb"})
if (fs.is_file(path)) then
- config = getopts.getoptsfromfile(path) or {}
- end
- config["lbu_included"]= getincexl("include") or {}
- config["lbu_excluded"]= getincexl("exclude") or {}
- config["LBU_MEDIA_LIST"]= lbumedias or {}
- config["DEFAULT_CIPHER_LIST"]= getciphers() or {}
- -- Next section is to set/show default values when a option is not configured in the configfile
- config["LBU_MEDIA"] = config["LBU_MEDIA"] or ""
- config["DEFAULT_CIPHER"] = config["DEFAULT_CIPHER"] or ""
+ configopts = getopts.getoptsfromfile_onperline(path) or {}
+ end
+ local lbumedias = availablemedias()
+ if not (configopts.LBU_MEDIA) then
+ local lbumessage = "No default"
+ table.insert(lbumedias, lbumessage)
+ config.LBU_MEDIA = lbumessage
+ else
+ config.LBU_MEDIA = configopts.LBU_MEDIA
+ end
+ config["debug"] = configopts
+ config["LBU_MEDIA"] = cfe({
+ name="LBU_MEDIA",
+ value=config["LBU_MEDIA"],
+ label="Default media for commit",
+ type="select",
+ option=lbumedias,
+ })
+
+ config["lbu_included"]= cfe({
+ name="lbu_included",
+ option=getincexl("include") or {},
+ label="Included item(s)",
+ type="select",
+ size=table.maxn(getincexl("include"))+1,
+ })
+ if (config["lbu_included"]["size"] == 1) then config["lbu_included"]["size"] = 2 end
+
+ config["lbu_excluded"]= cfe({
+ name="lbu_excluded",
+ option=getincexl("exclude") or {},
+ label="Excluded item(s)",
+ type="select",
+ size=table.maxn(getincexl("exclude"))+1,
+ })
+ if (config["lbu_excluded"]["size"] == 1) then config["lbu_excluded"]["size"] = 2 end
+
+ config["ENCRYPTION"] = cfe({
+ name="ENCRYPTION",
+ value="yes",
+ label="Password protected commits",
+ type="checkbox",
+ })
+ if (configopts["ENCRYPTION"]) and (#configopts["ENCRYPTION"] ~= 0) then
+ config["ENCRYPTION"]["checked"] = "yes"
+ end
+
+ config["DEFAULT_CIPHER"] = cfe({
+ name="DEFAULT_CIPHER",
+ value=configopts["DEFAULT_CIPHER"],
+ label="Cipher to use at encryption",
+ option=getciphers() or {},
+ type="select",
+ })
+
+ config["PASSWORD"] = cfe({
+ name="PASSWORD",
+ value=configopts["PASSWORD"],
+ label="Password when encrypting",
+ })
+
+---[[
+
-- Next section is to print errormessages when configs are wrong
- if (config["LBU_MEDIA"] == "") or (config["LBU_MEDIA"] == nil) then
- errors["LBU_MEDIA"] = "'Media' needs to be configured!"
+ if (configopts["LBU_MEDIA"] == "") or (configopts["LBU_MEDIA"] == nil) then
+ config.LBU_MEDIA.errtxt = "'Media' needs to be configured!"
end
- if (config["PASSWORD"] == nil) and (config["ENCRYPTION"] ~= nil) then
- errors["PASSWORD"] = "Encryption without password is not allowed!<BR> Deactivate 'Password protection' or configure a password!"
+ if (configopts["PASSWORD"] == nil) and (configopts["ENCRYPTION"] ~= nil) then
+ config.PASSWORD.errtxt = "Encryption without password is not allowed!<BR> Deactivate 'Password protection' or configure a password!"
end
for k,v in pairs(errors) do
- errors["last"] = v
+ config["errors"] = v
end
-
- return config, errors
+--]]
+ return config
end
function lbuincexcl(self,state,value,addremove)
@@ -166,7 +238,7 @@ function lbuincexcl(self,state,value,addremove)
incexl = f:read("*a")
f:close()
else
- return "Function setincexl() - Invalid command! Use include|exclude when calling this function!"
+ return "Function setincexl() - Invalid command! Use included|excluded when calling this function!"
end
return incexl
end
@@ -182,8 +254,21 @@ function editconfig (self,variable,value)
if not (value) or (value == "") then
deactivate = "#"
end
+ if (variable == "LBU_MEDIA") then
+ local errtxt
+ local lbumedias = availablemedias()
+ for k,v in pairs(lbumedias) do
+ errtxt = ""
+ if (value == v) then break end
+ errtxt = "Not a valid media!"
+ end
+ if (#errtxt > 0) then
+ return errtxt
+ end
+ end
+
-- Hardcode some parameters (e.g for some checkboxes)
- if (variable == "ENCRYPTION") then value = "$DEFAULT_CIPHER" end
+ if (variable == "ENCRYPTION") then value = "DEFAULT_CIPHER" end
configfilecontent = fs.read_file_as_array(path) or {}
-- Search if the variable is defined in the file
for k,v in pairs(configfilecontent) do
@@ -199,17 +284,37 @@ function editconfig (self,variable,value)
end
-- Write changes to file
fs.write_file(path,table.concat(cmdoutput,"\n"))
- return cmdoutput
+ return value
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
+ local filestats = fs.stat(path)
+ filedetails.name = cfe ({
+ name="name",
+ value=path,
+ label="File name"
+ })
+
+ filedetails.size = cfe ({
+ name="size",
+ value=filestats.size or "0",
+ label="File size",
+ })
+
+ filedetails.mtime = cfe ({
+ name="mtime",
+ value=filestats.mtime or "---",
+ label="File modified",
+ })
+
+ filedetails.modifications = cfe ({
+ name="modifications",
+ value=fs.read_file(path),
+ label="File content",
+ type="longtext",
+ })
+
return filedetails
end
function update_filecontent (self, modifications)
diff --git a/lbu-status-html.lsp b/lbu-status-html.lsp
index 852bdb8..99d1dbe 100644
--- a/lbu-status-html.lsp
+++ b/lbu-status-html.lsp
@@ -1,33 +1,59 @@
-<? local view = ... ?>
-
-<h1>SYSTEM INFO</h1>
+<? local form = ... ?>
+<?
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
+--]]
+?>
+<?
+function displayinfo(myform,tags,viewonly)
+ io.write("<DL>")
+ for k,v in pairs(tags) do
+ if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\t<DT")
+ if (#val.errtxt > 0) then io.write(" class='error'") end
+ io.write(">" .. val.label .. "</DT>\n")
+ if (viewonly) then
+ io.write("\t\t<DD>" .. val.value .. "\n")
+ else
+ io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
+ end
+ if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+ end
+ end
+ io.write("</DL>")
+end
+?>
-<dl>
- <dt>Program status</dt>
- <dd><?= view.status.status or "" ?></dd>
- <dt>Program version</dt>
- <dd><?= view.status.version ?></dd>
-</dl>
+<H1>SYSTEM INFO</H1>
+<?
+local myform = form.status
+local tags = { "status", "version", }
+displayinfo(myform,tags,"viewonly")
+?>
<H2>PROGRAM SPECIFIC OPTIONS/INFORMATION</H2>
-
-<dl>
- <dt>Archives will be saved to</dt>
- <dd><?= view.status.LBU_MEDIA or "No default" ?><? if (view.errors.LBU_MEDIA) then ?><p class=error><?= view.errors.LBU_MEDIA ?></p><? end ?></DD>
- <dt>Archives will be encrypted</dt>
- <dd><? if (view.status.ENCRYPTION) then io.write("yes <I>(Using cipher: " ..view.status.DEFAULT_CIPHER .. ")</I>") else io.write("No") end ?><? if (view.errors.PASSWORD) then ?><p class=error><?= view.errors.PASSWORD ?></p><? end ?></DD>
-</dl>
+<?
+local tags = { "LBU_MEDIA","ENCRYPTION", }
+displayinfo(myform,tags,"viewonly")
+?>
<H2>CHANGES SINCE LAST COMMIT</H2>
<dl>
<dt>Files changed since last commit</dt>
- <dd><pre><? for i = 1, table.maxn(view.lbustatus) do io.write(view.lbustatus[i]["status"] .. "\t" .. view.lbustatus[i]["name"] .. "\n") end ?></pre></DD>
+ <dd><pre><? for i = 1, table.maxn(form.lbustatus) do io.write(form.lbustatus[i]["status"] .. "\t" .. form.lbustatus[i]["name"] .. "\n") end ?><? if (#form.lbustatus == 0) then io.write("None") end ?></pre></DD>
</dl>
+
<?
--[[ DEBUG INFORMATION
-require("debugs")
-io.write(debugs.variables(view))
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
--]]
?>