diff options
Diffstat (limited to 'app/logfiles')
-rw-r--r-- | app/logfiles/logfiles-controller.lua | 33 | ||||
-rw-r--r-- | app/logfiles/logfiles-model.lua | 22 | ||||
-rw-r--r-- | app/logfiles/logfiles-read-html.lsp | 8 | ||||
-rw-r--r-- | app/logfiles/logfiles.menu | 2 |
4 files changed, 65 insertions, 0 deletions
diff --git a/app/logfiles/logfiles-controller.lua b/app/logfiles/logfiles-controller.lua new file mode 100644 index 0000000..1770754 --- /dev/null +++ b/app/logfiles/logfiles-controller.lua @@ -0,0 +1,33 @@ +module (..., package.seeall) + +-- Cause an http redirect to our "read" action +-- We use the self.conf table because it already has prefix,controller,etc +-- The redir code is defined in the application error handler (acf-controller) +local list_redir = function (self) + self.conf.action = "read" + self.conf.type = "redir" + error (self.conf) +end + +mvc={} +mvc.on_load = function(self, parent) + if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then + self.worker[self.conf.action] = list_redir(self) + end +end + +-- Public methods + +read = function (self ) + return ({logfile = self.model:get("/var/log/mini_httpd.log")} ) +end + +--update = function (self) +-- return nil +--end + +--delete = function (self) +-- return nil +--end + +--create = update diff --git a/app/logfiles/logfiles-model.lua b/app/logfiles/logfiles-model.lua new file mode 100644 index 0000000..6198107 --- /dev/null +++ b/app/logfiles/logfiles-model.lua @@ -0,0 +1,22 @@ +module (..., package.seeall) + +-- no initializer in model - use controller.init for that + +local function read_file ( path ) + local file = io.open(path) + if ( file ) then + local f = file:read("*a") or "unknown" + file:close() + return f + else + return "Cant find '" .. path .. "'" + end +end + +get = function (self,path) + local file_content = {} + file_content = cfe{value=read_file(path), name=path} + file_name = cfe{value=path, name=file_name} + return file_content, file_name +end + diff --git a/app/logfiles/logfiles-read-html.lsp b/app/logfiles/logfiles-read-html.lsp new file mode 100644 index 0000000..b8864f8 --- /dev/null +++ b/app/logfiles/logfiles-read-html.lsp @@ -0,0 +1,8 @@ +<? local view = ... ?> +<html> +<body> +<h1>Logfile</h1> +<dt><?= view.logfile.name ?></dt> +<dd><textarea name="<?= view.logfile.name ?>"><?= view.logfile.value ?></textarea></dd> +</body> +</html> diff --git a/app/logfiles/logfiles.menu b/app/logfiles/logfiles.menu new file mode 100644 index 0000000..f775cfc --- /dev/null +++ b/app/logfiles/logfiles.menu @@ -0,0 +1,2 @@ +#CAT GROUP/DESC TAB ACTION +General Logfiles dlogfiles read |