From 99f69b51db21781c3775956cb03acb64b3cb7477 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Fri, 18 Oct 2013 19:58:50 +0000 Subject: 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. --- asterisk-controller.lua | 15 ++++++++------- asterisk-model.lua | 16 +++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/asterisk-controller.lua b/asterisk-controller.lua index 404a141..0f04d00 100644 --- a/asterisk-controller.lua +++ b/asterisk-controller.lua @@ -1,21 +1,22 @@ -- the squid controller +local mymodule = {} -module (..., package.seeall) +mymodule.default_action = "status" -default_action = "status" - -status = function( self ) +mymodule.status = function( self ) return self.model.get_status() end -startstop = function( self ) +mymodule.startstop = function( self ) return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata) end -listfiles = function( self ) +mymodule.listfiles = function( self ) return self.model.list_files() end -edit = function( self ) +mymodule.edit = function( self ) return self.handle_form(self, self.model.get_file, self.model.update_file, self.clientdata, "Save", "Edit File", "File Saved") end + +return mymodule diff --git a/asterisk-model.lua b/asterisk-model.lua index 5ce9dd4..6858e6f 100644 --- a/asterisk-model.lua +++ b/asterisk-model.lua @@ -1,5 +1,5 @@ -- Copyright(c) 2007 A. Brodmann - Licensed under terms of GPL2 -module (..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -24,23 +24,23 @@ end -- ################################################################################ -- PUBLIC FUNCTIONS -get_status = function() +mymodule.get_status = function() return modelfunctions.getstatus(processname, packagename, "Asterisk Status") end -function get_startstop(self, clientdata) +mymodule.get_startstop = function(self, clientdata) return modelfunctions.get_startstop(processname) end -function startstop_service(self, startstop, action) +mymodule.startstop_service = function(self, startstop, action) return modelfunctions.startstop_service(startstop, action) end -get_file = function(self, clientdata) +mymodule.get_file = function(self, clientdata) return modelfunctions.getfiledetails(clientdata.filename, is_valid_filename) end -update_file = function(self, filedetails) +mymodule.update_file = function(self, filedetails) local ret = modelfunctions.setfiledetails(self, filedetails, is_valid_filename) if not ret.errtxt then posix.chmod(filedetails.value.filename.value, "rw-------") @@ -49,7 +49,7 @@ update_file = function(self, filedetails) return ret end -list_files = function() +mymodule.list_files = function() local retval = {} for file in fs.find(null, baseurl) do local details = fs.stat(file) @@ -61,3 +61,5 @@ list_files = function() table.sort(retval, function(a,b) return a.filename < b.filename end) return cfe({ type="structure", value=retval, label="List of Asterisk files" }) end + +return mymodule -- cgit v1.2.3