Added charset headers
This commit is contained in:
parent
1638d8aa8b
commit
32e4be15b0
1 changed files with 8 additions and 8 deletions
10
vrel.lua
10
vrel.lua
|
|
@ -232,8 +232,7 @@ httpd.start(config.address or "*", config.port or 8155, { -- Pages
|
||||||
#topbar input[name=syntax] { width: 5.5em; }
|
#topbar input[name=syntax] { width: 5.5em; }
|
||||||
#topbar input[type=submit] { cursor: pointer; width: 10em; }
|
#topbar input[type=submit] { cursor: pointer; width: 10em; }
|
||||||
#topbar #vrel { font-size: 1.5em; float: right; }
|
#topbar #vrel { font-size: 1.5em; float: right; }
|
||||||
</style></head><body>
|
</style></head><body><form method=POST action=/p><input name=web type=hidden value=on>
|
||||||
<form method=POST action=/p><input name=web type=hidden value=on>
|
|
||||||
<div id=topbar><span id=controls>expires in <input name=lifetime type=number min=1 max=]]..math.floor(maxLifetime/3600)..[[ value=]]..math.floor(defaultLifetime/3600)..
|
<div id=topbar><span id=controls>expires in <input name=lifetime type=number min=1 max=]]..math.floor(maxLifetime/3600)..[[ value=]]..math.floor(defaultLifetime/3600)..
|
||||||
[[> hours (<input name=burnOnRead type=checkbox>burn on read) <input name=syntax type=text placeholder=syntax> <input type=submit value=post></span><a id=vrel href=/>vrel</a></div>
|
[[> hours (<input name=burnOnRead type=checkbox>burn on read) <input name=syntax type=text placeholder=syntax> <input type=submit value=post></span><a id=vrel href=/>vrel</a></div>
|
||||||
<textarea name=data required autofocus placeholder="paste your text here"></textarea>
|
<textarea name=data required autofocus placeholder="paste your text here"></textarea>
|
||||||
|
|
@ -243,14 +242,15 @@ httpd.start(config.address or "*", config.port or 8155, { -- Pages
|
||||||
([[<!DOCTYPE html><html><head><meta charset=utf-8><title>%s - vrel</title><style>%s</style></head><body>%s</body></html>]]):format(name, highlight(paste, name:lower():match("%.([a-z]+)$"))) }
|
([[<!DOCTYPE html><html><head><meta charset=utf-8><title>%s - vrel</title><style>%s</style></head><body>%s</body></html>]]):format(name, highlight(paste, name:lower():match("%.([a-z]+)$"))) }
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
["/g/(.+)"] = function(request, name) local d = get(name, request) return d and { cache = d.expire - os.time(), "200 OK", {["Content-Type"] = "text"}, d.data } or nil end,
|
["/g/(.+)"] = function(request, name) local d = get(name, request) return d and { cache = d.expire - os.time(), "200 OK", {["Content-Type"] = "text; charset=utf-8"}, d.data } or nil end,
|
||||||
["/p"] = function(request)
|
["/p"] = function(request)
|
||||||
if request.method == "POST" and request.post.data then
|
if request.method == "POST" and request.post.data then
|
||||||
local name, paste = post({ lifetime = (tonumber(request.post.lifetime) or defaultLifetime)*(request.post.web and 1 or 1), burnOnRead = request.post.burnOnRead == "on",
|
local name, paste = post({ lifetime = (tonumber(request.post.lifetime) or defaultLifetime)*(request.post.web and 1 or 1), burnOnRead = request.post.burnOnRead == "on",
|
||||||
syntax = (request.post.web and request.post.syntax == "" and "text") or request.post.syntax, data = request.post.data }, request)
|
syntax = (request.post.web and request.post.syntax == "" and "text") or request.post.syntax, data = request.post.data }, request)
|
||||||
return request.post.web and {"303 See Other",{["Location"] = "/"..name},""} or {"200 OK", {["Content-Type"]="text/json"},([[{"name":"%s","lifetime":%s,"burnOnRead":%s,"syntax":"%s"}]]):format(name,paste.expire-os.time(),paste.burnOnRead,paste.syntax)}
|
return request.post.web and { "303 See Other", {["Location"] = "/"..name}, "" } or
|
||||||
|
{ "200 OK", {["Content-Type"] = "text/json; charset=utf-8"}, ([[{"name":"%s","lifetime":%s,"burnOnRead":%s,"syntax":"%s"}]]):format(name, paste.expire-os.time(), paste.burnOnRead,paste.syntax) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}, { -- Error pages
|
}, { -- Error pages
|
||||||
["404"] = { "404", {["Content-Type"] = "text/json"}, [[{"error":"page not found"}]] }, ["500"] = { "500", {["Content-Type"] = "text/json"}, [[{"error":"internal server error"}]] }
|
["404"] = { "404", {["Content-Type"] = "text/json; charset=utf-8"}, [[{"error":"page not found"}]] }, ["500"] = { "500", {["Content-Type"] = "text/json; charset=utf-8"}, [[{"error":"internal server error"}]] }
|
||||||
}, { timeout = config.timeout or 1, debug = config.debug or false, cacheCleanInterval = config.cacheCleanInterval or 3600 })
|
}, { timeout = config.timeout or 1, debug = config.debug or false, cacheCleanInterval = config.cacheCleanInterval or 3600 })
|
||||||
|
|
|
||||||
Reference in a new issue