From 64ed4dd6998ab8cbfe5b4042e9c91fe86a49c551 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Fri, 25 Jan 2008 15:42:57 +0000 Subject: 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 --- Makefile | 1 + lbu-controller.lua | 14 ++++++++++++++ lbu-expert-html.lsp | 45 +++++++++++++++++++++++++++++++++++++++++++++ lbu-model.lua | 17 +++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 lbu-expert-html.lsp 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 @@ + + +

SYSTEM INFO

+ +
+
Program status
+
+ +
Program version
+
+
+ +

CONFIGURATION

+

Expert config

+

File details

+ +
+
File name
+
+ +
File size
+
+ +
Last modified
+
+
+ +

File content

+ +
+ + + +

Save and apply above settings

+
+
Apply settings
+
+
+ + 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 -- cgit v1.2.3