diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-11-16 09:00:13 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-11-16 09:00:13 +0000 |
commit | b3a7f0d7db3f16db91e61bd03346316d0c0aaebb (patch) | |
tree | 39a700aa4daed2df157fe4d92998e859aa32cf8c | |
parent | 8a671177667ca794592155a3d8d7687f5d02496f (diff) | |
download | acf-core-b3a7f0d7db3f16db91e61bd03346316d0c0aaebb.tar.bz2 acf-core-b3a7f0d7db3f16db91e61bd03346316d0c0aaebb.tar.xz |
Added template-ajax.lsp and made www controller respect passed in viewtype.
-rw-r--r-- | app/Makefile | 1 | ||||
-rw-r--r-- | app/acf_www-controller.lua | 14 | ||||
-rw-r--r-- | app/template-ajax.lsp | 8 |
3 files changed, 22 insertions, 1 deletions
diff --git a/app/Makefile b/app/Makefile index 502d850..68c21de 100644 --- a/app/Makefile +++ b/app/Makefile @@ -27,6 +27,7 @@ APP_DIST= \ acf_www-controller.lua\ acf_cli-controller.lua\ menuhints.menu\ + template-ajax.lsp\ template-html.lsp\ template-stream.lsp\ dispatcherror-html.lsp\ diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua index ee41bb9..12c80ea 100644 --- a/app/acf_www-controller.lua +++ b/app/acf_www-controller.lua @@ -136,7 +136,6 @@ local find_view = function ( appdir, prefix, controller, action, viewtype ) end local has_view = function(self) - require("fs") for p in string.gmatch(self.conf.appdir, "[^,]+") do local file = posix.stat(p .. self.conf.prefix .. self.conf.controller .. "-" .. self.conf.action .. "-" .. (self.conf.viewtype or "html") .. ".lsp", "type") if file == "regular" or file == "link" then return true end @@ -450,6 +449,13 @@ dispatch = function (self, userprefix, userctlr, useraction) redirect(self, self.conf.action) -- controller and prefix already in self.conf end + -- Before we start checking for views, set the viewtype + if self.clientdata.viewtype then + self.conf.viewtype = self.clientdata.viewtype + else + self.conf.viewtype = "html" + end + -- If the controller or action are missing, display an error view if nil == controller then -- If we have a view w/o an action, just display the view (passing in the clientdata) @@ -507,6 +513,9 @@ end -- We use the self.conf table because it already has prefix,controller,etc -- The actual redirection is defined in exception_handler above redirect = function (self, str, result) + if self.conf.viewtype ~= "html" then + return + end if result then self.sessiondata[self.conf.action.."result"] = result end @@ -525,6 +534,9 @@ end -- 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 self.conf.viewtype ~= "html" then + return result + end if result and not self.conf.component then -- If we have a result, then we did something, so we might have to redirect if not ENV.HTTP_REFERER then diff --git a/app/template-ajax.lsp b/app/template-ajax.lsp new file mode 100644 index 0000000..96e6378 --- /dev/null +++ b/app/template-ajax.lsp @@ -0,0 +1,8 @@ +<% local view, viewlibrary, page_info = ... %> +<% require("json") %> +Status: 200 OK +Content-Type: "application/json" +<% io.write("\n") %> +<% + print(json.encode(view)) +%> |