Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(ES integration), refactor(ES views).
Add two space indentation, add more docs,
- Loading branch information
Nikhil R
committed
Aug 15, 2016
1 parent
7c2949a
commit 2c8be47
Showing
3 changed files
with
69 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,58 @@ | ||
<?lua local form = require "sailor.form" ?> | ||
|
||
<form method="post"> | ||
<h4>Search box</h4> | ||
<input type="text" id="search" name="search" /> | ||
<input type="submit" class="btn btn-primary btn-md"/> | ||
</form> | ||
<?lua | ||
function table.val_to_str ( v ) | ||
if "string" == type( v ) then | ||
v = string.gsub( v, "\n", "\\n" ) | ||
if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then | ||
return "'" .. v .. "'" | ||
end | ||
return '"' .. string.gsub(v,'"', '\\"' ) .. '"' | ||
else | ||
return "table" == type( v ) and table.tostring( v ) or | ||
tostring( v ) | ||
end | ||
end | ||
|
||
function table.key_to_str ( k ) | ||
if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then | ||
return k | ||
else | ||
return "[" .. table.val_to_str( k ) .. "]" | ||
end | ||
end | ||
|
||
function table.tostring( tbl ) | ||
local result, done = {}, {} | ||
for k, v in ipairs( tbl ) do | ||
table.insert( result, table.val_to_str( v ) ) | ||
done[ k ] = true | ||
end | ||
for k, v in pairs( tbl ) do | ||
if not done[ k ] then | ||
table.insert( result, | ||
table.key_to_str( k ) .. "=" .. table.val_to_str( v ) ) | ||
end | ||
end | ||
return "{" .. table.concat( result, "," ) .. "}" | ||
end | ||
if type(msg) == "table" then | ||
page:print(table.tostring(msg)) | ||
else | ||
page:print(msg) | ||
end | ||
?> | ||
<h4>Search box</h4> | ||
<input type="text" id="search" name="search" /> | ||
<input type="submit" class="btn btn-primary btn-md"/> | ||
</form> | ||
|
||
<?lua | ||
|
||
function table.val_to_str ( v ) | ||
|
||
if "string" == type( v ) then | ||
v = string.gsub( v, "\n", "\\n" ) | ||
|
||
if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then | ||
return "'" .. v .. "'" | ||
end | ||
return '"' .. string.gsub(v,'"', '\\"' ) .. '"' | ||
else | ||
return "table" == type( v ) and table.tostring( v ) or | ||
tostring( v ) | ||
end | ||
|
||
end | ||
|
||
function table.key_to_str ( k ) | ||
if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then | ||
return k | ||
else | ||
return "[" .. table.val_to_str( k ) .. "]" | ||
end | ||
end | ||
|
||
function table.tostring( tbl ) | ||
local result, done = {}, {} | ||
for k, v in ipairs( tbl ) do | ||
table.insert( result, table.val_to_str( v ) ) | ||
done[ k ] = true | ||
end | ||
|
||
for k, v in pairs( tbl ) do | ||
if not done[ k ] then | ||
table.insert( result, | ||
table.key_to_str( k ) .. "=" .. table.val_to_str( v ) ) | ||
end | ||
end | ||
|
||
return "{" .. table.concat( result, "," ) .. "}" | ||
end | ||
|
||
if type(msg) == "table" then | ||
page:print(table.tostring(msg)) | ||
else | ||
page:print(msg) | ||
end | ||
|
||
?> |