diff --git a/vrel.lua b/vrel.lua index e05f94f..5087452 100644 --- a/vrel.lua +++ b/vrel.lua @@ -232,25 +232,25 @@ httpd.start(config.address or "*", config.port or 8155, { -- Pages #topbar input[name=syntax] { width: 5.5em; } #topbar input[type=submit] { cursor: pointer; width: 10em; } #topbar #vrel { font-size: 1.5em; float: right; } - -
-
expires in hours (burn on read) vrel
- + +
expires in hours (burn on read) vrel
+
]] } else local paste = get(name:match("^[^.]+"), request) or { data = "paste not found", syntax = "text", expire = os.time() } return { cache = not paste.burnOnRead and paste.expire - os.time(), "200 OK", {["Content-Type"] = "text/html"}, ([[%s - vrel%s]]):format(name, highlight(paste, name:lower():match("%.([a-z]+)$"))) } 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) 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", 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 }, { -- 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 })