summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xapp/acf-util/password-html.lsp4
-rwxr-xr-xapp/acf-util/password-status-html.lsp4
-rw-r--r--app/acf-util/roles-editrole-html.lsp4
-rw-r--r--app/acf_www-controller.lua67
-rw-r--r--app/template-html.lsp17
5 files changed, 45 insertions, 51 deletions
diff --git a/app/acf-util/password-html.lsp b/app/acf-util/password-html.lsp
index 9de2d4f..8b6d563 100755
--- a/app/acf-util/password-html.lsp
+++ b/app/acf-util/password-html.lsp
@@ -1,4 +1,4 @@
-<? local form = ... ?>
+<? local form, viewlibrary, pageinfo = ... ?>
<? require("viewfunctions") ?>
<?
--[[ DEBUG INFORMATION
@@ -18,7 +18,7 @@ io.write("</span>")
form.value.password_confirm.type = "password"
end
-- If not in newuser action, disable userid
- if nil == string.find(ENV["PATH_INFO"], "/newuser") then
+ if pageinfo.action ~= "newuser" then
form.value.userid.contenteditable = false
end
local order = { "userid", "username", "roles", "password", "password_confirm" }
diff --git a/app/acf-util/password-status-html.lsp b/app/acf-util/password-status-html.lsp
index f544884..0db0256 100755
--- a/app/acf-util/password-status-html.lsp
+++ b/app/acf-util/password-status-html.lsp
@@ -1,4 +1,4 @@
-<? local form = ... ?>
+<? local form, viewlibrary, pageinfo = ... ?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -31,7 +31,7 @@ io.write("</span>")
<TD>
[<A HREF='edituser?userid=<?= name ?>'>Edit this account</A>]
[<A HREF='deleteuser?userid=<?= name ?>'>Delete this account</A>]
- [<A HREF='<?= ENV.SCRIPT_NAME ?>/acf-util/roles/viewuserroles?userid=<?= name ?>'>View roles for this account</A>]
+ [<A HREF='<?= pageinfo.appuri ?>/acf-util/roles/viewuserroles?userid=<?= name ?>'>View roles for this account</A>]
</TD>
</TR>
</TABLE></DD>
diff --git a/app/acf-util/roles-editrole-html.lsp b/app/acf-util/roles-editrole-html.lsp
index d96ac56..2094b54 100644
--- a/app/acf-util/roles-editrole-html.lsp
+++ b/app/acf-util/roles-editrole-html.lsp
@@ -1,4 +1,4 @@
-<? local form= ... ?>
+<? local form, viewtable, pageinfo = ... ?>
<? --[[
io.write(html.cfe_unpack(form))
io.write(html.cfe_unpack(FORM))
@@ -11,7 +11,7 @@
form.action = ""
form.submit = "Save"
-- If editing existing role, disable role
- if nil == string.find(ENV.PATH_INFO, "/newrole") then
+ if pageinfo.action ~= "newrole" then
form.value.role.contenteditable = false
end
local order = { "role", "permissions" }
diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua
index 55602fa..c9405c2 100644
--- a/app/acf_www-controller.lua
+++ b/app/acf_www-controller.lua
@@ -118,7 +118,7 @@ local find_view = function ( appdir, prefix, controller, action, viewtype )
end
-- This function is made available within the view to allow loading of components
-local dispatch_component = function(str, clientdata)
+local dispatch_component = function(str, clientdata, suppress_view)
-- Before we call dispatch, we have to set up conf and clientdata like it was really called for this component
self = APP
local tempconf = self.conf
@@ -127,6 +127,7 @@ local dispatch_component = function(str, clientdata)
self.conf[x] = y
end
self.conf.component = true
+ self.conf.suppress_view = suppress_view
local tempclientdata = self.clientdata
self.clientdata = clientdata or {}
self.clientdata.sessionid = tempclientdata.sessionid
@@ -134,13 +135,15 @@ local dispatch_component = function(str, clientdata)
local prefix, controller, action = self.parse_path_info("/" .. str)
if prefix == "/" then prefix = self.conf.prefix end
if controller == "" then controller = self.conf.controller end
- self.dispatch(self, prefix, controller, action)
+ local viewtable = self.dispatch(self, prefix, controller, action)
-- Revert to the old conf and clientdata
self.conf = nil
if not (self.conf) then self.conf = tempconf end
self.clientdata = nil
if not (self.clientdata) then self.clientdata = tempclientdata end
+
+ return viewtable
end
local create_helper_library = function ( self )
@@ -172,50 +175,27 @@ local view_resolver = function(self)
viewname = find_view ( self.conf.appdir, self.conf.prefix,
self.conf.controller, self.conf.action, viewtype )
+ local func = function() end
+ if template then
+ -- We have a template
+ func = haserl.loadfile (template)
+ elseif viewname then
+ -- No template, but have a view
+ func = haserl.loadfile (viewname)
+ end
+
-- create the view helper library
viewlibrary = create_helper_library ( self )
- -- ***************************************************
- -- This is how to call another controller (APP or self
- -- can be used... m will contain worker and model,
- -- with conf, and other "missing" parts pointing back
- -- to APP or self
- -- ***************************************************
-
- local m,worker_loaded,model_loaded = self:new("alpine-baselayout/hostname")
-
- -- If the worker and model loaded correctly, then
- -- use the sub-controller
- local h
- if worker_loaded and model_loaded then
- h = m.worker.read(m)
- else
- h = {}
- h.hostname = { value = "unknown" }
- end
-
local pageinfo = { viewfile = viewname,
- controller = m.conf.controller,
- -- ^^^ see.. m.conf doesnt exist - but it works
- -- the inheritance means self.conf is used instead
+ controller = self.conf.controller,
action = self.conf.action,
- hostname = h.hostname.value,
- -- alpineversion = alpineversion.worker.read(alpineversion),
prefix = self.conf.prefix,
- script = self.conf.appuri,
+ appuri = self.conf.appuri,
+ appname = self.conf.appname,
skin = self.conf.skin or ""
}
- m:destroy()
-
- local func = function() end
- if template then
- -- We have a template
- func = haserl.loadfile (template)
- elseif viewname then
- -- No template, but have a view
- func = haserl.loadfile (viewname)
- end
return func, viewlibrary, pageinfo, self.sessiondata
end
@@ -344,6 +324,7 @@ end
-- pass more parameters to the view
dispatch = function (self, userprefix, userctlr, useraction)
local controller = nil
+ local viewtable
local success, err = xpcall ( function ()
if userprefix == nil then
@@ -426,21 +407,23 @@ dispatch = function (self, userprefix, userctlr, useraction)
controller.worker.mvc.pre_exec ( controller )
end
- -- run the action
- local viewtable = controller.worker[action](controller)
+ -- run the action
+ viewtable = controller.worker[action](controller)
-- run the post_exec code
if type(controller.worker.mvc.post_exec) == "function" then
controller.worker.mvc.post_exec ( controller )
end
- local viewfunc, p1, p2, p3 = view_resolver(self)
+ if not self.conf.suppress_view then
+ local viewfunc, p1, p2, p3 = view_resolver(self)
+ viewfunc (viewtable, p1, p2, p3)
+ end
-- we're done with the controller, destroy it
controller:destroy()
controller = nil
- viewfunc (viewtable, p1, p2, p3)
end,
self:soft_traceback(message)
)
@@ -458,6 +441,8 @@ dispatch = function (self, userprefix, userctlr, useraction)
handler:exception_handler(err)
end
end
+
+ return viewtable
end
-- Cause a redirect to specified (or default) action
diff --git a/app/template-html.lsp b/app/template-html.lsp
index a60f2b5..307807f 100644
--- a/app/template-html.lsp
+++ b/app/template-html.lsp
@@ -13,7 +13,16 @@ Content-Type: text/html
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title><?= pageinfo.hostname .. " - " .. pageinfo.controller .. "->" .. pageinfo.action ?></title>
+<?
+local hostname = ""
+if viewlibrary and viewlibrary.dispatch_component then
+ local result = viewlibrary.dispatch_component("alpine-baselayout/hostname/read", nil, true)
+ if result and result.value then
+ hostname = result.value
+ end
+end
+?>
+<title><?= hostname .. " - " .. pageinfo.controller .. "->" .. pageinfo.action ?></title>
<link rel="stylesheet" type="text/css" href="/static/reset.css">
<link rel="stylesheet" type="text/css" href="<?= "/"..pageinfo.skin.."/"..pageinfo.skin..".css" ?>">
<!--[if IE]>
@@ -30,12 +39,12 @@ Content-Type: text/html
<div id="logo">
<div class="leader"></div>
<h1>AlpineLinux</h1>
- <p><?= pageinfo.hostname or "unknown hostname" ?></p>
+ <p><?= hostname or "unknown hostname" ?></p>
<div class="tailer"></div>
</div>
<span class="mute">
<p>
- <? local ctlr = pageinfo.script .. "/acf-util/logon/"
+ <? local ctlr = pageinfo.appuri .. "/acf-util/logon/"
if session.userinfo and session.userinfo.userid then
io.write ( string.format("\t\t\t\t\t\t<a href=\"%s\">Log out as '" .. session.userinfo.userid .. "'</a>\n", ctlr .. "logout" ) )
@@ -72,7 +81,7 @@ Content-Type: text/html
class=""
end
io.write (string.format("\t\t\t\t\t\t<li %s><a href=\"%s%s/%s/%s\">%s</a></li>\n",
- class,ENV.SCRIPT_NAME,group.prefix, group.controller, group.tabs[1].action, group.name ))
+ class,pageinfo.appuri,group.prefix, group.controller, group.tabs[1].action, group.name ))
end
io.write ( "\t\t\t\t\t</ul>" )
end