diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-10-17 19:07:53 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-10-17 19:07:53 +0000 |
commit | 2ece009273252437281c8cc0b84ba2ec49e5d07c (patch) | |
tree | 1c082ee4891a4717f2fea09f0df4a8946d9fdb41 /logfiles-model.lua | |
parent | 0537a242f9709271454252e7897a7709144a3b02 (diff) | |
download | acf-alpine-baselayout-2ece009273252437281c8cc0b84ba2ec49e5d07c.tar.bz2 acf-alpine-baselayout-2ece009273252437281c8cc0b84ba2ec49e5d07c.tar.xz |
Remove all calls to 'module' in preparation for move to Lua 5.2
Use mymodule parameter for module definition.
This was also helpful in revealing places where the code relied on the global environment.
Diffstat (limited to 'logfiles-model.lua')
-rw-r--r-- | logfiles-model.lua | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/logfiles-model.lua b/logfiles-model.lua index a43de6c..95bcb19 100644 --- a/logfiles-model.lua +++ b/logfiles-model.lua @@ -1,5 +1,5 @@ -- acf model for displaying logfiles -module (..., package.seeall) +local mymodule = {} posix = require("posix") modelfunctions = require("modelfunctions") @@ -80,9 +80,9 @@ local do_grep = function(filecontent, grep) end end -get_filedetails = function (path, grep) +mymodule.get_filedetails = function (path, grep) local success = false - local available_files = get() + local available_files = mymodule.get() for i,file in ipairs(available_files.value) do if file.value.filename.value == path then success = true @@ -106,14 +106,14 @@ get_filedetails = function (path, grep) return filedetails end -tail = function(path, offset, grep) +mymodule.tail = function(path, offset, grep) local filename = cfe({ value=path, label="File name", errtxt="File not found" }) local filesize = cfe({ value="0", label="File size" }) local filecontent = cfe({ type="longtext", label="File content" }) local fileoffset = cfe({ value="0", label="File offset" }) local filegrep = cfe({ value=grep or "", label="Grep" }) - local available_files = get() + local available_files = mymodule.get() for i,file in ipairs(available_files.value) do if ( file.value.filename.value == path ) then filename.errtxt = nil @@ -141,15 +141,15 @@ tail = function(path, offset, grep) return cfe({ type="group", value={filename=filename, filecontent=filecontent, filesize=filesize, fileoffset=fileoffset, grep=filegrep}, label="Tail Config file details" }) end -get = function () +mymodule.get = function () -- These folders (and their subfolers) are going to be listed return list_files( "/var/log", "/tmp/squid/log" ) end -get_delete = function() +mymodule.get_delete = function() local filename = cfe({ type="select", label="File name", option={} }) -- Get a list of files that could be deleted - local available_files = get() + local available_files = mymodule.get() for i,file in ipairs(available_files.value) do filename.option[#filename.option+1] = file.value.filename.value end @@ -158,7 +158,7 @@ get_delete = function() end -- Function to check if a file is deletable, and if it is, then delete it. -delete = function (self, filetodelete) +mymodule.delete = function (self, filetodelete) local success = modelfunctions.validateselect(filetodelete.value.filename) if success then @@ -182,9 +182,9 @@ delete = function (self, filetodelete) if not success then filetodelete.errtxt = "Failed to delete file" -self.logevent(filetodelete.value.filename.errtxt) end return filetodelete end +return mymodule |