diff options
author | Ted Trask <ttrask01@yahoo.com> | 2012-02-02 22:19:45 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2012-02-02 22:19:45 +0000 |
commit | c6aaa2c52c4ca3c9c3ecd95ceed29bc75b3be1a3 (patch) | |
tree | 96c67df79fc817e031d724181b1e759acb72f20a /app | |
parent | df80810456f4a13d48eba24bfa1fa79b360c8426 (diff) | |
download | acf-core-c6aaa2c52c4ca3c9c3ecd95ceed29bc75b3be1a3.tar.bz2 acf-core-c6aaa2c52c4ca3c9c3ecd95ceed29bc75b3be1a3.tar.xz |
Changed mvc and www view_resolvers to make auto_view work
Templates (for www) now receive a viewfunc, rather than using viewfile.
Actions without views with viewtype of html, ajax, stream, or serialized will now be displayed using standard code.
Fixed bug in acf-cli parameters messing up action
Diffstat (limited to 'app')
-rw-r--r-- | app/acf_cli-controller.lua | 6 | ||||
-rw-r--r-- | app/acf_www-controller.lua | 39 | ||||
-rw-r--r-- | app/template-ajax.lsp | 6 | ||||
-rw-r--r-- | app/template-html.lsp | 3 | ||||
-rw-r--r-- | app/template-stream.lsp | 2 |
5 files changed, 16 insertions, 40 deletions
diff --git a/app/acf_cli-controller.lua b/app/acf_cli-controller.lua index f3b7d6f..e68dfe9 100644 --- a/app/acf_cli-controller.lua +++ b/app/acf_cli-controller.lua @@ -30,12 +30,6 @@ end mvc.post_exec = function () end -view_resolver = function(self) - return function (viewtable) - print(session.serialize("result", viewtable)) - end -end - exception_handler = function (self, message ) print(session.serialize("exception", message)) parent_exception_handler(self, message) diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua index b4f8e91..462a226 100644 --- a/app/acf_www-controller.lua +++ b/app/acf_www-controller.lua @@ -14,6 +14,7 @@ require "posix" -- We use the parent exception handler in a last-case situation local parent_exception_handler local parent_create_helper_library +local parent_view_resolver local function build_menus(self) m=require("menubuilder") @@ -171,44 +172,27 @@ end -- Our local view resolver called by our dispatch - add the template and skin view_resolver = function(self) - local template, viewname, viewlibrary - local viewtype = self.conf.viewtype or "html" + self.conf.viewtype = self.conf.viewtype or "html" + local viewfunc, viewlibrary, pageinfo = parent_view_resolver(self) + pageinfo.viewfunc = viewfunc -- search for template + local template if self.conf.component ~= true then template = find_template ( self.conf.appdir, self.conf.prefix, - self.conf.controller, self.conf.action, viewtype ) + self.conf.controller, self.conf.action, self.conf.viewtype ) end - - -- search for view - viewname = find_view ( self.conf.appdir, self.conf.prefix, - self.conf.controller, self.conf.action, viewtype ) - local func = function() end + local func = viewfunc if template then - -- We have a template + -- We have a template, use it as the function func = haserl.loadfile (template) - elseif viewname then - -- No template, but have a view - func = haserl.loadfile (viewname) end - - -- create the view helper library - viewlibrary = self:create_helper_library() - - local pageinfo = { viewfile = viewname, - controller = self.conf.controller, - action = self.conf.action, - prefix = self.conf.prefix, - script = self.conf.script, - wwwprefix = self.conf.wwwprefix or "", - staticdir = self.conf.staticdir or "", - skin = self.conf.skin or "", - orig_action = self.conf.orig_action or self.conf.prefix .. self.conf.controller .. "/" .. self.conf.action, - clientdata = self.clientdata, - } + if self.sessiondata.userinfo and self.sessiondata.userinfo.skin and self.sessiondata.userinfo.skin ~= "" then pageinfo.skin = self.sessiondata.userinfo.skin + else + pageinfo.skin = self.conf.skin or "" end return func, viewlibrary, pageinfo, self.sessiondata @@ -235,6 +219,7 @@ mvc.on_load = function (self, parent) parent_exception_handler = parent.exception_handler parent_create_helper_library = parent.create_helper_library + parent_view_resolver = parent.view_resolver sessionlib=require ("session") diff --git a/app/template-ajax.lsp b/app/template-ajax.lsp index 96e6378..bb7fc9f 100644 --- a/app/template-ajax.lsp +++ b/app/template-ajax.lsp @@ -1,8 +1,6 @@ -<% local view, viewlibrary, page_info = ... %> +<% local view, viewlibrary, page_info, session = ... %> <% require("json") %> Status: 200 OK Content-Type: "application/json" <% io.write("\n") %> -<% - print(json.encode(view)) -%> +<% page_info.viewfunc(view, viewlibrary, page_info, session) %> diff --git a/app/template-html.lsp b/app/template-html.lsp index a37a31e..81043b6 100644 --- a/app/template-html.lsp +++ b/app/template-html.lsp @@ -131,8 +131,7 @@ end <div class="leader"> </div> - <% local func = haserl.loadfile(pageinfo.viewfile) %> - <% func (viewtable, viewlibrary, pageinfo, session) %> + <% pageinfo.viewfunc(viewtable, viewlibrary, pageinfo, session) %> <div class="tailer"> </div> diff --git a/app/template-stream.lsp b/app/template-stream.lsp index e8a6e68..17693af 100644 --- a/app/template-stream.lsp +++ b/app/template-stream.lsp @@ -9,4 +9,4 @@ Content-Length: <%= viewtable.length %> Content-Disposition: attachment; filename="<%= viewtable.label %>" <% end %> <% io.write("\n") %> -<%= viewtable.value %> +<% pageinfo.viewfunc(viewtable, viewlibrary, pageinfo, session) %> |