diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-04-22 15:25:14 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-04-22 15:25:14 +0000 |
commit | 80dcbfa5a0af2a90e0e0fada05d67fef0cc97c3d (patch) | |
tree | d64e74bfa77be3ba6f96212ce3b1ece834198b76 /apk-controller.lua | |
download | acf-apk-tools-80dcbfa5a0af2a90e0e0fada05d67fef0cc97c3d.tar.bz2 acf-apk-tools-80dcbfa5a0af2a90e0e0fada05d67fef0cc97c3d.tar.xz |
Addingv0.0.1
git-svn-id: svn://svn.alpinelinux.org/acf/apk/trunk@1032 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'apk-controller.lua')
-rw-r--r-- | apk-controller.lua | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/apk-controller.lua b/apk-controller.lua new file mode 100644 index 0000000..1661bba --- /dev/null +++ b/apk-controller.lua @@ -0,0 +1,55 @@ +-- the interfaces controller + +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 = "loaded" + self.conf.type = "redir" + error (self.conf) +end + +mvc= {} +mvc.on_load = function(self, parent) + self.conf.default_action = "loaded" +end + +read = function(self) + local loaded, available = self.model.get_packages() + --local loaded = self.model.get_loaded_packages() + --local available = self.model.get_available_packages() + return ( { loaded = loaded, available=available, self=self } ) +end + + +loaded = function(self) + -- Get command result out of session data + local cmdresult = self.sessiondata.cmdresult + self.sessiondata.cmdresult = nil + local loaded = self.model.get_loaded_packages() + return ( { loaded = loaded, cmdresult = cmdresult } ) +end + +available = function(self) + local available = self.model.get_available_packages() + return ( { available=available } ) +end + +delete = function(self) + local package = self.clientdata.package or "" + local cmdresult = self.model.delete_package(package, self.sessiondata) + -- Put the result in session data and redirect + self.sessiondata.cmdresult = cmdresult + list_redir(self) +end + +install = function(self) + local package = self.clientdata.package or "" + local cmdresult = self.model.install_package(package, self.sessiondata) + -- Put the result in session data and redirect + self.sessiondata.cmdresult = cmdresult + list_redir(self) +end + |