Added lovebird.allowhtml option and functionality

This commit is contained in:
rxi 2014-04-11 18:58:58 +01:00
parent df1fcaf9f6
commit 4ffe4920e6

View File

@ -12,15 +12,17 @@ local socket = require "socket"
local lovebird = { _version = "0.0.1" } local lovebird = { _version = "0.0.1" }
lovebird.inited = false lovebird.inited = false
lovebird.buffer = ""
lovebird.lines = {}
lovebird.host = "*" lovebird.host = "*"
lovebird.wrapprint = true lovebird.wrapprint = true
lovebird.timestamp = true lovebird.timestamp = true
lovebird.allowhtml = true
lovebird.port = 8000 lovebird.port = 8000
lovebird.whitelist = { "127.0.0.1", "localhost" } lovebird.whitelist = { "127.0.0.1", "localhost" }
lovebird.maxlines = 200 lovebird.maxlines = 200
lovebird.refreshrate = .5 lovebird.refreshrate = .5
lovebird.buffer = ""
lovebird.lines = {}
lovebird.page = [[ lovebird.page = [[
<!doctype html> <!doctype html>
@ -206,6 +208,9 @@ end
function lovebird.print(...) function lovebird.print(...)
local str = table.concat(map({...}, tostring), " ") local str = table.concat(map({...}, tostring), " ")
if not lovebird.allowhtml then
str = str:gsub("<", "&lt;")
end
if lovebird.timestamp then if lovebird.timestamp then
str = os.date('<span class="timestamp">[%H:%M:%S]</span> ') .. str str = os.date('<span class="timestamp">[%H:%M:%S]</span> ') .. str
end end