summaryrefslogtreecommitdiffstats
path: root/shorewall-restart-html.lsp
blob: 53d81b7f0c7e287a20cff56e0641234b8ed5c34e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?
local view = ...

local function packURL(script, prefix, controller, action, extra)
    ret = script .. "/" .. prefix .. controller .. "/" .. action
    sep = '?'
    for k,v in pairs(extra) do
        ret = ret .. sep .. k .. '=' .. v
        sep = '&'
    end
    return ret
end

--[[
view
  script, prefix, controller
  action[]
    name, script, prefix, controller
    section
    id
    label
    disabled
  active
    id
    action
  title
  text[]
    label
    content
--]]
?><h1><?= view.title
?></h1><?

--Status Block
    for i,item in ipairs(view.note or {}) do
        ?><p class='error'><?= item.content ?></p><?
    end

local section = ""
for i,item in ipairs(view.action) do
    if section ~= item.section then
	section = item.section
	?><h2><?= section ?></h2><?
    end
    if item.disabled then
        ?><i><?= item.label or item.name ?></i><?
    else
        ?><?= html.form.start {   
            method="POST",
            action = packURL(item.script or view.script,
                item.prefix or view.prefix,
                item.controller or view.controller,
                item.name, {})
        } ?><?= html.form.hidden { name="id", value=item.id } ?><?
        local label = (item.label or item.name)
        if item.id == view.active.id and item.name == view.active.action then
    	    label = '['..label..']'
        end
        ?><?= html.form.submit {
	    name = item.name, value = label
	} ?><?= html.form.stop() ?><?
    end
end
for i,item in ipairs(view.text) do
    if item.label then
        ?><h2><?= item.label ?></h2><?
    end
    ?><pre><?= item.content ?></pre><?
end
-- vim: set filetype=lua :
?>