From f83a1a729f68ab79138857a884308084e23cd595 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 9 Apr 2008 13:23:31 +0000 Subject: Cleaning up the code. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@966 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lbu-commit-html.lsp | 50 +++++++++----------------------------------------- lbu-config-html.lsp | 52 ++++++++++++++++------------------------------------ lbu-controller.lua | 26 ++++++++++++++------------ lbu-expert-html.lsp | 44 +++++++++----------------------------------- lbu-model.lua | 7 +++---- lbu-status-html.lsp | 45 +++++++++------------------------------------ 6 files changed, 60 insertions(+), 164 deletions(-) diff --git a/lbu-commit-html.lsp b/lbu-commit-html.lsp index a23b907..fdf44c6 100644 --- a/lbu-commit-html.lsp +++ b/lbu-commit-html.lsp @@ -1,4 +1,6 @@ - + DEBUGGING

DEBUG INFO: CFE

") @@ -6,67 +8,33 @@ io.write(html.cfe_unpack(form)) io.write("
") --]] ?> -") - for k,v in pairs(tags) do - if (myform[v]) and (myform[v]["value"]) then - local val = myform[v] - io.write("\t 0) then - val.class = "error" - io.write(" class='error'") - end - io.write(">" .. val.label .. "\n") - if (viewonly) then - io.write("\t\t
" .. val.value .. "\n") - else - io.write("\t\t
" .. html.form[val.type](val) .. "\n") - end - if (val.descr) and (#val.descr > 0) then io.write("\t\t

" .. string.gsub(val.descr, "\n", "
") .. "

\n") end - if (#val.errtxt > 0) then io.write("\t\t

" .. string.gsub(val.errtxt, "\n", "
") .. "

\n") end - io.write("\t\t
\n") - end - end - io.write("") -end -?>

SYSTEM INFO

+
+

PROGRAM SPECIFIC OPTIONS/INFORMATION

+
+

MANAGEMENT

Save to media

+
- - -
- -
Result of previous action
-
-
- -DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(form)) -io.write("
") ---]] -?> + diff --git a/lbu-config-html.lsp b/lbu-config-html.lsp index 22c1405..d9e1491 100644 --- a/lbu-config-html.lsp +++ b/lbu-config-html.lsp @@ -1,4 +1,6 @@ - + DEBUGGING

DEBUG INFO: CFE

") @@ -6,80 +8,58 @@ io.write(html.cfe_unpack(form)) io.write("
") --]] ?> -") - for k,v in pairs(tags) do - if (myform[v]) and (myform[v]["value"]) then - local val = myform[v] - io.write("\t 0) then - val.class = "error" - io.write(" class='error'") - end - io.write(">" .. val.label .. "\n") - if (viewonly) then - io.write("\t\t
" .. val.value .. "\n") - else - io.write("\t\t
" .. html.form[val.type](val) .. "\n") - end - if (val.descr) and (#val.descr > 0) then io.write("\t\t

" .. string.gsub(val.descr, "\n", "
") .. "

\n") end - if (#val.errtxt > 0) then io.write("\t\t

" .. string.gsub(val.errtxt, "\n", "
") .. "

\n") end - io.write("\t\t
\n") - end - end - io.write("
") -end -?>

SYSTEM INFO

+
+

CONFIG

Advanced config

Storage media

- + +

Included list

+
+

Excluded list

+
+

Security/Encryption

+
+

Save and apply above settings

+
- +
- -DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(form)) -io.write("
") ---]] -?> diff --git a/lbu-controller.lua b/lbu-controller.lua index 6bca902..f258f5f 100644 --- a/lbu-controller.lua +++ b/lbu-controller.lua @@ -1,22 +1,29 @@ module(..., package.seeall) -local list_redir = function(self) +-- Set variables +local cfgfile + +-- ################################################################################ +-- LOCAL FUNCTIONS + +local function list_redir (self) self.conf.action = "status" self.conf.type = "redir" error(self.conf) end -local cfgfile +-- ################################################################################ +-- PUBLIC FUNCTIONS mvc={} -mvc.on_load = function(self, parent) +function mvc.on_load (self, parent) cfgfile = self:new("cfgfile") if (self.worker[self.conf.action] == nil) or (self.conf.action == "init") then self.worker[self.conf.action] = list_redir(self) end end -status = function (self) +function status (self) local cmd = self.clientdata.cmd local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller local status, errors = self.model:getstatus() @@ -26,7 +33,7 @@ status = function (self) url = url, } ) end -config = function (self) +function config (self) local errors = {} local cmdresult if (self.clientdata.cmd_delete_excluded) and (self.clientdata.lbu_excluded) then @@ -145,12 +152,7 @@ function commit(self) end local status, errors = self.model:getstatus() ---[[ if (errors.last) then - self.conf.action = "config" - self.conf.type = "redir" - return config(self) - end ---]] + -- Add buttons status["lbusimulate"] = cfe({ name="lbusimulate", @@ -182,7 +184,7 @@ function commit(self) clientdata = self.clientdata, url = url, } ) end -expert = function (self) +function expert (self) local modifications = self.clientdata.filecontent or "" if ( self.clientdata.cmdsave) then modifications = self.model:update_filecontent(modifications) diff --git a/lbu-expert-html.lsp b/lbu-expert-html.lsp index 219d748..ed87ade 100644 --- a/lbu-expert-html.lsp +++ b/lbu-expert-html.lsp @@ -1,4 +1,6 @@ - + DEBUGGING

DEBUG INFO: CFE

") @@ -7,38 +9,14 @@ io.write("
") --]] ?> -") - for k,v in pairs(tags) do - if (myform[v]) and (myform[v]["value"]) then - local val = myform[v] - io.write("\t 0) then - val.class = "error" - io.write(" class='error'") - end - io.write(">" .. val.label .. "\n") - if (viewonly) then - io.write("\t\t
" .. val.value .. "\n") - else - io.write("\t\t
" .. html.form[val.type](val) .. "\n") - end - if (val.descr) and (#val.descr > 0) then io.write("\t\t

" .. string.gsub(val.descr, "\n", "
") .. "

\n") end - if (#val.errtxt > 0) then io.write("\t\t

" .. string.gsub(val.errtxt, "\n", "
") .. "

\n") end - io.write("\t\t
\n") - end - end - io.write("") -end -?> -

SYSTEM INFO

+
+

CONFIGURATION

@@ -46,11 +24,13 @@ displayinfo(myform,tags,"viewonly")

EXPERT CONFIGURATION

FILE DETAILS

+
+

FILE CONTENT

Save and apply above settings

+
+
- -DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(form)) -io.write("
") ---]] -?> diff --git a/lbu-model.lua b/lbu-model.lua index da5e22c..6807e87 100644 --- a/lbu-model.lua +++ b/lbu-model.lua @@ -1,10 +1,12 @@ module (..., package.seeall) +-- Load libraries require("fs") require("format") require("getopts") require("daemoncontrol") +-- Set variables local configfile = "/etc/lbu/lbu.conf" -- ################################################################################ @@ -41,7 +43,6 @@ local function getLbuCommit(flag) local err = {} local ret = "" local f = io.popen("/sbin/lbu commit " .. flag .. " 2>&1", "r") --- local ret = f:read("*a") for line in f:lines() do ret = ret .. line .. "\n" --Look for error messages in output @@ -207,8 +208,6 @@ function getconfig () label="Password when encrypting", }) ----[[ - -- Next section is to print errormessages when configs are wrong if (configopts["LBU_MEDIA"] == "") or (configopts["LBU_MEDIA"] == nil) then config.LBU_MEDIA.errtxt = "'Media' needs to be configured!" @@ -219,7 +218,7 @@ function getconfig () for k,v in pairs(errors) do config["errors"] = v end ---]] + return config end diff --git a/lbu-status-html.lsp b/lbu-status-html.lsp index 99d1dbe..eb1997b 100644 --- a/lbu-status-html.lsp +++ b/lbu-status-html.lsp @@ -1,4 +1,6 @@ - + DEBUGGING

DEBUG INFO: CFE

") @@ -6,55 +8,26 @@ io.write(html.cfe_unpack(form)) io.write("
") --]] ?> -") - for k,v in pairs(tags) do - if (myform[v]) and (myform[v]["value"]) then - local val = myform[v] - io.write("\t 0) then io.write(" class='error'") end - io.write(">" .. val.label .. "\n") - if (viewonly) then - io.write("\t\t
" .. val.value .. "\n") - else - io.write("\t\t
" .. html.form[val.type](val) .. "\n") - end - if (val.descr) and (#val.descr > 0) then io.write("\t\t

" .. string.gsub(val.descr, "\n", "
") .. "

\n") end - if (#val.errtxt > 0) then io.write("\t\t

" .. string.gsub(val.errtxt, "\n", "
") .. "

\n") end - io.write("\t\t
\n") - end - end - io.write("") -end -?>

SYSTEM INFO

+
+

PROGRAM SPECIFIC OPTIONS/INFORMATION

+
+

CHANGES SINCE LAST COMMIT

-
+
Files changed since last commit
-
- - -DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(form)) -io.write("
") ---]] -?> - - +
-- cgit v1.2.3