Fixed env.json page's indentation, removed default status

This commit is contained in:
rxi
2014-04-12 17:28:21 +01:00
parent d481a3ff95
commit a670e7da44

View File

@@ -139,7 +139,7 @@ end
<a href="https://github.com/rxi/lovebird">lovebird</a> <a href="https://github.com/rxi/lovebird">lovebird</a>
<span id="version"><?lua echo(lovebird._version) ?></span> <span id="version"><?lua echo(lovebird._version) ?></span>
</div> </div>
<div id="status">connected &#9679;</div> <div id="status"></div>
</div> </div>
<div id="main"> <div id="main">
<div id="console" class="greybordered"> <div id="console" class="greybordered">
@@ -267,44 +267,44 @@ lovebird.pages["buffer"] = [[ <?lua echo(lovebird.buffer) ?> ]]
lovebird.pages["env.json"] = [[ lovebird.pages["env.json"] = [[
<?lua <?lua
local t = _G local t = _G
local p = req.parsedurl.query.p or "" local p = req.parsedurl.query.p or ""
p = p:gsub("%.+", "%."):match("^[%.]*(.*)[%.]*$") p = p:gsub("%.+", "%."):match("^[%.]*(.*)[%.]*$")
if p ~= "" then if p ~= "" then
for x in p:gmatch("[^%.]+") do for x in p:gmatch("[^%.]+") do
t = t[x] t = t[x]
-- Return early if path does not exist -- Return early if path does not exist
if type(t) ~= "table" then if type(t) ~= "table" then
echo('{ "valid": false, "path": ' .. string.format("%q", p) .. ' }') echo('{ "valid": false, "path": ' .. string.format("%q", p) .. ' }')
return return
end
end end
end end
?> end
{ ?>
"valid": true, {
"path": "<?lua echo(p) ?>", "valid": true,
"vars": [ "path": "<?lua echo(p) ?>",
<?lua "vars": [
local keys = {} <?lua
for k in pairs(t) do table.insert(keys, k) end local keys = {}
table.sort(keys) for k in pairs(t) do table.insert(keys, k) end
for _, k in pairs(keys) do table.sort(keys)
local v = t[k] for _, k in pairs(keys) do
?> local v = t[k]
{ ?>
"key": "<?lua echo(k) ?>", {
"value": <?lua echo( "key": "<?lua echo(k) ?>",
string.format("%q", "value": <?lua echo(
lovebird.truncate( string.format("%q",
lovebird.htmlescape( lovebird.truncate(
tostring(v)), 26))) ?>, lovebird.htmlescape(
"type": "<?lua echo(type(v)) ?>", tostring(v)), 26))) ?>,
}, "type": "<?lua echo(type(v)) ?>",
<?lua end ?> },
] <?lua end ?>
} ]
}
]] ]]