webmcp
view demo-app/app/main/user/show.lua @ 28:ea2e8f3a2776
allow webmcp path to be set in cgi script
this allows another script to include the webmcp script when the cwd is not the cgi-bin. the script needs to set the WEBMCP_PATH variable.
this allows another script to include the webmcp script when the cwd is not the cgi-bin. the script needs to set the WEBMCP_PATH variable.
| author | Daniel Poelzleithner <poelzi@poelzi.org> | 
|---|---|
| date | Sun Sep 19 01:36:08 2010 +0200 (2010-09-19) | 
| parents | 9fdfb27f8e67 | 
| children | 
 line source
     1 local user
     2 local id = param.get_id()
     3 if id then
     4   user = User:by_id(id)
     5 end
     7 if user then
     8   slot.put_into("title", encode.html(_"User"))
     9 else
    10   slot.put_into("title", encode.html(_"New user"))
    11 end
    13 slot.select("actions", function()
    14   ui.link{
    15     content = _"Back",
    16     module = "user"
    17   }
    18   if user then
    19     ui.link{
    20       content = _"Delete",
    21       form_attr = {
    22         onsubmit = "return confirm('" .. _'Are you sure?' .. "');"
    23       },
    24       module  = "user",
    25       action  = "update",
    26       id      = user.id,
    27       params = { delete = true },
    28       routing = {
    29         default = {
    30           mode = "redirect",
    31           module = "user",
    32           view = "index"
    33         }
    34       }
    35     }
    36   end
    37 end)
    39 slot.select("main", function()
    40   ui.form{
    41     attr = { class = "vertical" },
    42     record = user,
    43     module = "user",
    44     action = "update",
    45     id = id,
    46     routing = {
    47       default = {
    48         mode = "redirect",
    49         module = "user",
    50         view = "index"
    51       }
    52     },
    53     content = function()
    54       if id then
    55         ui.field.integer{ label = _"Id", name = "id", readonly = true }
    56       end
    57       ui.field.text{    label = _"Ident",      name = "ident"      }
    58       ui.field.text{    label = _"Password",   name = "password"   }
    59       ui.field.text{    label = _"Name",       name = "name"       }
    60       ui.field.boolean{ label = _"Write Priv", name = "write_priv" }
    61       ui.field.boolean{ label = _"Admin",      name = "admin"      }
    62       ui.submit{ text = _"Save" }
    63     end
    64   }
    65 end)
