File: overview.lp

package info (click to toggle)
lua-cgi 6.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 956 kB
  • sloc: javascript: 2,216; makefile: 25
file content (68 lines) | stat: -rwxr-xr-x 1,795 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env cgilua.cgi
<?lua
-- Tries to load known libraries
for _, t in ipairs { "lxp", "luasql.postgres", "luasql.mysql", "luasql.oci8", "luasql.sqlite", "luasql.odbc", "socket", "xmlrpc", "soap", "lualdap", "logging", "md5", "zip", "stable", "copas", } do
	local ok, m = pcall (require, t)
	if ok then
		_G[t] = m
	end
end

libraries = { "lxp", "luasql", "socket", "xmlrpc", "soap", "lualdap", "logging", "md5", "zip", "stable", "copas", }

local colors = { "#999999", "#CCCCCC", "#FFFFFF", }
local i = 0
function color () i = math.fmod (i + 1, 3) return colors[i + 1] end

function pack_name (p) return string.gsub (p, "^([^.]+).-", "%1") end

function idx (t, f) return _G[t][f] or _G[t]["_"..f] or "" end
?>
<html>
<head><title>CGILua installation overview</title></head>

<body bgcolor="#FFFFFF">
<h1>CGILua installation overview</h1>

<table>
  <tr>
    <th bgcolor="#999999">Version
    <th bgcolor="#999999">Copyright
    <th bgcolor="#999999">Description
  </tr>
<?lua
local support = {
	{ "Lua", "_VERSION" },
	--{ "compat-5.1", "_COMPAT51" },
}
for _, l in ipairs (support) do bg = color()
?>
  <tr>
    <td bgcolor = "<%= bg %>"><%= tostring(_G[l[2]]) %>
    <td bgcolor = "<%= bg %>">
    <td bgcolor = "<%= bg %>">
  </tr>
<? end ?>
  <tr><td colspan="4"></tr>
<?lua
local pack = {}
for i, p in ipairs (libraries) do
	local s = _G[p]
	local n = pack_name(p)
	if type(_G[n]) == "table" and _G[n]._VERSION then
		pack[n] = true
		table.insert (pack, n)
	end
end
table.sort (pack)
for _, p in ipairs (pack) do bg = color() ?>
  <tr>
    <td bgcolor = "<%= bg %>"><%= idx(p,"VERSION") %>
    <td bgcolor = "<%= bg %>"><small><%= idx(p,"COPYRIGHT") %></small>
    <td bgcolor = "<%= bg %>"><small><%= idx(p,"DESCRIPTION") %></small>
  </tr>
<?lua end ?>
</table>

</body>
</html>