From 997b4dcd33463841aa8f1ca6d59dea7bc9d38ae9 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 2 Jul 2008 15:56:04 +0000 Subject: Modified core to create model and controller function libraries and some common html views. Moved cfe to a library. Modified redirect_to_referrer function - may break some pages. git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1267 ab2d0c66-481e-0410-8bed-d214d4d58bed --- app/Makefile | 4 ++++ app/acf_cli-controller.lua | 15 +-------------- app/acf_www-controller.lua | 30 ++++++++++++++++-------------- app/expert-html.lsp | 15 +++++++++++++++ app/filedetails-html.lsp | 25 +++++++++++++++++++++++++ app/startstop-html.lsp | 23 +++++++++++++++++++++++ app/status-html.lsp | 12 ++++++++++++ 7 files changed, 96 insertions(+), 28 deletions(-) create mode 100644 app/expert-html.lsp create mode 100644 app/filedetails-html.lsp create mode 100644 app/startstop-html.lsp create mode 100644 app/status-html.lsp (limited to 'app') diff --git a/app/Makefile b/app/Makefile index ef25865..6a3664f 100644 --- a/app/Makefile +++ b/app/Makefile @@ -27,6 +27,10 @@ APP_DIST= \ welcome-html.lsp\ dispatcherror-html.lsp\ exception-html.lsp\ + status-html.lsp\ + startstop-html.lsp\ + filedetails-html.lsp\ + expert-html.lsp\ EXTRA_DIST=README Makefile DISTFILES=$(APP_DIST) $(EXTRA_DIST) diff --git a/app/acf_cli-controller.lua b/app/acf_cli-controller.lua index dad6b85..672af25 100644 --- a/app/acf_cli-controller.lua +++ b/app/acf_cli-controller.lua @@ -16,6 +16,7 @@ mvc.on_load = function (self, parent) -- this sets the package path for us and our children package.path= self.conf.libdir .. "?.lua;" .. package.path + require ("cfe") self.session = {} local x=require("session") @@ -38,20 +39,6 @@ exception_handler = function (self, message ) print(message) end --- create a Configuration Framework Entity (cfe) --- returns a table with at least "value", "type", and "label" -cfe = function ( optiontable ) - optiontable = optiontable or {} - me = { value="", - type="text", - label="" } - for key,value in pairs(optiontable) do - me[key] = value - end - return me -end - - -- syslog something logit = function ( ... ) os.execute ( "logger \"" .. ... .. "\"" ) diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua index 55f529f..6b1bc6e 100644 --- a/app/acf_www-controller.lua +++ b/app/acf_www-controller.lua @@ -234,6 +234,7 @@ mvc.on_load = function (self, parent) -- this sets the package path for us and our children package.path= self.conf.libdir .. "?.lua;" .. package.path + require ("cfe") sessionlib=require ("session") @@ -464,21 +465,22 @@ redirect = function (self, str) error(self.conf) end -redirect_to_referrer = function(self) - error({type="redir_to_referrer"}) -end - --- create a Configuration Framework Entity (cfe) --- returns a table with at least "value", "type", and "label" -cfe = function ( optiontable ) - optiontable = optiontable or {} - me = { value="", - type="text", - label="" } - for key,value in pairs(optiontable) do - me[key] = value +-- If we've done something, cause a redirect to the referring page (assuming it's different) +-- Also handles retrieving the result of a previously redirected action +redirect_to_referrer = function(self, result) + -- If we have a result, then we did something, so we might have to redirect + if result then + local prefix, controller, action = self.parse_path_info(ENV.HTTP_REFERER) + if controller ~= self.conf.controller or action ~= self.conf.action then + self.sessiondata[self.conf.action.."result"] = result + error({type="redir_to_referrer"}) + end + -- If we don't have a result, then we might be a component redirected as above + elseif self.sessiondata[self.conf.action.."result"] then + result = self.sessiondata[self.conf.action.."result"] + self.sessiondata[self.conf.action.."result"] = nil end - return me + return result end -- FIXME - need to think more about this.. diff --git a/app/expert-html.lsp b/app/expert-html.lsp new file mode 100644 index 0000000..c4a76cd --- /dev/null +++ b/app/expert-html.lsp @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/app/filedetails-html.lsp b/app/filedetails-html.lsp new file mode 100644 index 0000000..34c8803 --- /dev/null +++ b/app/filedetails-html.lsp @@ -0,0 +1,25 @@ + + + +

Configuration

+

Expert Configuration

+

File Details

+
+ +
+ +

File Content

+

") ?>

+

") ?>

+
" method="POST"> + +

") ?>

+ +
+
diff --git a/app/startstop-html.lsp b/app/startstop-html.lsp new file mode 100644 index 0000000..c0ead72 --- /dev/null +++ b/app/startstop-html.lsp @@ -0,0 +1,23 @@ + + +

Management

+
+
" method="POST"> +
Program control-panel
+
+> +> +> +
+
+ + +
Previous action result
+
+ +

") ?>

+ +

") ?>

+ +
+
diff --git a/app/status-html.lsp b/app/status-html.lsp new file mode 100644 index 0000000..6cb9eea --- /dev/null +++ b/app/status-html.lsp @@ -0,0 +1,12 @@ + + +

System Info

+
+ +
-- cgit v1.2.3